diff --git a/interface/resources/qml/dialogs/TabletLoginDialog.qml b/interface/resources/qml/dialogs/TabletLoginDialog.qml index 89e94c3a57..7523d0406d 100644 --- a/interface/resources/qml/dialogs/TabletLoginDialog.qml +++ b/interface/resources/qml/dialogs/TabletLoginDialog.qml @@ -23,7 +23,7 @@ TabletModalWindow { property var eventBridge; signal sendToScript(var message); property bool isHMD: false - + property bool gotoPreviousApp: false; color: hifi.colors.baseGray property int colorScheme: hifi.colorSchemes.dark @@ -68,10 +68,11 @@ TabletModalWindow { onCanceled: { if (loginDialogRoot.Stack.view) { loginDialogRoot.Stack.view.pop(); - } else { + } else if (gotoPreviousApp) { var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); tablet.returnToPreviousApp(); } + } LoginDialog { diff --git a/interface/resources/qml/hifi/tablet/TabletGeneralPreferences.qml b/interface/resources/qml/hifi/tablet/TabletGeneralPreferences.qml index 6fc29ac920..d23daddd8d 100644 --- a/interface/resources/qml/hifi/tablet/TabletGeneralPreferences.qml +++ b/interface/resources/qml/hifi/tablet/TabletGeneralPreferences.qml @@ -18,7 +18,7 @@ StackView { initialItem: root objectName: "stack" property string title: "General Settings" - + property alias gotoPreviousApp: root.gotoPreviousApp; property var eventBridge; signal sendToScript(var message); diff --git a/interface/resources/qml/hifi/tablet/TabletRoot.qml b/interface/resources/qml/hifi/tablet/TabletRoot.qml index 4bbcb201bc..446d4c91ff 100644 --- a/interface/resources/qml/hifi/tablet/TabletRoot.qml +++ b/interface/resources/qml/hifi/tablet/TabletRoot.qml @@ -61,38 +61,42 @@ Item { tabletApps.clear(); loader.source = ""; // make sure we load the qml fresh each time. loader.source = url; + tabletApps.append({"appUrl": url, "isWebUrl": false, "scriptUrl": "", "appWebUrl": ""}); } function loadQMLOnTop(url) { - console.log("[DR] -> loading the url: " + url); - tabletApps.append({"appUrl": url, "isWebUrl": false, "scriptUrl": ""}); + tabletApps.append({"appUrl": url, "isWebUrl": false, "scriptUrl": "", "appWebUrl": ""}); loader.source = ""; loader.source = tabletApps.get(currentApp).appUrl; + if (loader.item.hasOwnProperty("gotoPreviousApp")) { + loader.item.gotoPreviousApp = true; + } } function loadWebOnTop(url, injectJavaScriptUrl) { - console.log("[DR] -> loading the url: " + url); tabletApps.append({"appUrl": loader.source, "isWebUrl": true, "scriptUrl": injectJavaScriptUrl, "appWebUrl": url}); loader.item.url = tabletApps.get(currentApp).appWebUrl; loader.item.scriptUrl = tabletApps.get(currentApp).scriptUrl; + if (loader.item.hasOwnProperty("gotoPreviousApp")) { + loader.item.gotoPreviousApp = true; + } } function returnToPreviousApp() { tabletApps.remove(currentApp); var isWebPage = tabletApps.get(currentApp).isWebUrl; - console.log(isWebPage); if (isWebPage) { var webUrl = tabletApps.get(currentApp).appWebUrl; var scriptUrl = tabletApps.get(currentApp).scriptUrl; loadSource("TabletWebView.qml"); loadWebUrl(webUrl, scriptUrl); } else { - console.log(tabletApps.get(currentApp).appUrl); loader.source = tabletApps.get(currentApp).appUrl; } } function loadWebUrl(url, injectedJavaScriptUrl) { + tabletApps.clear(); loader.item.url = url; loader.item.scriptURL = injectedJavaScriptUrl; tabletApps.append({"appUrl": "TabletWebView.qml", "isWebUrl": true, "scriptUrl": injectedJavaScriptUrl, "appWebUrl": url}); diff --git a/interface/resources/qml/hifi/tablet/tabletWindows/TabletPreferencesDialog.qml b/interface/resources/qml/hifi/tablet/tabletWindows/TabletPreferencesDialog.qml index 7ce0a6d714..2c8f6d9ea0 100644 --- a/interface/resources/qml/hifi/tablet/tabletWindows/TabletPreferencesDialog.qml +++ b/interface/resources/qml/hifi/tablet/tabletWindows/TabletPreferencesDialog.qml @@ -31,6 +31,7 @@ Item { property bool keyboardEnabled: false property bool keyboardRaised: false property bool punctuationMode: false + property bool gotoPreviousApp: false property var tablet; @@ -55,7 +56,13 @@ Item { } function closeDialog() { - Tablet.getTablet("com.highfidelity.interface.tablet.system").returnToPreviousApp(); + var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); + + if (gotoPreviousApp) { + tablet.returnToPreviousApp(); + } else { + tablet.gotoHomeScreen(); + } } Rectangle { diff --git a/libraries/script-engine/src/TabletScriptingInterface.h b/libraries/script-engine/src/TabletScriptingInterface.h index fc586957cd..be056dbf6f 100644 --- a/libraries/script-engine/src/TabletScriptingInterface.h +++ b/libraries/script-engine/src/TabletScriptingInterface.h @@ -99,7 +99,7 @@ public: bool getToolbarMode() const { return _toolbarMode; } void setToolbarMode(bool toolbarMode); - void initialScreen(const QVariant& url); + Q_INVOKABLE void initialScreen(const QVariant& url); /**jsdoc * transition to the home screen diff --git a/scripts/system/snapshot.js b/scripts/system/snapshot.js index 479545791d..78b9f210ba 100644 --- a/scripts/system/snapshot.js +++ b/scripts/system/snapshot.js @@ -37,13 +37,15 @@ function showFeedWindow() { || (!HMD.active && Settings.getValue("desktopTabletBecomesToolbar"))) { DialogsManager.showFeed(); } else { - tablet.loadQMLSource("TabletAddressDialog.qml"); + tablet.initialScreen("TabletAddressDialog.qml"); HMD.openTablet(); } } var outstanding; var readyData; +var shareAfterLogin = false; +var snapshotToShareAfterLogin; function onMessage(message) { // Receives message from the html dialog via the qwebchannel EventBridge. This is complicated by the following: // 1. Although we can send POJOs, we cannot receive a toplevel object. (Arrays of POJOs are fine, though.) @@ -82,24 +84,27 @@ function onMessage(message) { default: //tablet.webEventReceived.disconnect(onMessage); // <<< It's probably this that's missing?! HMD.closeTablet(); - tablet.gotoHomeScreen(); isLoggedIn = Account.isLoggedIn(); message.action.forEach(function (submessage) { if (submessage.share && !isLoggedIn) { needsLogin = true; submessage.share = false; + shareAfterLogin = true; + snapshotToShareAfterLogin = {path: submessage.localPath, href: submessage.href}; } if (submessage.share) { print('sharing', submessage.localPath); - outstanding++; - Window.shareSnapshot(submessage.localPath, submessage.href); + outstanding = true; + //Window.shareSnapshot(submessage.localPath, submessage.href); } else { print('not sharing', submessage.localPath); } }); - if (!outstanding && shouldOpenFeedAfterShare()) { - //showFeedWindow(); + print(shouldOpenFeedAfterShare()); + if (outstanding && shouldOpenFeedAfterShare()) { + showFeedWindow(); + outstanding = false; } if (needsLogin) { // after the possible feed, so that the login is on top var isLoggedIn = Account.isLoggedIn(); @@ -241,13 +246,22 @@ function onTabletScreenChanged(type, url) { isInSnapshotReview = false; } } +function onConnected() { + if (shareAfterLogin && Account.isLoggedIn()) { + print('sharing', snapshotToShareAfterLogin.path); + Window.shareSnapshot(snapshotToShareAfterLogin.path, snapshotToShareAfterLogin.href); + shareAfterLogin = false; + showFeedWindow(); + } + +} button.clicked.connect(onClicked); buttonConnected = true; Window.snapshotShared.connect(snapshotShared); Window.processingGif.connect(processingGif); tablet.screenChanged.connect(onTabletScreenChanged); - +Account.usernameChanged.connect(onConnected); Script.scriptEnding.connect(function () { if (buttonConnected) { button.clicked.disconnect(onClicked);