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 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 {

View file

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

View file

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

View file

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

View file

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