Display Clara.io download information

This commit is contained in:
David Rowe 2016-11-10 16:29:48 +13:00 committed by Seth Alves
parent 9c2252bd7e
commit 1987719cfd
3 changed files with 8 additions and 28 deletions

View file

@ -76,10 +76,6 @@ Rectangle {
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;
@ -92,26 +88,20 @@ Rectangle {
property var notFbxHandler: 'var element = $("a.btn.btn-primary.viewer-button.download-file")
element.click();'
// Replace Clara FBX download link action with Cara API action.
property string replaceFBXDownload: 'var element = $("a[data-extension=\'fbx\']:first");
element.unbind("click");
// Overload Clara FBX download link action.
property string replaceFBXDownload: 'var element = $("a.download-file");
element.removeClass("download-file");
element.removeAttr("download");
element.bind("click", function(event) {
console.log("Initiate Clara.io FBX file download for {uuid}");
EventBridge.emitWebEvent("CLARA.IO DOWNLOAD");
window.open("https://clara.io/api/scenes/{uuid}/export/fbx?fbxVersion=7.4&fbxEmbedTextures=true&centerScene=true&alignSceneGound=true");
return false;
console.log("Clara.io FBX file download initiated for {uuid}");
});'
onLinkHovered: {
desktop.currentUrl = hoveredUrl;
if (desktop.isClaraFBXZipDownload(desktop.currentUrl)) {
var doReplaceFBXDownload = replaceFBXDownload.replace(/{uuid}/g, desktop.currentUrl.slice(desktop.currentUrl.lastIndexOf("/") + 1, -1));
runJavaScript(doReplaceFBXDownload);
}
if (File.isZippedFbx(desktop.currentUrl)) {
runJavaScript(simpleDownload, function(){console.log("Download JS injection");});
runJavaScript(replaceFBXDownload, function(){console.log("Download JS injection");});
return;
}
@ -145,7 +135,7 @@ Rectangle {
newWindow.height = 0;
request.openIn(newWindow.webView);
if (desktop.isClaraFBXZipDownload(desktop.currentUrl)) {
if (File.isZippedFbx(desktop.currentUrl)) {
newWindow.setAutoAdd(true);
runJavaScript(autoCancel);
newWindow.loadingChanged.connect(function(status) {

View file

@ -105,11 +105,6 @@ OriginalDesktop.Desktop {
property string tempDir: ""
property bool autoAdd: false
function isClaraFBXZipDownload(url) {
// Clara.io FBX file: Original URL that is ovrridden in JavaScript to download using API.
return url.indexOf("clara.io/view/") !== -1 && url.slice(-1) === "#";
}
function initWebviewProfileHandlers(profile) {
console.log("The webview url in desktop is: " + currentUrl);
downloadUrl = currentUrl;
@ -122,9 +117,6 @@ OriginalDesktop.Desktop {
tempDir = File.getTempDir();
console.log("Temp dir created: " + tempDir);
download.path = tempDir + "/" + adaptedPath;
if (isClaraFBXZipDownload(downloadUrl)) {
download.path += "fbx.zip";
}
console.log("Path where object should download: " + download.path);
console.log("Auto add: " + autoAdd);
download.accept();

View file

@ -5475,7 +5475,7 @@ void Application::addAssetToWorldInitiate() {
if (!_addAssetToWorldMessageBox) {
_addAssetToWorldMessageBox = DependencyManager::get<OffscreenUi>()->createMessageBox(OffscreenUi::ICON_INFORMATION,
"Downloading Asset", "Preparing asset for download.", QMessageBox::Cancel, QMessageBox::NoButton);
"Downloading Asset", "Downloading asset file.", QMessageBox::Cancel, QMessageBox::NoButton);
}
connect(_addAssetToWorldMessageBox, SIGNAL(destroyed()), this, SLOT(onAssetToWorldMessageBoxClosed()));
@ -5499,8 +5499,6 @@ void Application::addAssetToWorld(QString filePath) {
return;
}
_addAssetToWorldMessageBox->setProperty("text", "Downloading asset file.");
if (!DependencyManager::get<NodeList>()->getThisNodeCanWriteAssets()) {
QString errorInfo = "Do not have permissions to write to asset server.";
qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo;