mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 14:29:13 +02:00
Fix Clara download failing if move mouse after initiating download
This commit is contained in:
parent
e79f6b1203
commit
b672b7e177
2 changed files with 7 additions and 5 deletions
|
@ -96,7 +96,7 @@ Rectangle {
|
||||||
property string replaceFBXDownload: 'var element = $("a[data-extension=\'fbx\']:first");
|
property string replaceFBXDownload: 'var element = $("a[data-extension=\'fbx\']:first");
|
||||||
element.unbind("click");
|
element.unbind("click");
|
||||||
element.bind("click", function(event) {
|
element.bind("click", function(event) {
|
||||||
console.log("Initiate Clara.io FBX file download");
|
console.log("Initiate Clara.io FBX file download for {uuid}");
|
||||||
window.open("https://clara.io/api/scenes/{uuid}/export/fbx?fbxVersion=7.4&fbxEmbedTextures=true¢erScene=true&alignSceneGound=true");
|
window.open("https://clara.io/api/scenes/{uuid}/export/fbx?fbxVersion=7.4&fbxEmbedTextures=true¢erScene=true&alignSceneGound=true");
|
||||||
return false;
|
return false;
|
||||||
});'
|
});'
|
||||||
|
@ -105,7 +105,7 @@ Rectangle {
|
||||||
desktop.currentUrl = hoveredUrl;
|
desktop.currentUrl = hoveredUrl;
|
||||||
|
|
||||||
if (desktop.isClaraFBXZipDownload(desktop.currentUrl)) {
|
if (desktop.isClaraFBXZipDownload(desktop.currentUrl)) {
|
||||||
var doReplaceFBXDownload = replaceFBXDownload.replace("{uuid}", desktop.currentUrl.slice(desktop.currentUrl.lastIndexOf("/") + 1, -1));
|
var doReplaceFBXDownload = replaceFBXDownload.replace(/{uuid}/g, desktop.currentUrl.slice(desktop.currentUrl.lastIndexOf("/") + 1, -1));
|
||||||
runJavaScript(doReplaceFBXDownload);
|
runJavaScript(doReplaceFBXDownload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,6 +100,7 @@ OriginalDesktop.Desktop {
|
||||||
// Accept a download through the webview
|
// Accept a download through the webview
|
||||||
property bool webViewProfileSetup: false
|
property bool webViewProfileSetup: false
|
||||||
property string currentUrl: ""
|
property string currentUrl: ""
|
||||||
|
property string downloadUrl: ""
|
||||||
property string adaptedPath: ""
|
property string adaptedPath: ""
|
||||||
property string tempDir: ""
|
property string tempDir: ""
|
||||||
property bool autoAdd: false
|
property bool autoAdd: false
|
||||||
|
@ -111,16 +112,17 @@ OriginalDesktop.Desktop {
|
||||||
|
|
||||||
function initWebviewProfileHandlers(profile) {
|
function initWebviewProfileHandlers(profile) {
|
||||||
console.log("The webview url in desktop is: " + currentUrl);
|
console.log("The webview url in desktop is: " + currentUrl);
|
||||||
|
downloadUrl = currentUrl;
|
||||||
if (webViewProfileSetup) return;
|
if (webViewProfileSetup) return;
|
||||||
webViewProfileSetup = true;
|
webViewProfileSetup = true;
|
||||||
|
|
||||||
profile.downloadRequested.connect(function(download){
|
profile.downloadRequested.connect(function(download){
|
||||||
console.log("Download start: " + download.state);
|
console.log("Download start: " + download.state);
|
||||||
adaptedPath = File.convertUrlToPath(currentUrl);
|
adaptedPath = File.convertUrlToPath(downloadUrl);
|
||||||
tempDir = File.getTempDir();
|
tempDir = File.getTempDir();
|
||||||
console.log("Temp dir created: " + tempDir);
|
console.log("Temp dir created: " + tempDir);
|
||||||
download.path = tempDir + "/" + adaptedPath;
|
download.path = tempDir + "/" + adaptedPath;
|
||||||
if (isClaraFBXZipDownload(currentUrl)) {
|
if (isClaraFBXZipDownload(downloadUrl)) {
|
||||||
download.path += "fbx.zip";
|
download.path += "fbx.zip";
|
||||||
}
|
}
|
||||||
console.log("Path where object should download: " + download.path);
|
console.log("Path where object should download: " + download.path);
|
||||||
|
@ -133,7 +135,7 @@ OriginalDesktop.Desktop {
|
||||||
|
|
||||||
profile.downloadFinished.connect(function(download){
|
profile.downloadFinished.connect(function(download){
|
||||||
if (download.state === WebEngineDownloadItem.DownloadCompleted) {
|
if (download.state === WebEngineDownloadItem.DownloadCompleted) {
|
||||||
File.runUnzip(download.path, currentUrl, autoAdd);
|
File.runUnzip(download.path, downloadUrl, autoAdd);
|
||||||
} else {
|
} else {
|
||||||
console.log("The download was corrupted, state: " + download.state);
|
console.log("The download was corrupted, state: " + download.state);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue