mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-30 07:50:14 +02:00
Made code more QA; extra browser and download widget close upon download
This commit is contained in:
parent
a94a304700
commit
b1b2ea48b2
13 changed files with 144 additions and 196 deletions
|
@ -140,7 +140,6 @@ ScrollingWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< ab02d16eb7656ea0a37785a398716fad62dff045
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id:permissionsContainer
|
id:permissionsContainer
|
||||||
visible:false
|
visible:false
|
||||||
|
@ -197,8 +196,6 @@ ScrollingWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
=======
|
|
||||||
>>>>>>> Zip download works
|
|
||||||
|
|
||||||
WebEngineView {
|
WebEngineView {
|
||||||
id: webview
|
id: webview
|
||||||
|
@ -221,15 +218,11 @@ ScrollingWindow {
|
||||||
onIconChanged: {
|
onIconChanged: {
|
||||||
console.log("New icon: " + icon)
|
console.log("New icon: " + icon)
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
desktop.initWebviewProfileHandlers(webview.profile)
|
desktop.initWebviewProfileHandlers(webview.profile)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//profile: desktop.browserProfile
|
//profile: desktop.browserProfile
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,23 +62,41 @@ WebEngineView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: zipTimer
|
||||||
|
running: false
|
||||||
|
repeat: false
|
||||||
|
interval: 1000
|
||||||
|
property var handler;
|
||||||
|
onTriggered: handler();
|
||||||
|
}
|
||||||
|
|
||||||
|
property var autoCancel: 'var element = $("a.btn.cancel");
|
||||||
|
element.click();'
|
||||||
|
|
||||||
onNewViewRequested: {
|
onNewViewRequested: {
|
||||||
console.log("new view requested url");
|
console.log("new view requested url");
|
||||||
//console.log("new view requested url" + request.url.toString());
|
|
||||||
var component = Qt.createComponent("../Browser.qml");
|
var component = Qt.createComponent("../Browser.qml");
|
||||||
var newWindow = component.createObject(desktop);
|
var newWindow = component.createObject(desktop);
|
||||||
request.openIn(newWindow.webView);
|
request.openIn(newWindow.webView);
|
||||||
|
if (File.testUrl(desktop.currentUrl)) {
|
||||||
|
zipTimer.handler = function() {
|
||||||
|
newWindow.destroy();
|
||||||
|
runJavaScript(autoCancel);
|
||||||
|
}
|
||||||
|
zipTimer.start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
property var myScript: 'var element = $("a.download-file");
|
property var simpleDownload: 'var element = $("a.download-file");
|
||||||
element.removeClass("download-file");
|
element.removeClass("download-file");
|
||||||
element.removeAttr("download _target");'
|
element.removeAttr("download");'
|
||||||
|
|
||||||
onLinkHovered: {
|
onLinkHovered: {
|
||||||
desktop.currentUrl = hoveredUrl
|
desktop.currentUrl = hoveredUrl
|
||||||
console.log("my url in WebView: " + desktop.currentUrl)
|
console.log("my url in WebView: " + desktop.currentUrl)
|
||||||
if (File.testUrl(desktop.currentUrl)) {
|
if (File.testUrl(desktop.currentUrl)) {
|
||||||
runJavaScript(myScript, function() {console.log("ran the JS"); });
|
runJavaScript(simpleDownload, function(){console.log("ran the JS");});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ OriginalDesktop.Desktop {
|
||||||
scrollGestureEnabled: false // we don't need/want these
|
scrollGestureEnabled: false // we don't need/want these
|
||||||
onEntered: ApplicationCompositor.reticleOverDesktop = true
|
onEntered: ApplicationCompositor.reticleOverDesktop = true
|
||||||
onExited: ApplicationCompositor.reticleOverDesktop = false
|
onExited: ApplicationCompositor.reticleOverDesktop = false
|
||||||
acceptedButtons: Qt.NoButtonMouseArea
|
acceptedButtons: Qt.NoButton
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -77,37 +77,32 @@ OriginalDesktop.Desktop {
|
||||||
property bool webViewProfileSetup: false
|
property bool webViewProfileSetup: false
|
||||||
property string currentUrl: ""
|
property string currentUrl: ""
|
||||||
property string adaptedPath: ""
|
property string adaptedPath: ""
|
||||||
|
|
||||||
function initWebviewProfileHandlers(profile) {
|
function initWebviewProfileHandlers(profile) {
|
||||||
console.log("the webview url in desktop is: " + currentUrl)
|
console.log("the webview url in desktop is: " + 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);
|
||||||
//if (!File.testUrl(currentUrl)) {
|
adaptedPath = File.convertUrlToPath(currentUrl);
|
||||||
//console.log("This file type is not accepted. Look for a zip file")
|
download.path = "C:/Users/elisa/Downloads/" + adaptedPath;
|
||||||
//download.cancel()
|
console.log("Path where it should download: " + download.path);
|
||||||
//return
|
download.accept();
|
||||||
//}
|
console.log("Download accept: " + download.state);
|
||||||
adaptedPath = File.convertUrlToPath(currentUrl)
|
|
||||||
download.path = "C:/Users/elisa/Downloads/" + adaptedPath
|
|
||||||
console.log("Path where it should download: " + download.path)
|
|
||||||
download.accept()
|
|
||||||
console.log("Download accept: " + download.state)
|
|
||||||
if (download.state === WebEngineDownloadItem.DownloadInterrupted) {
|
if (download.state === WebEngineDownloadItem.DownloadInterrupted) {
|
||||||
console.log("Download? " + download.state)
|
console.log("Download? " + download.state);
|
||||||
console.log("download failed to complete")
|
console.log("download failed to complete");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
profile.downloadFinished.connect(function(download){
|
profile.downloadFinished.connect(function(download){
|
||||||
if (download.state === WebEngineDownloadItem.DownloadCompleted) {
|
if (download.state === WebEngineDownloadItem.DownloadCompleted) {
|
||||||
console.log("Download Finished: " + download.state)
|
console.log("Download Finished: " + download.state);
|
||||||
console.log("File object is: " + File)
|
console.log("File object is: " + File);
|
||||||
File.runUnzip(download.path, currentUrl)
|
File.runUnzip(download.path, currentUrl);
|
||||||
//download.cancel()
|
|
||||||
} else {
|
} else {
|
||||||
console.log("The download was corrupted, state: " + download.state)
|
console.log("The download was corrupted, state: " + download.state);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -355,7 +355,6 @@ public:
|
||||||
|
|
||||||
if (message->message == WM_COPYDATA) {
|
if (message->message == WM_COPYDATA) {
|
||||||
COPYDATASTRUCT* pcds = (COPYDATASTRUCT*)(message->lParam);
|
COPYDATASTRUCT* pcds = (COPYDATASTRUCT*)(message->lParam);
|
||||||
qDebug() << "os windows url for some reason";
|
|
||||||
QUrl url = QUrl((const char*)(pcds->lpData));
|
QUrl url = QUrl((const char*)(pcds->lpData));
|
||||||
if (url.isValid() && url.scheme() == HIFI_URL_SCHEME) {
|
if (url.isValid() && url.scheme() == HIFI_URL_SCHEME) {
|
||||||
DependencyManager::get<AddressManager>()->handleLookupString(url.toString());
|
DependencyManager::get<AddressManager>()->handleLookupString(url.toString());
|
||||||
|
@ -1543,7 +1542,6 @@ void Application::initializeUi() {
|
||||||
rootContext->setContextProperty("Audio", &AudioScriptingInterface::getInstance());
|
rootContext->setContextProperty("Audio", &AudioScriptingInterface::getInstance());
|
||||||
rootContext->setContextProperty("Controller", DependencyManager::get<controller::ScriptingInterface>().data());
|
rootContext->setContextProperty("Controller", DependencyManager::get<controller::ScriptingInterface>().data());
|
||||||
rootContext->setContextProperty("Entities", DependencyManager::get<EntityScriptingInterface>().data());
|
rootContext->setContextProperty("Entities", DependencyManager::get<EntityScriptingInterface>().data());
|
||||||
//rootContext->setContextProperty("File", new FileScriptingInterface(engine));
|
|
||||||
FileScriptingInterface* fileDownload = new FileScriptingInterface(engine);
|
FileScriptingInterface* fileDownload = new FileScriptingInterface(engine);
|
||||||
rootContext->setContextProperty("File", fileDownload);
|
rootContext->setContextProperty("File", fileDownload);
|
||||||
connect(fileDownload, &FileScriptingInterface::unzipSuccess, this, &Application::toggleAssetServerWidget);
|
connect(fileDownload, &FileScriptingInterface::unzipSuccess, this, &Application::toggleAssetServerWidget);
|
||||||
|
@ -2020,14 +2018,6 @@ bool Application::importSVOFromURL(const QString& urlString) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// attempt to start ZIP download project
|
|
||||||
bool Application::importZIPFromURL(const QString& urlString) {
|
|
||||||
qDebug() << "zip import request has been emitted";
|
|
||||||
emit zipImportRequested(urlString);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// end attempt
|
|
||||||
|
|
||||||
bool Application::event(QEvent* event) {
|
bool Application::event(QEvent* event) {
|
||||||
|
|
||||||
if (!Menu::getInstance()) {
|
if (!Menu::getInstance()) {
|
||||||
|
@ -2147,26 +2137,21 @@ bool Application::event(QEvent* event) {
|
||||||
// handle custom URL
|
// handle custom URL
|
||||||
if (event->type() == QEvent::FileOpen) {
|
if (event->type() == QEvent::FileOpen) {
|
||||||
|
|
||||||
qDebug() << "we have received one url!: ";
|
|
||||||
QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event);
|
QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event);
|
||||||
|
|
||||||
QUrl url = fileEvent->url();
|
QUrl url = fileEvent->url();
|
||||||
|
|
||||||
if (!url.isEmpty()) {
|
if (!url.isEmpty()) {
|
||||||
QString urlString = url.toString();
|
QString urlString = url.toString();
|
||||||
qDebug() << "we got a url!: " + urlString;
|
|
||||||
if (canAcceptURL(urlString)) {
|
if (canAcceptURL(urlString)) {
|
||||||
qDebug() << "we got an ACCEPTED url!: " + urlString;
|
|
||||||
return acceptURL(urlString);
|
return acceptURL(urlString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event->type() == QEvent::None) {
|
|
||||||
qDebug() << "this url just didn't click";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (HFActionEvent::types().contains(event->type())) {
|
if (HFActionEvent::types().contains(event->type())) {
|
||||||
_controllerScriptingInterface->handleMetaEvent(static_cast<HFMetaEvent*>(event));
|
_controllerScriptingInterface->handleMetaEvent(static_cast<HFMetaEvent*>(event));
|
||||||
}
|
}
|
||||||
|
@ -3190,7 +3175,6 @@ void Application::saveSettings() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::importEntities(const QString& urlOrFilename) {
|
bool Application::importEntities(const QString& urlOrFilename) {
|
||||||
qDebug() << "import entities url";
|
|
||||||
bool success = false;
|
bool success = false;
|
||||||
_entityClipboard->withWriteLock([&] {
|
_entityClipboard->withWriteLock([&] {
|
||||||
_entityClipboard->eraseAllOctreeElements();
|
_entityClipboard->eraseAllOctreeElements();
|
||||||
|
@ -4800,7 +4784,6 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::canAcceptURL(const QString& urlString) const {
|
bool Application::canAcceptURL(const QString& urlString) const {
|
||||||
qDebug() << "stepping through 'canAcceptURL'";
|
|
||||||
QUrl url(urlString);
|
QUrl url(urlString);
|
||||||
if (urlString.startsWith(HIFI_URL_SCHEME)) {
|
if (urlString.startsWith(HIFI_URL_SCHEME)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -4817,7 +4800,6 @@ bool Application::canAcceptURL(const QString& urlString) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::acceptURL(const QString& urlString, bool defaultUpload) {
|
bool Application::acceptURL(const QString& urlString, bool defaultUpload) {
|
||||||
qDebug() << "stepping through 'acceptURL'";
|
|
||||||
if (urlString.startsWith(HIFI_URL_SCHEME)) {
|
if (urlString.startsWith(HIFI_URL_SCHEME)) {
|
||||||
// this is a hifi URL - have the AddressManager handle it
|
// this is a hifi URL - have the AddressManager handle it
|
||||||
QMetaObject::invokeMethod(DependencyManager::get<AddressManager>().data(), "handleLookupString",
|
QMetaObject::invokeMethod(DependencyManager::get<AddressManager>().data(), "handleLookupString",
|
||||||
|
@ -4847,7 +4829,6 @@ void Application::setSessionUUID(const QUuid& sessionUUID) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::askToSetAvatarUrl(const QString& url) {
|
bool Application::askToSetAvatarUrl(const QString& url) {
|
||||||
qDebug() << "setting avatar url";
|
|
||||||
QUrl realUrl(url);
|
QUrl realUrl(url);
|
||||||
if (realUrl.isLocalFile()) {
|
if (realUrl.isLocalFile()) {
|
||||||
OffscreenUi::warning("", "You can not use local files for avatar components.");
|
OffscreenUi::warning("", "You can not use local files for avatar components.");
|
||||||
|
@ -4904,7 +4885,6 @@ bool Application::askToSetAvatarUrl(const QString& url) {
|
||||||
|
|
||||||
|
|
||||||
bool Application::askToLoadScript(const QString& scriptFilenameOrURL) {
|
bool Application::askToLoadScript(const QString& scriptFilenameOrURL) {
|
||||||
qDebug() << "setting script url";
|
|
||||||
QMessageBox::StandardButton reply;
|
QMessageBox::StandardButton reply;
|
||||||
|
|
||||||
QString shortName = scriptFilenameOrURL;
|
QString shortName = scriptFilenameOrURL;
|
||||||
|
@ -4929,7 +4909,6 @@ bool Application::askToLoadScript(const QString& scriptFilenameOrURL) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::askToWearAvatarAttachmentUrl(const QString& url) {
|
bool Application::askToWearAvatarAttachmentUrl(const QString& url) {
|
||||||
qDebug() << "setting avatar attachment url";
|
|
||||||
QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
||||||
QNetworkRequest networkRequest = QNetworkRequest(url);
|
QNetworkRequest networkRequest = QNetworkRequest(url);
|
||||||
networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||||
|
@ -5011,7 +4990,6 @@ bool Application::displayAvatarAttachmentConfirmationDialog(const QString& name)
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::toggleRunningScriptsWidget() const {
|
void Application::toggleRunningScriptsWidget() const {
|
||||||
qDebug() << "toggle running scripts url";
|
|
||||||
static const QUrl url("hifi/dialogs/RunningScripts.qml");
|
static const QUrl url("hifi/dialogs/RunningScripts.qml");
|
||||||
DependencyManager::get<OffscreenUi>()->show(url, "RunningScripts");
|
DependencyManager::get<OffscreenUi>()->show(url, "RunningScripts");
|
||||||
//if (_runningScriptsWidget->isVisible()) {
|
//if (_runningScriptsWidget->isVisible()) {
|
||||||
|
@ -5029,7 +5007,7 @@ void Application::toggleRunningScriptsWidget() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::toggleAssetServerWidget(QString filePath) {
|
void Application::toggleAssetServerWidget(QString filePath) {
|
||||||
qDebug() << "toggle asset before if";
|
qDebug() << "toggle asset before if: " + filePath;
|
||||||
if (!DependencyManager::get<NodeList>()->getThisNodeCanWriteAssets()) {
|
if (!DependencyManager::get<NodeList>()->getThisNodeCanWriteAssets()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -5051,7 +5029,6 @@ void Application::packageModel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::openUrl(const QUrl& url) const {
|
void Application::openUrl(const QUrl& url) const {
|
||||||
qDebug() << "open url";
|
|
||||||
if (!url.isEmpty()) {
|
if (!url.isEmpty()) {
|
||||||
if (url.scheme() == HIFI_URL_SCHEME) {
|
if (url.scheme() == HIFI_URL_SCHEME) {
|
||||||
DependencyManager::get<AddressManager>()->handleLookupString(url.toString());
|
DependencyManager::get<AddressManager>()->handleLookupString(url.toString());
|
||||||
|
@ -5082,7 +5059,6 @@ void Application::setPreviousScriptLocation(const QString& location) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::loadScriptURLDialog() const {
|
void Application::loadScriptURLDialog() const {
|
||||||
qDebug() << "load script url dialog";
|
|
||||||
auto newScript = OffscreenUi::getText(nullptr, "Open and Run Script", "Script URL");
|
auto newScript = OffscreenUi::getText(nullptr, "Open and Run Script", "Script URL");
|
||||||
if (!newScript.isEmpty()) {
|
if (!newScript.isEmpty()) {
|
||||||
DependencyManager::get<ScriptEngines>()->loadScript(newScript);
|
DependencyManager::get<ScriptEngines>()->loadScript(newScript);
|
||||||
|
|
|
@ -250,7 +250,6 @@ public:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void svoImportRequested(const QString& url);
|
void svoImportRequested(const QString& url);
|
||||||
void zipImportRequested(const QString& url);
|
|
||||||
|
|
||||||
void fullAvatarURLChanged(const QString& newValue, const QString& modelName);
|
void fullAvatarURLChanged(const QString& newValue, const QString& modelName);
|
||||||
|
|
||||||
|
@ -386,7 +385,6 @@ private:
|
||||||
|
|
||||||
bool importJSONFromURL(const QString& urlString);
|
bool importJSONFromURL(const QString& urlString);
|
||||||
bool importSVOFromURL(const QString& urlString);
|
bool importSVOFromURL(const QString& urlString);
|
||||||
bool importZIPFromURL(const QString& urlString);
|
|
||||||
|
|
||||||
bool nearbyEntitiesAreReadyForPhysics();
|
bool nearbyEntitiesAreReadyForPhysics();
|
||||||
int processOctreeStats(ReceivedMessage& message, SharedNodePointer sendingNode);
|
int processOctreeStats(ReceivedMessage& message, SharedNodePointer sendingNode);
|
||||||
|
|
|
@ -59,20 +59,6 @@ WindowScriptingInterface::WindowScriptingInterface() {
|
||||||
OffscreenUi::warning("Import SVO Error", "You need to be running edit.js to import entities.");
|
OffscreenUi::warning("Import SVO Error", "You need to be running edit.js to import entities.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// attempt to start ZIP download project
|
|
||||||
connect(qApp, &Application::zipImportRequested, [this](const QString& urlString) {
|
|
||||||
qDebug() << "zip import has been requested";
|
|
||||||
static const QMetaMethod zipImportRequestedSignal =
|
|
||||||
QMetaMethod::fromSignal(&WindowScriptingInterface::zipImportRequested);
|
|
||||||
|
|
||||||
if (isSignalConnected(zipImportRequestedSignal)) {
|
|
||||||
QUrl url(urlString);
|
|
||||||
emit zipImportRequested(url.url());
|
|
||||||
} else {
|
|
||||||
OffscreenUi::warning("Import ZIP Error", "You need to be running edit.js to import entities.");
|
|
||||||
}
|
|
||||||
// end attempt
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WebWindowClass* WindowScriptingInterface::doCreateWebWindow(const QString& title, const QString& url, int width, int height) {
|
WebWindowClass* WindowScriptingInterface::doCreateWebWindow(const QString& title, const QString& url, int width, int height) {
|
||||||
|
|
|
@ -58,7 +58,6 @@ public slots:
|
||||||
signals:
|
signals:
|
||||||
void domainChanged(const QString& domainHostname);
|
void domainChanged(const QString& domainHostname);
|
||||||
void svoImportRequested(const QString& url);
|
void svoImportRequested(const QString& url);
|
||||||
void zipImportRequested(const QString& url); // zip project
|
|
||||||
void domainConnectionRefused(const QString& reasonMessage, int reasonCode);
|
void domainConnectionRefused(const QString& reasonMessage, int reasonCode);
|
||||||
void snapshotTaken(const QString& path);
|
void snapshotTaken(const QString& path);
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,6 @@ void FileScriptingInterface::runUnzip(QString path, QUrl url) {
|
||||||
QUrl url = QUrl::fromLocalFile(file);
|
QUrl url = QUrl::fromLocalFile(file);
|
||||||
qDebug() << "url from local file: " + url.toString();
|
qDebug() << "url from local file: " + url.toString();
|
||||||
emit unzipSuccess(url.toString());
|
emit unzipSuccess(url.toString());
|
||||||
//Application::toggleAssetServerWidget(file);
|
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "unzip failed";
|
qDebug() << "unzip failed";
|
||||||
}
|
}
|
||||||
|
@ -52,11 +51,12 @@ bool FileScriptingInterface::testUrl(QUrl url) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this function is not in use
|
||||||
QString FileScriptingInterface::getTempDir() {
|
QString FileScriptingInterface::getTempDir() {
|
||||||
QTemporaryDir dir;
|
QTemporaryDir dir;
|
||||||
dir.setAutoRemove(false);
|
dir.setAutoRemove(false);
|
||||||
return dir.path();
|
return dir.path();
|
||||||
// remember I must do something to delete this temp dir later
|
// do something to delete this temp dir later
|
||||||
}
|
}
|
||||||
|
|
||||||
QString FileScriptingInterface::convertUrlToPath(QUrl url) {
|
QString FileScriptingInterface::convertUrlToPath(QUrl url) {
|
||||||
|
@ -67,6 +67,7 @@ QString FileScriptingInterface::convertUrlToPath(QUrl url) {
|
||||||
return newUrl;
|
return newUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this function is not in use
|
||||||
void FileScriptingInterface::downloadZip(QString path, const QString link) {
|
void FileScriptingInterface::downloadZip(QString path, const QString link) {
|
||||||
QUrl url = QUrl(link);
|
QUrl url = QUrl(link);
|
||||||
auto request = ResourceManager::createResourceRequest(nullptr, url);
|
auto request = ResourceManager::createResourceRequest(nullptr, url);
|
||||||
|
@ -76,13 +77,14 @@ void FileScriptingInterface::downloadZip(QString path, const QString link) {
|
||||||
request->send();
|
request->send();
|
||||||
}
|
}
|
||||||
|
|
||||||
// clement's help :D
|
|
||||||
QString FileScriptingInterface::unzipFile(QString path) {
|
QString FileScriptingInterface::unzipFile(QString path) {
|
||||||
|
|
||||||
qDebug() << "Zip file was downloaded";
|
|
||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
QString dirName = dir.path();
|
QString dirName = dir.path();
|
||||||
qDebug() << "Zip directory is stored at: " + dirName;
|
qDebug() << "Zip directory is stored at: " + dirName;
|
||||||
|
QString target = path.section("/", -1) + "/model_repo";
|
||||||
|
qDebug() << "Target path: " + target;
|
||||||
QStringList list = JlCompress::extractDir(dirName, "C:/Users/elisa/Downloads/test");
|
QStringList list = JlCompress::extractDir(dirName, "C:/Users/elisa/Downloads/test");
|
||||||
|
|
||||||
qDebug() << list;
|
qDebug() << list;
|
||||||
|
@ -96,6 +98,7 @@ QString FileScriptingInterface::unzipFile(QString path) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this function is not in use
|
||||||
void FileScriptingInterface::recursiveFileScan(QFileInfo file, QString* dirName) {
|
void FileScriptingInterface::recursiveFileScan(QFileInfo file, QString* dirName) {
|
||||||
/*if (!file.isDir()) {
|
/*if (!file.isDir()) {
|
||||||
qDebug() << "Regular file logged: " + file.fileName();
|
qDebug() << "Regular file logged: " + file.fileName();
|
||||||
|
|
|
@ -503,7 +503,6 @@ void ScriptEngine::init() {
|
||||||
registerGlobalObject("Uuid", &_uuidLibrary);
|
registerGlobalObject("Uuid", &_uuidLibrary);
|
||||||
registerGlobalObject("Messages", DependencyManager::get<MessagesClient>().data());
|
registerGlobalObject("Messages", DependencyManager::get<MessagesClient>().data());
|
||||||
|
|
||||||
// unzip project
|
|
||||||
registerGlobalObject("File", new FileScriptingInterface(this));
|
registerGlobalObject("File", new FileScriptingInterface(this));
|
||||||
|
|
||||||
qScriptRegisterMetaType(this, animVarMapToScriptValue, animVarMapFromScriptValue);
|
qScriptRegisterMetaType(this, animVarMapToScriptValue, animVarMapFromScriptValue);
|
||||||
|
|
|
@ -78,20 +78,17 @@ class UrlHandler : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
Q_INVOKABLE bool canHandleUrl(const QString& url) {
|
Q_INVOKABLE bool canHandleUrl(const QString& url) {
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
static auto handler = dynamic_cast<AbstractUriHandler*>(qApp);
|
static auto handler = dynamic_cast<AbstractUriHandler*>(qApp);
|
||||||
return handler->canAcceptURL(url);
|
return handler->canAcceptURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_INVOKABLE bool handleUrl(const QString& url) {
|
Q_INVOKABLE bool handleUrl(const QString& url) {
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
static auto handler = dynamic_cast<AbstractUriHandler*>(qApp);
|
static auto handler = dynamic_cast<AbstractUriHandler*>(qApp);
|
||||||
return handler->acceptURL(url);
|
return handler->acceptURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME hack for authentication, remove when we migrate to Qt 5.6
|
// FIXME hack for authentication, remove when we migrate to Qt 5.6
|
||||||
Q_INVOKABLE QString fixupUrl(const QString& originalUrl) {
|
Q_INVOKABLE QString fixupUrl(const QString& originalUrl) {
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
return fixupHifiUrl(originalUrl);
|
return fixupHifiUrl(originalUrl);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1205,22 +1205,6 @@ function importSVO(importURL) {
|
||||||
}
|
}
|
||||||
Window.svoImportRequested.connect(importSVO);
|
Window.svoImportRequested.connect(importSVO);
|
||||||
|
|
||||||
// attempt to start ZIP download project, GET RID OF THIS
|
|
||||||
function importZIP(importURL) {
|
|
||||||
print("Import ZIP requested: " + importURL);
|
|
||||||
/*if (!Entities.canAdjustLocks()) {
|
|
||||||
Window.alert(INSUFFICIENT_PERMISSIONS_IMPORT_ERROR_MSG);
|
|
||||||
return;
|
|
||||||
}*/
|
|
||||||
var path = File.getTempDir();
|
|
||||||
print("Temporary path to zip: " + path);
|
|
||||||
File.runUnzip(path, importURL);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
Window.zipImportRequested.connect(importZIP);
|
|
||||||
//end attempt
|
|
||||||
|
|
||||||
Menu.menuItemEvent.connect(handeMenuEvent);
|
Menu.menuItemEvent.connect(handeMenuEvent);
|
||||||
|
|
||||||
Controller.keyPressEvent.connect(function (event) {
|
Controller.keyPressEvent.connect(function (event) {
|
||||||
|
|
Loading…
Reference in a new issue