diff --git a/interface/resources/qml/hifi/Desktop.qml b/interface/resources/qml/hifi/Desktop.qml index 5fa6234504..3239471a00 100644 --- a/interface/resources/qml/hifi/Desktop.qml +++ b/interface/resources/qml/hifi/Desktop.qml @@ -12,6 +12,8 @@ import controlsUit 1.0 OriginalDesktop.Desktop { id: desktop + property alias toolbarObjectName: sysToolbar.objectName + MouseArea { id: hoverWatch anchors.fill: parent @@ -70,7 +72,12 @@ OriginalDesktop.Desktop { x: sysToolbar.x buttonModel: tablet ? tablet.buttons : null; shown: tablet ? tablet.toolbarMode : false; + + onVisibleChanged: { + desktop.toolbarVisibleChanged(visible, sysToolbar.objectName); + } } + signal toolbarVisibleChanged(bool isVisible, string toolbarName); QtSettings.Settings { id: settings; diff --git a/libraries/ui/src/OffscreenUi.cpp b/libraries/ui/src/OffscreenUi.cpp index 1e6a01c187..f0b27904ae 100644 --- a/libraries/ui/src/OffscreenUi.cpp +++ b/libraries/ui/src/OffscreenUi.cpp @@ -27,6 +27,7 @@ #include "VrMenu.h" #include "ui/Logging.h" +#include "ui/ToolbarScriptingInterface.h" #include #include "MainWindow.h" @@ -688,6 +689,10 @@ void OffscreenUi::createDesktop(const QUrl& url) { menuInitializer(_vrMenu); } + + auto toolbarScriptingInterface = DependencyManager::get(); + connect(_desktop, SIGNAL(toolbarVisibleChanged(bool, QString)), toolbarScriptingInterface.data(), SIGNAL(toolbarVisibleChanged(bool, QString))); + auto keyboardFocus = new KeyboardFocusHack(); connect(_desktop, SIGNAL(showDesktop()), this, SIGNAL(showDesktop())); emit desktopReady(); diff --git a/libraries/ui/src/ui/ToolbarScriptingInterface.h b/libraries/ui/src/ui/ToolbarScriptingInterface.h index 409ea28fdc..952d3cce95 100644 --- a/libraries/ui/src/ui/ToolbarScriptingInterface.h +++ b/libraries/ui/src/ui/ToolbarScriptingInterface.h @@ -150,6 +150,9 @@ public: * @returns {ToolbarProxy} */ Q_INVOKABLE ToolbarProxy* getToolbar(const QString& toolbarId); + +signals: + void toolbarVisibleChanged(bool isVisible, QString toolbarName); }; diff --git a/scripts/simplifiedUI/ui/simplifiedUI.js b/scripts/simplifiedUI/ui/simplifiedUI.js index 0553672655..16f081fb6b 100644 --- a/scripts/simplifiedUI/ui/simplifiedUI.js +++ b/scripts/simplifiedUI/ui/simplifiedUI.js @@ -457,16 +457,18 @@ function onGeometryChanged(rect) { } } -var TIMEOUT_BEFORE_REHIDE_TOOLBAR_MS = 700; function onDisplayModeChanged(isHMDMode) { if (isHMDMode) { Camera.setModeString("first person"); - } else if (Settings.getValue("simplifiedUI/keepExistingUIAndScripts", false)) { - // works for now, but not a permanent fix by any means. - Script.setTimeout(function () { - var toolbar = Toolbars.getToolbar(TOOLBAR_NAME); + } +} + +function onToolbarVisibleChanged(isVisible, toolbarName) { + if (isVisible && toolbarName == TOOLBAR_NAME && !Settings.getValue("simplifiedUI/keepExistingUIAndScripts", false)) { + var toolbar = Toolbars.getToolbar(toolbarName); + if (toolbar) { toolbar.writeProperty("visible", false); - }, TIMEOUT_BEFORE_REHIDE_TOOLBAR_MS); + } } } @@ -497,7 +499,9 @@ function startup() { if (!HMD.active) { var toolbar = Toolbars.getToolbar(TOOLBAR_NAME); - toolbar.writeProperty("visible", false); + if (toolbar) { + toolbar.writeProperty("visible", false); + } } } @@ -517,6 +521,7 @@ function startup() { Audio.localInjectorGainChanged.connect(maybeUpdateOutputDeviceMutedOverlay); Audio.serverInjectorGainChanged.connect(maybeUpdateOutputDeviceMutedOverlay); Audio.systemInjectorGainChanged.connect(maybeUpdateOutputDeviceMutedOverlay); + Toolbars.toolbarVisibleChanged.connect(onToolbarVisibleChanged); oldShowAudioTools = AvatarInputs.showAudioTools; AvatarInputs.showAudioTools = false; @@ -544,7 +549,7 @@ function shutdown() { var toolbar = Toolbars.getToolbar(TOOLBAR_NAME); if (toolbar) { toolbar.writeProperty("visible", true); - } + } } } @@ -573,6 +578,7 @@ function shutdown() { Audio.localInjectorGainChanged.disconnect(maybeUpdateOutputDeviceMutedOverlay); Audio.serverInjectorGainChanged.disconnect(maybeUpdateOutputDeviceMutedOverlay); Audio.systemInjectorGainChanged.disconnect(maybeUpdateOutputDeviceMutedOverlay); + Toolbars.toolbarVisibleChanged.disconnect(onToolbarVisibleChanged); AvatarInputs.showAudioTools = oldShowAudioTools; AvatarInputs.showBubbleTools = oldShowBubbleTools;