Showing the changes to interface/src/Application.cpp (1 of 111 files). Show all
Unified · Split
| @@ -63,6 +63,7 @@ · 62 unmodified lines | |||
| 63 | #include <GlowEffect.h> | 63 | #include <GlowEffect.h> |
| 64 | #include <HFActionEvent.h> | 64 | #include <HFActionEvent.h> |
| 65 | #include <HFBackEvent.h> | 65 | #include <HFBackEvent.h> |
| 66 | #include <VrMenu.h> | ||
| 66 | #include <LogHandler.h> | 67 | #include <LogHandler.h> |
| 67 | #include <MainWindow.h> | 68 | #include <MainWindow.h> |
| 68 | #include <ModelEntityItem.h> | 69 | #include <ModelEntityItem.h> |
| @@ -357,9 +358,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 288 unmodified lines | |||
| 357 | 358 | ||
| 358 | _bookmarks = new Bookmarks(); // Before setting up the menu | 359 | _bookmarks = new Bookmarks(); // Before setting up the menu |
| 359 | 360 | ||
| 360 | // call Menu getInstance static method to set up the menu | ||
| 361 | _window->setMenuBar(Menu::getInstance()); | ||
| 362 | |||
| 363 | _runningScriptsWidget = new RunningScriptsWidget(_window); | 361 | _runningScriptsWidget = new RunningScriptsWidget(_window); |
| 364 | 362 | ||
| 365 | // start the nodeThread so its event loop is running | 363 | // start the nodeThread so its event loop is running |
| @@ -466,6 +464,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 100 unmodified lines | |||
| 466 | addressManager->setOrientationGetter(getOrientationForPath); | 464 | addressManager->setOrientationGetter(getOrientationForPath); |
| 467 | 465 | ||
| 468 | connect(addressManager.data(), &AddressManager::rootPlaceNameChanged, this, &Application::updateWindowTitle); | 466 | connect(addressManager.data(), &AddressManager::rootPlaceNameChanged, this, &Application::updateWindowTitle); |
| 467 | connect(this, &QCoreApplication::aboutToQuit, addressManager.data(), &AddressManager::storeCurrentAddress); | ||
| 469 | 468 | ||
| 470 | #ifdef _WIN32 | 469 | #ifdef _WIN32 |
| 471 | WSADATA WsaData; | 470 | WSADATA WsaData; |
| @@ -731,6 +730,10 @@ void Application::initializeGL() { · 259 unmodified lines | |||
| 731 | qCDebug(interfaceapp, "Initialized Offscreen UI."); | 730 | qCDebug(interfaceapp, "Initialized Offscreen UI."); |
| 732 | _glWidget->makeCurrent(); | 731 | _glWidget->makeCurrent(); |
| 733 | 732 | ||
| 733 | // call Menu getInstance static method to set up the menu | ||
| 734 | // Needs to happen AFTER the QML UI initialization | ||
| 735 | _window->setMenuBar(Menu::getInstance()); | ||
| 736 | |||
| 734 | init(); | 737 | init(); |
| 735 | qCDebug(interfaceapp, "init() complete."); | 738 | qCDebug(interfaceapp, "init() complete."); |
| 736 | 739 | ||
| @@ -766,6 +769,7 @@ void Application::initializeUi() { · 29 unmodified lines | |||
| 766 | AddressBarDialog::registerType(); | 769 | AddressBarDialog::registerType(); |
| 767 | LoginDialog::registerType(); | 770 | LoginDialog::registerType(); |
| 768 | MessageDialog::registerType(); | 771 | MessageDialog::registerType(); |
| 772 | VrMenu::registerType(); | ||
| 769 | 773 | ||
| 770 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); | 774 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); |
| 771 | offscreenUi->create(_glWidget->context()->contextHandle()); | 775 | offscreenUi->create(_glWidget->context()->contextHandle()); |
| @@ -774,6 +778,8 @@ void Application::initializeUi() { · 2 unmodified lines | |||
| 774 | offscreenUi->setBaseUrl(QUrl::fromLocalFile(PathUtils::resourcesPath() + "/qml/")); | 778 | offscreenUi->setBaseUrl(QUrl::fromLocalFile(PathUtils::resourcesPath() + "/qml/")); |
| 775 | offscreenUi->load("Root.qml"); | 779 | offscreenUi->load("Root.qml"); |
| 776 | offscreenUi->load("RootMenu.qml"); | 780 | offscreenUi->load("RootMenu.qml"); |
| 781 | VrMenu::load(); | ||
| 782 | VrMenu::executeQueuedLambdas(); | ||
| 777 | offscreenUi->setMouseTranslator([this](const QPointF& p){ | 783 | offscreenUi->setMouseTranslator([this](const QPointF& p){ |
| 778 | if (OculusManager::isConnected()) { | 784 | if (OculusManager::isConnected()) { |
| 779 | glm::vec2 pos = _applicationOverlay.screenToOverlay(toGlm(p)); | 785 | glm::vec2 pos = _applicationOverlay.screenToOverlay(toGlm(p)); |
| @@ -1068,8 +1074,10 @@ bool Application::eventFilter(QObject* object, QEvent* event) { · 288 unmodified lines | |||
| 1068 | return false; | 1074 | return false; |
| 1069 | } | 1075 | } |
| 1070 | 1076 | ||
| 1071 | void Application::keyPressEvent(QKeyEvent* event) { | 1077 | static bool _altPressed{ false }; |
| 1072 | 1078 | ||
| 1079 | void Application::keyPressEvent(QKeyEvent* event) { | ||
| 1080 | _altPressed = event->key() == Qt::Key_Alt; | ||
| 1073 | _keysPressed.insert(event->key()); | 1081 | _keysPressed.insert(event->key()); |
| 1074 | 1082 | ||
| 1075 | _controllerScriptingInterface.emitKeyPressEvent(event); // send events to any registered scripts | 1083 | _controllerScriptingInterface.emitKeyPressEvent(event); // send events to any registered scripts |
| @@ -1146,7 +1154,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 70 unmodified lines | |||
| 1146 | case Qt::Key_A: | 1154 | case Qt::Key_A: |
| 1147 | if (isShifted) { | 1155 | if (isShifted) { |
| 1148 | Menu::getInstance()->triggerOption(MenuOption::Atmosphere); | 1156 | Menu::getInstance()->triggerOption(MenuOption::Atmosphere); |
| 1149 | } else { | 1157 | } else if (!isMeta) { |
| 1150 | _myAvatar->setDriveKeys(ROT_LEFT, 1.0f); | 1158 | _myAvatar->setDriveKeys(ROT_LEFT, 1.0f); |
| 1151 | } | 1159 | } |
| 1152 | break; | 1160 | break; |
| @@ -1317,7 +1325,19 @@ void Application::keyPressEvent(QKeyEvent* event) { · 164 unmodified lines | |||
| 1317 | } | 1325 | } |
| 1318 | } | 1326 | } |
| 1319 | 1327 | ||
| 1328 | |||
| 1329 | //#define VR_MENU_ONLY_IN_HMD | ||
| 1330 | |||
| 1320 | void Application::keyReleaseEvent(QKeyEvent* event) { | 1331 | void Application::keyReleaseEvent(QKeyEvent* event) { |
| 1332 | if (event->key() == Qt::Key_Alt && _altPressed && _window->isActiveWindow()) { | ||
| 1333 | #ifdef VR_MENU_ONLY_IN_HMD | ||
| 1334 | if (OculusManager::isConnected()) { | ||
| 1335 | #endif | ||
| 1336 | VrMenu::toggle(); | ||
| 1337 | #ifdef VR_MENU_ONLY_IN_HMD | ||
| 1338 | } | ||
| 1339 | #endif | ||
| 1340 | } | ||
| 1321 | 1341 | ||
| 1322 | _keysPressed.remove(event->key()); | 1342 | _keysPressed.remove(event->key()); |
| 1323 | 1343 | ||
| @@ -1328,6 +1348,7 @@ void Application::keyReleaseEvent(QKeyEvent* event) { · 4 unmodified lines | |||
| 1328 | return; | 1348 | return; |
| 1329 | } | 1349 | } |
| 1330 | 1350 | ||
| 1351 | |||
| 1331 | switch (event->key()) { | 1352 | switch (event->key()) { |
| 1332 | case Qt::Key_E: | 1353 | case Qt::Key_E: |
| 1333 | case Qt::Key_PageUp: | 1354 | case Qt::Key_PageUp: |
| @@ -4457,3 +4478,7 @@ void Application::friendsWindowClosed() { · 3123 unmodified lines | |||
| 4457 | delete _friendsWindow; | 4478 | delete _friendsWindow; |
| 4458 | _friendsWindow = NULL; | 4479 | _friendsWindow = NULL; |
| 4459 | } | 4480 | } |
| 4481 | |||
| 4482 | void Application::postLambdaEvent(std::function<void()> f) { | ||
| 4483 | QCoreApplication::postEvent(this, new LambdaEvent(f)); | ||
| 4484 | } | ||