Merge pull request #11251 from elisa-lj11/blocks

Blocks app accommodates updated Blocks website
This commit is contained in:
druiz17 2017-08-25 16:32:14 -07:00 committed by GitHub
commit 06ab8ddbb2
5 changed files with 47 additions and 8 deletions

View file

@ -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"}
}

View file

@ -96,7 +96,7 @@ Item {
function loadTabletWebBase() {
loader.source = "";
loader.source = "../../controls/TabletWebView.qml";
loader.source = "./BlocksWebView.qml";
}
function returnToPreviousApp() {

View file

@ -44,7 +44,7 @@ Windows.ScrollingWindow {
function loadTabletWebBase() {
loader.source = "";
loader.source = "../../controls/TabletWebView.qml";
loader.source = "./BlocksWebView.qml";
}
function loadWebUrl(url, injectedJavaScriptUrl) {

View file

@ -6457,7 +6457,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<NodeList>()->getThisNodeCanWriteAssets()) {
@ -6487,7 +6487,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;
}
@ -6504,6 +6504,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";

View file

@ -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);