History

Merged from master

Olivier Prat committed 9 years ago

Commit 490aad22 parents 22acf1a 7785c11106 files · +2115 −564Browse files

Showing the changes to interface/src/Application.cpp (1 of 106 files). Show all

Unified · Split

interface/src/Application.cpp+47−22
@@ -61,6 +61,7 @@ · 60 unmodified lines
6161 #include <AssetClient.h>
6262 #include <AssetUpload.h>
6363 #include <AutoUpdater.h>
64+#include <Midi.h>
6465 #include <AudioInjectorManager.h>
6566 #include <AvatarBookmarks.h>
6667 #include <CursorManager.h>
@@ -398,6 +399,10 @@ public: · 331 unmodified lines
398399 return true;
399400 }
400401 }
402+
403+ if (message->message == WM_DEVICECHANGE) {
404+ Midi::USBchanged(); // re-scan the MIDI bus
405+ }
401406 }
402407 return false;
403408 }
@@ -567,6 +572,7 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 163 unmodified lines
567572 DependencyManager::set<SceneScriptingInterface>();
568573 DependencyManager::set<OffscreenUi>();
569574 DependencyManager::set<AutoUpdater>();
575+ DependencyManager::set<Midi>();
570576 DependencyManager::set<PathUtils>();
571577 DependencyManager::set<InterfaceDynamicFactory>();
572578 DependencyManager::set<AudioInjectorManager>();
@@ -618,6 +624,7 @@ const float DEFAULT_DESKTOP_TABLET_SCALE_PERCENT = 75.0f; · 45 unmodified lines
618624 const bool DEFAULT_DESKTOP_TABLET_BECOMES_TOOLBAR = true;
619625 const bool DEFAULT_HMD_TABLET_BECOMES_TOOLBAR = false;
620626 const bool DEFAULT_PREFER_AVATAR_FINGER_OVER_STYLUS = false;
627+const QString DEFAULT_CURSOR_NAME = "DEFAULT";
621628
622629 Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bool runningMarkerExisted) :
623630 QApplication(argc, argv),
@@ -637,6 +644,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 13 unmodified lines
637644 _hmdTabletBecomesToolbarSetting("hmdTabletBecomesToolbar", DEFAULT_HMD_TABLET_BECOMES_TOOLBAR),
638645 _preferAvatarFingerOverStylusSetting("preferAvatarFingerOverStylus", DEFAULT_PREFER_AVATAR_FINGER_OVER_STYLUS),
639646 _constrainToolbarPosition("toolbar/constrainToolbarToCenterX", true),
647+ _preferredCursor("preferredCursor", DEFAULT_CURSOR_NAME),
640648 _scaleMirror(1.0f),
641649 _rotateMirror(0.0f),
642650 _raiseMirror(0.0f),
@@ -932,14 +940,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 289 unmodified lines
932940 _glWidget->setFocusPolicy(Qt::StrongFocus);
933941 _glWidget->setFocus();
934942
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()));
943944
944945 // enable mouse tracking; otherwise, we only get drag events
945946 _glWidget->setMouseTracking(true);
@@ -1784,9 +1785,16 @@ void Application::checkChangeCursor() { · 838 unmodified lines
17841785 }
17851786 }
17861787
1787−void Application::showCursor(const QCursor& cursor) {
1788+void Application::showCursor(const Cursor::Icon& cursor) {
17881789 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;
17901798 _cursorNeedsChanging = true;
17911799 }
17921800
@@ -2161,7 +2169,6 @@ void Application::initializeUi() { · 368 unmodified lines
21612169 surfaceContext->setContextProperty("AvatarManager", DependencyManager::get<AvatarManager>().data());
21622170 surfaceContext->setContextProperty("UndoStack", &_undoStackScriptingInterface);
21632171 surfaceContext->setContextProperty("LODManager", DependencyManager::get<LODManager>().data());
2164− surfaceContext->setContextProperty("Paths", DependencyManager::get<PathUtils>().data());
21652172 surfaceContext->setContextProperty("HMD", DependencyManager::get<HMDScriptingInterface>().data());
21662173 surfaceContext->setContextProperty("Scene", DependencyManager::get<SceneScriptingInterface>().data());
21672174 surfaceContext->setContextProperty("Render", _renderEngine->getConfiguration().get());
@@ -2207,9 +2214,11 @@ void Application::initializeUi() { · 39 unmodified lines
22072214 _window->setMenuBar(new Menu());
22082215
22092216 auto compositorHelper = DependencyManager::get<CompositorHelper>();
2210− connect(compositorHelper.data(), &CompositorHelper::allowMouseCaptureChanged, [=] {
2217+ connect(compositorHelper.data(), &CompositorHelper::allowMouseCaptureChanged, this, [=] {
22112218 if (isHMDMode()) {
2212− showCursor(compositorHelper->getAllowMouseCapture() ? Qt::BlankCursor : Qt::ArrowCursor);
2219+ showCursor(compositorHelper->getAllowMouseCapture() ?
2220+ Cursor::Manager::lookupIcon(_preferredCursor.get()) :
2221+ Cursor::Icon::SYSTEM);
22132222 }
22142223 });
22152224
@@ -2551,6 +2560,12 @@ void Application::setPreferAvatarFingerOverStylus(bool value) { · 335 unmodified lines
25512560 _preferAvatarFingerOverStylusSetting.set(value);
25522561 }
25532562
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+
25542569 void Application::setSettingConstrainToolbarPosition(bool setting) {
25552570 _constrainToolbarPosition.set(setting);
25562571 DependencyManager::get<OffscreenUi>()->setConstrainToolbarToCenterX(setting);
@@ -3067,7 +3082,9 @@ void Application::keyPressEvent(QKeyEvent* event) { · 510 unmodified lines
30673082 break;
30683083
30693084 case Qt::Key_F: {
3070− _physicsEngine->dumpNextStats();
3085+ if (isOption) {
3086+ _physicsEngine->dumpNextStats();
3087+ }
30713088 break;
30723089 }
30733090
@@ -3111,9 +3128,13 @@ void Application::keyPressEvent(QKeyEvent* event) { · 37 unmodified lines
31113128 auto cursor = Cursor::Manager::instance().getCursor();
31123129 auto curIcon = cursor->getIcon();
31133130 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);
31153136 } else {
3116− cursor->setIcon(Cursor::Icon::DEFAULT);
3137+ showCursor(Cursor::Icon::DEFAULT);
31173138 }
31183139 } else {
31193140 resetSensors(true);
@@ -4507,27 +4528,31 @@ void Application::cameraModeChanged() { · 1387 unmodified lines
45074528
45084529
45094530 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) {
45124537 _myCamera.setMode(CAMERA_MODE_MIRROR);
45134538 }
4514− } else if (Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson)) {
4539+ } else if (menu->isOptionChecked(MenuOption::FirstPerson)) {
45154540 if (_myCamera.getMode() != CAMERA_MODE_FIRST_PERSON) {
45164541 _myCamera.setMode(CAMERA_MODE_FIRST_PERSON);
45174542 getMyAvatar()->setBoomLength(MyAvatar::ZOOM_MIN);
45184543 }
4519− } else if (Menu::getInstance()->isOptionChecked(MenuOption::ThirdPerson)) {
4544+ } else if (menu->isOptionChecked(MenuOption::ThirdPerson)) {
45204545 if (_myCamera.getMode() != CAMERA_MODE_THIRD_PERSON) {
45214546 _myCamera.setMode(CAMERA_MODE_THIRD_PERSON);
45224547 if (getMyAvatar()->getBoomLength() == MyAvatar::ZOOM_MIN) {
45234548 getMyAvatar()->setBoomLength(MyAvatar::ZOOM_DEFAULT);
45244549 }
45254550 }
4526− } else if (Menu::getInstance()->isOptionChecked(MenuOption::IndependentMode)) {
4551+ } else if (menu->isOptionChecked(MenuOption::IndependentMode)) {
45274552 if (_myCamera.getMode() != CAMERA_MODE_INDEPENDENT) {
45284553 _myCamera.setMode(CAMERA_MODE_INDEPENDENT);
45294554 }
4530− } else if (Menu::getInstance()->isOptionChecked(MenuOption::CameraEntityMode)) {
4555+ } else if (menu->isOptionChecked(MenuOption::CameraEntityMode)) {
45314556 if (_myCamera.getMode() != CAMERA_MODE_ENTITY) {
45324557 _myCamera.setMode(CAMERA_MODE_ENTITY);
45334558 }