From 90f5d02c990db8f79b25002da949d4947423fbc6 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Thu, 6 Apr 2017 00:13:53 +0100 Subject: [PATCH 1/5] goto toggle option --- interface/src/ui/DialogsManager.cpp | 43 +++++++++++++++++-- interface/src/ui/DialogsManager.h | 1 + .../src/TabletScriptingInterface.cpp | 8 ++++ .../src/TabletScriptingInterface.h | 3 ++ 4 files changed, 52 insertions(+), 3 deletions(-) diff --git a/interface/src/ui/DialogsManager.cpp b/interface/src/ui/DialogsManager.cpp index 402e27e256..a95ac8d91f 100644 --- a/interface/src/ui/DialogsManager.cpp +++ b/interface/src/ui/DialogsManager.cpp @@ -31,6 +31,7 @@ #include "TabletScriptingInterface.h" #include "scripting/HMDScriptingInterface.h" +static const QVariant TABLET_ADDRESS_DIALOG = "TabletAddressDialog.qml"; template void DialogsManager::maybeCreateDialog(QPointer& member) { if (!member) { @@ -46,12 +47,48 @@ void DialogsManager::maybeCreateDialog(QPointer& member) { } void DialogsManager::toggleAddressBar() { - AddressBarDialog::toggle(); - emit addressBarToggled(); + auto hmd = DependencyManager::get(); + auto tabletScriptingInterface = DependencyManager::get(); + auto tablet = dynamic_cast(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); + if (tablet->getToolbarMode()) { + if (tablet->isPathLoaded(TABLET_ADDRESS_DIALOG)) { + tablet->gotoHomeScreen(); + emit addressBarToggled(); + } else { + tablet->loadQMLSource(TABLET_ADDRESS_DIALOG); + emit addressBarToggled(); + } + } else { + if (hmd->getShouldShowTablet()) { + if (tablet->isPathLoaded(TABLET_ADDRESS_DIALOG) && _closeAddressBar) { + tablet->gotoHomeScreen(); + hmd->closeTablet(); + _closeAddressBar = false; + emit addressBarToggled(); + } else { + tablet->loadQMLSource(TABLET_ADDRESS_DIALOG); + _closeAddressBar = true; + emit addressBarToggled(); + } + } else { + tablet->loadQMLSource(TABLET_ADDRESS_DIALOG); + hmd->openTablet(); + _closeAddressBar = true; + emit addressBarToggled(); + } + + } } void DialogsManager::showAddressBar() { - AddressBarDialog::show(); + auto hmd = DependencyManager::get(); + auto tabletScriptingInterface = DependencyManager::get(); + auto tablet = dynamic_cast(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); + tablet->loadQMLSource(TABLET_ADDRESS_DIALOG); + + if (!hmd->getShouldShowTablet()) { + hmd->openTablet(); + } } void DialogsManager::showFeed() { diff --git a/interface/src/ui/DialogsManager.h b/interface/src/ui/DialogsManager.h index 608195aca7..24b9078baf 100644 --- a/interface/src/ui/DialogsManager.h +++ b/interface/src/ui/DialogsManager.h @@ -79,6 +79,7 @@ private: QPointer _octreeStatsDialog; QPointer _testingDialog; QPointer _domainConnectionDialog; + bool _closeAddressBar { false }; }; #endif // hifi_DialogsManager_h diff --git a/libraries/script-engine/src/TabletScriptingInterface.cpp b/libraries/script-engine/src/TabletScriptingInterface.cpp index b4d8977b6d..7747e1b6dc 100644 --- a/libraries/script-engine/src/TabletScriptingInterface.cpp +++ b/libraries/script-engine/src/TabletScriptingInterface.cpp @@ -275,6 +275,9 @@ void TabletProxy::emitWebEvent(QVariant msg) { emit webEventReceived(msg); } +bool TabletProxy::isPathLoaded(QVariant path) { + return path.toString() == _currentPathLoaded.toString(); +} void TabletProxy::setQmlTabletRoot(QQuickItem* qmlTabletRoot, QObject* qmlOffscreenSurface) { std::lock_guard guard(_mutex); _qmlOffscreenSurface = qmlOffscreenSurface; @@ -322,6 +325,7 @@ void TabletProxy::setQmlTabletRoot(QQuickItem* qmlTabletRoot, QObject* qmlOffscr removeButtonsFromHomeScreen(); _state = State::Uninitialized; emit screenChanged(QVariant("Closed"), QVariant("")); + _currentPathLoaded = ""; } } @@ -345,6 +349,7 @@ void TabletProxy::gotoMenuScreen(const QString& submenu) { QMetaObject::invokeMethod(root, "loadSource", Q_ARG(const QVariant&, QVariant(VRMENU_SOURCE_URL))); _state = State::Menu; emit screenChanged(QVariant("Menu"), QVariant(VRMENU_SOURCE_URL)); + _currentPathLoaded = VRMENU_SOURCE_URL; QMetaObject::invokeMethod(root, "setShown", Q_ARG(const QVariant&, QVariant(true))); } } @@ -364,6 +369,7 @@ void TabletProxy::loadQMLSource(const QVariant& path) { QMetaObject::invokeMethod(root, "loadSource", Q_ARG(const QVariant&, path)); _state = State::QML; emit screenChanged(QVariant("QML"), path); + _currentPathLoaded = path; QMetaObject::invokeMethod(root, "setShown", Q_ARG(const QVariant&, QVariant(true))); } } else { @@ -426,6 +432,7 @@ void TabletProxy::loadHomeScreen(bool forceOntoHomeScreen) { } _state = State::Home; emit screenChanged(QVariant("Home"), QVariant(TABLET_SOURCE_URL)); + _currentPathLoaded = TABLET_SOURCE_URL; } } @@ -450,6 +457,7 @@ void TabletProxy::gotoWebScreen(const QString& url, const QString& injectedJavaS } _state = State::Web; emit screenChanged(QVariant("Web"), QVariant(url)); + _currentPathLoaded = QVariant(url); } QObject* TabletProxy::addButton(const QVariant& properties) { diff --git a/libraries/script-engine/src/TabletScriptingInterface.h b/libraries/script-engine/src/TabletScriptingInterface.h index e9ae60fee1..195db02789 100644 --- a/libraries/script-engine/src/TabletScriptingInterface.h +++ b/libraries/script-engine/src/TabletScriptingInterface.h @@ -183,6 +183,8 @@ public: Q_INVOKABLE void setLandscape(bool landscape) { _landscape = landscape; } Q_INVOKABLE bool getLandscape() { return _landscape; } + Q_INVOKABLE bool isPathLoaded(QVariant path); + QQuickItem* getTabletRoot() const { return _qmlTabletRoot; } QObject* getTabletSurface(); @@ -235,6 +237,7 @@ protected: bool _initialScreen { false }; QVariant _initialPath { "" }; + QVariant _currentPathLoaded { "" }; QString _name; std::mutex _mutex; std::vector> _tabletButtonProxies; From 52fd446d4d5bc965acd6d60b11a2d05236206df3 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Thu, 6 Apr 2017 22:27:37 +0100 Subject: [PATCH 2/5] toggle goto in tablet --- interface/resources/qml/hifi/Card.qml | 7 +----- .../qml/hifi/tablet/TabletAddressDialog.qml | 25 ++++++++++++++----- interface/src/Application.cpp | 1 + .../src/TabletScriptingInterface.cpp | 2 +- scripts/system/tablet-goto.js | 13 +++++++--- 5 files changed, 31 insertions(+), 17 deletions(-) diff --git a/interface/resources/qml/hifi/Card.qml b/interface/resources/qml/hifi/Card.qml index 217cfec707..b72901fbdf 100644 --- a/interface/resources/qml/hifi/Card.qml +++ b/interface/resources/qml/hifi/Card.qml @@ -243,12 +243,7 @@ Rectangle { } } } - DropShadow { - anchors.fill: actionIcon - radius: 8.0 - color: "#80000000" - source: actionIcon - } + MouseArea { id: messageArea; width: rectIcon.width; diff --git a/interface/resources/qml/hifi/tablet/TabletAddressDialog.qml b/interface/resources/qml/hifi/tablet/TabletAddressDialog.qml index b0b8c68789..fbb78d2694 100644 --- a/interface/resources/qml/hifi/tablet/TabletAddressDialog.qml +++ b/interface/resources/qml/hifi/tablet/TabletAddressDialog.qml @@ -25,22 +25,31 @@ StackView { HifiConstants { id: hifi } HifiStyles.HifiConstants { id: hifiStyleConstants } initialItem: addressBarDialog - width: parent.width - height: parent.height property var eventBridge; property var allStories: []; property int cardWidth: 460; property int cardHeight: 320; property string metaverseBase: addressBarDialog.metaverseServerUrl + "/api/v1/"; + property var tablet: null; + property bool isDesktop: false; + Component { id: tabletStoryCard; TabletStoryCard {} } Component.onCompleted: { root.currentItem.focus = true; root.currentItem.forceActiveFocus(); + addressLine.focus = true; + addressLine.forceActiveFocus(); fillDestinations(); updateLocationText(false); root.parentChanged.connect(center); center(); + isDesktop = (typeof desktop !== "undefined"); + tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); + + if (desktop) { + root.title = "GOTO"; + } } Component.onDestruction: { root.parentChanged.disconnect(center); @@ -107,7 +116,6 @@ StackView { imageURL: "../../../images/home.svg" onClicked: { addressBarDialog.loadHome(); - root.shown = false; } anchors { left: parent.left @@ -291,9 +299,8 @@ StackView { left: parent.left right: parent.right leftMargin: 10 - verticalCenter: parent.verticalCenter; - horizontalCenter: parent.horizontalCenter; } + model: suggestions orientation: ListView.Vertical @@ -547,7 +554,13 @@ StackView { if (addressLine.text !== "") { addressBarDialog.loadAddress(addressLine.text, fromSuggestions) } - root.shown = false; + + if (root.desktop) { + tablet.gotoHomeScreen(); + } else { + HMD.closeTablet(); + } + } Keys.onPressed: { diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index e19eea0a2e..feba5a74a7 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2010,6 +2010,7 @@ void Application::initializeUi() { rootContext->setContextProperty("SoundCache", DependencyManager::get().data()); rootContext->setContextProperty("Account", AccountScriptingInterface::getInstance()); + rootContext->setContextProperty("Tablet", DependencyManager::get().data()); rootContext->setContextProperty("DialogsManager", _dialogsManagerScriptingInterface); rootContext->setContextProperty("GlobalServices", GlobalServicesScriptingInterface::getInstance()); rootContext->setContextProperty("FaceTracker", DependencyManager::get().data()); diff --git a/libraries/script-engine/src/TabletScriptingInterface.cpp b/libraries/script-engine/src/TabletScriptingInterface.cpp index 7747e1b6dc..3aa0cc99e7 100644 --- a/libraries/script-engine/src/TabletScriptingInterface.cpp +++ b/libraries/script-engine/src/TabletScriptingInterface.cpp @@ -83,7 +83,7 @@ QQuickWindow* TabletScriptingInterface::getTabletWindow() { QObject* qmlSurface = tablet->getTabletSurface(); OffscreenQmlSurface* surface = dynamic_cast(qmlSurface); - if (!surface) { + if (!surface) { return nullptr; } QQuickWindow* window = surface->getWindow(); diff --git a/scripts/system/tablet-goto.js b/scripts/system/tablet-goto.js index eb95d9d8a3..84f7357b1a 100644 --- a/scripts/system/tablet-goto.js +++ b/scripts/system/tablet-goto.js @@ -29,10 +29,15 @@ } function onScreenChanged(type, url) { - // for toolbar mode: change button to active when window is first openend, false otherwise. - button.editProperties({isActive: shouldActivateButton}); - shouldActivateButton = false; - onGotoScreen = false; + if (url === gotoQmlSource) { + onGotoScreen = true; + shouldActivateButton = true; + button.editProperties({isActive: shouldActivateButton}); + } else { + shouldActivateButton = false; + onGotoScreen = false; + button.editProperties({isActive: shouldActivateButton}); + } } var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); From 22521526ece9f2b4af843169906c87500911323c Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Thu, 6 Apr 2017 23:41:30 +0100 Subject: [PATCH 3/5] removed stray space --- libraries/script-engine/src/TabletScriptingInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/script-engine/src/TabletScriptingInterface.cpp b/libraries/script-engine/src/TabletScriptingInterface.cpp index 3aa0cc99e7..7747e1b6dc 100644 --- a/libraries/script-engine/src/TabletScriptingInterface.cpp +++ b/libraries/script-engine/src/TabletScriptingInterface.cpp @@ -83,7 +83,7 @@ QQuickWindow* TabletScriptingInterface::getTabletWindow() { QObject* qmlSurface = tablet->getTabletSurface(); OffscreenQmlSurface* surface = dynamic_cast(qmlSurface); - if (!surface) { + if (!surface) { return nullptr; } QQuickWindow* window = surface->getWindow(); From 909fda98a48ec9bd6ab57b5fa77f5870e74c66e6 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Fri, 7 Apr 2017 21:01:53 +0100 Subject: [PATCH 4/5] git goto button toggle hightlight --- interface/resources/qml/hifi/tablet/TabletAddressDialog.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/tablet/TabletAddressDialog.qml b/interface/resources/qml/hifi/tablet/TabletAddressDialog.qml index 396f03a1c9..e4f6aa3407 100644 --- a/interface/resources/qml/hifi/tablet/TabletAddressDialog.qml +++ b/interface/resources/qml/hifi/tablet/TabletAddressDialog.qml @@ -560,7 +560,7 @@ StackView { addressBarDialog.loadAddress(addressLine.text, fromSuggestions) } - if (root.desktop) { + if (isDesktop) { tablet.gotoHomeScreen(); } else { HMD.closeTablet(); From cde9310f3e1c56ae6afb8b74012acd3f5ba2b7ba Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Fri, 7 Apr 2017 21:35:28 +0100 Subject: [PATCH 5/5] goto home button fix --- interface/resources/qml/hifi/tablet/TabletAddressDialog.qml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/interface/resources/qml/hifi/tablet/TabletAddressDialog.qml b/interface/resources/qml/hifi/tablet/TabletAddressDialog.qml index e4f6aa3407..39892f27a4 100644 --- a/interface/resources/qml/hifi/tablet/TabletAddressDialog.qml +++ b/interface/resources/qml/hifi/tablet/TabletAddressDialog.qml @@ -119,6 +119,8 @@ StackView { onClicked: { addressBarDialog.loadHome(); tabletRoot.shown = false; + tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); + tablet.gotoHomeScreen(); } anchors { left: parent.left