Download through QML

It kind of works, not crashing like before, but the weird ghost
file/type error is still happening with multiple downloads
This commit is contained in:
elisa-lj11 2016-07-18 15:29:15 -07:00
parent eab7714d70
commit 6152fa28b7
7 changed files with 35 additions and 16 deletions

View file

@ -218,12 +218,27 @@ ScrollingWindow {
onIconChanged: {
console.log("New icon: " + icon)
}
onNewViewRequested:{
var component = Qt.createComponent("Browser.qml");
var newWindow = component.createObject(desktop);
request.openIn(newWindow.webView)
}
Component.onCompleted: {
webview.profile.downloadRequested.connect(function(download){
console.log("Download start: " + download.state)
download.accept()
console.log("Download accept: " + download.state)
if (download.state === WebEngineDownloadItem.DownloadInterrupted) {
console.log("Download? " + download.state)
console.log("download failed to complete")
}
})
webview.profile.downloadFinished.connect(function(download){
console.log("Download Finished: " + download.state)
if (download.state === WebEngineDownloadItem.DownloadCompleted) {console.log("getting download completed state")}
console.log("download success")
File.runUnzip(download.path)
})
}
//profile: desktop.browserProfile
}

View file

@ -62,8 +62,7 @@ WebEngineView {
onNewViewRequested: {
console.log("new view requested url");
console.log(request.url.toString());
//if (toString(request.url) )
//console.log("new view requested url" + request.url.toString());
var component = Qt.createComponent("../Browser.qml");
var newWindow = component.createObject(desktop);
request.openIn(newWindow.webView);

View file

@ -57,6 +57,7 @@
#include <display-plugins/DisplayPlugin.h>
#include <EntityScriptingInterface.h>
#include <ErrorDialog.h>
#include <FileScriptingInterface.h>
#include <Finally.h>
#include <FramebufferCache.h>
#include <gpu/Batch.h>
@ -1542,6 +1543,7 @@ void Application::initializeUi() {
rootContext->setContextProperty("Audio", &AudioScriptingInterface::getInstance());
rootContext->setContextProperty("Controller", DependencyManager::get<controller::ScriptingInterface>().data());
rootContext->setContextProperty("Entities", DependencyManager::get<EntityScriptingInterface>().data());
rootContext->setContextProperty("File", new FileScriptingInterface(engine));
rootContext->setContextProperty("MyAvatar", getMyAvatar());
rootContext->setContextProperty("Messages", DependencyManager::get<MessagesClient>().data());
rootContext->setContextProperty("Recording", DependencyManager::get<RecordingScriptingInterface>().data());

View file

@ -31,9 +31,9 @@ FileScriptingInterface::FileScriptingInterface(QObject* parent) : QObject(parent
// nothing for now
}
void FileScriptingInterface::runUnzip(QString path, QString importURL) {
downloadZip(path, importURL);
void FileScriptingInterface::runUnzip(QString path) {
//downloadZip(path, importURL);
qDebug() << "Path where download is saved: " + path;
}
QString FileScriptingInterface::getTempDir() {

View file

@ -21,17 +21,18 @@ class FileScriptingInterface : public QObject {
public:
FileScriptingInterface(QObject* parent);
void runUnzip(QString path, QString importURL);
//void runUnzip(QString path, QString importURL);
QString getTempDir();
public slots:
void unzipFile(QString path);
//void unzipFile(QString path);
void runUnzip(QString path);
signals:
private:
//void downloadZip();
//void unzipFile();
void unzipFile(QString path);
void recursiveFileScan(QFileInfo file, QString* dirName);
void downloadZip(QString path, const QString link);

View file

@ -1205,7 +1205,7 @@ function importSVO(importURL) {
}
Window.svoImportRequested.connect(importSVO);
// attempt to start ZIP download project
// attempt to start ZIP download project, GET RID OF THIS
function importZIP(importURL) {
print("Import ZIP requested: " + importURL);
/*if (!Entities.canAdjustLocks()) {

View file

@ -11,9 +11,11 @@
var toolIconUrl = Script.resolvePath("assets/images/tools/");
var EXAMPLES_URL = "https://metaverse.highfidelity.com/examples";
//var EXAMPLES_URL = "https://metaverse.highfidelity.com/examples";
//var EXAMPLES_URL = "https://clara.io/view/c1c4d926-5648-4fd3-9673-6d9018ad4627";
//var EXAMPLES_URL = "http://s3.amazonaws.com/DreamingContent/test.html";
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";
var examplesWindow = new OverlayWebWindow({
title: 'Examples',