From 2b402609535e3b758df1ecd707ae9f162abd54d6 Mon Sep 17 00:00:00 2001 From: Roxanne Skelly Date: Tue, 5 Feb 2019 09:27:12 -0800 Subject: [PATCH] QmlMarketplace - disable HTML for quest --- .../hifi/commerce/marketplace/Marketplace.qml | 43 +++++++++++---- .../commerce/marketplace/MarketplaceItem.qml | 54 +++++++++++-------- interface/src/Application.cpp | 7 +++ .../PlatformInfoScriptingInterface.cpp | 8 +++ .../PlatformInfoScriptingInterface.h | 6 +++ 5 files changed, 85 insertions(+), 33 deletions(-) diff --git a/interface/resources/qml/hifi/commerce/marketplace/Marketplace.qml b/interface/resources/qml/hifi/commerce/marketplace/Marketplace.qml index a4cf260173..1db133c249 100644 --- a/interface/resources/qml/hifi/commerce/marketplace/Marketplace.qml +++ b/interface/resources/qml/hifi/commerce/marketplace/Marketplace.qml @@ -39,7 +39,8 @@ Rectangle { property bool keyboardRaised: false property string searchScopeString: "Featured" property bool isLoggedIn: false; - + property bool supports3DHTML: true; + anchors.fill: (typeof parent === undefined) ? undefined : parent function getMarketplaceItems() { @@ -60,6 +61,8 @@ Rectangle { Component.onCompleted: { Commerce.getLoginStatus(); + + supports3DHTML = PlatformInfo.has3DHTML(); } Component.onDestruction: { @@ -103,7 +106,7 @@ Rectangle { if (result.status !== 'success') { console.log("Failed to get Marketplace Item", result.data.message); } else { - + marketplaceItem.supports3DHTML = root.supports3DHTML; marketplaceItem.item_id = result.data.id; marketplaceItem.image_url = result.data.thumbnail_url; marketplaceItem.name = result.data.title; @@ -958,8 +961,16 @@ Rectangle { } onShowLicense: { - licenseInfoWebView.url = url; - licenseInfo.visible = true; + var xhr = new XMLHttpRequest; + xhr.open("GET", url); + xhr.onreadystatechange = function() { + if (xhr.readyState == XMLHttpRequest.DONE) { + console.log(xhr.responseText); + licenseText.text = xhr.responseText; + licenseInfo.visible = true; + } + }; + xhr.send(); } onCategoryClicked: { root.categoryString = category; @@ -1001,11 +1012,13 @@ Rectangle { leftMargin: 15 } + + Item { id: footerText anchors.fill: parent - visible: itemsList.visible + visible: root.supports3DHTML && itemsList.visible HiFiGlyphs { id: footerGlyph @@ -1072,6 +1085,8 @@ Rectangle { rightMargin: 10 } + visible: root.supports3DHTML + text: "SEE ALL MARKETS" width: 180 @@ -1100,16 +1115,24 @@ Rectangle { visible: false; - HifiControlsUit.WebView { - id: licenseInfoWebView - + ScrollView { anchors { bottomMargin: 1 topMargin: 60 - leftMargin: 1 - rightMargin: 1 + leftMargin: 15 fill: parent } + + RalewayRegular { + id: licenseText + + width:440 + wrapMode: Text.Wrap + + text: "" + size: 18; + color: hifi.colors.baseGray + } } Item { diff --git a/interface/resources/qml/hifi/commerce/marketplace/MarketplaceItem.qml b/interface/resources/qml/hifi/commerce/marketplace/MarketplaceItem.qml index b7e9a711d2..0c6d661609 100644 --- a/interface/resources/qml/hifi/commerce/marketplace/MarketplaceItem.qml +++ b/interface/resources/qml/hifi/commerce/marketplace/MarketplaceItem.qml @@ -43,6 +43,8 @@ Rectangle { property string created_at: "" property bool isLoggedIn: false; property int edition: -1; + property bool supports3DHTML: false; + onCategoriesChanged: { categoriesListModel.clear(); @@ -52,8 +54,13 @@ Rectangle { } onDescriptionChanged: { - descriptionTextModel.clear(); - descriptionTextModel.append({text: description}) + + if(root.supports3DHTML) { + descriptionTextModel.clear(); + descriptionTextModel.append({text: description}); + } else { + descriptionText.text = description; + } } signal buy() @@ -410,22 +417,22 @@ Rectangle { if (root.license === "No Rights Reserved (CC0)") { url = "https://creativecommons.org/publicdomain/zero/1.0/" } else if (root.license === "Attribution (CC BY)") { - url = "https://creativecommons.org/licenses/by/4.0/" + url = "https://creativecommons.org/licenses/by/4.0/legalcode.txt" } else if (root.license === "Attribution-ShareAlike (CC BY-SA)") { - url = "https://creativecommons.org/licenses/by-sa/4.0/" + url = "https://creativecommons.org/licenses/by-sa/4.0/legalcode.txt" } else if (root.license === "Attribution-NoDerivs (CC BY-ND)") { - url = "https://creativecommons.org/licenses/by-nd/4.0/" + url = "https://creativecommons.org/licenses/by-nd/4.0/legalcode.txt" } else if (root.license === "Attribution-NonCommercial (CC BY-NC)") { - url = "https://creativecommons.org/licenses/by-nc/4.0/" + url = "https://creativecommons.org/licenses/by-nc/4.0/legalcode.txt" } else if (root.license === "Attribution-NonCommercial-ShareAlike (CC BY-NC-SA)") { - url = "https://creativecommons.org/licenses/by-nc-sa/4.0/" + url = "https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode.txt" } else if (root.license === "Attribution-NonCommercial-NoDerivs (CC BY-NC-ND)") { - url = "https://creativecommons.org/licenses/by-nc-nd/4.0/" + url = "https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode.txt" } else if (root.license === "Proof of Provenance License (PoP License)") { url = "https://digitalassetregistry.com/PoP-License/v1/" } if(url) { - licenseInfoWebView.url = url; + showLicense(url) } } } @@ -460,20 +467,21 @@ Rectangle { verticalAlignment: Text.AlignVCenter } - //RalewaySemiBold { - // id: descriptionText - // - // anchors.top: descriptionLabel.bottom - // anchors.left: parent.left - // anchors.topMargin: 5 - // width: parent.width - // - // text: root.description - // size: 14 - // color: hifi.colors.lightGray - // verticalAlignment: Text.AlignVCenter - // wrapMode: Text.Wrap - //} + RalewaySemiBold { + id: descriptionText + + anchors.top: descriptionLabel.bottom + anchors.left: parent.left + anchors.topMargin: 5 + width: parent.width + + visible: !root.supports3DHTML + + text: root.description + size: 14 + color: hifi.colors.lightGray + wrapMode: Text.Wrap + } ListModel { diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 39ab3a8b1c..48c8f35ede 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3000,6 +3000,13 @@ void Application::initializeUi() { QUrl{ "hifi/commerce/marketplace/Marketplace.qml" }, }, marketplaceCallback); + QmlContextCallback platformInfoCallback = [](QQmlContext* context) { + context->setContextProperty("PlatformInfo", new PlatformInfoScriptingInterface()); + }; + OffscreenQmlSurface::addWhitelistContextHandler({ + QUrl{ "hifi/commerce/marketplace/Marketplace.qml" }, + }, platformInfoCallback); + QmlContextCallback ttsCallback = [](QQmlContext* context) { context->setContextProperty("TextToSpeech", DependencyManager::get().data()); }; diff --git a/interface/src/scripting/PlatformInfoScriptingInterface.cpp b/interface/src/scripting/PlatformInfoScriptingInterface.cpp index b6e4df0d40..b390ab7119 100644 --- a/interface/src/scripting/PlatformInfoScriptingInterface.cpp +++ b/interface/src/scripting/PlatformInfoScriptingInterface.cpp @@ -133,3 +133,11 @@ bool PlatformInfoScriptingInterface::hasRiftControllers() { bool PlatformInfoScriptingInterface::hasViveControllers() { return qApp->hasViveControllers(); } + +bool PlatformInfoScriptingInterface::has3DHTML() { +#if defined(Q_OS_ANDROID) + return false; +#else + return true; +#endif +} diff --git a/interface/src/scripting/PlatformInfoScriptingInterface.h b/interface/src/scripting/PlatformInfoScriptingInterface.h index 3ed57965c9..aece09b008 100644 --- a/interface/src/scripting/PlatformInfoScriptingInterface.h +++ b/interface/src/scripting/PlatformInfoScriptingInterface.h @@ -65,6 +65,12 @@ public slots: * @function Window.hasRift * @returns {boolean} true if running on Windows, otherwise false.*/ bool hasViveControllers(); + + /**jsdoc + * Returns true if device supports 3d HTML + * @function Window.hasRift + * @returns {boolean} true if device supports 3d HTML, otherwise false.*/ + bool has3DHTML(); }; #endif // hifi_PlatformInfoScriptingInterface_h