Showing the changes to interface/src/Application.cpp (1 of 106 files). Show all
Unified · Split
| @@ -61,6 +61,7 @@ · 60 unmodified lines | ||
| 61 | 61 | #include <AssetClient.h> |
| 62 | 62 | #include <AssetUpload.h> |
| 63 | 63 | #include <AutoUpdater.h> |
| 64 | +#include <Midi.h> | |
| 64 | 65 | #include <AudioInjectorManager.h> |
| 65 | 66 | #include <AvatarBookmarks.h> |
| 66 | 67 | #include <CursorManager.h> |
| @@ -398,6 +399,10 @@ public: · 331 unmodified lines | ||
| 398 | 399 | return true; |
| 399 | 400 | } |
| 400 | 401 | } |
| 402 | + | |
| 403 | + if (message->message == WM_DEVICECHANGE) { | |
| 404 | + Midi::USBchanged(); // re-scan the MIDI bus | |
| 405 | + } | |
| 401 | 406 | } |
| 402 | 407 | return false; |
| 403 | 408 | } |
| @@ -567,6 +572,7 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 163 unmodified lines | ||
| 567 | 572 | DependencyManager::set<SceneScriptingInterface>(); |
| 568 | 573 | DependencyManager::set<OffscreenUi>(); |
| 569 | 574 | DependencyManager::set<AutoUpdater>(); |
| 575 | + DependencyManager::set<Midi>(); | |
| 570 | 576 | DependencyManager::set<PathUtils>(); |
| 571 | 577 | DependencyManager::set<InterfaceDynamicFactory>(); |
| 572 | 578 | DependencyManager::set<AudioInjectorManager>(); |
| @@ -618,6 +624,7 @@ const float DEFAULT_DESKTOP_TABLET_SCALE_PERCENT = 75.0f; · 45 unmodified lines | ||
| 618 | 624 | const bool DEFAULT_DESKTOP_TABLET_BECOMES_TOOLBAR = true; |
| 619 | 625 | const bool DEFAULT_HMD_TABLET_BECOMES_TOOLBAR = false; |
| 620 | 626 | const bool DEFAULT_PREFER_AVATAR_FINGER_OVER_STYLUS = false; |
| 627 | +const QString DEFAULT_CURSOR_NAME = "DEFAULT"; | |
| 621 | 628 | |
| 622 | 629 | Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bool runningMarkerExisted) : |
| 623 | 630 | QApplication(argc, argv), |
| @@ -637,6 +644,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 13 unmodified lines | ||
| 637 | 644 | _hmdTabletBecomesToolbarSetting("hmdTabletBecomesToolbar", DEFAULT_HMD_TABLET_BECOMES_TOOLBAR), |
| 638 | 645 | _preferAvatarFingerOverStylusSetting("preferAvatarFingerOverStylus", DEFAULT_PREFER_AVATAR_FINGER_OVER_STYLUS), |
| 639 | 646 | _constrainToolbarPosition("toolbar/constrainToolbarToCenterX", true), |
| 647 | + _preferredCursor("preferredCursor", DEFAULT_CURSOR_NAME), | |
| 640 | 648 | _scaleMirror(1.0f), |
| 641 | 649 | _rotateMirror(0.0f), |
| 642 | 650 | _raiseMirror(0.0f), |
| @@ -932,14 +940,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 289 unmodified lines | ||
| 932 | 940 | _glWidget->setFocusPolicy(Qt::StrongFocus); |
| 933 | 941 | _glWidget->setFocus(); |
| 934 | 942 | |
| 935 | −#ifdef Q_OS_MAC | |
| 936 | − auto cursorTarget = _window; // OSX doesn't seem to provide for hiding the cursor only on the GL widget | |
| 937 | −#else | |
| 938 | − // On windows and linux, hiding the top level cursor also means it's invisible when hovering over the | |
| 939 | − // window menu, which is a pain, so only hide it for the GL surface | |
| 940 | − auto cursorTarget = _glWidget; | |
| 941 | −#endif | |
| 942 | − cursorTarget->setCursor(Qt::BlankCursor); | |
| 943 | + showCursor(Cursor::Manager::lookupIcon(_preferredCursor.get())); | |
| 943 | 944 | |
| 944 | 945 | // enable mouse tracking; otherwise, we only get drag events |
| 945 | 946 | _glWidget->setMouseTracking(true); |
| @@ -1784,9 +1785,16 @@ void Application::checkChangeCursor() { · 838 unmodified lines | ||
| 1784 | 1785 | } |
| 1785 | 1786 | } |
| 1786 | 1787 | |
| 1787 | −void Application::showCursor(const QCursor& cursor) { | |
| 1788 | +void Application::showCursor(const Cursor::Icon& cursor) { | |
| 1788 | 1789 | QMutexLocker locker(&_changeCursorLock); |
| 1789 | − _desiredCursor = cursor; | |
| 1790 | + | |
| 1791 | + auto managedCursor = Cursor::Manager::instance().getCursor(); | |
| 1792 | + auto curIcon = managedCursor->getIcon(); | |
| 1793 | + if (curIcon != cursor) { | |
| 1794 | + managedCursor->setIcon(cursor); | |
| 1795 | + curIcon = cursor; | |
| 1796 | + } | |
| 1797 | + _desiredCursor = cursor == Cursor::Icon::SYSTEM ? Qt::ArrowCursor : Qt::BlankCursor; | |
| 1790 | 1798 | _cursorNeedsChanging = true; |
| 1791 | 1799 | } |
| 1792 | 1800 | |
| @@ -2161,7 +2169,6 @@ void Application::initializeUi() { · 368 unmodified lines | ||
| 2161 | 2169 | surfaceContext->setContextProperty("AvatarManager", DependencyManager::get<AvatarManager>().data()); |
| 2162 | 2170 | surfaceContext->setContextProperty("UndoStack", &_undoStackScriptingInterface); |
| 2163 | 2171 | surfaceContext->setContextProperty("LODManager", DependencyManager::get<LODManager>().data()); |
| 2164 | − surfaceContext->setContextProperty("Paths", DependencyManager::get<PathUtils>().data()); | |
| 2165 | 2172 | surfaceContext->setContextProperty("HMD", DependencyManager::get<HMDScriptingInterface>().data()); |
| 2166 | 2173 | surfaceContext->setContextProperty("Scene", DependencyManager::get<SceneScriptingInterface>().data()); |
| 2167 | 2174 | surfaceContext->setContextProperty("Render", _renderEngine->getConfiguration().get()); |
| @@ -2207,9 +2214,11 @@ void Application::initializeUi() { · 39 unmodified lines | ||
| 2207 | 2214 | _window->setMenuBar(new Menu()); |
| 2208 | 2215 | |
| 2209 | 2216 | auto compositorHelper = DependencyManager::get<CompositorHelper>(); |
| 2210 | − connect(compositorHelper.data(), &CompositorHelper::allowMouseCaptureChanged, [=] { | |
| 2217 | + connect(compositorHelper.data(), &CompositorHelper::allowMouseCaptureChanged, this, [=] { | |
| 2211 | 2218 | if (isHMDMode()) { |
| 2212 | − showCursor(compositorHelper->getAllowMouseCapture() ? Qt::BlankCursor : Qt::ArrowCursor); | |
| 2219 | + showCursor(compositorHelper->getAllowMouseCapture() ? | |
| 2220 | + Cursor::Manager::lookupIcon(_preferredCursor.get()) : | |
| 2221 | + Cursor::Icon::SYSTEM); | |
| 2213 | 2222 | } |
| 2214 | 2223 | }); |
| 2215 | 2224 | |
| @@ -2551,6 +2560,12 @@ void Application::setPreferAvatarFingerOverStylus(bool value) { · 335 unmodified lines | ||
| 2551 | 2560 | _preferAvatarFingerOverStylusSetting.set(value); |
| 2552 | 2561 | } |
| 2553 | 2562 | |
| 2563 | +void Application::setPreferredCursor(const QString& cursorName) { | |
| 2564 | + qCDebug(interfaceapp) << "setPreferredCursor" << cursorName; | |
| 2565 | + _preferredCursor.set(cursorName.isEmpty() ? DEFAULT_CURSOR_NAME : cursorName); | |
| 2566 | + showCursor(Cursor::Manager::lookupIcon(_preferredCursor.get())); | |
| 2567 | +} | |
| 2568 | + | |
| 2554 | 2569 | void Application::setSettingConstrainToolbarPosition(bool setting) { |
| 2555 | 2570 | _constrainToolbarPosition.set(setting); |
| 2556 | 2571 | DependencyManager::get<OffscreenUi>()->setConstrainToolbarToCenterX(setting); |
| @@ -3067,7 +3082,9 @@ void Application::keyPressEvent(QKeyEvent* event) { · 510 unmodified lines | ||
| 3067 | 3082 | break; |
| 3068 | 3083 | |
| 3069 | 3084 | case Qt::Key_F: { |
| 3070 | − _physicsEngine->dumpNextStats(); | |
| 3085 | + if (isOption) { | |
| 3086 | + _physicsEngine->dumpNextStats(); | |
| 3087 | + } | |
| 3071 | 3088 | break; |
| 3072 | 3089 | } |
| 3073 | 3090 | |
| @@ -3111,9 +3128,13 @@ void Application::keyPressEvent(QKeyEvent* event) { · 37 unmodified lines | ||
| 3111 | 3128 | auto cursor = Cursor::Manager::instance().getCursor(); |
| 3112 | 3129 | auto curIcon = cursor->getIcon(); |
| 3113 | 3130 | if (curIcon == Cursor::Icon::DEFAULT) { |
| 3114 | − cursor->setIcon(Cursor::Icon::LINK); | |
| 3131 | + showCursor(Cursor::Icon::RETICLE); | |
| 3132 | + } else if (curIcon == Cursor::Icon::RETICLE) { | |
| 3133 | + showCursor(Cursor::Icon::SYSTEM); | |
| 3134 | + } else if (curIcon == Cursor::Icon::SYSTEM) { | |
| 3135 | + showCursor(Cursor::Icon::LINK); | |
| 3115 | 3136 | } else { |
| 3116 | − cursor->setIcon(Cursor::Icon::DEFAULT); | |
| 3137 | + showCursor(Cursor::Icon::DEFAULT); | |
| 3117 | 3138 | } |
| 3118 | 3139 | } else { |
| 3119 | 3140 | resetSensors(true); |
| @@ -4507,27 +4528,31 @@ void Application::cameraModeChanged() { · 1387 unmodified lines | ||
| 4507 | 4528 | |
| 4508 | 4529 | |
| 4509 | 4530 | void Application::cameraMenuChanged() { |
| 4510 | − if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { | |
| 4511 | − if (_myCamera.getMode() != CAMERA_MODE_MIRROR) { | |
| 4531 | + auto menu = Menu::getInstance(); | |
| 4532 | + if (menu->isOptionChecked(MenuOption::FullscreenMirror)) { | |
| 4533 | + if (isHMDMode()) { | |
| 4534 | + menu->setIsOptionChecked(MenuOption::FullscreenMirror, false); | |
| 4535 | + menu->setIsOptionChecked(MenuOption::FirstPerson, true); | |
| 4536 | + } else if (_myCamera.getMode() != CAMERA_MODE_MIRROR) { | |
| 4512 | 4537 | _myCamera.setMode(CAMERA_MODE_MIRROR); |
| 4513 | 4538 | } |
| 4514 | − } else if (Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson)) { | |
| 4539 | + } else if (menu->isOptionChecked(MenuOption::FirstPerson)) { | |
| 4515 | 4540 | if (_myCamera.getMode() != CAMERA_MODE_FIRST_PERSON) { |
| 4516 | 4541 | _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); |
| 4517 | 4542 | getMyAvatar()->setBoomLength(MyAvatar::ZOOM_MIN); |
| 4518 | 4543 | } |
| 4519 | − } else if (Menu::getInstance()->isOptionChecked(MenuOption::ThirdPerson)) { | |
| 4544 | + } else if (menu->isOptionChecked(MenuOption::ThirdPerson)) { | |
| 4520 | 4545 | if (_myCamera.getMode() != CAMERA_MODE_THIRD_PERSON) { |
| 4521 | 4546 | _myCamera.setMode(CAMERA_MODE_THIRD_PERSON); |
| 4522 | 4547 | if (getMyAvatar()->getBoomLength() == MyAvatar::ZOOM_MIN) { |
| 4523 | 4548 | getMyAvatar()->setBoomLength(MyAvatar::ZOOM_DEFAULT); |
| 4524 | 4549 | } |
| 4525 | 4550 | } |
| 4526 | − } else if (Menu::getInstance()->isOptionChecked(MenuOption::IndependentMode)) { | |
| 4551 | + } else if (menu->isOptionChecked(MenuOption::IndependentMode)) { | |
| 4527 | 4552 | if (_myCamera.getMode() != CAMERA_MODE_INDEPENDENT) { |
| 4528 | 4553 | _myCamera.setMode(CAMERA_MODE_INDEPENDENT); |
| 4529 | 4554 | } |
| 4530 | − } else if (Menu::getInstance()->isOptionChecked(MenuOption::CameraEntityMode)) { | |
| 4555 | + } else if (menu->isOptionChecked(MenuOption::CameraEntityMode)) { | |
| 4531 | 4556 | if (_myCamera.getMode() != CAMERA_MODE_ENTITY) { |
| 4532 | 4557 | _myCamera.setMode(CAMERA_MODE_ENTITY); |
| 4533 | 4558 | } |