Showing the changes to interface/src/Application.cpp (1 of 106 files). Show all
Unified · Split
| @@ -61,6 +61,7 @@ · 60 unmodified lines | |||
| 61 | #include <AssetClient.h> | 61 | #include <AssetClient.h> |
| 62 | #include <AssetUpload.h> | 62 | #include <AssetUpload.h> |
| 63 | #include <AutoUpdater.h> | 63 | #include <AutoUpdater.h> |
| 64 | #include <Midi.h> | ||
| 64 | #include <AudioInjectorManager.h> | 65 | #include <AudioInjectorManager.h> |
| 65 | #include <AvatarBookmarks.h> | 66 | #include <AvatarBookmarks.h> |
| 66 | #include <CursorManager.h> | 67 | #include <CursorManager.h> |
| @@ -398,6 +399,10 @@ public: · 331 unmodified lines | |||
| 398 | return true; | 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 | return false; | 407 | return false; |
| 403 | } | 408 | } |
| @@ -567,6 +572,7 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 163 unmodified lines | |||
| 567 | DependencyManager::set<SceneScriptingInterface>(); | 572 | DependencyManager::set<SceneScriptingInterface>(); |
| 568 | DependencyManager::set<OffscreenUi>(); | 573 | DependencyManager::set<OffscreenUi>(); |
| 569 | DependencyManager::set<AutoUpdater>(); | 574 | DependencyManager::set<AutoUpdater>(); |
| 575 | DependencyManager::set<Midi>(); | ||
| 570 | DependencyManager::set<PathUtils>(); | 576 | DependencyManager::set<PathUtils>(); |
| 571 | DependencyManager::set<InterfaceDynamicFactory>(); | 577 | DependencyManager::set<InterfaceDynamicFactory>(); |
| 572 | DependencyManager::set<AudioInjectorManager>(); | 578 | DependencyManager::set<AudioInjectorManager>(); |
| @@ -618,6 +624,7 @@ const float DEFAULT_DESKTOP_TABLET_SCALE_PERCENT = 75.0f; · 45 unmodified lines | |||
| 618 | const bool DEFAULT_DESKTOP_TABLET_BECOMES_TOOLBAR = true; | 624 | const bool DEFAULT_DESKTOP_TABLET_BECOMES_TOOLBAR = true; |
| 619 | const bool DEFAULT_HMD_TABLET_BECOMES_TOOLBAR = false; | 625 | const bool DEFAULT_HMD_TABLET_BECOMES_TOOLBAR = false; |
| 620 | const bool DEFAULT_PREFER_AVATAR_FINGER_OVER_STYLUS = false; | 626 | const bool DEFAULT_PREFER_AVATAR_FINGER_OVER_STYLUS = false; |
| 627 | const QString DEFAULT_CURSOR_NAME = "DEFAULT"; | ||
| 621 | 628 | ||
| 622 | Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bool runningMarkerExisted) : | 629 | Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bool runningMarkerExisted) : |
| 623 | QApplication(argc, argv), | 630 | QApplication(argc, argv), |
| @@ -637,6 +644,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 13 unmodified lines | |||
| 637 | _hmdTabletBecomesToolbarSetting("hmdTabletBecomesToolbar", DEFAULT_HMD_TABLET_BECOMES_TOOLBAR), | 644 | _hmdTabletBecomesToolbarSetting("hmdTabletBecomesToolbar", DEFAULT_HMD_TABLET_BECOMES_TOOLBAR), |
| 638 | _preferAvatarFingerOverStylusSetting("preferAvatarFingerOverStylus", DEFAULT_PREFER_AVATAR_FINGER_OVER_STYLUS), | 645 | _preferAvatarFingerOverStylusSetting("preferAvatarFingerOverStylus", DEFAULT_PREFER_AVATAR_FINGER_OVER_STYLUS), |
| 639 | _constrainToolbarPosition("toolbar/constrainToolbarToCenterX", true), | 646 | _constrainToolbarPosition("toolbar/constrainToolbarToCenterX", true), |
| 647 | _preferredCursor("preferredCursor", DEFAULT_CURSOR_NAME), | ||
| 640 | _scaleMirror(1.0f), | 648 | _scaleMirror(1.0f), |
| 641 | _rotateMirror(0.0f), | 649 | _rotateMirror(0.0f), |
| 642 | _raiseMirror(0.0f), | 650 | _raiseMirror(0.0f), |
| @@ -932,14 +940,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 289 unmodified lines | |||
| 932 | _glWidget->setFocusPolicy(Qt::StrongFocus); | 940 | _glWidget->setFocusPolicy(Qt::StrongFocus); |
| 933 | _glWidget->setFocus(); | 941 | _glWidget->setFocus(); |
| 934 | 942 | ||
| 935 | #ifdef Q_OS_MAC | 943 | showCursor(Cursor::Manager::lookupIcon(_preferredCursor.get())); |
| 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 | 944 | ||
| 944 | // enable mouse tracking; otherwise, we only get drag events | 945 | // enable mouse tracking; otherwise, we only get drag events |
| 945 | _glWidget->setMouseTracking(true); | 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 | QMutexLocker locker(&_changeCursorLock); | 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 | _cursorNeedsChanging = true; | 1798 | _cursorNeedsChanging = true; |
| 1791 | } | 1799 | } |
| 1792 | 1800 | ||
| @@ -2161,7 +2169,6 @@ void Application::initializeUi() { · 368 unmodified lines | |||
| 2161 | surfaceContext->setContextProperty("AvatarManager", DependencyManager::get<AvatarManager>().data()); | 2169 | surfaceContext->setContextProperty("AvatarManager", DependencyManager::get<AvatarManager>().data()); |
| 2162 | surfaceContext->setContextProperty("UndoStack", &_undoStackScriptingInterface); | 2170 | surfaceContext->setContextProperty("UndoStack", &_undoStackScriptingInterface); |
| 2163 | surfaceContext->setContextProperty("LODManager", DependencyManager::get<LODManager>().data()); | 2171 | surfaceContext->setContextProperty("LODManager", DependencyManager::get<LODManager>().data()); |
| 2164 | surfaceContext->setContextProperty("Paths", DependencyManager::get<PathUtils>().data()); | ||
| 2165 | surfaceContext->setContextProperty("HMD", DependencyManager::get<HMDScriptingInterface>().data()); | 2172 | surfaceContext->setContextProperty("HMD", DependencyManager::get<HMDScriptingInterface>().data()); |
| 2166 | surfaceContext->setContextProperty("Scene", DependencyManager::get<SceneScriptingInterface>().data()); | 2173 | surfaceContext->setContextProperty("Scene", DependencyManager::get<SceneScriptingInterface>().data()); |
| 2167 | surfaceContext->setContextProperty("Render", _renderEngine->getConfiguration().get()); | 2174 | surfaceContext->setContextProperty("Render", _renderEngine->getConfiguration().get()); |
| @@ -2207,9 +2214,11 @@ void Application::initializeUi() { · 39 unmodified lines | |||
| 2207 | _window->setMenuBar(new Menu()); | 2214 | _window->setMenuBar(new Menu()); |
| 2208 | 2215 | ||
| 2209 | auto compositorHelper = DependencyManager::get<CompositorHelper>(); | 2216 | auto compositorHelper = DependencyManager::get<CompositorHelper>(); |
| 2210 | connect(compositorHelper.data(), &CompositorHelper::allowMouseCaptureChanged, [=] { | 2217 | connect(compositorHelper.data(), &CompositorHelper::allowMouseCaptureChanged, this, [=] { |
| 2211 | if (isHMDMode()) { | 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 | _preferAvatarFingerOverStylusSetting.set(value); | 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 | void Application::setSettingConstrainToolbarPosition(bool setting) { | 2569 | void Application::setSettingConstrainToolbarPosition(bool setting) { |
| 2555 | _constrainToolbarPosition.set(setting); | 2570 | _constrainToolbarPosition.set(setting); |
| 2556 | DependencyManager::get<OffscreenUi>()->setConstrainToolbarToCenterX(setting); | 2571 | DependencyManager::get<OffscreenUi>()->setConstrainToolbarToCenterX(setting); |
| @@ -3067,7 +3082,9 @@ void Application::keyPressEvent(QKeyEvent* event) { · 510 unmodified lines | |||
| 3067 | break; | 3082 | break; |
| 3068 | 3083 | ||
| 3069 | case Qt::Key_F: { | 3084 | case Qt::Key_F: { |
| 3070 | _physicsEngine->dumpNextStats(); | 3085 | if (isOption) { |
| 3086 | _physicsEngine->dumpNextStats(); | ||
| 3087 | } | ||
| 3071 | break; | 3088 | break; |
| 3072 | } | 3089 | } |
| 3073 | 3090 | ||
| @@ -3111,9 +3128,13 @@ void Application::keyPressEvent(QKeyEvent* event) { · 37 unmodified lines | |||
| 3111 | auto cursor = Cursor::Manager::instance().getCursor(); | 3128 | auto cursor = Cursor::Manager::instance().getCursor(); |
| 3112 | auto curIcon = cursor->getIcon(); | 3129 | auto curIcon = cursor->getIcon(); |
| 3113 | if (curIcon == Cursor::Icon::DEFAULT) { | 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 | } else { | 3136 | } else { |
| 3116 | cursor->setIcon(Cursor::Icon::DEFAULT); | 3137 | showCursor(Cursor::Icon::DEFAULT); |
| 3117 | } | 3138 | } |
| 3118 | } else { | 3139 | } else { |
| 3119 | resetSensors(true); | 3140 | resetSensors(true); |
| @@ -4507,27 +4528,31 @@ void Application::cameraModeChanged() { · 1387 unmodified lines | |||
| 4507 | 4528 | ||
| 4508 | 4529 | ||
| 4509 | void Application::cameraMenuChanged() { | 4530 | void Application::cameraMenuChanged() { |
| 4510 | if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { | 4531 | auto menu = Menu::getInstance(); |
| 4511 | if (_myCamera.getMode() != CAMERA_MODE_MIRROR) { | 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 | _myCamera.setMode(CAMERA_MODE_MIRROR); | 4537 | _myCamera.setMode(CAMERA_MODE_MIRROR); |
| 4513 | } | 4538 | } |
| 4514 | } else if (Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson)) { | 4539 | } else if (menu->isOptionChecked(MenuOption::FirstPerson)) { |
| 4515 | if (_myCamera.getMode() != CAMERA_MODE_FIRST_PERSON) { | 4540 | if (_myCamera.getMode() != CAMERA_MODE_FIRST_PERSON) { |
| 4516 | _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); | 4541 | _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); |
| 4517 | getMyAvatar()->setBoomLength(MyAvatar::ZOOM_MIN); | 4542 | getMyAvatar()->setBoomLength(MyAvatar::ZOOM_MIN); |
| 4518 | } | 4543 | } |
| 4519 | } else if (Menu::getInstance()->isOptionChecked(MenuOption::ThirdPerson)) { | 4544 | } else if (menu->isOptionChecked(MenuOption::ThirdPerson)) { |
| 4520 | if (_myCamera.getMode() != CAMERA_MODE_THIRD_PERSON) { | 4545 | if (_myCamera.getMode() != CAMERA_MODE_THIRD_PERSON) { |
| 4521 | _myCamera.setMode(CAMERA_MODE_THIRD_PERSON); | 4546 | _myCamera.setMode(CAMERA_MODE_THIRD_PERSON); |
| 4522 | if (getMyAvatar()->getBoomLength() == MyAvatar::ZOOM_MIN) { | 4547 | if (getMyAvatar()->getBoomLength() == MyAvatar::ZOOM_MIN) { |
| 4523 | getMyAvatar()->setBoomLength(MyAvatar::ZOOM_DEFAULT); | 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 | if (_myCamera.getMode() != CAMERA_MODE_INDEPENDENT) { | 4552 | if (_myCamera.getMode() != CAMERA_MODE_INDEPENDENT) { |
| 4528 | _myCamera.setMode(CAMERA_MODE_INDEPENDENT); | 4553 | _myCamera.setMode(CAMERA_MODE_INDEPENDENT); |
| 4529 | } | 4554 | } |
| 4530 | } else if (Menu::getInstance()->isOptionChecked(MenuOption::CameraEntityMode)) { | 4555 | } else if (menu->isOptionChecked(MenuOption::CameraEntityMode)) { |
| 4531 | if (_myCamera.getMode() != CAMERA_MODE_ENTITY) { | 4556 | if (_myCamera.getMode() != CAMERA_MODE_ENTITY) { |
| 4532 | _myCamera.setMode(CAMERA_MODE_ENTITY); | 4557 | _myCamera.setMode(CAMERA_MODE_ENTITY); |
| 4533 | } | 4558 | } |