diff --git a/interface/resources/qml/hifi/tablet/BlocksWebView.qml b/interface/resources/qml/hifi/tablet/BlocksWebView.qml new file mode 100644 index 0000000000..1e9eb3beb4 --- /dev/null +++ b/interface/resources/qml/hifi/tablet/BlocksWebView.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 +import QtWebEngine 1.2 + +import "../../controls" as Controls + +Controls.TabletWebView { + profile: WebEngineProfile { httpUserAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36"} +} + + diff --git a/interface/resources/qml/hifi/tablet/TabletRoot.qml b/interface/resources/qml/hifi/tablet/TabletRoot.qml index bbf56c7827..2f4c3cf62a 100644 --- a/interface/resources/qml/hifi/tablet/TabletRoot.qml +++ b/interface/resources/qml/hifi/tablet/TabletRoot.qml @@ -96,7 +96,7 @@ Item { function loadTabletWebBase() { loader.source = ""; - loader.source = "../../controls/TabletWebView.qml"; + loader.source = "./BlocksWebView.qml"; } function returnToPreviousApp() { diff --git a/interface/resources/qml/hifi/tablet/WindowRoot.qml b/interface/resources/qml/hifi/tablet/WindowRoot.qml index 8596007956..94847b2973 100644 --- a/interface/resources/qml/hifi/tablet/WindowRoot.qml +++ b/interface/resources/qml/hifi/tablet/WindowRoot.qml @@ -44,7 +44,7 @@ Windows.ScrollingWindow { function loadTabletWebBase() { loader.source = ""; - loader.source = "../../controls/TabletWebView.qml"; + loader.source = "./BlocksWebView.qml"; } function loadWebUrl(url, injectedJavaScriptUrl) { diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 8ffc51e4c7..f0d7fd0873 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -6458,7 +6458,7 @@ void Application::addAssetToWorldFromURL(QString url) { } if (url.contains("vr.google.com/downloads")) { filename = url.section('/', -1); - filename.remove(".zip?noDownload=false"); + filename.remove(".zip"); } if (!DependencyManager::get()->getThisNodeCanWriteAssets()) { @@ -6488,7 +6488,7 @@ void Application::addAssetToWorldFromURLRequestFinished() { } if (url.contains("vr.google.com/downloads")) { filename = url.section('/', -1); - filename.remove(".zip?noDownload=false"); + filename.remove(".zip"); isBlocks = true; } @@ -6505,6 +6505,7 @@ void Application::addAssetToWorldFromURLRequestFinished() { if (tempFile.open(QIODevice::WriteOnly)) { tempFile.write(request->getData()); addAssetToWorldInfoClear(filename); // Remove message from list; next one added will have a different key. + tempFile.close(); qApp->getFileDownloadInterface()->runUnzip(downloadPath, url, true, false, isBlocks); } else { QString errorInfo = "Couldn't open temporary file for download"; diff --git a/unpublishedScripts/marketplace/blocks/blocksApp.js b/unpublishedScripts/marketplace/blocks/blocksApp.js index 2c20e13005..c9e8682b23 100644 --- a/unpublishedScripts/marketplace/blocks/blocksApp.js +++ b/unpublishedScripts/marketplace/blocks/blocksApp.js @@ -15,28 +15,56 @@ (function () { var APP_NAME = "BLOCKS"; var APP_URL = "https://vr.google.com/objects/"; + var APP_OUTDATED_URL = "https://hifi-content.s3.amazonaws.com/elisalj/blocks/updateToBlocks.html"; var APP_ICON = "https://hifi-content.s3.amazonaws.com/elisalj/blocks/blocks-i.svg"; + var APP_ICON_ACTIVE = "https://hifi-content.s3.amazonaws.com/elisalj/blocks/blocks-a.svg"; try { print("Current Interface version: " + Window.checkVersion()); } catch(err) { print("Outdated Interface version does not support Blocks"); - APP_URL = "https://hifi-content.s3.amazonaws.com/elisalj/blocks/updateToBlocks.html"; + APP_URL = APP_OUTDATED_URL; } var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); var button = tablet.addButton({ - icon: APP_ICON, + icon: APP_ICON, + activeIcon: APP_ICON_ACTIVE, text: APP_NAME }); function onClicked() { - tablet.gotoWebScreen(APP_URL, "", true); + if (!shown) { + tablet.gotoWebScreen(APP_URL, "", true); + } else { + tablet.gotoHomeScreen(); + } } button.clicked.connect(onClicked); + var shown = false; + + function checkIfBlocks(url) { + if (url.indexOf("google") !== -1) { + return true; + } + return false; + } + + function onScreenChanged(type, url) { + if ((type === 'Web' && checkIfBlocks(url)) || url === APP_OUTDATED_URL) { + button.editProperties({ isActive: true }); + shown = true; + } else { + button.editProperties({ isActive: false }); + shown = false; + } + } + + tablet.screenChanged.connect(onScreenChanged); + function cleanup() { - tablet.removeButton(button); + tablet.removeButton(button); } Script.scriptEnding.connect(cleanup);