diff --git a/interface/resources/qml/Marketplaces.qml b/interface/resources/qml/Marketplaces.qml index 3acd90d6a1..8e6fe51245 100644 --- a/interface/resources/qml/Marketplaces.qml +++ b/interface/resources/qml/Marketplaces.qml @@ -28,8 +28,9 @@ Rectangle { property var marketplacesUrl: "../../scripts/system/html/marketplaces.html" property int statusBarHeight: 50 property int statusMargin: 50 - property string standardMessage: "Check out other marketplaces" - property string claraMessage: "Choose a model from the list and click Download -> Autodesk FBX" + property string standardMessage: "Check out other marketplaces." + property string claraMessage: "Choose a model and click Download -> Autodesk FBX." + property string claraError: "High Fidelity only supports Autodesk FBX models." Controls.BaseWebView { id: webview @@ -48,18 +49,48 @@ Rectangle { onTriggered: handler(); } + Timer { + id: alertTimer + running: false + repeat: false + interval: 9000 + property var handler; + onTriggered: handler(); + } + property var autoCancel: 'var element = $("a.btn.cancel"); element.click();' property var simpleDownload: 'var element = $("a.download-file"); element.removeClass("download-file"); element.removeAttr("download");' + + function displayErrorStatus() { + alertTimer.handler = function() { + statusLabel.text = claraMessage; + statusBar.color = hifi.colors.blueHighlight; + statusIcon.text = hifi.glyphs.info; + } + alertTimer.start(); + } - property var checkFileType: "$('[data-extension]:not([data-extension=\"fbx\"])').parent().remove()" + property var notFbxHandler: 'var element = $("a.btn.btn-primary.viewer-button.download-file") + element.click();' + + // this code is for removing other file types from Clara.io's download options + //property var checkFileType: "$('[data-extension]:not([data-extension=\"fbx\"])').parent().remove()" onLinkHovered: { desktop.currentUrl = hoveredUrl; - runJavaScript(checkFileType, function(){console.log("Remove filetypes JS injection");}); + //runJavaScript(checkFileType, function(){console.log("Remove filetypes JS injection");}); + + if (File.isNotFbx(desktop.currentUrl)) { + statusLabel.text = claraError; + statusBar.color = hifi.colors.redHighlight; + statusIcon.text = hifi.glyphs.alert; + runJavaScript(notFbxHandler, displayErrorStatus()); + } + if (File.isZippedFbx(desktop.currentUrl)) { runJavaScript(simpleDownload, function(){console.log("Download JS injection");}); } @@ -71,6 +102,8 @@ Rectangle { } else { statusLabel.text = standardMessage; } + statusBar.color = hifi.colors.blueHighlight; + statusIcon.text = hifi.glyphs.info; } onNewViewRequested: { @@ -78,9 +111,9 @@ Rectangle { var newWindow = component.createObject(desktop); request.openIn(newWindow.webView); if (File.isZippedFbx(desktop.currentUrl)) { + runJavaScript(autoCancel); zipTimer.handler = function() { newWindow.destroy(); - runJavaScript(autoCancel); } zipTimer.start(); } @@ -116,6 +149,7 @@ Rectangle { anchors.leftMargin: statusMargin color: hifi.colors.white text: standardMessage + size: 18 } HiFiGlyphs { diff --git a/libraries/script-engine/src/FileScriptingInterface.cpp b/libraries/script-engine/src/FileScriptingInterface.cpp index 46bcd66ede..88d6f348aa 100644 --- a/libraries/script-engine/src/FileScriptingInterface.cpp +++ b/libraries/script-engine/src/FileScriptingInterface.cpp @@ -69,11 +69,18 @@ bool FileScriptingInterface::isTempDir(QString tempDir) { return false; } +// checks whether the webview is displaying a Clara.io page for Marketplaces.qml bool FileScriptingInterface::isClaraLink(QUrl url) { if (url.toString().contains("clara") && !url.toString().contains("clara.io/signup")) return true; return false; } +// checks whether a user tries to download a file that is not in .fbx format +bool FileScriptingInterface::isNotFbx(QUrl url) { + if (url.toString().contains(".zip") && !(url.toString().contains("fbx") )) return true; + return false; +} + bool FileScriptingInterface::isZippedFbx(QUrl url) { if (url.toString().contains(".zip") && url.toString().contains("fbx")) return true; return false; diff --git a/libraries/script-engine/src/FileScriptingInterface.h b/libraries/script-engine/src/FileScriptingInterface.h index 976a9a0097..ffb10d7ada 100644 --- a/libraries/script-engine/src/FileScriptingInterface.h +++ b/libraries/script-engine/src/FileScriptingInterface.h @@ -24,6 +24,7 @@ public: public slots: + bool isNotFbx(QUrl url); bool isZippedFbx(QUrl url); bool isClaraLink(QUrl url); QString convertUrlToPath(QUrl url); diff --git a/scripts/system/html/css/marketplaces.css b/scripts/system/html/css/marketplaces.css index e516715c03..734501f3fc 100644 --- a/scripts/system/html/css/marketplaces.css +++ b/scripts/system/html/css/marketplaces.css @@ -8,6 +8,7 @@ body { background: white; padding: 0 0 0 0; + font-family:Raleway-SemiBold; } .marketplaces-container { display: inline-block; @@ -38,6 +39,7 @@ body { width: 62%; } .exploreButton { + font-size: 16px !important; width: 200px !important; height: 45px !important; margin-top: 20px; diff --git a/scripts/system/marketplaces/clara.js b/scripts/system/marketplaces/clara.js index b6e79f04e2..a04400497f 100644 --- a/scripts/system/marketplaces/clara.js +++ b/scripts/system/marketplaces/clara.js @@ -21,8 +21,8 @@ var MARKETPLACE_URL = "https://metaverse.highfidelity.com/marketplace"; var marketplaceWindow = new OverlayWindow({ title: "Marketplace", source: qml, - width: 900, - height: 700, + width: 1000, + height: 900, toolWindow: false, visible: false, });