Added error feature when user tries to download a non fbx file

This commit is contained in:
elisa-lj11 2016-08-31 17:46:35 -07:00
parent 5c40e9a8f5
commit bebf9c5890
5 changed files with 51 additions and 7 deletions

View file

@ -28,8 +28,9 @@ Rectangle {
property var marketplacesUrl: "../../scripts/system/html/marketplaces.html" property var marketplacesUrl: "../../scripts/system/html/marketplaces.html"
property int statusBarHeight: 50 property int statusBarHeight: 50
property int statusMargin: 50 property int statusMargin: 50
property string standardMessage: "Check out other marketplaces" property string standardMessage: "Check out other marketplaces."
property string claraMessage: "Choose a model from the list and click Download -> Autodesk FBX" property string claraMessage: "Choose a model and click Download -> Autodesk FBX."
property string claraError: "High Fidelity only supports Autodesk FBX models."
Controls.BaseWebView { Controls.BaseWebView {
id: webview id: webview
@ -48,6 +49,15 @@ Rectangle {
onTriggered: handler(); onTriggered: handler();
} }
Timer {
id: alertTimer
running: false
repeat: false
interval: 9000
property var handler;
onTriggered: handler();
}
property var autoCancel: 'var element = $("a.btn.cancel"); property var autoCancel: 'var element = $("a.btn.cancel");
element.click();' element.click();'
@ -55,11 +65,32 @@ Rectangle {
element.removeClass("download-file"); element.removeClass("download-file");
element.removeAttr("download");' element.removeAttr("download");'
property var checkFileType: "$('[data-extension]:not([data-extension=\"fbx\"])').parent().remove()" function displayErrorStatus() {
alertTimer.handler = function() {
statusLabel.text = claraMessage;
statusBar.color = hifi.colors.blueHighlight;
statusIcon.text = hifi.glyphs.info;
}
alertTimer.start();
}
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: { onLinkHovered: {
desktop.currentUrl = hoveredUrl; 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)) { if (File.isZippedFbx(desktop.currentUrl)) {
runJavaScript(simpleDownload, function(){console.log("Download JS injection");}); runJavaScript(simpleDownload, function(){console.log("Download JS injection");});
} }
@ -71,6 +102,8 @@ Rectangle {
} else { } else {
statusLabel.text = standardMessage; statusLabel.text = standardMessage;
} }
statusBar.color = hifi.colors.blueHighlight;
statusIcon.text = hifi.glyphs.info;
} }
onNewViewRequested: { onNewViewRequested: {
@ -78,9 +111,9 @@ Rectangle {
var newWindow = component.createObject(desktop); var newWindow = component.createObject(desktop);
request.openIn(newWindow.webView); request.openIn(newWindow.webView);
if (File.isZippedFbx(desktop.currentUrl)) { if (File.isZippedFbx(desktop.currentUrl)) {
runJavaScript(autoCancel);
zipTimer.handler = function() { zipTimer.handler = function() {
newWindow.destroy(); newWindow.destroy();
runJavaScript(autoCancel);
} }
zipTimer.start(); zipTimer.start();
} }
@ -116,6 +149,7 @@ Rectangle {
anchors.leftMargin: statusMargin anchors.leftMargin: statusMargin
color: hifi.colors.white color: hifi.colors.white
text: standardMessage text: standardMessage
size: 18
} }
HiFiGlyphs { HiFiGlyphs {

View file

@ -69,11 +69,18 @@ bool FileScriptingInterface::isTempDir(QString tempDir) {
return false; return false;
} }
// checks whether the webview is displaying a Clara.io page for Marketplaces.qml
bool FileScriptingInterface::isClaraLink(QUrl url) { bool FileScriptingInterface::isClaraLink(QUrl url) {
if (url.toString().contains("clara") && !url.toString().contains("clara.io/signup")) return true; if (url.toString().contains("clara") && !url.toString().contains("clara.io/signup")) return true;
return false; 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) { bool FileScriptingInterface::isZippedFbx(QUrl url) {
if (url.toString().contains(".zip") && url.toString().contains("fbx")) return true; if (url.toString().contains(".zip") && url.toString().contains("fbx")) return true;
return false; return false;

View file

@ -24,6 +24,7 @@ public:
public slots: public slots:
bool isNotFbx(QUrl url);
bool isZippedFbx(QUrl url); bool isZippedFbx(QUrl url);
bool isClaraLink(QUrl url); bool isClaraLink(QUrl url);
QString convertUrlToPath(QUrl url); QString convertUrlToPath(QUrl url);

View file

@ -8,6 +8,7 @@
body { body {
background: white; background: white;
padding: 0 0 0 0; padding: 0 0 0 0;
font-family:Raleway-SemiBold;
} }
.marketplaces-container { .marketplaces-container {
display: inline-block; display: inline-block;
@ -38,6 +39,7 @@ body {
width: 62%; width: 62%;
} }
.exploreButton { .exploreButton {
font-size: 16px !important;
width: 200px !important; width: 200px !important;
height: 45px !important; height: 45px !important;
margin-top: 20px; margin-top: 20px;

View file

@ -21,8 +21,8 @@ var MARKETPLACE_URL = "https://metaverse.highfidelity.com/marketplace";
var marketplaceWindow = new OverlayWindow({ var marketplaceWindow = new OverlayWindow({
title: "Marketplace", title: "Marketplace",
source: qml, source: qml,
width: 900, width: 1000,
height: 700, height: 900,
toolWindow: false, toolWindow: false,
visible: false, visible: false,
}); });