Working download and unpackage from Clara.io

This commit is contained in:
elisa-lj11 2016-07-22 15:33:58 -07:00
parent 49712060ed
commit 615627e981
5 changed files with 28 additions and 11 deletions

View file

@ -225,6 +225,9 @@ ScrollingWindow {
Component.onCompleted: {
desktop.initWebviewProfileHandlers(webview.profile)
}
//profile: desktop.browserProfile

View file

@ -25,6 +25,8 @@ WebEngineView {
});
}
// FIXME hack to get the URL with the auth token included. Remove when we move to Qt 5.6
Timer {
id: urlReplacementTimer
@ -68,9 +70,17 @@ WebEngineView {
request.openIn(newWindow.webView);
}
property var myScript: 'var element = $("a.download-file");
element.removeClass("download-file");
element.removeAttr("download _target");'
onLinkHovered: {
desktop.currentUrl = hoveredUrl
console.log("my url in WebView: " + desktop.currentUrl)
if (File.testUrl(desktop.currentUrl)) {
runJavaScript(myScript, function() {console.log("ran the JS"); });
}
}
// This breaks the webchannel used for passing messages. Fixed in Qt 5.6

View file

@ -19,7 +19,9 @@ OriginalDesktop.Desktop {
scrollGestureEnabled: false // we don't need/want these
onEntered: ApplicationCompositor.reticleOverDesktop = true
onExited: ApplicationCompositor.reticleOverDesktop = false
acceptedButtons: Qt.NoButton
acceptedButtons: Qt.NoButtonMouseArea
}
// The tool window, one instance
@ -82,11 +84,11 @@ OriginalDesktop.Desktop {
profile.downloadRequested.connect(function(download){
console.log("Download start: " + download.state)
if (!File.testUrl(currentUrl)) {
console.log("This file type is not accepted. Look for a zip file")
download.cancel()
return
}
//if (!File.testUrl(currentUrl)) {
//console.log("This file type is not accepted. Look for a zip file")
//download.cancel()
//return
//}
adaptedPath = File.convertUrlToPath(currentUrl)
download.path = "C:/Users/elisa/Downloads/" + adaptedPath
console.log("Path where it should download: " + download.path)

View file

@ -38,7 +38,8 @@ void FileScriptingInterface::runUnzip(QString path, QUrl url) {
}
bool FileScriptingInterface::testUrl(QUrl url) {
if (url.toString().contains(".zip")) return true;
if (url.toString().contains(".zip") && url.toString().contains("fbx")) return true;
qDebug() << "This model is not a .fbx packaged in a .zip. Please try with another model.";
return false;
}
@ -80,14 +81,14 @@ void FileScriptingInterface::unzipFile(QString path) {
//QString zipFileName = QFile::decodeName(compressedFileContent);
QString dirName = dir.path();
QDir testPath("C:/Users/elisa/Downloads/banana.zip");
//QDir testPath("C:/Users/elisa/Downloads/banana.zip");
qDebug() << "Zip directory is stored at: " + dirName;
QStringList list = JlCompress::extractDir(testPath.path(), "C:/Users/elisa/Downloads/test");
QStringList list = JlCompress::extractDir(dirName, "C:/Users/elisa/Downloads/test");
qDebug() << list;
//QFileInfoList files = dir.entryInfoList();
QFileInfoList files = testPath.entryInfoList();
QFileInfoList files = dir.entryInfoList();
foreach(QFileInfo file, files) {
qDebug() << "My file: " + file.fileName();
recursiveFileScan(file, &dirName);

View file

@ -12,7 +12,8 @@
var toolIconUrl = Script.resolvePath("assets/images/tools/");
//var EXAMPLES_URL = "https://metaverse.highfidelity.com/examples";
var EXAMPLES_URL = "https://clara.io/view/c1c4d926-5648-4fd3-9673-6d9018ad4627";
//var EXAMPLES_URL = "https://clara.io/view/c1c4d926-5648-4fd3-9673-6d9018ad4627";
var EXAMPLES_URL = "https://clara.io/library";
//var EXAMPLES_URL = "http://s3.amazonaws.com/DreamingContent/test.html";
//var EXAMPLES_URL = "https://hifi-content.s3.amazonaws.com/elisalj/test.html";
//var EXAMPLES_URL = "https://hifi-content.s3.amazonaws.com/elisalj/test_download.html";