From da5bb03187431111156690788e17ef848a6989d4 Mon Sep 17 00:00:00 2001 From: Elisa Lupin-Jimenez Date: Thu, 10 Aug 2017 16:34:37 -0700 Subject: [PATCH] Trying to add in a back button --- interface/resources/qml/hifi/tablet/TabletRoot.qml | 5 +++++ interface/resources/qml/hifi/tablet/WindowRoot.qml | 5 +++++ libraries/ui/src/ui/TabletScriptingInterface.cpp | 8 ++++++-- libraries/ui/src/ui/TabletScriptingInterface.h | 2 +- scripts/system/marketplaces/blocksApp.js | 4 ++-- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/interface/resources/qml/hifi/tablet/TabletRoot.qml b/interface/resources/qml/hifi/tablet/TabletRoot.qml index c7df6ac64f..c89317c93c 100644 --- a/interface/resources/qml/hifi/tablet/TabletRoot.qml +++ b/interface/resources/qml/hifi/tablet/TabletRoot.qml @@ -93,6 +93,11 @@ Item { loader.source = ""; loader.source = "TabletWebView.qml"; } + + function loadTabletWebBase() { + loader.source = ""; + loader.source = "../../controls/TabletWebView.qml"; + } function returnToPreviousApp() { tabletApps.remove(currentApp); diff --git a/interface/resources/qml/hifi/tablet/WindowRoot.qml b/interface/resources/qml/hifi/tablet/WindowRoot.qml index fdfcfcf806..0858b46b40 100644 --- a/interface/resources/qml/hifi/tablet/WindowRoot.qml +++ b/interface/resources/qml/hifi/tablet/WindowRoot.qml @@ -42,6 +42,11 @@ Windows.ScrollingWindow { loader.source = "WindowWebView.qml"; } + function loadTabletWebBase() { + loader.source = ""; + loader.source = "../../controls/TabletWebView.qml"; + } + function loadWebUrl(url, injectedJavaScriptUrl) { loader.item.url = url; loader.item.scriptURL = injectedJavaScriptUrl; diff --git a/libraries/ui/src/ui/TabletScriptingInterface.cpp b/libraries/ui/src/ui/TabletScriptingInterface.cpp index 984d743ebf..1331b47590 100644 --- a/libraries/ui/src/ui/TabletScriptingInterface.cpp +++ b/libraries/ui/src/ui/TabletScriptingInterface.cpp @@ -604,7 +604,7 @@ void TabletProxy::loadWebScreenOnTop(const QVariant& url, const QString& injectJ _state = State::Web; } -void TabletProxy::gotoWebScreen(const QString& url, const QString& injectedJavaScriptUrl) { +void TabletProxy::gotoWebScreen(const QString& url, const QString& injectedJavaScriptUrl, bool loadOtherBase) { if (QThread::currentThread() != thread()) { QMetaObject::invokeMethod(this, "gotoWebScreen", Q_ARG(QString, url), Q_ARG(QString, injectedJavaScriptUrl)); return; @@ -619,7 +619,11 @@ void TabletProxy::gotoWebScreen(const QString& url, const QString& injectedJavaS if (root) { removeButtonsFromHomeScreen(); - QMetaObject::invokeMethod(root, "loadWebBase"); + if (loadOtherBase) { + QMetaObject::invokeMethod(root, "loadTabletWebBase"); + } else { + QMetaObject::invokeMethod(root, "loadWebBase"); + } QMetaObject::invokeMethod(root, "setShown", Q_ARG(const QVariant&, QVariant(true))); QMetaObject::invokeMethod(root, "loadWebUrl", Q_ARG(const QVariant&, QVariant(url)), Q_ARG(const QVariant&, QVariant(injectedJavaScriptUrl))); } diff --git a/libraries/ui/src/ui/TabletScriptingInterface.h b/libraries/ui/src/ui/TabletScriptingInterface.h index af38cb9351..822bae839e 100644 --- a/libraries/ui/src/ui/TabletScriptingInterface.h +++ b/libraries/ui/src/ui/TabletScriptingInterface.h @@ -122,7 +122,7 @@ public: * @param [injectedJavaScriptUrl] {string} optional url to an additional JS script to inject into the web page. */ Q_INVOKABLE void gotoWebScreen(const QString& url); - Q_INVOKABLE void gotoWebScreen(const QString& url, const QString& injectedJavaScriptUrl); + Q_INVOKABLE void gotoWebScreen(const QString& url, const QString& injectedJavaScriptUrl, bool loadOtherBase = false); Q_INVOKABLE void loadQMLSource(const QVariant& path); // FIXME: This currently relies on a script initializing the tablet (hence the bool denoting success); diff --git a/scripts/system/marketplaces/blocksApp.js b/scripts/system/marketplaces/blocksApp.js index 46a102042e..520b3657b9 100644 --- a/scripts/system/marketplaces/blocksApp.js +++ b/scripts/system/marketplaces/blocksApp.js @@ -10,7 +10,7 @@ }); function onClicked() { - tablet.gotoWebScreen(APP_URL); + tablet.gotoWebScreen(APP_URL, "", true); } button.clicked.connect(onClicked); @@ -19,4 +19,4 @@ } Script.scriptEnding.connect(cleanup); -}()); \ No newline at end of file +}());