From 4f33e1502f19835460b007891c33c13dd2d6b90f Mon Sep 17 00:00:00 2001 From: elisa-lj11 Date: Mon, 27 Jun 2016 17:41:21 -0700 Subject: [PATCH 01/31] starting the zip project --- interface/src/Application.cpp | 7 +++++++ .../src/scripting/WindowScriptingInterface.cpp | 13 +++++++++++++ scripts/system/edit.js | 13 +++++++++++++ 3 files changed, 33 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 5d50a1c9fe..08788cb5bc 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2015,6 +2015,13 @@ bool Application::importSVOFromURL(const QString& urlString) { return true; } +// attempt to start ZIP download project +bool Appplication::importZIPFromURL(const QString& urlString) { + emit zipImportRequested(urlString); + return true; +} +// end attempt + bool Application::event(QEvent* event) { if (!Menu::getInstance()) { diff --git a/interface/src/scripting/WindowScriptingInterface.cpp b/interface/src/scripting/WindowScriptingInterface.cpp index b165cda135..4a4f4b1025 100644 --- a/interface/src/scripting/WindowScriptingInterface.cpp +++ b/interface/src/scripting/WindowScriptingInterface.cpp @@ -59,6 +59,19 @@ WindowScriptingInterface::WindowScriptingInterface() { 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) { + 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) { diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 25c25a9a7e..18a76eb45f 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -1205,6 +1205,19 @@ function importSVO(importURL) { } Window.svoImportRequested.connect(importSVO); +// attempt to start ZIP download project +function importZIP(importURL) { + print("Import ZIP requested: " + importURL); + if (!Entities.canAdjustLocks()) { + Window.alert(INSUFFICIENT_PERMISSIONS_IMPORT_ERROR_MSG); + return; + } + + +} +Window.zipImportRequested.connect(importZIP); +//end attempt + Menu.menuItemEvent.connect(handeMenuEvent); Controller.keyPressEvent.connect(function (event) { From f277a019bff5aadf8f8b809cd8b3eb44d28dd821 Mon Sep 17 00:00:00 2001 From: elisa-lj11 Date: Tue, 28 Jun 2016 17:56:28 -0700 Subject: [PATCH 02/31] FileScriptingInterface Created new .cpp and .h for the download and unzipping of a model --- .../src/scripting/WindowScriptingInterface.h | 1 + .../src/FileScriptingInterface.cpp | 51 +++++++++++++++++++ .../src/FileScriptingInterface.h | 30 +++++++++++ libraries/script-engine/src/ScriptEngine.cpp | 5 ++ 4 files changed, 87 insertions(+) create mode 100644 libraries/script-engine/src/FileScriptingInterface.cpp create mode 100644 libraries/script-engine/src/FileScriptingInterface.h diff --git a/interface/src/scripting/WindowScriptingInterface.h b/interface/src/scripting/WindowScriptingInterface.h index 9d73111333..b33da4ef4d 100644 --- a/interface/src/scripting/WindowScriptingInterface.h +++ b/interface/src/scripting/WindowScriptingInterface.h @@ -58,6 +58,7 @@ public slots: signals: void domainChanged(const QString& domainHostname); void svoImportRequested(const QString& url); + void zipImportRequested(const QString& url); // zip project void domainConnectionRefused(const QString& reasonMessage, int reasonCode); void snapshotTaken(const QString& path); diff --git a/libraries/script-engine/src/FileScriptingInterface.cpp b/libraries/script-engine/src/FileScriptingInterface.cpp new file mode 100644 index 0000000000..3ecb1bfd22 --- /dev/null +++ b/libraries/script-engine/src/FileScriptingInterface.cpp @@ -0,0 +1,51 @@ +// +// FileScriptingInterface.cpp +// interface/src/scripting +// +// Created by Elisa Lupin-Jimenez on 6/28/16. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include +#include +#include +#include "ResourceManager.h" + +#include "FileScriptingInterface.h" + + +FileScriptingInterface::FileScriptingInterface(QObject* parent) { + // nothing for now +} + +void FileScriptingInterface::downloadZip() { + QUrl url(*parent); + auto request = ResourceManager::createResourceRequest(nullptr, url); + connect(request, &ResourceRequest::finished, this, &FileScriptingInterface::unzipFile); + request->send(); +} + +// clement's help :D +bool FileScriptingInterface::unzipFile() { + ResourceRequest* request = qobject_cast(sender()); + + // Get the file URL + QUrl url = request->getUrl(); + + if (request->getResult() == ResourceRequest::Success) { + qDebug() << "Success =)"; + + QByteArray fileContent = request->getData(); // <-- Downloaded file is in here + // Do stuff + // + // unzipFile(fileContent); + + } else { + qDebug() << "Could not download the file =("; + } + +} + diff --git a/libraries/script-engine/src/FileScriptingInterface.h b/libraries/script-engine/src/FileScriptingInterface.h new file mode 100644 index 0000000000..67ea207aba --- /dev/null +++ b/libraries/script-engine/src/FileScriptingInterface.h @@ -0,0 +1,30 @@ +// +// FileScriptingInterface.h +// interface/src/scripting +// +// Created by Elisa Lupin-Jimenez on 6/28/16. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_FileScriptingInterface_h +#define hifi_FileScriptingInterface_h + +#include + +class FileScriptingInterface : public QObject { + Q_OBJECT + +public: + FileScriptingInterface(QObject* parent); + +public slots: + QScriptValue hasFocus(); + +}; + + + +#endif // hifi_FileScriptingInterface_h \ No newline at end of file diff --git a/libraries/script-engine/src/ScriptEngine.cpp b/libraries/script-engine/src/ScriptEngine.cpp index f98b07478b..fe7e1c4036 100644 --- a/libraries/script-engine/src/ScriptEngine.cpp +++ b/libraries/script-engine/src/ScriptEngine.cpp @@ -49,6 +49,7 @@ #include "BatchLoader.h" #include "DataViewClass.h" #include "EventTypes.h" +#include "FileScriptingInterface.h" // unzip project #include "MenuItemProperties.h" #include "ScriptAudioInjector.h" #include "ScriptCache.h" @@ -501,6 +502,10 @@ void ScriptEngine::init() { registerGlobalObject("Mat4", &_mat4Library); registerGlobalObject("Uuid", &_uuidLibrary); registerGlobalObject("Messages", DependencyManager::get().data()); + + // unzip project + registerGlobalObject("File", new FileScriptingInterface(this)); + qScriptRegisterMetaType(this, animVarMapToScriptValue, animVarMapFromScriptValue); qScriptRegisterMetaType(this, resultHandlerToScriptValue, resultHandlerFromScriptValue); From 0e79aa9dbe6b132cd57e26b6355a97975a2b2e82 Mon Sep 17 00:00:00 2001 From: elisa-lj11 Date: Wed, 29 Jun 2016 18:10:51 -0700 Subject: [PATCH 03/31] Added quazip for unzipping functions --- BUILD.md | 1 + CMakeLists.txt | 1 + libraries/script-engine/CMakeLists.txt | 6 ++ .../src/FileScriptingInterface.cpp | 85 ++++++++++++++++--- .../src/FileScriptingInterface.h | 11 ++- 5 files changed, 89 insertions(+), 15 deletions(-) diff --git a/BUILD.md b/BUILD.md index c1ccd3193e..4ff45a0b1e 100644 --- a/BUILD.md +++ b/BUILD.md @@ -5,6 +5,7 @@ * [OpenSSL](https://www.openssl.org/community/binaries.html) ~> 1.0.1m * IMPORTANT: Using the recommended version of OpenSSL is critical to avoid security vulnerabilities. * [VHACD](https://github.com/virneo/v-hacd)(clone this repository)(Optional) +* [QuaZip](http://sourceforge.net/projects/quazip/files/quazip/) ~> 0.7.1 ####CMake External Project Dependencies diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d42be3d95..c0e11a72be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -201,6 +201,7 @@ set_property(DIRECTORY PROPERTY EP_PREFIX ${EXTERNAL_PROJECT_PREFIX}) setup_externals_binary_dir() option(USE_NSIGHT "Attempt to find the nSight libraries" 1) +option(GET_QUAZIP "Get QuaZip library automatically as external project" 1) if (WIN32) diff --git a/libraries/script-engine/CMakeLists.txt b/libraries/script-engine/CMakeLists.txt index 48fda99b9d..79fa7a1504 100644 --- a/libraries/script-engine/CMakeLists.txt +++ b/libraries/script-engine/CMakeLists.txt @@ -1,3 +1,9 @@ set(TARGET_NAME script-engine) setup_hifi_library(Gui Network Script ScriptTools WebSockets Widgets) + +add_dependency_external_projects(quazip) +find_package(QuaZip REQUIRED) +target_include_directories(${TARGET_NAME} SYSTEM PUBLIC ${QUAZIP_INCLUDE_DIRS}) +target_link_libraries(${TARGET_NAME} ${QUAZIP_LIBRARIES}) + link_hifi_libraries(shared networking octree gpu ui procedural model model-networking recording avatars fbx entities controllers animation audio physics) diff --git a/libraries/script-engine/src/FileScriptingInterface.cpp b/libraries/script-engine/src/FileScriptingInterface.cpp index 3ecb1bfd22..6e9652e134 100644 --- a/libraries/script-engine/src/FileScriptingInterface.cpp +++ b/libraries/script-engine/src/FileScriptingInterface.cpp @@ -3,7 +3,7 @@ // interface/src/scripting // // Created by Elisa Lupin-Jimenez on 6/28/16. -// Copyright 2014 High Fidelity, Inc. +// Copyright 2016 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -12,6 +12,10 @@ #include #include #include +#include +#include +#include +#include #include "ResourceManager.h" #include "FileScriptingInterface.h" @@ -29,23 +33,78 @@ void FileScriptingInterface::downloadZip() { } // clement's help :D -bool FileScriptingInterface::unzipFile() { +void FileScriptingInterface::unzipFile() { ResourceRequest* request = qobject_cast(sender()); + QUrl url = request->getUrl(); - // Get the file URL - QUrl url = request->getUrl(); + if (request->getResult() == ResourceRequest::Success) { + qDebug() << "Zip file was downloaded"; + QTemporaryDir dir; + QByteArray compressedFileContent = request->getData(); // <-- Downloaded file is in here + QBuffer buffer(&compressedFileContent); + buffer.open(QIODevice::ReadOnly); - if (request->getResult() == ResourceRequest::Success) { - qDebug() << "Success =)"; + QString dirName = dir.path(); + JICompress::extractDir(buffer, dirName); - QByteArray fileContent = request->getData(); // <-- Downloaded file is in here - // Do stuff - // - // unzipFile(fileContent); - - } else { - qDebug() << "Could not download the file =("; + QFileInfoList files = dir.entryInfoList(); + foreach (QFileInfo file, files) { + recursiveFileScan(file); } + + /*foreach (QFileInfo file, files) { + if (file.isDir()) { + if (file.fileName().contains(".zip")) { + qDebug() << "Zip file expanded: " + file.fileName(); + } + + qDebug() << "Regular file logged: " + file.fileName(); + } + }*/ + + + //QString zipFileName = QFile::decodeName(&compressedFileContent); + + //QFile file = + //need to convert this byte array to a file + /*QuaZip zip(zipFileName); + + if (zip.open(QuaZip::mdUnzip)) { + qDebug() << "Opened"; + + for (bool more = zip.goToFirstFile(); more; more = zip.goToNextFile()) { + // do something + qDebug() << zip.getCurrentFileName(); + } + if (zip.getZipError() == UNZ_OK) { + // ok, there was no error + }*/ + + + buffer.close(); + } else { + qDebug() << "Could not download the zip file"; + } + } +void FileScriptingInterface::recursiveFileScan(QFileInfo file) { + if (!file.isDir()) { + qDebug() << "Regular file logged:" + file.fileName(); + return; + } + if (file.fileName().contains(".zip")) { + + } + + QFileInfoList files = file.entryInfoList(); + if (files.empty()) { + files = JlCompress::getFileList(file.fileName()); + } + foreach (QFileInfo file, files) { + if (file.fileName().contains(".zip")) { + + } + } +} diff --git a/libraries/script-engine/src/FileScriptingInterface.h b/libraries/script-engine/src/FileScriptingInterface.h index 67ea207aba..89e3434382 100644 --- a/libraries/script-engine/src/FileScriptingInterface.h +++ b/libraries/script-engine/src/FileScriptingInterface.h @@ -3,7 +3,7 @@ // interface/src/scripting // // Created by Elisa Lupin-Jimenez on 6/28/16. -// Copyright 2014 High Fidelity, Inc. +// Copyright 2016 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -21,10 +21,17 @@ public: FileScriptingInterface(QObject* parent); public slots: - QScriptValue hasFocus(); + void unzipFile(); + +signals: + void downloadZip(); }; +private: + void downloadZip(); + void unzipFile(); + #endif // hifi_FileScriptingInterface_h \ No newline at end of file From c9c965b1e80a6081d043d64093785fb857a8e743 Mon Sep 17 00:00:00 2001 From: elisa-lj11 Date: Wed, 29 Jun 2016 18:12:52 -0700 Subject: [PATCH 04/31] added new files for quazip --- cmake/externals/quazip/CMakeLists.txt | 37 +++++++++++++++++++++++++++ cmake/modules/FindQuaZip.cmake | 33 ++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 cmake/externals/quazip/CMakeLists.txt create mode 100644 cmake/modules/FindQuaZip.cmake diff --git a/cmake/externals/quazip/CMakeLists.txt b/cmake/externals/quazip/CMakeLists.txt new file mode 100644 index 0000000000..5795e6bc5d --- /dev/null +++ b/cmake/externals/quazip/CMakeLists.txt @@ -0,0 +1,37 @@ +set(EXTERNAL_NAME quazip) + +if (ANDROID) + set(ANDROID_CMAKE_ARGS "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" "-DANDROID_NATIVE_API_LEVEL=19") +endif () + +include(ExternalProject) +ExternalProject_Add( + ${EXTERNAL_NAME} + URL http://headache.hungry.com/~seth/hifi/quazip-0.7.1.tar.gz + URL_MD5 e4a14ad41b9a1ce494f8dd9add56429e + # BUILD_COMMAND ${MAKE_COMMAND} tbb_os=macos + # CONFIGURE_COMMAND "" + # INSTALL_COMMAND ${PLATFORM_BUILD_COMMAND} + CMAKE_ARGS ${ANDROID_CMAKE_ARGS} -DCMAKE_INSTALL_PREFIX:PATH= + BINARY_DIR ${EXTERNAL_PROJECT_PREFIX}/build + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 +) + +# Hide this external target (for ide users) +set_target_properties(${EXTERNAL_NAME} PROPERTIES FOLDER "hidden/externals") + +ExternalProject_Get_Property(${EXTERNAL_NAME} INSTALL_DIR) + +string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER) + +if (WIN32) + set(${EXTERNAL_NAME_UPPER}_LIBRARY_DEBUG ${INSTALL_DIR}/lib/Debug/QUAZIP_LIB.lib CACHE FILEPATH "Path to QuaZip debug library") + set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${INSTALL_DIR}/lib/Release/QUAZIP_LIB.lib CACHE FILEPATH "Path to QuaZip release library") +else () + set(${EXTERNAL_NAME_UPPER}_LIBRARY_DEBUG "" CACHE FILEPATH "Path to QuaZip debug library") + set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${INSTALL_DIR}/lib/libquazip.so CACHE FILEPATH "Path to QuaZip release library") +endif () + +set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIRS ${INSTALL_DIR}/include CACHE FILEPATH "Path to QuaZip include directory") \ No newline at end of file diff --git a/cmake/modules/FindQuaZip.cmake b/cmake/modules/FindQuaZip.cmake new file mode 100644 index 0000000000..a9f53ec788 --- /dev/null +++ b/cmake/modules/FindQuaZip.cmake @@ -0,0 +1,33 @@ +# +# FindQuaZip.cmake +# +# Once done this will define +# +# QUAZIP_FOUND - system found QuaZip +# QUAZIP_INCLUDE_DIRS - the QuaZip include directory +# QUAZIP_LIBRARIES - link to this to use QuaZip +# +# Created on 2015-8-1 by Seth Alves +# Copyright 2015 High Fidelity, Inc. +# +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# + +include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") +hifi_library_search_hints("quazip") + +find_path(QUAZIP_INCLUDE_DIRS quazip.h PATH_SUFFIXES include HINTS ${QUAZIP_SEARCH_DIRS}) + +find_library(QUAZIP_LIBRARY_DEBUG NAMES QUAZIP QUAZIP_LIB PATH_SUFFIXES lib/Debug HINTS ${QUAZIP_SEARCH_DIRS}) +find_library(QUAZIP_LIBRARY_RELEASE NAMES QUAZIP QUAZIP_LIB PATH_SUFFIXES lib/Release lib HINTS ${QUAZIP_SEARCH_DIRS}) + +include(SelectLibraryConfigurations) +select_library_configurations(QUAZIP) + +set(QUAZIP_LIBRARIES ${QUAZIP_LIBRARY}) + +find_package_handle_standard_args(QUAZIP "Could NOT find QuaZip, try to set the path to QuaZip root folder in the system variable QUAZIP_ROOT_DIR or create a directory quazip in HIFI_LIB_DIR and paste the necessary files there" + QUAZIP_INCLUDE_DIRS QUAZIP_LIBRARIES) + +mark_as_advanced(QUAZIP_INCLUDE_DIRS QUAZIP_LIBRARIES QUAZIP_SEARCH_DIRS) \ No newline at end of file From 87cbb79d673433d949b1f49abdadda0fd1882022 Mon Sep 17 00:00:00 2001 From: elisa-lj11 Date: Tue, 5 Jul 2016 10:34:14 -0700 Subject: [PATCH 05/31] fixing up quazip --- cmake/macros/TargetQuazip.cmake | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 cmake/macros/TargetQuazip.cmake diff --git a/cmake/macros/TargetQuazip.cmake b/cmake/macros/TargetQuazip.cmake new file mode 100644 index 0000000000..f704f03050 --- /dev/null +++ b/cmake/macros/TargetQuazip.cmake @@ -0,0 +1,16 @@ +# +# Copyright 2015 High Fidelity, Inc. +# Created by Leonardo Murillo on 2015/11/20 +# +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# +macro(TARGET_QUAZIP) + add_dependency_external_projects(quazip) + find_package(QuaZip REQUIRED) + target_include_directories(${TARGET_NAME} PUBLIC ${QUAZIP_INCLUDE_DIRS}) + target_link_libraries(${TARGET_NAME} ${QUAZIP_LIBRARIES}) + if (WIN32) + add_paths_to_fixup_libs(${QUAZIP_DLL_PATH}) + endif () +endmacro() \ No newline at end of file From 212e4f9ccaddf80d8bc9f8a09dc48bd4270c0578 Mon Sep 17 00:00:00 2001 From: elisa-lj11 Date: Tue, 5 Jul 2016 10:38:35 -0700 Subject: [PATCH 06/31] making quazip work --- cmake/externals/quazip/CMakeLists.txt | 53 ++++++++++++------- cmake/modules/FindQuaZip.cmake | 46 ++++++++-------- interface/src/Application.cpp | 2 +- interface/src/Application.h | 2 + libraries/script-engine/CMakeLists.txt | 2 + .../src/FileScriptingInterface.cpp | 35 +++++++----- .../src/FileScriptingInterface.h | 12 ++--- 7 files changed, 87 insertions(+), 65 deletions(-) diff --git a/cmake/externals/quazip/CMakeLists.txt b/cmake/externals/quazip/CMakeLists.txt index 5795e6bc5d..413a07efec 100644 --- a/cmake/externals/quazip/CMakeLists.txt +++ b/cmake/externals/quazip/CMakeLists.txt @@ -1,37 +1,52 @@ set(EXTERNAL_NAME quazip) - -if (ANDROID) - set(ANDROID_CMAKE_ARGS "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" "-DANDROID_NATIVE_API_LEVEL=19") -endif () +string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER) +cmake_policy(SET CMP0046 OLD) include(ExternalProject) + +if (WIN32) + # windows shell does not like backslashes expanded on the command line, + # so convert all backslashes in the QT path to forward slashes + string(REPLACE \\ / QT_CMAKE_PREFIX_PATH $ENV{QT_CMAKE_PREFIX_PATH}) +elseif ($ENV{QT_CMAKE_PREFIX_PATH}) + set(QT_CMAKE_PREFIX_PATH $ENV{QT_CMAKE_PREFIX_PATH}) +endif () + ExternalProject_Add( ${EXTERNAL_NAME} - URL http://headache.hungry.com/~seth/hifi/quazip-0.7.1.tar.gz - URL_MD5 e4a14ad41b9a1ce494f8dd9add56429e - # BUILD_COMMAND ${MAKE_COMMAND} tbb_os=macos - # CONFIGURE_COMMAND "" - # INSTALL_COMMAND ${PLATFORM_BUILD_COMMAND} - CMAKE_ARGS ${ANDROID_CMAKE_ARGS} -DCMAKE_INSTALL_PREFIX:PATH= + URL http://s3-us-west-1.amazonaws.com/hifi-production/dependencies/quazip-0.6.2.zip + URL_MD5 514851970f1a14d815bdc3ad6267af4d BINARY_DIR ${EXTERNAL_PROJECT_PREFIX}/build + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= -DCMAKE_PREFIX_PATH=${QT_CMAKE_PREFIX_PATH} -DCMAKE_INSTALL_NAME_DIR:PATH=/lib -DZLIB_ROOT=${ZLIB_ROOT} LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 ) +add_dependencies(quazip zlib) + # Hide this external target (for ide users) -set_target_properties(${EXTERNAL_NAME} PROPERTIES FOLDER "hidden/externals") +set_target_properties(${EXTERNAL_NAME} PROPERTIES + FOLDER "hidden/externals" + INSTALL_NAME_DIR ${INSTALL_DIR}/lib + BUILD_WITH_INSTALL_RPATH True) ExternalProject_Get_Property(${EXTERNAL_NAME} INSTALL_DIR) +set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIR ${INSTALL_DIR}/include CACHE PATH "List of QuaZip include directories") +set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIRS ${${EXTERNAL_NAME_UPPER}_INCLUDE_DIR} CACHE PATH "List of QuaZip include directories") +set(${EXTERNAL_NAME_UPPER}_DLL_PATH ${INSTALL_DIR}/lib CACHE FILEPATH "Location of QuaZip DLL") -string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER) - -if (WIN32) - set(${EXTERNAL_NAME_UPPER}_LIBRARY_DEBUG ${INSTALL_DIR}/lib/Debug/QUAZIP_LIB.lib CACHE FILEPATH "Path to QuaZip debug library") - set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${INSTALL_DIR}/lib/Release/QUAZIP_LIB.lib CACHE FILEPATH "Path to QuaZip release library") +if (APPLE) + set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${INSTALL_DIR}/lib/libquazip.1.0.0.dylib CACHE FILEPATH "Location of QuaZip release library") +elseif (WIN32) + set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${INSTALL_DIR}/lib/quazip.lib CACHE FILEPATH "Location of QuaZip release library") else () - set(${EXTERNAL_NAME_UPPER}_LIBRARY_DEBUG "" CACHE FILEPATH "Path to QuaZip debug library") - set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${INSTALL_DIR}/lib/libquazip.so CACHE FILEPATH "Path to QuaZip release library") + set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${INSTALL_DIR}/lib/libquazip.so CACHE FILEPATH "Location of QuaZip release library") endif () -set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIRS ${INSTALL_DIR}/include CACHE FILEPATH "Path to QuaZip include directory") \ No newline at end of file +include(SelectLibraryConfigurations) +select_library_configurations(${EXTERNAL_NAME_UPPER}) + +# Force selected libraries into the cache +set(${EXTERNAL_NAME_UPPER}_LIBRARY ${${EXTERNAL_NAME_UPPER}_LIBRARY} CACHE FILEPATH "Location of QuaZip libraries") +set(${EXTERNAL_NAME_UPPER}_LIBRARIES ${${EXTERNAL_NAME_UPPER}_LIBRARIES} CACHE FILEPATH "Location of QuaZip libraries") \ No newline at end of file diff --git a/cmake/modules/FindQuaZip.cmake b/cmake/modules/FindQuaZip.cmake index a9f53ec788..2b2a577919 100644 --- a/cmake/modules/FindQuaZip.cmake +++ b/cmake/modules/FindQuaZip.cmake @@ -1,33 +1,29 @@ # -# FindQuaZip.cmake -# -# Once done this will define -# -# QUAZIP_FOUND - system found QuaZip -# QUAZIP_INCLUDE_DIRS - the QuaZip include directory -# QUAZIP_LIBRARIES - link to this to use QuaZip -# -# Created on 2015-8-1 by Seth Alves -# Copyright 2015 High Fidelity, Inc. -# -# Distributed under the Apache License, Version 2.0. -# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# FindQuaZip.h +# StackManagerQt/cmake/modules # +# Created by Mohammed Nafees. +# Copyright (c) 2014 High Fidelity. All rights reserved. +# + +# QUAZIP_FOUND - QuaZip library was found +# QUAZIP_INCLUDE_DIR - Path to QuaZip include dir +# QUAZIP_INCLUDE_DIRS - Path to QuaZip and zlib include dir (combined from QUAZIP_INCLUDE_DIR + ZLIB_INCLUDE_DIR) +# QUAZIP_LIBRARIES - List of QuaZip libraries +# QUAZIP_ZLIB_INCLUDE_DIR - The include dir of zlib headers include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") hifi_library_search_hints("quazip") -find_path(QUAZIP_INCLUDE_DIRS quazip.h PATH_SUFFIXES include HINTS ${QUAZIP_SEARCH_DIRS}) +if (WIN32) + find_path(QUAZIP_INCLUDE_DIRS quazip.h PATH_SUFFIXES include/quazip HINTS ${QUAZIP_SEARCH_DIRS}) +elseif (APPLE) + find_path(QUAZIP_INCLUDE_DIRS quazip.h PATH_SUFFIXES include/quazip HINTS ${QUAZIP_SEARCH_DIRS}) +else () + find_path(QUAZIP_INCLUDE_DIRS quazip.h PATH_SUFFIXES quazip HINTS ${QUAZIP_SEARCH_DIRS}) +endif () -find_library(QUAZIP_LIBRARY_DEBUG NAMES QUAZIP QUAZIP_LIB PATH_SUFFIXES lib/Debug HINTS ${QUAZIP_SEARCH_DIRS}) -find_library(QUAZIP_LIBRARY_RELEASE NAMES QUAZIP QUAZIP_LIB PATH_SUFFIXES lib/Release lib HINTS ${QUAZIP_SEARCH_DIRS}) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(QUAZIP DEFAULT_MSG QUAZIP_INCLUDE_DIRS) -include(SelectLibraryConfigurations) -select_library_configurations(QUAZIP) - -set(QUAZIP_LIBRARIES ${QUAZIP_LIBRARY}) - -find_package_handle_standard_args(QUAZIP "Could NOT find QuaZip, try to set the path to QuaZip root folder in the system variable QUAZIP_ROOT_DIR or create a directory quazip in HIFI_LIB_DIR and paste the necessary files there" - QUAZIP_INCLUDE_DIRS QUAZIP_LIBRARIES) - -mark_as_advanced(QUAZIP_INCLUDE_DIRS QUAZIP_LIBRARIES QUAZIP_SEARCH_DIRS) \ No newline at end of file +mark_as_advanced(QUAZIP_INCLUDE_DIRS QUAZIP_SEARCH_DIRS) \ No newline at end of file diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 08788cb5bc..4be9a3c5c1 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2016,7 +2016,7 @@ bool Application::importSVOFromURL(const QString& urlString) { } // attempt to start ZIP download project -bool Appplication::importZIPFromURL(const QString& urlString) { +bool Application::importZIPFromURL(const QString& urlString) { emit zipImportRequested(urlString); return true; } diff --git a/interface/src/Application.h b/interface/src/Application.h index 0af65f665f..d8f02f41b7 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -250,6 +250,7 @@ public: signals: void svoImportRequested(const QString& url); + void zipImportRequested(const QString& url); void fullAvatarURLChanged(const QString& newValue, const QString& modelName); @@ -385,6 +386,7 @@ private: bool importJSONFromURL(const QString& urlString); bool importSVOFromURL(const QString& urlString); + bool importZIPFromURL(const QString& urlString); bool nearbyEntitiesAreReadyForPhysics(); int processOctreeStats(ReceivedMessage& message, SharedNodePointer sendingNode); diff --git a/libraries/script-engine/CMakeLists.txt b/libraries/script-engine/CMakeLists.txt index 79fa7a1504..b484937ea5 100644 --- a/libraries/script-engine/CMakeLists.txt +++ b/libraries/script-engine/CMakeLists.txt @@ -1,6 +1,8 @@ set(TARGET_NAME script-engine) setup_hifi_library(Gui Network Script ScriptTools WebSockets Widgets) +target_zlib() + add_dependency_external_projects(quazip) find_package(QuaZip REQUIRED) target_include_directories(${TARGET_NAME} SYSTEM PUBLIC ${QUAZIP_INCLUDE_DIRS}) diff --git a/libraries/script-engine/src/FileScriptingInterface.cpp b/libraries/script-engine/src/FileScriptingInterface.cpp index 6e9652e134..017c3f83e1 100644 --- a/libraries/script-engine/src/FileScriptingInterface.cpp +++ b/libraries/script-engine/src/FileScriptingInterface.cpp @@ -11,17 +11,20 @@ #include #include +#include +#include #include #include #include +#include #include -#include +#include #include "ResourceManager.h" #include "FileScriptingInterface.h" -FileScriptingInterface::FileScriptingInterface(QObject* parent) { +FileScriptingInterface::FileScriptingInterface(QObject* parent) : QObject(parent) { // nothing for now } @@ -45,11 +48,11 @@ void FileScriptingInterface::unzipFile() { buffer.open(QIODevice::ReadOnly); QString dirName = dir.path(); - JICompress::extractDir(buffer, dirName); + JlCompress::extractDir(buffer, dirName); QFileInfoList files = dir.entryInfoList(); foreach (QFileInfo file, files) { - recursiveFileScan(file); + recursiveFileScan(file, &dirName); } @@ -89,22 +92,26 @@ void FileScriptingInterface::unzipFile() { } -void FileScriptingInterface::recursiveFileScan(QFileInfo file) { +void FileScriptingInterface::recursiveFileScan(QFileInfo file, QString* dirName) { if (!file.isDir()) { - qDebug() << "Regular file logged:" + file.fileName(); + qDebug() << "Regular file logged: " + file.fileName(); return; } + QFileInfoList files; + if (file.fileName().contains(".zip")) { - - } + JlCompress::extractDir(file); + qDebug() << "Extracting archive: " + file.fileName(); + } + files = file.entryInfoList(); - QFileInfoList files = file.entryInfoList(); - if (files.empty()) { + /*if (files.empty()) { files = JlCompress::getFileList(file.fileName()); - } - foreach (QFileInfo file, files) { - if (file.fileName().contains(".zip")) { + }*/ - } + foreach (QFileInfo file, files) { + qDebug() << "Looking into file: " + file.fileName(); + recursiveFileScan(file, &dirName); } + return; } diff --git a/libraries/script-engine/src/FileScriptingInterface.h b/libraries/script-engine/src/FileScriptingInterface.h index 89e3434382..cf965afa34 100644 --- a/libraries/script-engine/src/FileScriptingInterface.h +++ b/libraries/script-engine/src/FileScriptingInterface.h @@ -13,6 +13,7 @@ #define hifi_FileScriptingInterface_h #include +#include class FileScriptingInterface : public QObject { Q_OBJECT @@ -26,12 +27,11 @@ public slots: signals: void downloadZip(); +private: + //void downloadZip(); + //void unzipFile(); + void recursiveFileScan(QFileInfo file, QString* dirName); + }; -private: - void downloadZip(); - void unzipFile(); - - - #endif // hifi_FileScriptingInterface_h \ No newline at end of file From 9833ba19878bcc2b5e493ba00b69b587eecc2c88 Mon Sep 17 00:00:00 2001 From: elisa-lj11 Date: Wed, 6 Jul 2016 16:43:23 -0700 Subject: [PATCH 07/31] No errors upon build --- cmake/externals/quazip/CMakeLists.txt | 10 ++--- libraries/script-engine/CMakeLists.txt | 4 ++ .../src/FileScriptingInterface.cpp | 45 +++++++++++++------ .../src/FileScriptingInterface.h | 9 ++-- scripts/system/edit.js | 7 ++- 5 files changed, 52 insertions(+), 23 deletions(-) diff --git a/cmake/externals/quazip/CMakeLists.txt b/cmake/externals/quazip/CMakeLists.txt index 413a07efec..bf51a52fc5 100644 --- a/cmake/externals/quazip/CMakeLists.txt +++ b/cmake/externals/quazip/CMakeLists.txt @@ -14,8 +14,8 @@ endif () ExternalProject_Add( ${EXTERNAL_NAME} - URL http://s3-us-west-1.amazonaws.com/hifi-production/dependencies/quazip-0.6.2.zip - URL_MD5 514851970f1a14d815bdc3ad6267af4d + URL https://s3-us-west-1.amazonaws.com/hifi-production/dependencies/quazip-0.7.2.zip + URL_MD5 2955176048a31262c09259ca8d309d19 BINARY_DIR ${EXTERNAL_PROJECT_PREFIX}/build CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= -DCMAKE_PREFIX_PATH=${QT_CMAKE_PREFIX_PATH} -DCMAKE_INSTALL_NAME_DIR:PATH=/lib -DZLIB_ROOT=${ZLIB_ROOT} LOG_DOWNLOAD 1 @@ -37,11 +37,11 @@ set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIRS ${${EXTERNAL_NAME_UPPER}_INCLUDE_DIR} CA set(${EXTERNAL_NAME_UPPER}_DLL_PATH ${INSTALL_DIR}/lib CACHE FILEPATH "Location of QuaZip DLL") if (APPLE) - set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${INSTALL_DIR}/lib/libquazip.1.0.0.dylib CACHE FILEPATH "Location of QuaZip release library") + set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${INSTALL_DIR}/lib/libquazip5d.1.0.0.dylib CACHE FILEPATH "Location of QuaZip release library") elseif (WIN32) - set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${INSTALL_DIR}/lib/quazip.lib CACHE FILEPATH "Location of QuaZip release library") + set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${INSTALL_DIR}/lib/quazip5d.lib CACHE FILEPATH "Location of QuaZip release library") else () - set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${INSTALL_DIR}/lib/libquazip.so CACHE FILEPATH "Location of QuaZip release library") + set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${INSTALL_DIR}/lib/libquazip5d.so CACHE FILEPATH "Location of QuaZip release library") endif () include(SelectLibraryConfigurations) diff --git a/libraries/script-engine/CMakeLists.txt b/libraries/script-engine/CMakeLists.txt index b484937ea5..c3a9a9f38a 100644 --- a/libraries/script-engine/CMakeLists.txt +++ b/libraries/script-engine/CMakeLists.txt @@ -8,4 +8,8 @@ find_package(QuaZip REQUIRED) target_include_directories(${TARGET_NAME} SYSTEM PUBLIC ${QUAZIP_INCLUDE_DIRS}) target_link_libraries(${TARGET_NAME} ${QUAZIP_LIBRARIES}) +if (WIN32) + add_paths_to_fixup_libs(${QUAZIP_DLL_PATH}) +endif () + link_hifi_libraries(shared networking octree gpu ui procedural model model-networking recording avatars fbx entities controllers animation audio physics) diff --git a/libraries/script-engine/src/FileScriptingInterface.cpp b/libraries/script-engine/src/FileScriptingInterface.cpp index 017c3f83e1..814a054e5e 100644 --- a/libraries/script-engine/src/FileScriptingInterface.cpp +++ b/libraries/script-engine/src/FileScriptingInterface.cpp @@ -1,6 +1,6 @@ // // FileScriptingInterface.cpp -// interface/src/scripting +// libraries/script-engine/src // // Created by Elisa Lupin-Jimenez on 6/28/16. // Copyright 2016 High Fidelity, Inc. @@ -10,15 +10,18 @@ // #include +#include #include #include #include +#include +#include #include #include #include #include -#include -#include +#include +#include #include "ResourceManager.h" #include "FileScriptingInterface.h" @@ -28,27 +31,43 @@ FileScriptingInterface::FileScriptingInterface(QObject* parent) : QObject(parent // nothing for now } -void FileScriptingInterface::downloadZip() { - QUrl url(*parent); +void FileScriptingInterface::runUnzip(QString path, QString importURL) { + downloadZip(path, importURL); + +} + +QString FileScriptingInterface::getTempDir() { + QTemporaryDir dir; + dir.setAutoRemove(false); + return dir.path(); + // remember I must do something to delete this temp dir later +} + +void FileScriptingInterface::downloadZip(QString path, const QString link) { + QUrl url = QUrl(link); auto request = ResourceManager::createResourceRequest(nullptr, url); - connect(request, &ResourceRequest::finished, this, &FileScriptingInterface::unzipFile); + connect(request, &ResourceRequest::finished, this, [this, path]{ + unzipFile(path); + }); request->send(); } // clement's help :D -void FileScriptingInterface::unzipFile() { +void FileScriptingInterface::unzipFile(QString path) { ResourceRequest* request = qobject_cast(sender()); QUrl url = request->getUrl(); if (request->getResult() == ResourceRequest::Success) { qDebug() << "Zip file was downloaded"; - QTemporaryDir dir; + QDir dir(path); QByteArray compressedFileContent = request->getData(); // <-- Downloaded file is in here QBuffer buffer(&compressedFileContent); buffer.open(QIODevice::ReadOnly); + //QString zipFileName = QFile::decodeName(compressedFileContent); QString dirName = dir.path(); - JlCompress::extractDir(buffer, dirName); + qDebug() << "Zip directory is stored at: " + dirName; + JlCompress::extractDir(&buffer, dirName); QFileInfoList files = dir.entryInfoList(); foreach (QFileInfo file, files) { @@ -67,7 +86,7 @@ void FileScriptingInterface::unzipFile() { }*/ - //QString zipFileName = QFile::decodeName(&compressedFileContent); + //QFile file = //need to convert this byte array to a file @@ -100,10 +119,10 @@ void FileScriptingInterface::recursiveFileScan(QFileInfo file, QString* dirName) QFileInfoList files; if (file.fileName().contains(".zip")) { - JlCompress::extractDir(file); + JlCompress::extractDir(file.fileName()); qDebug() << "Extracting archive: " + file.fileName(); } - files = file.entryInfoList(); + files = file.dir().entryInfoList(); /*if (files.empty()) { files = JlCompress::getFileList(file.fileName()); @@ -111,7 +130,7 @@ void FileScriptingInterface::recursiveFileScan(QFileInfo file, QString* dirName) foreach (QFileInfo file, files) { qDebug() << "Looking into file: " + file.fileName(); - recursiveFileScan(file, &dirName); + recursiveFileScan(file, dirName); } return; } diff --git a/libraries/script-engine/src/FileScriptingInterface.h b/libraries/script-engine/src/FileScriptingInterface.h index cf965afa34..a9ccd3442f 100644 --- a/libraries/script-engine/src/FileScriptingInterface.h +++ b/libraries/script-engine/src/FileScriptingInterface.h @@ -1,6 +1,6 @@ // // FileScriptingInterface.h -// interface/src/scripting +// libraries/script-engine/src // // Created by Elisa Lupin-Jimenez on 6/28/16. // Copyright 2016 High Fidelity, Inc. @@ -14,23 +14,26 @@ #include #include +#include class FileScriptingInterface : public QObject { Q_OBJECT public: FileScriptingInterface(QObject* parent); + void runUnzip(QString path, QString importURL); + QString getTempDir(); public slots: - void unzipFile(); + void unzipFile(QString path); signals: - void downloadZip(); private: //void downloadZip(); //void unzipFile(); void recursiveFileScan(QFileInfo file, QString* dirName); + void downloadZip(QString path, const QString link); }; diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 18a76eb45f..f096deb0a7 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -1208,10 +1208,13 @@ Window.svoImportRequested.connect(importSVO); // attempt to start ZIP download project function importZIP(importURL) { print("Import ZIP requested: " + importURL); - if (!Entities.canAdjustLocks()) { + /*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); } From 76a847d34f1ca3df84d7606f796f5c02e97742f3 Mon Sep 17 00:00:00 2001 From: elisa-lj11 Date: Fri, 8 Jul 2016 10:54:11 -0700 Subject: [PATCH 08/31] testing for URL bug --- interface/src/Application.cpp | 7 +++++-- interface/src/scripting/WindowScriptingInterface.cpp | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 4be9a3c5c1..3d0a4628b1 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2010,13 +2010,13 @@ bool Application::importJSONFromURL(const QString& urlString) { } bool Application::importSVOFromURL(const QString& urlString) { - emit svoImportRequested(urlString); 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; } @@ -2141,13 +2141,16 @@ bool Application::event(QEvent* event) { // handle custom URL if (event->type() == QEvent::FileOpen) { - QFileOpenEvent* fileEvent = static_cast(event); + qDebug() << "we have received one url!: "; + QFileOpenEvent* fileEvent = static_cast(event); QUrl url = fileEvent->url(); if (!url.isEmpty()) { QString urlString = url.toString(); + qDebug() << "we got a url!: " + urlString; if (canAcceptURL(urlString)) { + qDebug() << "we got an ACCEPTED url!: " + urlString; return acceptURL(urlString); } } diff --git a/interface/src/scripting/WindowScriptingInterface.cpp b/interface/src/scripting/WindowScriptingInterface.cpp index 4a4f4b1025..2ea562143e 100644 --- a/interface/src/scripting/WindowScriptingInterface.cpp +++ b/interface/src/scripting/WindowScriptingInterface.cpp @@ -61,6 +61,7 @@ WindowScriptingInterface::WindowScriptingInterface() { }); // 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); From eab7714d70ccda26395a8b05c444dc42fc68db68 Mon Sep 17 00:00:00 2001 From: elisa-lj11 Date: Wed, 13 Jul 2016 12:47:19 -0700 Subject: [PATCH 09/31] working within webview to access url --- interface/resources/qml/Browser.qml | 1 + .../resources/qml/controls-uit/WebView.qml | 16 +++- interface/src/Application.cpp | 18 ++++- libraries/ui/src/OffscreenUi.cpp | 3 + scripts/system/examples.js | 77 +++++++++++++++++++ 5 files changed, 109 insertions(+), 6 deletions(-) create mode 100644 scripts/system/examples.js diff --git a/interface/resources/qml/Browser.qml b/interface/resources/qml/Browser.qml index 47231957c2..33595c2038 100644 --- a/interface/resources/qml/Browser.qml +++ b/interface/resources/qml/Browser.qml @@ -223,6 +223,7 @@ ScrollingWindow { var newWindow = component.createObject(desktop); request.openIn(newWindow.webView) } + //profile: desktop.browserProfile } diff --git a/interface/resources/qml/controls-uit/WebView.qml b/interface/resources/qml/controls-uit/WebView.qml index b599e29fe0..99064cdcbd 100644 --- a/interface/resources/qml/controls-uit/WebView.qml +++ b/interface/resources/qml/controls-uit/WebView.qml @@ -49,6 +49,7 @@ WebEngineView { onLoadingChanged: { // Required to support clicking on "hifi://" links + console.log("loading change requested url"); if (WebEngineView.LoadStartedStatus == loadRequest.status) { var url = loadRequest.url.toString(); if (urlHandler.canHandleUrl(url)) { @@ -59,12 +60,19 @@ WebEngineView { } } - onNewViewRequested:{ - var component = Qt.createComponent("../Browser.qml"); - var newWindow = component.createObject(desktop); - request.openIn(newWindow.webView) + onNewViewRequested: { + console.log("new view requested url"); + console.log(request.url.toString()); + //if (toString(request.url) ) + var component = Qt.createComponent("../Browser.qml"); + var newWindow = component.createObject(desktop); + request.openIn(newWindow.webView); } + onLinkHovered: { + console.log(hoveredUrl); + } + // This breaks the webchannel used for passing messages. Fixed in Qt 5.6 // See https://bugreports.qt.io/browse/QTBUG-49521 //profile: desktop.browserProfile diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 3d0a4628b1..2fee3488f9 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -354,6 +354,7 @@ public: if (message->message == WM_COPYDATA) { COPYDATASTRUCT* pcds = (COPYDATASTRUCT*)(message->lParam); + qDebug() << "os windows url for some reason"; QUrl url = QUrl((const char*)(pcds->lpData)); if (url.isValid() && url.scheme() == HIFI_URL_SCHEME) { DependencyManager::get()->handleLookupString(url.toString()); @@ -2157,6 +2158,10 @@ bool Application::event(QEvent* event) { return false; } + if (event->type() == QEvent::None) { + qDebug() << "this url just didn't click"; + } + if (HFActionEvent::types().contains(event->type())) { _controllerScriptingInterface->handleMetaEvent(static_cast(event)); } @@ -3180,6 +3185,7 @@ void Application::saveSettings() const { } bool Application::importEntities(const QString& urlOrFilename) { + qDebug() << "import entities url"; bool success = false; _entityClipboard->withWriteLock([&] { _entityClipboard->eraseAllOctreeElements(); @@ -4789,6 +4795,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri } bool Application::canAcceptURL(const QString& urlString) const { + qDebug() << "stepping through 'canAcceptURL'"; QUrl url(urlString); if (urlString.startsWith(HIFI_URL_SCHEME)) { return true; @@ -4805,6 +4812,7 @@ bool Application::canAcceptURL(const QString& urlString) const { } bool Application::acceptURL(const QString& urlString, bool defaultUpload) { + qDebug() << "stepping through 'acceptURL'"; if (urlString.startsWith(HIFI_URL_SCHEME)) { // this is a hifi URL - have the AddressManager handle it QMetaObject::invokeMethod(DependencyManager::get().data(), "handleLookupString", @@ -4834,6 +4842,7 @@ void Application::setSessionUUID(const QUuid& sessionUUID) const { } bool Application::askToSetAvatarUrl(const QString& url) { + qDebug() << "setting avatar url"; QUrl realUrl(url); if (realUrl.isLocalFile()) { OffscreenUi::warning("", "You can not use local files for avatar components."); @@ -4890,6 +4899,7 @@ bool Application::askToSetAvatarUrl(const QString& url) { bool Application::askToLoadScript(const QString& scriptFilenameOrURL) { + qDebug() << "setting script url"; QMessageBox::StandardButton reply; QString shortName = scriptFilenameOrURL; @@ -4914,7 +4924,7 @@ bool Application::askToLoadScript(const QString& scriptFilenameOrURL) { } bool Application::askToWearAvatarAttachmentUrl(const QString& url) { - + qDebug() << "setting avatar attachment url"; QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance(); QNetworkRequest networkRequest = QNetworkRequest(url); networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT); @@ -4996,6 +5006,7 @@ bool Application::displayAvatarAttachmentConfirmationDialog(const QString& name) } void Application::toggleRunningScriptsWidget() const { + qDebug() << "toggle running scripts url"; static const QUrl url("hifi/dialogs/RunningScripts.qml"); DependencyManager::get()->show(url, "RunningScripts"); //if (_runningScriptsWidget->isVisible()) { @@ -5013,10 +5024,11 @@ void Application::toggleRunningScriptsWidget() const { } void Application::toggleAssetServerWidget(QString filePath) { + qDebug() << "toggle asset before if"; if (!DependencyManager::get()->getThisNodeCanWriteAssets()) { return; } - + qDebug() << "toggle asset after if"; static const QUrl url { "AssetServer.qml" }; auto startUpload = [=](QQmlContext* context, QObject* newObject){ @@ -5033,6 +5045,7 @@ void Application::packageModel() { } void Application::openUrl(const QUrl& url) const { + qDebug() << "open url"; if (!url.isEmpty()) { if (url.scheme() == HIFI_URL_SCHEME) { DependencyManager::get()->handleLookupString(url.toString()); @@ -5063,6 +5076,7 @@ void Application::setPreviousScriptLocation(const QString& location) { } void Application::loadScriptURLDialog() const { + qDebug() << "load script url dialog"; auto newScript = OffscreenUi::getText(nullptr, "Open and Run Script", "Script URL"); if (!newScript.isEmpty()) { DependencyManager::get()->loadScript(newScript); diff --git a/libraries/ui/src/OffscreenUi.cpp b/libraries/ui/src/OffscreenUi.cpp index 06ef456006..82a9186f92 100644 --- a/libraries/ui/src/OffscreenUi.cpp +++ b/libraries/ui/src/OffscreenUi.cpp @@ -78,17 +78,20 @@ class UrlHandler : public QObject { Q_OBJECT public: Q_INVOKABLE bool canHandleUrl(const QString& url) { + qDebug() << Q_FUNC_INFO; static auto handler = dynamic_cast(qApp); return handler->canAcceptURL(url); } Q_INVOKABLE bool handleUrl(const QString& url) { + qDebug() << Q_FUNC_INFO; static auto handler = dynamic_cast(qApp); return handler->acceptURL(url); } // FIXME hack for authentication, remove when we migrate to Qt 5.6 Q_INVOKABLE QString fixupUrl(const QString& originalUrl) { + qDebug() << Q_FUNC_INFO; return fixupHifiUrl(originalUrl); } }; diff --git a/scripts/system/examples.js b/scripts/system/examples.js new file mode 100644 index 0000000000..32d977834b --- /dev/null +++ b/scripts/system/examples.js @@ -0,0 +1,77 @@ +// +// examples.js +// examples +// +// Created by Eric Levin on 8 Jan 2016 +// Copyright 2016 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +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 = "http://s3.amazonaws.com/DreamingContent/test.html"; + +var examplesWindow = new OverlayWebWindow({ + title: 'Examples', + source: "about:blank", + width: 900, + height: 700, + visible: false +}); + +var toolHeight = 50; +var toolWidth = 50; +var TOOLBAR_MARGIN_Y = 0; + + +function showExamples(marketplaceID) { + var url = EXAMPLES_URL; + if (marketplaceID) { + url = url + "/items/" + marketplaceID; + } + print("setting examples URL to " + url); + examplesWindow.setURL(url); + examplesWindow.setVisible(true); + + UserActivityLogger.openedMarketplace(); +} + +function hideExamples() { + examplesWindow.setVisible(false); + examplesWindow.setURL("about:blank"); +} + +function toggleExamples() { + if (examplesWindow.visible) { + hideExamples(); + } else { + showExamples(); + } +} + +var toolBar = Toolbars.getToolbar("com.highfidelity.interface.toolbar.system"); + +var browseExamplesButton = toolBar.addButton({ + imageURL: toolIconUrl + "market.svg", + objectName: "examples", + buttonState: 1, + alpha: 0.9 +}); + +function onExamplesWindowVisibilityChanged() { + browseExamplesButton.writeProperty('buttonState', examplesWindow.visible ? 0 : 1); +} +function onClick() { + toggleExamples(); +} +browseExamplesButton.clicked.connect(onClick); +examplesWindow.visibleChanged.connect(onExamplesWindowVisibilityChanged); + +Script.scriptEnding.connect(function () { + browseExamplesButton.clicked.disconnect(onClick); + examplesWindow.visibleChanged.disconnect(onExamplesWindowVisibilityChanged); +}); From 6152fa28b7bc908a554609a01c14f7e6e72720e0 Mon Sep 17 00:00:00 2001 From: elisa-lj11 Date: Mon, 18 Jul 2016 15:29:15 -0700 Subject: [PATCH 10/31] Download through QML It kind of works, not crashing like before, but the weird ghost file/type error is still happening with multiple downloads --- interface/resources/qml/Browser.qml | 25 +++++++++++++++---- .../resources/qml/controls-uit/WebView.qml | 3 +-- interface/src/Application.cpp | 2 ++ .../src/FileScriptingInterface.cpp | 6 ++--- .../src/FileScriptingInterface.h | 7 +++--- scripts/system/edit.js | 2 +- scripts/system/examples.js | 6 +++-- 7 files changed, 35 insertions(+), 16 deletions(-) diff --git a/interface/resources/qml/Browser.qml b/interface/resources/qml/Browser.qml index 33595c2038..7436328dd8 100644 --- a/interface/resources/qml/Browser.qml +++ b/interface/resources/qml/Browser.qml @@ -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 } diff --git a/interface/resources/qml/controls-uit/WebView.qml b/interface/resources/qml/controls-uit/WebView.qml index 99064cdcbd..3d3fc20888 100644 --- a/interface/resources/qml/controls-uit/WebView.qml +++ b/interface/resources/qml/controls-uit/WebView.qml @@ -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); diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 2fee3488f9..ccffceede0 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -57,6 +57,7 @@ #include #include #include +#include #include #include #include @@ -1542,6 +1543,7 @@ void Application::initializeUi() { rootContext->setContextProperty("Audio", &AudioScriptingInterface::getInstance()); rootContext->setContextProperty("Controller", DependencyManager::get().data()); rootContext->setContextProperty("Entities", DependencyManager::get().data()); + rootContext->setContextProperty("File", new FileScriptingInterface(engine)); rootContext->setContextProperty("MyAvatar", getMyAvatar()); rootContext->setContextProperty("Messages", DependencyManager::get().data()); rootContext->setContextProperty("Recording", DependencyManager::get().data()); diff --git a/libraries/script-engine/src/FileScriptingInterface.cpp b/libraries/script-engine/src/FileScriptingInterface.cpp index 814a054e5e..ea6f42a44a 100644 --- a/libraries/script-engine/src/FileScriptingInterface.cpp +++ b/libraries/script-engine/src/FileScriptingInterface.cpp @@ -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() { diff --git a/libraries/script-engine/src/FileScriptingInterface.h b/libraries/script-engine/src/FileScriptingInterface.h index a9ccd3442f..0e12d3aa47 100644 --- a/libraries/script-engine/src/FileScriptingInterface.h +++ b/libraries/script-engine/src/FileScriptingInterface.h @@ -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); diff --git a/scripts/system/edit.js b/scripts/system/edit.js index f096deb0a7..1284202c6d 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -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()) { diff --git a/scripts/system/examples.js b/scripts/system/examples.js index 32d977834b..f67dd407bb 100644 --- a/scripts/system/examples.js +++ b/scripts/system/examples.js @@ -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', From ab02d16eb7656ea0a37785a398716fad62dff045 Mon Sep 17 00:00:00 2001 From: elisa-lj11 Date: Mon, 18 Jul 2016 19:37:24 -0700 Subject: [PATCH 11/31] QML troubleshooting Trying to find out why it does multiple downloads on one click, when everything fails. Has something to do with a download finish request getting sent despite not being completed. --- interface/resources/qml/Browser.qml | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/interface/resources/qml/Browser.qml b/interface/resources/qml/Browser.qml index 7436328dd8..e9421d5ad1 100644 --- a/interface/resources/qml/Browser.qml +++ b/interface/resources/qml/Browser.qml @@ -221,20 +221,25 @@ ScrollingWindow { 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") + if (download.state === WebEngineDownloadItem.DownloadRequested) { + 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) + if (download.state === WebEngineDownloadItem.DownloadCompleted) { + console.log("Download Finished: " + download.state) + console.log("File object is: " + File) + File.runUnzip(download.path) + } else { + console.log("The download was corrupted") + } }) } From c36fc29363c9772a479cf01dd3eea3d2d5257146 Mon Sep 17 00:00:00 2001 From: elisa-lj11 Date: Tue, 19 Jul 2016 19:48:16 -0700 Subject: [PATCH 12/31] Zip download works --- interface/resources/qml/Browser.qml | 29 +++----------- .../resources/qml/controls-uit/WebView.qml | 7 +++- interface/resources/qml/hifi/Desktop.qml | 39 +++++++++++++++++++ .../src/FileScriptingInterface.cpp | 38 ++++++++++++------ .../src/FileScriptingInterface.h | 6 ++- 5 files changed, 82 insertions(+), 37 deletions(-) diff --git a/interface/resources/qml/Browser.qml b/interface/resources/qml/Browser.qml index e9421d5ad1..79d045cf0f 100644 --- a/interface/resources/qml/Browser.qml +++ b/interface/resources/qml/Browser.qml @@ -140,6 +140,7 @@ ScrollingWindow { } } +<<<<<<< ab02d16eb7656ea0a37785a398716fad62dff045 Rectangle { id:permissionsContainer visible:false @@ -196,6 +197,8 @@ ScrollingWindow { } } } +======= +>>>>>>> Zip download works WebEngineView { id: webview @@ -220,35 +223,15 @@ ScrollingWindow { } Component.onCompleted: { - webview.profile.downloadRequested.connect(function(download){ - if (download.state === WebEngineDownloadItem.DownloadRequested) { - 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){ - if (download.state === WebEngineDownloadItem.DownloadCompleted) { - console.log("Download Finished: " + download.state) - console.log("File object is: " + File) - File.runUnzip(download.path) - } else { - console.log("The download was corrupted") - } - }) + desktop.initWebviewProfileHandlers(webview.profile) } - //profile: desktop.browserProfile } } // item - + + Keys.onPressed: { switch(event.key) { case Qt.Key_L: diff --git a/interface/resources/qml/controls-uit/WebView.qml b/interface/resources/qml/controls-uit/WebView.qml index 3d3fc20888..3ab1478750 100644 --- a/interface/resources/qml/controls-uit/WebView.qml +++ b/interface/resources/qml/controls-uit/WebView.qml @@ -69,9 +69,14 @@ WebEngineView { } onLinkHovered: { - console.log(hoveredUrl); + desktop.currentUrl = hoveredUrl + console.log("my url in WebView: " + desktop.currentUrl) } + //onLinkHovered: { + // console.log(hoveredUrl); + //} + // This breaks the webchannel used for passing messages. Fixed in Qt 5.6 // See https://bugreports.qt.io/browse/QTBUG-49521 //profile: desktop.browserProfile diff --git a/interface/resources/qml/hifi/Desktop.qml b/interface/resources/qml/hifi/Desktop.qml index 561bd722f2..29f982887c 100644 --- a/interface/resources/qml/hifi/Desktop.qml +++ b/interface/resources/qml/hifi/Desktop.qml @@ -71,6 +71,45 @@ OriginalDesktop.Desktop { }); } + // Accept a download through the webview + property bool webViewProfileSetup: false + property string currentUrl: "" + property string adaptedPath: "" + function initWebviewProfileHandlers(profile) { + console.log("the webview url in desktop is: " + currentUrl) + if (webViewProfileSetup) return; + webViewProfileSetup = true; + + 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 + } + 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) { + console.log("Download? " + download.state) + console.log("download failed to complete") + } + }) + + profile.downloadFinished.connect(function(download){ + if (download.state === WebEngineDownloadItem.DownloadCompleted) { + console.log("Download Finished: " + download.state) + console.log("File object is: " + File) + File.runUnzip(download.path, currentUrl) + //download.cancel() + } else { + console.log("The download was corrupted, state: " + download.state) + } + }) + } + // Create or fetch a toolbar with the given name function getToolbar(name) { var result = toolbars[name]; diff --git a/libraries/script-engine/src/FileScriptingInterface.cpp b/libraries/script-engine/src/FileScriptingInterface.cpp index ea6f42a44a..937618e9aa 100644 --- a/libraries/script-engine/src/FileScriptingInterface.cpp +++ b/libraries/script-engine/src/FileScriptingInterface.cpp @@ -31,9 +31,15 @@ FileScriptingInterface::FileScriptingInterface(QObject* parent) : QObject(parent // nothing for now } -void FileScriptingInterface::runUnzip(QString path) { - //downloadZip(path, importURL); +void FileScriptingInterface::runUnzip(QString path, QUrl url) { + qDebug() << "Url that was downloaded: " + url.toString(); qDebug() << "Path where download is saved: " + path; + unzipFile(path); +} + +bool FileScriptingInterface::testUrl(QUrl url) { + if (url.toString().contains(".zip")) return true; + return false; } QString FileScriptingInterface::getTempDir() { @@ -43,6 +49,14 @@ QString FileScriptingInterface::getTempDir() { // remember I must do something to delete this temp dir later } +QString FileScriptingInterface::convertUrlToPath(QUrl url) { + QString newUrl; + QString oldUrl = url.toString(); + newUrl = oldUrl.section("filename=", 1, 1); + qDebug() << "Filename should be: " + newUrl; + return newUrl; +} + void FileScriptingInterface::downloadZip(QString path, const QString link) { QUrl url = QUrl(link); auto request = ResourceManager::createResourceRequest(nullptr, url); @@ -54,15 +68,15 @@ void FileScriptingInterface::downloadZip(QString path, const QString link) { // clement's help :D void FileScriptingInterface::unzipFile(QString path) { - ResourceRequest* request = qobject_cast(sender()); - QUrl url = request->getUrl(); + //ResourceRequest* request = qobject_cast(sender()); + //QUrl url = request->getUrl(); - if (request->getResult() == ResourceRequest::Success) { + //if (request->getResult() == ResourceRequest::Success) { qDebug() << "Zip file was downloaded"; QDir dir(path); - QByteArray compressedFileContent = request->getData(); // <-- Downloaded file is in here - QBuffer buffer(&compressedFileContent); - buffer.open(QIODevice::ReadOnly); + //QByteArray compressedFileContent = request->getData(); // <-- Downloaded file is in here + //QBuffer buffer(&compressedFileContent); + //buffer.open(QIODevice::ReadOnly); //QString zipFileName = QFile::decodeName(compressedFileContent); QString dirName = dir.path(); @@ -104,10 +118,10 @@ void FileScriptingInterface::unzipFile(QString path) { }*/ - buffer.close(); - } else { - qDebug() << "Could not download the zip file"; - } + //buffer.close(); + //} else { + // qDebug() << "Could not download the zip file"; + //} } diff --git a/libraries/script-engine/src/FileScriptingInterface.h b/libraries/script-engine/src/FileScriptingInterface.h index 0e12d3aa47..6ba6044060 100644 --- a/libraries/script-engine/src/FileScriptingInterface.h +++ b/libraries/script-engine/src/FileScriptingInterface.h @@ -21,12 +21,16 @@ class FileScriptingInterface : public QObject { public: FileScriptingInterface(QObject* parent); + //void runUnzip(QString path, QString importURL); QString getTempDir(); + public slots: //void unzipFile(QString path); - void runUnzip(QString path); + bool testUrl(QUrl url); + QString convertUrlToPath(QUrl url); + void runUnzip(QString path, QUrl url); signals: From 49712060ed6e9cf9390365b9c551ab0f4792fdf6 Mon Sep 17 00:00:00 2001 From: elisa-lj11 Date: Thu, 21 Jul 2016 17:43:19 -0700 Subject: [PATCH 13/31] switching to the main site progress --- interface/resources/qml/Browser.qml | 1 + .../resources/qml/controls-uit/WebView.qml | 4 ---- .../src/FileScriptingInterface.cpp | 20 ++++++++++++------- scripts/system/examples.js | 4 ++-- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/interface/resources/qml/Browser.qml b/interface/resources/qml/Browser.qml index 79d045cf0f..f3bdab74f4 100644 --- a/interface/resources/qml/Browser.qml +++ b/interface/resources/qml/Browser.qml @@ -225,6 +225,7 @@ ScrollingWindow { Component.onCompleted: { desktop.initWebviewProfileHandlers(webview.profile) } + //profile: desktop.browserProfile } diff --git a/interface/resources/qml/controls-uit/WebView.qml b/interface/resources/qml/controls-uit/WebView.qml index 3ab1478750..5fa0f5f584 100644 --- a/interface/resources/qml/controls-uit/WebView.qml +++ b/interface/resources/qml/controls-uit/WebView.qml @@ -73,10 +73,6 @@ WebEngineView { console.log("my url in WebView: " + desktop.currentUrl) } - //onLinkHovered: { - // console.log(hoveredUrl); - //} - // This breaks the webchannel used for passing messages. Fixed in Qt 5.6 // See https://bugreports.qt.io/browse/QTBUG-49521 //profile: desktop.browserProfile diff --git a/libraries/script-engine/src/FileScriptingInterface.cpp b/libraries/script-engine/src/FileScriptingInterface.cpp index 937618e9aa..ad4ae8bdc2 100644 --- a/libraries/script-engine/src/FileScriptingInterface.cpp +++ b/libraries/script-engine/src/FileScriptingInterface.cpp @@ -80,12 +80,18 @@ void FileScriptingInterface::unzipFile(QString path) { //QString zipFileName = QFile::decodeName(compressedFileContent); QString dirName = dir.path(); + QDir testPath("C:/Users/elisa/Downloads/banana.zip"); qDebug() << "Zip directory is stored at: " + dirName; - JlCompress::extractDir(&buffer, dirName); + QStringList list = JlCompress::extractDir(testPath.path(), "C:/Users/elisa/Downloads/test"); - QFileInfoList files = dir.entryInfoList(); - foreach (QFileInfo file, files) { - recursiveFileScan(file, &dirName); + qDebug() << list; + + //QFileInfoList files = dir.entryInfoList(); + QFileInfoList files = testPath.entryInfoList(); + foreach(QFileInfo file, files) { + qDebug() << "My file: " + file.fileName(); + recursiveFileScan(file, &dirName); + } @@ -126,15 +132,15 @@ void FileScriptingInterface::unzipFile(QString path) { } void FileScriptingInterface::recursiveFileScan(QFileInfo file, QString* dirName) { - if (!file.isDir()) { + /*if (!file.isDir()) { qDebug() << "Regular file logged: " + file.fileName(); return; - } + }*/ QFileInfoList files; if (file.fileName().contains(".zip")) { + qDebug() << "Extracting archive: " + file.fileName(); JlCompress::extractDir(file.fileName()); - qDebug() << "Extracting archive: " + file.fileName(); } files = file.dir().entryInfoList(); diff --git a/scripts/system/examples.js b/scripts/system/examples.js index f67dd407bb..c445f218bc 100644 --- a/scripts/system/examples.js +++ b/scripts/system/examples.js @@ -12,8 +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 = "http://s3.amazonaws.com/DreamingContent/test.html"; +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 = "https://hifi-content.s3.amazonaws.com/elisalj/test.html"; //var EXAMPLES_URL = "https://hifi-content.s3.amazonaws.com/elisalj/test_download.html"; From 615627e98138a82089385841e20d223447d12f2e Mon Sep 17 00:00:00 2001 From: elisa-lj11 Date: Fri, 22 Jul 2016 15:33:58 -0700 Subject: [PATCH 14/31] Working download and unpackage from Clara.io --- interface/resources/qml/Browser.qml | 3 +++ interface/resources/qml/controls-uit/WebView.qml | 10 ++++++++++ interface/resources/qml/hifi/Desktop.qml | 14 ++++++++------ .../script-engine/src/FileScriptingInterface.cpp | 9 +++++---- scripts/system/examples.js | 3 ++- 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/interface/resources/qml/Browser.qml b/interface/resources/qml/Browser.qml index f3bdab74f4..833816972a 100644 --- a/interface/resources/qml/Browser.qml +++ b/interface/resources/qml/Browser.qml @@ -225,6 +225,9 @@ ScrollingWindow { Component.onCompleted: { desktop.initWebviewProfileHandlers(webview.profile) } + + + //profile: desktop.browserProfile diff --git a/interface/resources/qml/controls-uit/WebView.qml b/interface/resources/qml/controls-uit/WebView.qml index 5fa0f5f584..50ba2d92c3 100644 --- a/interface/resources/qml/controls-uit/WebView.qml +++ b/interface/resources/qml/controls-uit/WebView.qml @@ -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 diff --git a/interface/resources/qml/hifi/Desktop.qml b/interface/resources/qml/hifi/Desktop.qml index 29f982887c..db501be031 100644 --- a/interface/resources/qml/hifi/Desktop.qml +++ b/interface/resources/qml/hifi/Desktop.qml @@ -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) diff --git a/libraries/script-engine/src/FileScriptingInterface.cpp b/libraries/script-engine/src/FileScriptingInterface.cpp index ad4ae8bdc2..3a9cca64c4 100644 --- a/libraries/script-engine/src/FileScriptingInterface.cpp +++ b/libraries/script-engine/src/FileScriptingInterface.cpp @@ -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); diff --git a/scripts/system/examples.js b/scripts/system/examples.js index c445f218bc..6c01fd58af 100644 --- a/scripts/system/examples.js +++ b/scripts/system/examples.js @@ -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"; From a94a3047007e54a1ee5f24cf01e851d6a952efdb Mon Sep 17 00:00:00 2001 From: elisa-lj11 Date: Mon, 25 Jul 2016 16:15:43 -0700 Subject: [PATCH 15/31] Downloads from Clara.io and uploads to asset server --- interface/resources/qml/AssetServer.qml | 1 + interface/src/Application.cpp | 6 +- .../src/FileScriptingInterface.cpp | 82 ++++++------------- .../src/FileScriptingInterface.h | 3 +- 4 files changed, 31 insertions(+), 61 deletions(-) diff --git a/interface/resources/qml/AssetServer.qml b/interface/resources/qml/AssetServer.qml index 8d971e48d3..eca3d11721 100644 --- a/interface/resources/qml/AssetServer.qml +++ b/interface/resources/qml/AssetServer.qml @@ -320,6 +320,7 @@ ScrollingWindow { id: timer } function uploadClicked(fileUrl) { + console.log("Upload clicked url: " + fileUrl); if (uploadOpen) { return; } diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ccffceede0..7cf6410fd8 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1543,7 +1543,10 @@ void Application::initializeUi() { rootContext->setContextProperty("Audio", &AudioScriptingInterface::getInstance()); rootContext->setContextProperty("Controller", DependencyManager::get().data()); rootContext->setContextProperty("Entities", DependencyManager::get().data()); - rootContext->setContextProperty("File", new FileScriptingInterface(engine)); + //rootContext->setContextProperty("File", new FileScriptingInterface(engine)); + FileScriptingInterface* fileDownload = new FileScriptingInterface(engine); + rootContext->setContextProperty("File", fileDownload); + connect(fileDownload, &FileScriptingInterface::unzipSuccess, this, &Application::toggleAssetServerWidget); rootContext->setContextProperty("MyAvatar", getMyAvatar()); rootContext->setContextProperty("Messages", DependencyManager::get().data()); rootContext->setContextProperty("Recording", DependencyManager::get().data()); @@ -5035,6 +5038,7 @@ void Application::toggleAssetServerWidget(QString filePath) { auto startUpload = [=](QQmlContext* context, QObject* newObject){ if (!filePath.isEmpty()) { + qDebug() << "file in toggle: " + filePath; emit uploadRequest(filePath); } }; diff --git a/libraries/script-engine/src/FileScriptingInterface.cpp b/libraries/script-engine/src/FileScriptingInterface.cpp index 3a9cca64c4..ac72b99c9f 100644 --- a/libraries/script-engine/src/FileScriptingInterface.cpp +++ b/libraries/script-engine/src/FileScriptingInterface.cpp @@ -34,7 +34,16 @@ FileScriptingInterface::FileScriptingInterface(QObject* parent) : QObject(parent void FileScriptingInterface::runUnzip(QString path, QUrl url) { qDebug() << "Url that was downloaded: " + url.toString(); qDebug() << "Path where download is saved: " + path; - unzipFile(path); + QString file = unzipFile(path); + if (file != "") { + qDebug() << "file to upload: " + file; + QUrl url = QUrl::fromLocalFile(file); + qDebug() << "url from local file: " + url.toString(); + emit unzipSuccess(url.toString()); + //Application::toggleAssetServerWidget(file); + } else { + qDebug() << "unzip failed"; + } } bool FileScriptingInterface::testUrl(QUrl url) { @@ -68,67 +77,22 @@ void FileScriptingInterface::downloadZip(QString path, const QString link) { } // clement's help :D -void FileScriptingInterface::unzipFile(QString path) { - //ResourceRequest* request = qobject_cast(sender()); - //QUrl url = request->getUrl(); +QString FileScriptingInterface::unzipFile(QString path) { - //if (request->getResult() == ResourceRequest::Success) { - qDebug() << "Zip file was downloaded"; - QDir dir(path); - //QByteArray compressedFileContent = request->getData(); // <-- Downloaded file is in here - //QBuffer buffer(&compressedFileContent); - //buffer.open(QIODevice::ReadOnly); + qDebug() << "Zip file was downloaded"; + QDir dir(path); + QString dirName = dir.path(); + qDebug() << "Zip directory is stored at: " + dirName; + QStringList list = JlCompress::extractDir(dirName, "C:/Users/elisa/Downloads/test"); - //QString zipFileName = QFile::decodeName(compressedFileContent); - QString dirName = dir.path(); - //QDir testPath("C:/Users/elisa/Downloads/banana.zip"); - qDebug() << "Zip directory is stored at: " + dirName; - QStringList list = JlCompress::extractDir(dirName, "C:/Users/elisa/Downloads/test"); + qDebug() << list; - qDebug() << list; - - //QFileInfoList files = dir.entryInfoList(); - QFileInfoList files = dir.entryInfoList(); - foreach(QFileInfo file, files) { - qDebug() << "My file: " + file.fileName(); - recursiveFileScan(file, &dirName); - - } - - - /*foreach (QFileInfo file, files) { - if (file.isDir()) { - if (file.fileName().contains(".zip")) { - qDebug() << "Zip file expanded: " + file.fileName(); - } - - qDebug() << "Regular file logged: " + file.fileName(); - } - }*/ - - - - - //QFile file = - //need to convert this byte array to a file - /*QuaZip zip(zipFileName); - - if (zip.open(QuaZip::mdUnzip)) { - qDebug() << "Opened"; - - for (bool more = zip.goToFirstFile(); more; more = zip.goToNextFile()) { - // do something - qDebug() << zip.getCurrentFileName(); - } - if (zip.getZipError() == UNZ_OK) { - // ok, there was no error - }*/ - - - //buffer.close(); - //} else { - // qDebug() << "Could not download the zip file"; - //} + if (!list.isEmpty()) { + return list.front(); + } else { + qDebug() << "Extraction failed"; + return ""; + } } diff --git a/libraries/script-engine/src/FileScriptingInterface.h b/libraries/script-engine/src/FileScriptingInterface.h index 6ba6044060..d90bf1ed2b 100644 --- a/libraries/script-engine/src/FileScriptingInterface.h +++ b/libraries/script-engine/src/FileScriptingInterface.h @@ -33,10 +33,11 @@ public slots: void runUnzip(QString path, QUrl url); signals: + void unzipSuccess(QString url); private: //void downloadZip(); - void unzipFile(QString path); + QString unzipFile(QString path); void recursiveFileScan(QFileInfo file, QString* dirName); void downloadZip(QString path, const QString link); From b1b2ea48b245d26e38a7cda88340f8718c51fd1e Mon Sep 17 00:00:00 2001 From: elisa-lj11 Date: Tue, 26 Jul 2016 16:33:06 -0700 Subject: [PATCH 16/31] Made code more QA; extra browser and download widget close upon download --- interface/resources/qml/AssetServer.qml | 2 +- interface/resources/qml/Browser.qml | 7 -- .../resources/qml/controls-uit/WebView.qml | 54 ++++++--- interface/resources/qml/hifi/Desktop.qml | 69 +++++------ interface/src/Application.cpp | 40 ++----- interface/src/Application.h | 2 - .../scripting/WindowScriptingInterface.cpp | 14 --- .../src/scripting/WindowScriptingInterface.h | 1 - .../src/FileScriptingInterface.cpp | 109 +++++++++--------- .../src/FileScriptingInterface.h | 22 ++-- libraries/script-engine/src/ScriptEngine.cpp | 1 - libraries/ui/src/OffscreenUi.cpp | 3 - scripts/system/edit.js | 16 --- 13 files changed, 144 insertions(+), 196 deletions(-) diff --git a/interface/resources/qml/AssetServer.qml b/interface/resources/qml/AssetServer.qml index eca3d11721..0f55e77a66 100644 --- a/interface/resources/qml/AssetServer.qml +++ b/interface/resources/qml/AssetServer.qml @@ -320,7 +320,7 @@ ScrollingWindow { id: timer } function uploadClicked(fileUrl) { - console.log("Upload clicked url: " + fileUrl); + console.log("Upload clicked url: " + fileUrl); if (uploadOpen) { return; } diff --git a/interface/resources/qml/Browser.qml b/interface/resources/qml/Browser.qml index 833816972a..2be0ca176d 100644 --- a/interface/resources/qml/Browser.qml +++ b/interface/resources/qml/Browser.qml @@ -140,7 +140,6 @@ ScrollingWindow { } } -<<<<<<< ab02d16eb7656ea0a37785a398716fad62dff045 Rectangle { id:permissionsContainer visible:false @@ -197,8 +196,6 @@ ScrollingWindow { } } } -======= ->>>>>>> Zip download works WebEngineView { id: webview @@ -221,15 +218,11 @@ ScrollingWindow { onIconChanged: { console.log("New icon: " + icon) } - Component.onCompleted: { desktop.initWebviewProfileHandlers(webview.profile) } - - - //profile: desktop.browserProfile } diff --git a/interface/resources/qml/controls-uit/WebView.qml b/interface/resources/qml/controls-uit/WebView.qml index 50ba2d92c3..fdc1452d9b 100644 --- a/interface/resources/qml/controls-uit/WebView.qml +++ b/interface/resources/qml/controls-uit/WebView.qml @@ -25,7 +25,7 @@ WebEngineView { }); } - + // FIXME hack to get the URL with the auth token included. Remove when we move to Qt 5.6 Timer { @@ -51,7 +51,7 @@ WebEngineView { onLoadingChanged: { // Required to support clicking on "hifi://" links - console.log("loading change requested url"); + console.log("loading change requested url"); if (WebEngineView.LoadStartedStatus == loadRequest.status) { var url = loadRequest.url.toString(); if (urlHandler.canHandleUrl(url)) { @@ -62,26 +62,44 @@ WebEngineView { } } - onNewViewRequested: { - console.log("new view requested 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); + Timer { + id: zipTimer + running: false + repeat: false + interval: 1000 + property var handler; + onTriggered: handler(); } - property var myScript: 'var element = $("a.download-file"); - element.removeClass("download-file"); - element.removeAttr("download _target");' + property var autoCancel: 'var element = $("a.btn.cancel"); + element.click();' - 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"); }); - } + onNewViewRequested: { + console.log("new view requested url"); + var component = Qt.createComponent("../Browser.qml"); + var newWindow = component.createObject(desktop); + request.openIn(newWindow.webView); + if (File.testUrl(desktop.currentUrl)) { + zipTimer.handler = function() { + newWindow.destroy(); + runJavaScript(autoCancel); + } + zipTimer.start(); + } + } - } + property var simpleDownload: 'var element = $("a.download-file"); + element.removeClass("download-file"); + element.removeAttr("download");' + + onLinkHovered: { + desktop.currentUrl = hoveredUrl + console.log("my url in WebView: " + desktop.currentUrl) + if (File.testUrl(desktop.currentUrl)) { + runJavaScript(simpleDownload, function(){console.log("ran the JS");}); + } + + } // This breaks the webchannel used for passing messages. Fixed in Qt 5.6 // See https://bugreports.qt.io/browse/QTBUG-49521 diff --git a/interface/resources/qml/hifi/Desktop.qml b/interface/resources/qml/hifi/Desktop.qml index db501be031..9ab9324b74 100644 --- a/interface/resources/qml/hifi/Desktop.qml +++ b/interface/resources/qml/hifi/Desktop.qml @@ -19,7 +19,7 @@ OriginalDesktop.Desktop { scrollGestureEnabled: false // we don't need/want these onEntered: ApplicationCompositor.reticleOverDesktop = true onExited: ApplicationCompositor.reticleOverDesktop = false - acceptedButtons: Qt.NoButtonMouseArea + acceptedButtons: Qt.NoButton } @@ -73,44 +73,39 @@ OriginalDesktop.Desktop { }); } - // Accept a download through the webview - property bool webViewProfileSetup: false - property string currentUrl: "" - property string adaptedPath: "" - function initWebviewProfileHandlers(profile) { - console.log("the webview url in desktop is: " + currentUrl) - if (webViewProfileSetup) return; - webViewProfileSetup = true; + // Accept a download through the webview + property bool webViewProfileSetup: false + property string currentUrl: "" + property string adaptedPath: "" - 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 - //} - 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) { - console.log("Download? " + download.state) - console.log("download failed to complete") - } - }) + function initWebviewProfileHandlers(profile) { + console.log("the webview url in desktop is: " + currentUrl); + if (webViewProfileSetup) return; + webViewProfileSetup = true; - profile.downloadFinished.connect(function(download){ - if (download.state === WebEngineDownloadItem.DownloadCompleted) { - console.log("Download Finished: " + download.state) - console.log("File object is: " + File) - File.runUnzip(download.path, currentUrl) - //download.cancel() - } else { - console.log("The download was corrupted, state: " + download.state) - } - }) - } + profile.downloadRequested.connect(function(download){ + console.log("Download start: " + 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) { + console.log("Download? " + download.state); + console.log("download failed to complete"); + } + }) + + profile.downloadFinished.connect(function(download){ + if (download.state === WebEngineDownloadItem.DownloadCompleted) { + console.log("Download Finished: " + download.state); + console.log("File object is: " + File); + File.runUnzip(download.path, currentUrl); + } else { + console.log("The download was corrupted, state: " + download.state); + } + }) + } // Create or fetch a toolbar with the given name function getToolbar(name) { diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 7cf6410fd8..66fb6ed6b6 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -355,7 +355,6 @@ public: if (message->message == WM_COPYDATA) { COPYDATASTRUCT* pcds = (COPYDATASTRUCT*)(message->lParam); - qDebug() << "os windows url for some reason"; QUrl url = QUrl((const char*)(pcds->lpData)); if (url.isValid() && url.scheme() == HIFI_URL_SCHEME) { DependencyManager::get()->handleLookupString(url.toString()); @@ -1543,10 +1542,9 @@ void Application::initializeUi() { rootContext->setContextProperty("Audio", &AudioScriptingInterface::getInstance()); rootContext->setContextProperty("Controller", DependencyManager::get().data()); rootContext->setContextProperty("Entities", DependencyManager::get().data()); - //rootContext->setContextProperty("File", new FileScriptingInterface(engine)); - FileScriptingInterface* fileDownload = new FileScriptingInterface(engine); - rootContext->setContextProperty("File", fileDownload); - connect(fileDownload, &FileScriptingInterface::unzipSuccess, this, &Application::toggleAssetServerWidget); + FileScriptingInterface* fileDownload = new FileScriptingInterface(engine); + rootContext->setContextProperty("File", fileDownload); + connect(fileDownload, &FileScriptingInterface::unzipSuccess, this, &Application::toggleAssetServerWidget); rootContext->setContextProperty("MyAvatar", getMyAvatar()); rootContext->setContextProperty("Messages", DependencyManager::get().data()); rootContext->setContextProperty("Recording", DependencyManager::get().data()); @@ -2020,14 +2018,6 @@ bool Application::importSVOFromURL(const QString& urlString) { 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) { if (!Menu::getInstance()) { @@ -2147,26 +2137,21 @@ bool Application::event(QEvent* event) { // handle custom URL if (event->type() == QEvent::FileOpen) { - qDebug() << "we have received one url!: "; QFileOpenEvent* fileEvent = static_cast(event); QUrl url = fileEvent->url(); if (!url.isEmpty()) { QString urlString = url.toString(); - qDebug() << "we got a url!: " + urlString; + if (canAcceptURL(urlString)) { - qDebug() << "we got an ACCEPTED url!: " + urlString; + return acceptURL(urlString); } } return false; } - if (event->type() == QEvent::None) { - qDebug() << "this url just didn't click"; - } - if (HFActionEvent::types().contains(event->type())) { _controllerScriptingInterface->handleMetaEvent(static_cast(event)); } @@ -3190,7 +3175,6 @@ void Application::saveSettings() const { } bool Application::importEntities(const QString& urlOrFilename) { - qDebug() << "import entities url"; bool success = false; _entityClipboard->withWriteLock([&] { _entityClipboard->eraseAllOctreeElements(); @@ -4800,7 +4784,6 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri } bool Application::canAcceptURL(const QString& urlString) const { - qDebug() << "stepping through 'canAcceptURL'"; QUrl url(urlString); if (urlString.startsWith(HIFI_URL_SCHEME)) { return true; @@ -4817,7 +4800,6 @@ bool Application::canAcceptURL(const QString& urlString) const { } bool Application::acceptURL(const QString& urlString, bool defaultUpload) { - qDebug() << "stepping through 'acceptURL'"; if (urlString.startsWith(HIFI_URL_SCHEME)) { // this is a hifi URL - have the AddressManager handle it QMetaObject::invokeMethod(DependencyManager::get().data(), "handleLookupString", @@ -4847,7 +4829,6 @@ void Application::setSessionUUID(const QUuid& sessionUUID) const { } bool Application::askToSetAvatarUrl(const QString& url) { - qDebug() << "setting avatar url"; QUrl realUrl(url); if (realUrl.isLocalFile()) { 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) { - qDebug() << "setting script url"; QMessageBox::StandardButton reply; QString shortName = scriptFilenameOrURL; @@ -4929,7 +4909,6 @@ bool Application::askToLoadScript(const QString& scriptFilenameOrURL) { } bool Application::askToWearAvatarAttachmentUrl(const QString& url) { - qDebug() << "setting avatar attachment url"; QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance(); QNetworkRequest networkRequest = QNetworkRequest(url); networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT); @@ -5011,7 +4990,6 @@ bool Application::displayAvatarAttachmentConfirmationDialog(const QString& name) } void Application::toggleRunningScriptsWidget() const { - qDebug() << "toggle running scripts url"; static const QUrl url("hifi/dialogs/RunningScripts.qml"); DependencyManager::get()->show(url, "RunningScripts"); //if (_runningScriptsWidget->isVisible()) { @@ -5029,16 +5007,16 @@ void Application::toggleRunningScriptsWidget() const { } void Application::toggleAssetServerWidget(QString filePath) { - qDebug() << "toggle asset before if"; + qDebug() << "toggle asset before if: " + filePath; if (!DependencyManager::get()->getThisNodeCanWriteAssets()) { return; } - qDebug() << "toggle asset after if"; + qDebug() << "toggle asset after if"; static const QUrl url { "AssetServer.qml" }; auto startUpload = [=](QQmlContext* context, QObject* newObject){ if (!filePath.isEmpty()) { - qDebug() << "file in toggle: " + filePath; + qDebug() << "file in toggle: " + filePath; emit uploadRequest(filePath); } }; @@ -5051,7 +5029,6 @@ void Application::packageModel() { } void Application::openUrl(const QUrl& url) const { - qDebug() << "open url"; if (!url.isEmpty()) { if (url.scheme() == HIFI_URL_SCHEME) { DependencyManager::get()->handleLookupString(url.toString()); @@ -5082,7 +5059,6 @@ void Application::setPreviousScriptLocation(const QString& location) { } void Application::loadScriptURLDialog() const { - qDebug() << "load script url dialog"; auto newScript = OffscreenUi::getText(nullptr, "Open and Run Script", "Script URL"); if (!newScript.isEmpty()) { DependencyManager::get()->loadScript(newScript); diff --git a/interface/src/Application.h b/interface/src/Application.h index d8f02f41b7..0af65f665f 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -250,7 +250,6 @@ public: signals: void svoImportRequested(const QString& url); - void zipImportRequested(const QString& url); void fullAvatarURLChanged(const QString& newValue, const QString& modelName); @@ -386,7 +385,6 @@ private: bool importJSONFromURL(const QString& urlString); bool importSVOFromURL(const QString& urlString); - bool importZIPFromURL(const QString& urlString); bool nearbyEntitiesAreReadyForPhysics(); int processOctreeStats(ReceivedMessage& message, SharedNodePointer sendingNode); diff --git a/interface/src/scripting/WindowScriptingInterface.cpp b/interface/src/scripting/WindowScriptingInterface.cpp index 2ea562143e..b165cda135 100644 --- a/interface/src/scripting/WindowScriptingInterface.cpp +++ b/interface/src/scripting/WindowScriptingInterface.cpp @@ -59,20 +59,6 @@ WindowScriptingInterface::WindowScriptingInterface() { 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) { diff --git a/interface/src/scripting/WindowScriptingInterface.h b/interface/src/scripting/WindowScriptingInterface.h index b33da4ef4d..9d73111333 100644 --- a/interface/src/scripting/WindowScriptingInterface.h +++ b/interface/src/scripting/WindowScriptingInterface.h @@ -58,7 +58,6 @@ public slots: signals: void domainChanged(const QString& domainHostname); void svoImportRequested(const QString& url); - void zipImportRequested(const QString& url); // zip project void domainConnectionRefused(const QString& reasonMessage, int reasonCode); void snapshotTaken(const QString& path); diff --git a/libraries/script-engine/src/FileScriptingInterface.cpp b/libraries/script-engine/src/FileScriptingInterface.cpp index ac72b99c9f..4126b5fdad 100644 --- a/libraries/script-engine/src/FileScriptingInterface.cpp +++ b/libraries/script-engine/src/FileScriptingInterface.cpp @@ -28,94 +28,97 @@ FileScriptingInterface::FileScriptingInterface(QObject* parent) : QObject(parent) { - // nothing for now + // nothing for now } void FileScriptingInterface::runUnzip(QString path, QUrl url) { - qDebug() << "Url that was downloaded: " + url.toString(); - qDebug() << "Path where download is saved: " + path; - QString file = unzipFile(path); - if (file != "") { - qDebug() << "file to upload: " + file; - QUrl url = QUrl::fromLocalFile(file); - qDebug() << "url from local file: " + url.toString(); - emit unzipSuccess(url.toString()); - //Application::toggleAssetServerWidget(file); - } else { - qDebug() << "unzip failed"; - } + qDebug() << "Url that was downloaded: " + url.toString(); + qDebug() << "Path where download is saved: " + path; + QString file = unzipFile(path); + if (file != "") { + qDebug() << "file to upload: " + file; + QUrl url = QUrl::fromLocalFile(file); + qDebug() << "url from local file: " + url.toString(); + emit unzipSuccess(url.toString()); + } else { + qDebug() << "unzip failed"; + } } bool FileScriptingInterface::testUrl(QUrl url) { - 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; + 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; } +// this function is not in use QString FileScriptingInterface::getTempDir() { - QTemporaryDir dir; - dir.setAutoRemove(false); - return dir.path(); - // remember I must do something to delete this temp dir later + QTemporaryDir dir; + dir.setAutoRemove(false); + return dir.path(); + // do something to delete this temp dir later } QString FileScriptingInterface::convertUrlToPath(QUrl url) { - QString newUrl; - QString oldUrl = url.toString(); - newUrl = oldUrl.section("filename=", 1, 1); - qDebug() << "Filename should be: " + newUrl; - return newUrl; + QString newUrl; + QString oldUrl = url.toString(); + newUrl = oldUrl.section("filename=", 1, 1); + qDebug() << "Filename should be: " + newUrl; + return newUrl; } +// this function is not in use void FileScriptingInterface::downloadZip(QString path, const QString link) { - QUrl url = QUrl(link); - auto request = ResourceManager::createResourceRequest(nullptr, url); - connect(request, &ResourceRequest::finished, this, [this, path]{ - unzipFile(path); - }); + QUrl url = QUrl(link); + auto request = ResourceManager::createResourceRequest(nullptr, url); + connect(request, &ResourceRequest::finished, this, [this, path]{ + unzipFile(path); + }); request->send(); } -// clement's help :D + QString FileScriptingInterface::unzipFile(QString path) { - qDebug() << "Zip file was downloaded"; - QDir dir(path); + QDir 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"); - qDebug() << list; + qDebug() << list; - if (!list.isEmpty()) { - return list.front(); - } else { - qDebug() << "Extraction failed"; - return ""; - } + if (!list.isEmpty()) { + return list.front(); + } else { + qDebug() << "Extraction failed"; + return ""; + } } +// this function is not in use void FileScriptingInterface::recursiveFileScan(QFileInfo file, QString* dirName) { - /*if (!file.isDir()) { - qDebug() << "Regular file logged: " + file.fileName(); - return; - }*/ + /*if (!file.isDir()) { + qDebug() << "Regular file logged: " + file.fileName(); + return; + }*/ QFileInfoList files; - if (file.fileName().contains(".zip")) { - qDebug() << "Extracting archive: " + file.fileName(); - JlCompress::extractDir(file.fileName()); + if (file.fileName().contains(".zip")) { + qDebug() << "Extracting archive: " + file.fileName(); + JlCompress::extractDir(file.fileName()); } files = file.dir().entryInfoList(); - /*if (files.empty()) { - files = JlCompress::getFileList(file.fileName()); - }*/ + /*if (files.empty()) { + files = JlCompress::getFileList(file.fileName()); + }*/ - foreach (QFileInfo file, files) { + foreach (QFileInfo file, files) { qDebug() << "Looking into file: " + file.fileName(); recursiveFileScan(file, dirName); - } + } return; } diff --git a/libraries/script-engine/src/FileScriptingInterface.h b/libraries/script-engine/src/FileScriptingInterface.h index d90bf1ed2b..df6b91c678 100644 --- a/libraries/script-engine/src/FileScriptingInterface.h +++ b/libraries/script-engine/src/FileScriptingInterface.h @@ -22,24 +22,24 @@ class FileScriptingInterface : public QObject { public: FileScriptingInterface(QObject* parent); - //void runUnzip(QString path, QString importURL); - QString getTempDir(); + //void runUnzip(QString path, QString importURL); + QString getTempDir(); public slots: - //void unzipFile(QString path); - bool testUrl(QUrl url); - QString convertUrlToPath(QUrl url); - void runUnzip(QString path, QUrl url); + //void unzipFile(QString path); + bool testUrl(QUrl url); + QString convertUrlToPath(QUrl url); + void runUnzip(QString path, QUrl url); signals: - void unzipSuccess(QString url); + void unzipSuccess(QString url); private: - //void downloadZip(); - QString unzipFile(QString path); - void recursiveFileScan(QFileInfo file, QString* dirName); - void downloadZip(QString path, const QString link); + //void downloadZip(); + QString unzipFile(QString path); + void recursiveFileScan(QFileInfo file, QString* dirName); + void downloadZip(QString path, const QString link); }; diff --git a/libraries/script-engine/src/ScriptEngine.cpp b/libraries/script-engine/src/ScriptEngine.cpp index fe7e1c4036..dd3fcad749 100644 --- a/libraries/script-engine/src/ScriptEngine.cpp +++ b/libraries/script-engine/src/ScriptEngine.cpp @@ -503,7 +503,6 @@ void ScriptEngine::init() { registerGlobalObject("Uuid", &_uuidLibrary); registerGlobalObject("Messages", DependencyManager::get().data()); - // unzip project registerGlobalObject("File", new FileScriptingInterface(this)); qScriptRegisterMetaType(this, animVarMapToScriptValue, animVarMapFromScriptValue); diff --git a/libraries/ui/src/OffscreenUi.cpp b/libraries/ui/src/OffscreenUi.cpp index 82a9186f92..06ef456006 100644 --- a/libraries/ui/src/OffscreenUi.cpp +++ b/libraries/ui/src/OffscreenUi.cpp @@ -78,20 +78,17 @@ class UrlHandler : public QObject { Q_OBJECT public: Q_INVOKABLE bool canHandleUrl(const QString& url) { - qDebug() << Q_FUNC_INFO; static auto handler = dynamic_cast(qApp); return handler->canAcceptURL(url); } Q_INVOKABLE bool handleUrl(const QString& url) { - qDebug() << Q_FUNC_INFO; static auto handler = dynamic_cast(qApp); return handler->acceptURL(url); } // FIXME hack for authentication, remove when we migrate to Qt 5.6 Q_INVOKABLE QString fixupUrl(const QString& originalUrl) { - qDebug() << Q_FUNC_INFO; return fixupHifiUrl(originalUrl); } }; diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 1284202c6d..25c25a9a7e 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -1205,22 +1205,6 @@ function importSVO(importURL) { } 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); Controller.keyPressEvent.connect(function (event) { From a9a8710689022e1e36f1d07bed282a885505828a Mon Sep 17 00:00:00 2001 From: elisa-lj11 Date: Tue, 26 Jul 2016 17:47:54 -0700 Subject: [PATCH 17/31] Switched saving download/upload to temporary directory --- interface/resources/qml/controls-uit/WebView.qml | 2 +- interface/resources/qml/hifi/Desktop.qml | 7 ++++--- .../script-engine/src/FileScriptingInterface.cpp | 14 ++++++++------ .../script-engine/src/FileScriptingInterface.h | 10 +++------- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/interface/resources/qml/controls-uit/WebView.qml b/interface/resources/qml/controls-uit/WebView.qml index fdc1452d9b..bb08e5e389 100644 --- a/interface/resources/qml/controls-uit/WebView.qml +++ b/interface/resources/qml/controls-uit/WebView.qml @@ -66,7 +66,7 @@ WebEngineView { id: zipTimer running: false repeat: false - interval: 1000 + interval: 1500 property var handler; onTriggered: handler(); } diff --git a/interface/resources/qml/hifi/Desktop.qml b/interface/resources/qml/hifi/Desktop.qml index 9ab9324b74..ab1fffdcf5 100644 --- a/interface/resources/qml/hifi/Desktop.qml +++ b/interface/resources/qml/hifi/Desktop.qml @@ -77,6 +77,7 @@ OriginalDesktop.Desktop { property bool webViewProfileSetup: false property string currentUrl: "" property string adaptedPath: "" + property string tempDir: "" function initWebviewProfileHandlers(profile) { console.log("the webview url in desktop is: " + currentUrl); @@ -86,12 +87,12 @@ OriginalDesktop.Desktop { profile.downloadRequested.connect(function(download){ console.log("Download start: " + download.state); adaptedPath = File.convertUrlToPath(currentUrl); - download.path = "C:/Users/elisa/Downloads/" + adaptedPath; + tempDir = File.getTempDir(); + download.path = tempDir + "/" + adaptedPath; console.log("Path where it should download: " + download.path); download.accept(); console.log("Download accept: " + download.state); if (download.state === WebEngineDownloadItem.DownloadInterrupted) { - console.log("Download? " + download.state); console.log("download failed to complete"); } }) @@ -100,7 +101,7 @@ OriginalDesktop.Desktop { if (download.state === WebEngineDownloadItem.DownloadCompleted) { console.log("Download Finished: " + download.state); console.log("File object is: " + File); - File.runUnzip(download.path, currentUrl); + File.runUnzip(download.path, tempDir, currentUrl); } else { console.log("The download was corrupted, state: " + download.state); } diff --git a/libraries/script-engine/src/FileScriptingInterface.cpp b/libraries/script-engine/src/FileScriptingInterface.cpp index 4126b5fdad..94d8d1b424 100644 --- a/libraries/script-engine/src/FileScriptingInterface.cpp +++ b/libraries/script-engine/src/FileScriptingInterface.cpp @@ -31,10 +31,10 @@ FileScriptingInterface::FileScriptingInterface(QObject* parent) : QObject(parent // nothing for now } -void FileScriptingInterface::runUnzip(QString path, QUrl url) { +void FileScriptingInterface::runUnzip(QString path, QString tempDir, QUrl url) { qDebug() << "Url that was downloaded: " + url.toString(); qDebug() << "Path where download is saved: " + path; - QString file = unzipFile(path); + QString file = unzipFile(path, tempDir); if (file != "") { qDebug() << "file to upload: " + file; QUrl url = QUrl::fromLocalFile(file); @@ -43,6 +43,8 @@ void FileScriptingInterface::runUnzip(QString path, QUrl url) { } else { qDebug() << "unzip failed"; } + qDebug() << "Removing temporary directory at: " + tempDir; + QDir(tempDir).removeRecursively(); } bool FileScriptingInterface::testUrl(QUrl url) { @@ -72,20 +74,20 @@ void FileScriptingInterface::downloadZip(QString path, const QString link) { QUrl url = QUrl(link); auto request = ResourceManager::createResourceRequest(nullptr, url); connect(request, &ResourceRequest::finished, this, [this, path]{ - unzipFile(path); + unzipFile(path, ""); // so intellisense isn't mad }); request->send(); } -QString FileScriptingInterface::unzipFile(QString path) { +QString FileScriptingInterface::unzipFile(QString path, QString tempDir) { QDir dir(path); QString dirName = dir.path(); qDebug() << "Zip directory is stored at: " + dirName; - QString target = path.section("/", -1) + "/model_repo"; + QString target = tempDir + "/model_repo"; qDebug() << "Target path: " + target; - QStringList list = JlCompress::extractDir(dirName, "C:/Users/elisa/Downloads/test"); + QStringList list = JlCompress::extractDir(dirName, target); qDebug() << list; diff --git a/libraries/script-engine/src/FileScriptingInterface.h b/libraries/script-engine/src/FileScriptingInterface.h index df6b91c678..2658622644 100644 --- a/libraries/script-engine/src/FileScriptingInterface.h +++ b/libraries/script-engine/src/FileScriptingInterface.h @@ -22,22 +22,18 @@ class FileScriptingInterface : public QObject { public: FileScriptingInterface(QObject* parent); - //void runUnzip(QString path, QString importURL); - QString getTempDir(); - public slots: - //void unzipFile(QString path); bool testUrl(QUrl url); QString convertUrlToPath(QUrl url); - void runUnzip(QString path, QUrl url); + void runUnzip(QString path, QString tempDir, QUrl url); + QString getTempDir(); signals: void unzipSuccess(QString url); private: - //void downloadZip(); - QString unzipFile(QString path); + QString unzipFile(QString path, QString tempDir); void recursiveFileScan(QFileInfo file, QString* dirName); void downloadZip(QString path, const QString link); From cd7706e80b2831ed0f4bd17155d74ed1439f994e Mon Sep 17 00:00:00 2001 From: elisa-lj11 Date: Thu, 28 Jul 2016 13:56:38 -0700 Subject: [PATCH 18/31] Release now has quazip features --- cmake/externals/quazip/CMakeLists.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cmake/externals/quazip/CMakeLists.txt b/cmake/externals/quazip/CMakeLists.txt index bf51a52fc5..d8ab492be5 100644 --- a/cmake/externals/quazip/CMakeLists.txt +++ b/cmake/externals/quazip/CMakeLists.txt @@ -37,11 +37,14 @@ set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIRS ${${EXTERNAL_NAME_UPPER}_INCLUDE_DIR} CA set(${EXTERNAL_NAME_UPPER}_DLL_PATH ${INSTALL_DIR}/lib CACHE FILEPATH "Location of QuaZip DLL") if (APPLE) - set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${INSTALL_DIR}/lib/libquazip5d.1.0.0.dylib CACHE FILEPATH "Location of QuaZip release library") + set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${INSTALL_DIR}/lib/libquazip5.1.0.0.dylib CACHE FILEPATH "Location of QuaZip release library") + set(${EXTERNAL_NAME_UPPER}_LIBRARY_DEBUG ${INSTALL_DIR}/lib/libquazip5d.1.0.0.dylib CACHE FILEPATH "Location of QuaZip release library") elseif (WIN32) - set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${INSTALL_DIR}/lib/quazip5d.lib CACHE FILEPATH "Location of QuaZip release library") + set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${INSTALL_DIR}/lib/quazip5.lib CACHE FILEPATH "Location of QuaZip release library") + set(${EXTERNAL_NAME_UPPER}_LIBRARY_DEBUG ${INSTALL_DIR}/lib/quazip5d.lib CACHE FILEPATH "Location of QuaZip release library") else () - set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${INSTALL_DIR}/lib/libquazip5d.so CACHE FILEPATH "Location of QuaZip release library") + set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${INSTALL_DIR}/lib/libquazip5.so CACHE FILEPATH "Location of QuaZip release library") + set(${EXTERNAL_NAME_UPPER}_LIBRARY_DEBUG ${INSTALL_DIR}/lib/libquazip5d.so CACHE FILEPATH "Location of QuaZip release library") endif () include(SelectLibraryConfigurations) From d63d0ba870a6ffac8be96b6458b7457bfdbbdaef Mon Sep 17 00:00:00 2001 From: elisa-lj11 Date: Wed, 3 Aug 2016 14:16:39 -0700 Subject: [PATCH 19/31] In process of creating combobox for marketplace with qml --- interface/resources/qml/QmlWindow.qml | 10 ++- .../resources/qml/controls-uit/ComboBox.qml | 1 + .../resources/qml/controls-uit/Label.qml | 1 + .../qml/controls-uit/MarketplaceComboBox.qml | 43 ++++++++++ scripts/system/marketplace - Elisa.js | 82 +++++++++++++++++++ scripts/system/marketplace.js | 1 + 6 files changed, 136 insertions(+), 2 deletions(-) create mode 100644 interface/resources/qml/controls-uit/MarketplaceComboBox.qml create mode 100644 scripts/system/marketplace - Elisa.js diff --git a/interface/resources/qml/QmlWindow.qml b/interface/resources/qml/QmlWindow.qml index 7be747a3ad..47857ac7c1 100644 --- a/interface/resources/qml/QmlWindow.qml +++ b/interface/resources/qml/QmlWindow.qml @@ -1,13 +1,16 @@ -import QtQuick 2.3 -import QtQuick.Controls 1.2 +import QtQuick 2.5 +import QtQuick.Controls 1.4 import QtWebChannel 1.0 +import QtWebEngine 1.1 import QtWebSockets 1.0 import "qrc:///qtwebchannel/qwebchannel.js" as WebChannel import "windows" as Windows import "controls" +import "controls-uit" as Controls import "styles" +import "styles-uit" Windows.Window { id: root @@ -23,6 +26,8 @@ Windows.Window { property var eventBridge; property var component; property var dynamicContent; + + onSourceChanged: { if (dynamicContent) { dynamicContent.destroy(); @@ -71,5 +76,6 @@ Windows.Window { Item { id: contentHolder anchors.fill: parent + } } diff --git a/interface/resources/qml/controls-uit/ComboBox.qml b/interface/resources/qml/controls-uit/ComboBox.qml index eb0c08624b..fa100a965f 100644 --- a/interface/resources/qml/controls-uit/ComboBox.qml +++ b/interface/resources/qml/controls-uit/ComboBox.qml @@ -18,6 +18,7 @@ import "." as VrControls FocusScope { id: root + HifiConstants { id: hifi } property alias model: comboBox.model; property alias comboBox: comboBox diff --git a/interface/resources/qml/controls-uit/Label.qml b/interface/resources/qml/controls-uit/Label.qml index 3b4d757154..330d74fa14 100644 --- a/interface/resources/qml/controls-uit/Label.qml +++ b/interface/resources/qml/controls-uit/Label.qml @@ -13,6 +13,7 @@ import QtQuick 2.5 import "../styles-uit" RalewaySemiBold { + HifiConstants { id: hifi } property int colorScheme: hifi.colorSchemes.light size: hifi.fontSizes.inputLabel diff --git a/interface/resources/qml/controls-uit/MarketplaceComboBox.qml b/interface/resources/qml/controls-uit/MarketplaceComboBox.qml new file mode 100644 index 0000000000..986131f3ec --- /dev/null +++ b/interface/resources/qml/controls-uit/MarketplaceComboBox.qml @@ -0,0 +1,43 @@ +// +// MarketplaceComboBox.qml +// +// Created by Elisa Lupin-Jimenez on 3 Aug 2016 +// Copyright 2016 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +import QtQuick 2.5 +import QtQuick.Controls 1.4 +import QtWebChannel 1.0 +import QtWebEngine 1.1 +import QtWebSockets 1.0 +import "qrc:///qtwebchannel/qwebchannel.js" as WebChannel + +import "controls" +import "controls-uit" as Controls +import "styles" +import "styles-uit" + +// just temporary + Controls.WebView { + id: webview + anchors.fill: parent + url: "about:blank" + focus: true + } + + Controls.ComboBox { + id: switchMarketView + //anchors.top: parent.bottom + //anchors.bottomMargin: 4 + anchors.fill: parent + visible: true + model: ListModel { + id: cbItems + ListElement { text: "Banana" } + ListElement { text: "Apple" } + ListElement { text: "Coconut" } + } + } diff --git a/scripts/system/marketplace - Elisa.js b/scripts/system/marketplace - Elisa.js new file mode 100644 index 0000000000..7a4057d77b --- /dev/null +++ b/scripts/system/marketplace - Elisa.js @@ -0,0 +1,82 @@ +// +// marketplace.js +// +// Created by Eric Levin on 8 Jan 2016 +// Copyright 2016 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +var toolIconUrl = Script.resolvePath("assets/images/tools/"); + +var MARKETPLACE_URL = "https://metaverse.highfidelity.com/marketplace"; +var CLARA_URL = "https://clara.io/library"; +var marketplaceWindow = new OverlayWindow({ + title: "Marketplace", + source: "about:blank", + //source: MARKETPLACE_URL, + //source: "https://s3.amazonaws.com/DreamingContent/qml/content.qml", + //source: "C:\Users\elisa\Documents\GitHub\hifi\interface\resources\qml\controls-uit\WebView.qml", + width: 900, + height: 700, + toolWindow: false, + visible: false, +}); + +var toolHeight = 50; +var toolWidth = 50; +var TOOLBAR_MARGIN_Y = 0; + + +function showMarketplace(marketplaceID) { + var url = MARKETPLACE_URL; + if (marketplaceID) { + url = url + "/items/" + marketplaceID; + } + marketplaceWindow.setVisible(true); + //marketplaceWindow.webview.url = url; + + UserActivityLogger.openedMarketplace(); +} + +function hideMarketplace() { + marketplaceWindow.setVisible(false); + marketplaceWindow.webview.url = "about:blank"; +} + +function toggleMarketplace() { + if (marketplaceWindow.visible) { + hideMarketplace(); + } else { + showMarketplace(); + } +} + +var toolBar = Toolbars.getToolbar("com.highfidelity.interface.toolbar.system"); + +var browseExamplesButton = toolBar.addButton({ + imageURL: toolIconUrl + "market.svg", + objectName: "marketplace", + buttonState: 1, + defaultState: 1, + hoverState: 3, + alpha: 0.9 +}); + +function onExamplesWindowVisibilityChanged() { + browseExamplesButton.writeProperty('buttonState', marketplaceWindow.visible ? 0 : 1); + browseExamplesButton.writeProperty('defaultState', marketplaceWindow.visible ? 0 : 1); + browseExamplesButton.writeProperty('hoverState', marketplaceWindow.visible ? 2 : 3); +} +function onClick() { + toggleMarketplace(); +} +browseExamplesButton.clicked.connect(onClick); +marketplaceWindow.visibleChanged.connect(onExamplesWindowVisibilityChanged); + +Script.scriptEnding.connect(function () { + toolBar.removeButton("marketplace"); + browseExamplesButton.clicked.disconnect(onClick); + marketplaceWindow.visibleChanged.disconnect(onExamplesWindowVisibilityChanged); +}); diff --git a/scripts/system/marketplace.js b/scripts/system/marketplace.js index 356ed8e8cf..e83e0c2ccb 100644 --- a/scripts/system/marketplace.js +++ b/scripts/system/marketplace.js @@ -11,6 +11,7 @@ var toolIconUrl = Script.resolvePath("assets/images/tools/"); var MARKETPLACE_URL = "https://metaverse.highfidelity.com/marketplace"; + var marketplaceWindow = new OverlayWebWindow({ title: "Marketplace", source: "about:blank", From b39c8c52abe0e722ac62cc1170a8abf706c05681 Mon Sep 17 00:00:00 2001 From: elisa-lj11 Date: Wed, 3 Aug 2016 19:08:14 -0700 Subject: [PATCH 20/31] Included combobox in marketplace view --- .../resources/qml/MarketplaceComboBox.qml | 52 +++++++++++++++++++ interface/resources/qml/QmlWindow.qml | 1 - .../qml/controls-uit/MarketplaceComboBox.qml | 43 --------------- scripts/system/marketplace - Elisa.js | 9 ++-- 4 files changed, 56 insertions(+), 49 deletions(-) create mode 100644 interface/resources/qml/MarketplaceComboBox.qml delete mode 100644 interface/resources/qml/controls-uit/MarketplaceComboBox.qml diff --git a/interface/resources/qml/MarketplaceComboBox.qml b/interface/resources/qml/MarketplaceComboBox.qml new file mode 100644 index 0000000000..21a7d48556 --- /dev/null +++ b/interface/resources/qml/MarketplaceComboBox.qml @@ -0,0 +1,52 @@ +// +// MarketplaceComboBox.qml +// +// Created by Elisa Lupin-Jimenez on 3 Aug 2016 +// Copyright 2016 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +import QtQuick 2.5 +import QtQuick.Controls 1.4 +import QtWebChannel 1.0 +import QtWebEngine 1.1 +import QtWebSockets 1.0 +import "qrc:///qtwebchannel/qwebchannel.js" as WebChannel + +import "controls" +import "controls-uit" as Controls +import "styles" +import "styles-uit" + +Item { + id: marketplaceComboBox + anchors.fill: parent + property var currentUrl: "https://metaverse.highfidelity.com/marketplace" + Controls.WebView { + id: webview + url: currentUrl + anchors.top: parent.top + width: parent.width + height: parent.height - 50 + //anchors.bottom: switchMarketView.top + focus: true + } + + Controls.ComboBox { + id: switchMarketView + anchors.bottom: parent.bottom + width: parent.width + height: 50 + visible: true + label: "Market View: " + model: ["Marketplace", "Clara.io"] + onCurrentIndexChanged: { + if (currentIndex === 0) { webview.url = "https://metaverse.highfidelity.com/marketplace"; } + if (currentIndex === 1) { webview.url = "https://clara.io/library"; } + } + + } + +} \ No newline at end of file diff --git a/interface/resources/qml/QmlWindow.qml b/interface/resources/qml/QmlWindow.qml index 47857ac7c1..908c1b1a77 100644 --- a/interface/resources/qml/QmlWindow.qml +++ b/interface/resources/qml/QmlWindow.qml @@ -76,6 +76,5 @@ Windows.Window { Item { id: contentHolder anchors.fill: parent - } } diff --git a/interface/resources/qml/controls-uit/MarketplaceComboBox.qml b/interface/resources/qml/controls-uit/MarketplaceComboBox.qml deleted file mode 100644 index 986131f3ec..0000000000 --- a/interface/resources/qml/controls-uit/MarketplaceComboBox.qml +++ /dev/null @@ -1,43 +0,0 @@ -// -// MarketplaceComboBox.qml -// -// Created by Elisa Lupin-Jimenez on 3 Aug 2016 -// Copyright 2016 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtWebChannel 1.0 -import QtWebEngine 1.1 -import QtWebSockets 1.0 -import "qrc:///qtwebchannel/qwebchannel.js" as WebChannel - -import "controls" -import "controls-uit" as Controls -import "styles" -import "styles-uit" - -// just temporary - Controls.WebView { - id: webview - anchors.fill: parent - url: "about:blank" - focus: true - } - - Controls.ComboBox { - id: switchMarketView - //anchors.top: parent.bottom - //anchors.bottomMargin: 4 - anchors.fill: parent - visible: true - model: ListModel { - id: cbItems - ListElement { text: "Banana" } - ListElement { text: "Apple" } - ListElement { text: "Coconut" } - } - } diff --git a/scripts/system/marketplace - Elisa.js b/scripts/system/marketplace - Elisa.js index 7a4057d77b..baec825c8d 100644 --- a/scripts/system/marketplace - Elisa.js +++ b/scripts/system/marketplace - Elisa.js @@ -9,15 +9,14 @@ // var toolIconUrl = Script.resolvePath("assets/images/tools/"); +var qml = Script.resolvePath("../../interface/resources/qml/MarketplaceComboBox.qml") var MARKETPLACE_URL = "https://metaverse.highfidelity.com/marketplace"; var CLARA_URL = "https://clara.io/library"; var marketplaceWindow = new OverlayWindow({ title: "Marketplace", - source: "about:blank", - //source: MARKETPLACE_URL, - //source: "https://s3.amazonaws.com/DreamingContent/qml/content.qml", - //source: "C:\Users\elisa\Documents\GitHub\hifi\interface\resources\qml\controls-uit\WebView.qml", + //source: "about:blank", + source: qml, width: 900, height: 700, toolWindow: false, @@ -42,7 +41,7 @@ function showMarketplace(marketplaceID) { function hideMarketplace() { marketplaceWindow.setVisible(false); - marketplaceWindow.webview.url = "about:blank"; + //marketplaceWindow.webview.url = "about:blank"; } function toggleMarketplace() { From 90a1325f65aadf0466fbd81d9d69cb47798accba Mon Sep 17 00:00:00 2001 From: elisa-lj11 Date: Thu, 4 Aug 2016 15:45:16 -0700 Subject: [PATCH 21/31] Finalized combobox feature --- .../resources/qml/MarketplaceComboBox.qml | 25 ++++-- scripts/system/marketplace - Elisa.js | 81 ------------------- scripts/system/marketplace.js | 10 +-- 3 files changed, 22 insertions(+), 94 deletions(-) delete mode 100644 scripts/system/marketplace - Elisa.js diff --git a/interface/resources/qml/MarketplaceComboBox.qml b/interface/resources/qml/MarketplaceComboBox.qml index 21a7d48556..da9a994bcc 100644 --- a/interface/resources/qml/MarketplaceComboBox.qml +++ b/interface/resources/qml/MarketplaceComboBox.qml @@ -20,27 +20,28 @@ import "controls-uit" as Controls import "styles" import "styles-uit" -Item { +Rectangle { + HifiConstants { id: hifi } id: marketplaceComboBox anchors.fill: parent + color: hifi.colors.baseGrayShadow property var currentUrl: "https://metaverse.highfidelity.com/marketplace" Controls.WebView { id: webview url: currentUrl - anchors.top: parent.top + anchors.top: switchMarketView.bottom width: parent.width - height: parent.height - 50 - //anchors.bottom: switchMarketView.top + height: parent.height - 40 focus: true } Controls.ComboBox { id: switchMarketView - anchors.bottom: parent.bottom - width: parent.width - height: 50 + anchors.top: parent.top + anchors.right: parent.right + width: 200 + height: 40 visible: true - label: "Market View: " model: ["Marketplace", "Clara.io"] onCurrentIndexChanged: { if (currentIndex === 0) { webview.url = "https://metaverse.highfidelity.com/marketplace"; } @@ -49,4 +50,12 @@ Item { } + Controls.Label { + id: switchMarketLabel + anchors.verticalCenter: switchMarketView.verticalCenter + anchors.right: switchMarketView.left + color: hifi.colors.white + text: "Explore interesting content from: " + } + } \ No newline at end of file diff --git a/scripts/system/marketplace - Elisa.js b/scripts/system/marketplace - Elisa.js deleted file mode 100644 index baec825c8d..0000000000 --- a/scripts/system/marketplace - Elisa.js +++ /dev/null @@ -1,81 +0,0 @@ -// -// marketplace.js -// -// Created by Eric Levin on 8 Jan 2016 -// Copyright 2016 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -var toolIconUrl = Script.resolvePath("assets/images/tools/"); -var qml = Script.resolvePath("../../interface/resources/qml/MarketplaceComboBox.qml") - -var MARKETPLACE_URL = "https://metaverse.highfidelity.com/marketplace"; -var CLARA_URL = "https://clara.io/library"; -var marketplaceWindow = new OverlayWindow({ - title: "Marketplace", - //source: "about:blank", - source: qml, - width: 900, - height: 700, - toolWindow: false, - visible: false, -}); - -var toolHeight = 50; -var toolWidth = 50; -var TOOLBAR_MARGIN_Y = 0; - - -function showMarketplace(marketplaceID) { - var url = MARKETPLACE_URL; - if (marketplaceID) { - url = url + "/items/" + marketplaceID; - } - marketplaceWindow.setVisible(true); - //marketplaceWindow.webview.url = url; - - UserActivityLogger.openedMarketplace(); -} - -function hideMarketplace() { - marketplaceWindow.setVisible(false); - //marketplaceWindow.webview.url = "about:blank"; -} - -function toggleMarketplace() { - if (marketplaceWindow.visible) { - hideMarketplace(); - } else { - showMarketplace(); - } -} - -var toolBar = Toolbars.getToolbar("com.highfidelity.interface.toolbar.system"); - -var browseExamplesButton = toolBar.addButton({ - imageURL: toolIconUrl + "market.svg", - objectName: "marketplace", - buttonState: 1, - defaultState: 1, - hoverState: 3, - alpha: 0.9 -}); - -function onExamplesWindowVisibilityChanged() { - browseExamplesButton.writeProperty('buttonState', marketplaceWindow.visible ? 0 : 1); - browseExamplesButton.writeProperty('defaultState', marketplaceWindow.visible ? 0 : 1); - browseExamplesButton.writeProperty('hoverState', marketplaceWindow.visible ? 2 : 3); -} -function onClick() { - toggleMarketplace(); -} -browseExamplesButton.clicked.connect(onClick); -marketplaceWindow.visibleChanged.connect(onExamplesWindowVisibilityChanged); - -Script.scriptEnding.connect(function () { - toolBar.removeButton("marketplace"); - browseExamplesButton.clicked.disconnect(onClick); - marketplaceWindow.visibleChanged.disconnect(onExamplesWindowVisibilityChanged); -}); diff --git a/scripts/system/marketplace.js b/scripts/system/marketplace.js index e83e0c2ccb..01aa4c76ce 100644 --- a/scripts/system/marketplace.js +++ b/scripts/system/marketplace.js @@ -9,15 +9,17 @@ // var toolIconUrl = Script.resolvePath("assets/images/tools/"); +var qml = Script.resolvePath("../../resources/qml/MarketplaceComboBox.qml") var MARKETPLACE_URL = "https://metaverse.highfidelity.com/marketplace"; -var marketplaceWindow = new OverlayWebWindow({ +var marketplaceWindow = new OverlayWindow({ title: "Marketplace", - source: "about:blank", + source: qml, width: 900, height: 700, - visible: false + toolWindow: false, + visible: false, }); var toolHeight = 50; @@ -30,7 +32,6 @@ function showMarketplace(marketplaceID) { if (marketplaceID) { url = url + "/items/" + marketplaceID; } - marketplaceWindow.setURL(url); marketplaceWindow.setVisible(true); UserActivityLogger.openedMarketplace(); @@ -38,7 +39,6 @@ function showMarketplace(marketplaceID) { function hideMarketplace() { marketplaceWindow.setVisible(false); - marketplaceWindow.setURL("about:blank"); } function toggleMarketplace() { From e8c5303f1b933508c3736717ff3182def37cbdb8 Mon Sep 17 00:00:00 2001 From: elisa-lj11 Date: Thu, 4 Aug 2016 17:23:36 -0700 Subject: [PATCH 22/31] Removed examples.js --- scripts/system/examples.js | 80 -------------------------------------- 1 file changed, 80 deletions(-) delete mode 100644 scripts/system/examples.js diff --git a/scripts/system/examples.js b/scripts/system/examples.js deleted file mode 100644 index 6c01fd58af..0000000000 --- a/scripts/system/examples.js +++ /dev/null @@ -1,80 +0,0 @@ -// -// examples.js -// examples -// -// Created by Eric Levin on 8 Jan 2016 -// Copyright 2016 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -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/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"; - -var examplesWindow = new OverlayWebWindow({ - title: 'Examples', - source: "about:blank", - width: 900, - height: 700, - visible: false -}); - -var toolHeight = 50; -var toolWidth = 50; -var TOOLBAR_MARGIN_Y = 0; - - -function showExamples(marketplaceID) { - var url = EXAMPLES_URL; - if (marketplaceID) { - url = url + "/items/" + marketplaceID; - } - print("setting examples URL to " + url); - examplesWindow.setURL(url); - examplesWindow.setVisible(true); - - UserActivityLogger.openedMarketplace(); -} - -function hideExamples() { - examplesWindow.setVisible(false); - examplesWindow.setURL("about:blank"); -} - -function toggleExamples() { - if (examplesWindow.visible) { - hideExamples(); - } else { - showExamples(); - } -} - -var toolBar = Toolbars.getToolbar("com.highfidelity.interface.toolbar.system"); - -var browseExamplesButton = toolBar.addButton({ - imageURL: toolIconUrl + "market.svg", - objectName: "examples", - buttonState: 1, - alpha: 0.9 -}); - -function onExamplesWindowVisibilityChanged() { - browseExamplesButton.writeProperty('buttonState', examplesWindow.visible ? 0 : 1); -} -function onClick() { - toggleExamples(); -} -browseExamplesButton.clicked.connect(onClick); -examplesWindow.visibleChanged.connect(onExamplesWindowVisibilityChanged); - -Script.scriptEnding.connect(function () { - browseExamplesButton.clicked.disconnect(onClick); - examplesWindow.visibleChanged.disconnect(onExamplesWindowVisibilityChanged); -}); From c00983468579621c551dd2e1d0fbd5d42d84878d Mon Sep 17 00:00:00 2001 From: elisa-lj11 Date: Fri, 5 Aug 2016 17:36:27 -0700 Subject: [PATCH 23/31] Fixes for linux build of quazip --- cmake/externals/quazip/CMakeLists.txt | 2 +- interface/resources/qml/MarketplaceComboBox.qml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/externals/quazip/CMakeLists.txt b/cmake/externals/quazip/CMakeLists.txt index d8ab492be5..f00403640a 100644 --- a/cmake/externals/quazip/CMakeLists.txt +++ b/cmake/externals/quazip/CMakeLists.txt @@ -17,7 +17,7 @@ ExternalProject_Add( URL https://s3-us-west-1.amazonaws.com/hifi-production/dependencies/quazip-0.7.2.zip URL_MD5 2955176048a31262c09259ca8d309d19 BINARY_DIR ${EXTERNAL_PROJECT_PREFIX}/build - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= -DCMAKE_PREFIX_PATH=${QT_CMAKE_PREFIX_PATH} -DCMAKE_INSTALL_NAME_DIR:PATH=/lib -DZLIB_ROOT=${ZLIB_ROOT} + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= -DCMAKE_PREFIX_PATH=${QT_CMAKE_PREFIX_PATH} -DCMAKE_INSTALL_NAME_DIR:PATH=/lib -DZLIB_ROOT=${ZLIB_ROOT} -DCMAKE_POSITION_INDEPENDENT_CODE=ON LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 diff --git a/interface/resources/qml/MarketplaceComboBox.qml b/interface/resources/qml/MarketplaceComboBox.qml index da9a994bcc..d0c55c9fe7 100644 --- a/interface/resources/qml/MarketplaceComboBox.qml +++ b/interface/resources/qml/MarketplaceComboBox.qml @@ -39,6 +39,7 @@ Rectangle { id: switchMarketView anchors.top: parent.top anchors.right: parent.right + colorScheme: hifi.colorSchemes.dark width: 200 height: 40 visible: true From b8f5a9d22f79239f9c643847fb8ba523417fd011 Mon Sep 17 00:00:00 2001 From: elisa-lj11 Date: Wed, 10 Aug 2016 10:26:58 -0700 Subject: [PATCH 24/31] CR changes --- interface/resources/qml/Browser.qml | 6 +-- .../resources/qml/MarketplaceComboBox.qml | 42 +++++++++++++++++++ interface/resources/qml/QmlWindow.qml | 2 +- .../resources/qml/controls-uit/WebView.qml | 38 ----------------- 4 files changed, 46 insertions(+), 42 deletions(-) diff --git a/interface/resources/qml/Browser.qml b/interface/resources/qml/Browser.qml index 2be0ca176d..3693b9dfea 100644 --- a/interface/resources/qml/Browser.qml +++ b/interface/resources/qml/Browser.qml @@ -218,9 +218,9 @@ ScrollingWindow { onIconChanged: { console.log("New icon: " + icon) } - Component.onCompleted: { - desktop.initWebviewProfileHandlers(webview.profile) - } + Component.onCompleted: { + desktop.initWebviewProfileHandlers(webview.profile) + } //profile: desktop.browserProfile diff --git a/interface/resources/qml/MarketplaceComboBox.qml b/interface/resources/qml/MarketplaceComboBox.qml index d0c55c9fe7..e7981cabec 100644 --- a/interface/resources/qml/MarketplaceComboBox.qml +++ b/interface/resources/qml/MarketplaceComboBox.qml @@ -20,12 +20,14 @@ import "controls-uit" as Controls import "styles" import "styles-uit" + Rectangle { HifiConstants { id: hifi } id: marketplaceComboBox anchors.fill: parent color: hifi.colors.baseGrayShadow property var currentUrl: "https://metaverse.highfidelity.com/marketplace" + Controls.WebView { id: webview url: currentUrl @@ -33,6 +35,46 @@ Rectangle { width: parent.width height: parent.height - 40 focus: true + + Timer { + id: zipTimer + running: false + repeat: false + interval: 1500 + property var handler; + onTriggered: handler(); + } + + property var autoCancel: 'var element = $("a.btn.cancel"); + element.click();' + + onNewViewRequested: { + console.log("new view requested url"); + var component = Qt.createComponent("Browser.qml"); + var newWindow = component.createObject(desktop); + request.openIn(newWindow.webView); + if (File.testUrl(desktop.currentUrl)) { + zipTimer.handler = function() { + newWindow.destroy(); + runJavaScript(autoCancel); + } + zipTimer.start(); + } + } + + property var simpleDownload: 'var element = $("a.download-file"); + element.removeClass("download-file"); + element.removeAttr("download");' + + onLinkHovered: { + desktop.currentUrl = hoveredUrl + console.log("my url in WebView: " + desktop.currentUrl) + if (File.testUrl(desktop.currentUrl)) { + runJavaScript(simpleDownload, function(){console.log("ran the JS");}); + } + + } + } Controls.ComboBox { diff --git a/interface/resources/qml/QmlWindow.qml b/interface/resources/qml/QmlWindow.qml index 908c1b1a77..ac6ae31c7f 100644 --- a/interface/resources/qml/QmlWindow.qml +++ b/interface/resources/qml/QmlWindow.qml @@ -1,5 +1,5 @@ -import QtQuick 2.5 +import QtQuick 2.3 import QtQuick.Controls 1.4 import QtWebChannel 1.0 import QtWebEngine 1.1 diff --git a/interface/resources/qml/controls-uit/WebView.qml b/interface/resources/qml/controls-uit/WebView.qml index bb08e5e389..8069ee79fb 100644 --- a/interface/resources/qml/controls-uit/WebView.qml +++ b/interface/resources/qml/controls-uit/WebView.qml @@ -62,44 +62,6 @@ WebEngineView { } } - Timer { - id: zipTimer - running: false - repeat: false - interval: 1500 - property var handler; - onTriggered: handler(); - } - - property var autoCancel: 'var element = $("a.btn.cancel"); - element.click();' - - onNewViewRequested: { - console.log("new view requested url"); - var component = Qt.createComponent("../Browser.qml"); - var newWindow = component.createObject(desktop); - request.openIn(newWindow.webView); - if (File.testUrl(desktop.currentUrl)) { - zipTimer.handler = function() { - newWindow.destroy(); - runJavaScript(autoCancel); - } - zipTimer.start(); - } - } - - property var simpleDownload: 'var element = $("a.download-file"); - element.removeClass("download-file"); - element.removeAttr("download");' - - onLinkHovered: { - desktop.currentUrl = hoveredUrl - console.log("my url in WebView: " + desktop.currentUrl) - if (File.testUrl(desktop.currentUrl)) { - runJavaScript(simpleDownload, function(){console.log("ran the JS");}); - } - - } // This breaks the webchannel used for passing messages. Fixed in Qt 5.6 // See https://bugreports.qt.io/browse/QTBUG-49521 From 9ea9baeadf5015a15f5f459b253f8bdf8bad2e7a Mon Sep 17 00:00:00 2001 From: elisa-lj11 Date: Tue, 16 Aug 2016 14:12:19 -0700 Subject: [PATCH 25/31] Making JS/QML safer (DOES NOT WORK) --- BUILD.md | 2 +- interface/resources/qml/MarketplaceComboBox.qml | 4 ++-- interface/resources/qml/hifi/Desktop.qml | 3 ++- libraries/script-engine/src/FileScriptingInterface.cpp | 8 ++++++-- libraries/script-engine/src/FileScriptingInterface.h | 4 ++-- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/BUILD.md b/BUILD.md index 4ff45a0b1e..c868a8e9d9 100644 --- a/BUILD.md +++ b/BUILD.md @@ -5,7 +5,6 @@ * [OpenSSL](https://www.openssl.org/community/binaries.html) ~> 1.0.1m * IMPORTANT: Using the recommended version of OpenSSL is critical to avoid security vulnerabilities. * [VHACD](https://github.com/virneo/v-hacd)(clone this repository)(Optional) -* [QuaZip](http://sourceforge.net/projects/quazip/files/quazip/) ~> 0.7.1 ####CMake External Project Dependencies @@ -19,6 +18,7 @@ * [oglplus](http://oglplus.org/) ~> 0.63 * [OpenVR](https://github.com/ValveSoftware/openvr) ~> 0.91 (Win32 only) * [Polyvox](http://www.volumesoffun.com/) ~> 0.2.1 +* [QuaZip](http://sourceforge.net/projects/quazip/files/quazip/) ~> 0.7.1 * [SDL2](https://www.libsdl.org/download-2.0.php) ~> 2.0.3 * [soxr](http://soxr.sourceforge.net) ~> 0.1.1 * [Intel Threading Building Blocks](https://www.threadingbuildingblocks.org/) ~> 4.3 diff --git a/interface/resources/qml/MarketplaceComboBox.qml b/interface/resources/qml/MarketplaceComboBox.qml index e7981cabec..559f4b9d65 100644 --- a/interface/resources/qml/MarketplaceComboBox.qml +++ b/interface/resources/qml/MarketplaceComboBox.qml @@ -53,7 +53,7 @@ Rectangle { var component = Qt.createComponent("Browser.qml"); var newWindow = component.createObject(desktop); request.openIn(newWindow.webView); - if (File.testUrl(desktop.currentUrl)) { + if (File.isZippedFbx(desktop.currentUrl)) { zipTimer.handler = function() { newWindow.destroy(); runJavaScript(autoCancel); @@ -69,7 +69,7 @@ Rectangle { onLinkHovered: { desktop.currentUrl = hoveredUrl console.log("my url in WebView: " + desktop.currentUrl) - if (File.testUrl(desktop.currentUrl)) { + if (File.isZippedFbx(desktop.currentUrl)) { runJavaScript(simpleDownload, function(){console.log("ran the JS");}); } diff --git a/interface/resources/qml/hifi/Desktop.qml b/interface/resources/qml/hifi/Desktop.qml index ab1fffdcf5..ebc776617f 100644 --- a/interface/resources/qml/hifi/Desktop.qml +++ b/interface/resources/qml/hifi/Desktop.qml @@ -88,6 +88,7 @@ OriginalDesktop.Desktop { console.log("Download start: " + download.state); adaptedPath = File.convertUrlToPath(currentUrl); tempDir = File.getTempDir(); + console.log("Temp dir created: " + tempDir); download.path = tempDir + "/" + adaptedPath; console.log("Path where it should download: " + download.path); download.accept(); @@ -101,7 +102,7 @@ OriginalDesktop.Desktop { if (download.state === WebEngineDownloadItem.DownloadCompleted) { console.log("Download Finished: " + download.state); console.log("File object is: " + File); - File.runUnzip(download.path, tempDir, currentUrl); + File.runUnzip(download.path, currentUrl); } else { console.log("The download was corrupted, state: " + download.state); } diff --git a/libraries/script-engine/src/FileScriptingInterface.cpp b/libraries/script-engine/src/FileScriptingInterface.cpp index 94d8d1b424..3908f2f1c8 100644 --- a/libraries/script-engine/src/FileScriptingInterface.cpp +++ b/libraries/script-engine/src/FileScriptingInterface.cpp @@ -31,9 +31,13 @@ FileScriptingInterface::FileScriptingInterface(QObject* parent) : QObject(parent // nothing for now } -void FileScriptingInterface::runUnzip(QString path, QString tempDir, QUrl url) { +void FileScriptingInterface::runUnzip(QString path, QUrl url) { qDebug() << "Url that was downloaded: " + url.toString(); qDebug() << "Path where download is saved: " + path; + QString fileName = "/" + path.section("/", -1); + qDebug() << "Filename to remove from temp path: " + fileName; + QString tempDir = path.remove(fileName); + qDebug() << "Temporary directory at: " + tempDir; QString file = unzipFile(path, tempDir); if (file != "") { qDebug() << "file to upload: " + file; @@ -47,7 +51,7 @@ void FileScriptingInterface::runUnzip(QString path, QString tempDir, QUrl url) { QDir(tempDir).removeRecursively(); } -bool FileScriptingInterface::testUrl(QUrl url) { +bool FileScriptingInterface::isZippedFbx(QUrl url) { 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; diff --git a/libraries/script-engine/src/FileScriptingInterface.h b/libraries/script-engine/src/FileScriptingInterface.h index 2658622644..2e8de6b174 100644 --- a/libraries/script-engine/src/FileScriptingInterface.h +++ b/libraries/script-engine/src/FileScriptingInterface.h @@ -24,9 +24,9 @@ public: public slots: - bool testUrl(QUrl url); + bool isZippedFbx(QUrl url); QString convertUrlToPath(QUrl url); - void runUnzip(QString path, QString tempDir, QUrl url); + void runUnzip(QString path, QUrl url); QString getTempDir(); signals: From 5d2fb68924f5dfaf48ffa0571cd8edc59e036d9f Mon Sep 17 00:00:00 2001 From: elisa-lj11 Date: Tue, 16 Aug 2016 15:47:57 -0700 Subject: [PATCH 26/31] Fixed temp dir access --- libraries/script-engine/src/FileScriptingInterface.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/script-engine/src/FileScriptingInterface.cpp b/libraries/script-engine/src/FileScriptingInterface.cpp index 3908f2f1c8..63849c238d 100644 --- a/libraries/script-engine/src/FileScriptingInterface.cpp +++ b/libraries/script-engine/src/FileScriptingInterface.cpp @@ -36,7 +36,8 @@ void FileScriptingInterface::runUnzip(QString path, QUrl url) { qDebug() << "Path where download is saved: " + path; QString fileName = "/" + path.section("/", -1); qDebug() << "Filename to remove from temp path: " + fileName; - QString tempDir = path.remove(fileName); + QString tempDir = path; + tempDir.remove(fileName); qDebug() << "Temporary directory at: " + tempDir; QString file = unzipFile(path, tempDir); if (file != "") { From 5d19267d00e7237e6a5717d33b193a27acb60510 Mon Sep 17 00:00:00 2001 From: elisa-lj11 Date: Wed, 17 Aug 2016 11:10:38 -0700 Subject: [PATCH 27/31] Safeguard against file corruption This is what could be a temporary (or permanent) fix to users trying to delete important files on their computer through JS --- .../src/FileScriptingInterface.cpp | 19 +++++++++++++++++++ .../src/FileScriptingInterface.h | 1 + 2 files changed, 20 insertions(+) diff --git a/libraries/script-engine/src/FileScriptingInterface.cpp b/libraries/script-engine/src/FileScriptingInterface.cpp index 63849c238d..2c8a68258f 100644 --- a/libraries/script-engine/src/FileScriptingInterface.cpp +++ b/libraries/script-engine/src/FileScriptingInterface.cpp @@ -39,6 +39,11 @@ void FileScriptingInterface::runUnzip(QString path, QUrl url) { QString tempDir = path; tempDir.remove(fileName); qDebug() << "Temporary directory at: " + tempDir; + if (!isTempDir(tempDir)) { + qDebug() << "Temporary directory mismatch; risk of losing files"; + return; + } + QString file = unzipFile(path, tempDir); if (file != "") { qDebug() << "file to upload: " + file; @@ -52,6 +57,20 @@ void FileScriptingInterface::runUnzip(QString path, QUrl url) { QDir(tempDir).removeRecursively(); } +// fix to check that we are only referring to a temporary directory +bool FileScriptingInterface::isTempDir(QString tempDir) { + QString folderName = "/" + tempDir.section("/", -1); + QString tempContainer = tempDir; + tempContainer.remove(folderName); + QTemporaryDir test; + QString testDir = test.path(); + folderName = "/" + testDir.section("/", -1); + QString testContainer = testDir; + testContainer.remove(folderName); + if (testContainer == tempContainer) return true; + return false; +} + bool FileScriptingInterface::isZippedFbx(QUrl url) { 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."; diff --git a/libraries/script-engine/src/FileScriptingInterface.h b/libraries/script-engine/src/FileScriptingInterface.h index 2e8de6b174..dd6ca3225b 100644 --- a/libraries/script-engine/src/FileScriptingInterface.h +++ b/libraries/script-engine/src/FileScriptingInterface.h @@ -33,6 +33,7 @@ signals: void unzipSuccess(QString url); private: + bool isTempDir(QString tempDir); QString unzipFile(QString path, QString tempDir); void recursiveFileScan(QFileInfo file, QString* dirName); void downloadZip(QString path, const QString link); From 8bc9a92429396763b36761b69bc5848e2c54053f Mon Sep 17 00:00:00 2001 From: elisa-lj11 Date: Fri, 19 Aug 2016 11:32:13 -0700 Subject: [PATCH 28/31] removed extraneous debug prints --- interface/resources/qml/AssetServer.qml | 1 - interface/resources/qml/MarketplaceComboBox.qml | 2 -- interface/resources/qml/controls-uit/WebView.qml | 1 - interface/resources/qml/hifi/Desktop.qml | 7 ++----- libraries/script-engine/src/FileScriptingInterface.cpp | 7 +------ 5 files changed, 3 insertions(+), 15 deletions(-) diff --git a/interface/resources/qml/AssetServer.qml b/interface/resources/qml/AssetServer.qml index 87dcf9368c..050bc8e99e 100644 --- a/interface/resources/qml/AssetServer.qml +++ b/interface/resources/qml/AssetServer.qml @@ -328,7 +328,6 @@ ScrollingWindow { id: timer } function uploadClicked(fileUrl) { - console.log("Upload clicked url: " + fileUrl); if (uploadOpen) { return; } diff --git a/interface/resources/qml/MarketplaceComboBox.qml b/interface/resources/qml/MarketplaceComboBox.qml index 559f4b9d65..7a600d7bbe 100644 --- a/interface/resources/qml/MarketplaceComboBox.qml +++ b/interface/resources/qml/MarketplaceComboBox.qml @@ -49,7 +49,6 @@ Rectangle { element.click();' onNewViewRequested: { - console.log("new view requested url"); var component = Qt.createComponent("Browser.qml"); var newWindow = component.createObject(desktop); request.openIn(newWindow.webView); @@ -68,7 +67,6 @@ Rectangle { onLinkHovered: { desktop.currentUrl = hoveredUrl - console.log("my url in WebView: " + desktop.currentUrl) if (File.isZippedFbx(desktop.currentUrl)) { runJavaScript(simpleDownload, function(){console.log("ran the JS");}); } diff --git a/interface/resources/qml/controls-uit/WebView.qml b/interface/resources/qml/controls-uit/WebView.qml index 8069ee79fb..faf7f746a2 100644 --- a/interface/resources/qml/controls-uit/WebView.qml +++ b/interface/resources/qml/controls-uit/WebView.qml @@ -51,7 +51,6 @@ WebEngineView { onLoadingChanged: { // Required to support clicking on "hifi://" links - console.log("loading change requested url"); if (WebEngineView.LoadStartedStatus == loadRequest.status) { var url = loadRequest.url.toString(); if (urlHandler.canHandleUrl(url)) { diff --git a/interface/resources/qml/hifi/Desktop.qml b/interface/resources/qml/hifi/Desktop.qml index ebc776617f..62f31f07fc 100644 --- a/interface/resources/qml/hifi/Desktop.qml +++ b/interface/resources/qml/hifi/Desktop.qml @@ -80,7 +80,7 @@ OriginalDesktop.Desktop { property string tempDir: "" function initWebviewProfileHandlers(profile) { - console.log("the webview url in desktop is: " + currentUrl); + console.log("The webview url in desktop is: " + currentUrl); if (webViewProfileSetup) return; webViewProfileSetup = true; @@ -90,9 +90,8 @@ OriginalDesktop.Desktop { tempDir = File.getTempDir(); console.log("Temp dir created: " + tempDir); download.path = tempDir + "/" + adaptedPath; - console.log("Path where it should download: " + download.path); + console.log("Path where object should download: " + download.path); download.accept(); - console.log("Download accept: " + download.state); if (download.state === WebEngineDownloadItem.DownloadInterrupted) { console.log("download failed to complete"); } @@ -100,8 +99,6 @@ OriginalDesktop.Desktop { profile.downloadFinished.connect(function(download){ if (download.state === WebEngineDownloadItem.DownloadCompleted) { - console.log("Download Finished: " + download.state); - console.log("File object is: " + File); File.runUnzip(download.path, currentUrl); } else { console.log("The download was corrupted, state: " + download.state); diff --git a/libraries/script-engine/src/FileScriptingInterface.cpp b/libraries/script-engine/src/FileScriptingInterface.cpp index 2c8a68258f..fa38e46d31 100644 --- a/libraries/script-engine/src/FileScriptingInterface.cpp +++ b/libraries/script-engine/src/FileScriptingInterface.cpp @@ -35,7 +35,6 @@ void FileScriptingInterface::runUnzip(QString path, QUrl url) { qDebug() << "Url that was downloaded: " + url.toString(); qDebug() << "Path where download is saved: " + path; QString fileName = "/" + path.section("/", -1); - qDebug() << "Filename to remove from temp path: " + fileName; QString tempDir = path; tempDir.remove(fileName); qDebug() << "Temporary directory at: " + tempDir; @@ -46,9 +45,8 @@ void FileScriptingInterface::runUnzip(QString path, QUrl url) { QString file = unzipFile(path, tempDir); if (file != "") { - qDebug() << "file to upload: " + file; + qDebug() << "Object file to upload: " + file; QUrl url = QUrl::fromLocalFile(file); - qDebug() << "url from local file: " + url.toString(); emit unzipSuccess(url.toString()); } else { qDebug() << "unzip failed"; @@ -73,7 +71,6 @@ bool FileScriptingInterface::isTempDir(QString tempDir) { bool FileScriptingInterface::isZippedFbx(QUrl url) { 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; } @@ -108,9 +105,7 @@ QString FileScriptingInterface::unzipFile(QString path, QString tempDir) { QDir dir(path); QString dirName = dir.path(); - qDebug() << "Zip directory is stored at: " + dirName; QString target = tempDir + "/model_repo"; - qDebug() << "Target path: " + target; QStringList list = JlCompress::extractDir(dirName, target); qDebug() << list; From 8bf87128d98e6cd5c7a0a27e798bbebff34fb8a8 Mon Sep 17 00:00:00 2001 From: elisa-lj11 Date: Mon, 22 Aug 2016 16:04:55 -0700 Subject: [PATCH 29/31] Fixed browser.qml 'onNewViewRequested' --- interface/resources/qml/Browser.qml | 5 +++++ interface/resources/qml/MarketplaceComboBox.qml | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/interface/resources/qml/Browser.qml b/interface/resources/qml/Browser.qml index 3693b9dfea..050e10eead 100644 --- a/interface/resources/qml/Browser.qml +++ b/interface/resources/qml/Browser.qml @@ -217,6 +217,11 @@ 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: { desktop.initWebviewProfileHandlers(webview.profile) diff --git a/interface/resources/qml/MarketplaceComboBox.qml b/interface/resources/qml/MarketplaceComboBox.qml index 7a600d7bbe..f7f224485b 100644 --- a/interface/resources/qml/MarketplaceComboBox.qml +++ b/interface/resources/qml/MarketplaceComboBox.qml @@ -66,7 +66,8 @@ Rectangle { element.removeAttr("download");' onLinkHovered: { - desktop.currentUrl = hoveredUrl + desktop.currentUrl = hoveredUrl; + // add an error message for non-fbx files if (File.isZippedFbx(desktop.currentUrl)) { runJavaScript(simpleDownload, function(){console.log("ran the JS");}); } From 137f795f2951b083e762daf44cabdd2a3b7276db Mon Sep 17 00:00:00 2001 From: elisa-lj11 Date: Tue, 23 Aug 2016 11:22:01 -0700 Subject: [PATCH 30/31] Made clara marketplace its own .js --- scripts/defaultScripts.js | 2 +- scripts/system/marketplace.js | 78 ----------------------------------- 2 files changed, 1 insertion(+), 79 deletions(-) delete mode 100644 scripts/system/marketplace.js diff --git a/scripts/defaultScripts.js b/scripts/defaultScripts.js index dc252afcf1..0d76498e84 100644 --- a/scripts/defaultScripts.js +++ b/scripts/defaultScripts.js @@ -15,7 +15,7 @@ Script.load("system/users.js"); Script.load("system/mute.js"); Script.load("system/goto.js"); Script.load("system/hmd.js"); -Script.load("system/marketplace.js"); +Script.load("system/marketplaces/marketplace.js"); Script.load("system/edit.js"); Script.load("system/mod.js"); Script.load("system/selectAudioDevice.js"); diff --git a/scripts/system/marketplace.js b/scripts/system/marketplace.js deleted file mode 100644 index 01aa4c76ce..0000000000 --- a/scripts/system/marketplace.js +++ /dev/null @@ -1,78 +0,0 @@ -// -// marketplace.js -// -// Created by Eric Levin on 8 Jan 2016 -// Copyright 2016 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -var toolIconUrl = Script.resolvePath("assets/images/tools/"); -var qml = Script.resolvePath("../../resources/qml/MarketplaceComboBox.qml") - -var MARKETPLACE_URL = "https://metaverse.highfidelity.com/marketplace"; - -var marketplaceWindow = new OverlayWindow({ - title: "Marketplace", - source: qml, - width: 900, - height: 700, - toolWindow: false, - visible: false, -}); - -var toolHeight = 50; -var toolWidth = 50; -var TOOLBAR_MARGIN_Y = 0; - - -function showMarketplace(marketplaceID) { - var url = MARKETPLACE_URL; - if (marketplaceID) { - url = url + "/items/" + marketplaceID; - } - marketplaceWindow.setVisible(true); - - UserActivityLogger.openedMarketplace(); -} - -function hideMarketplace() { - marketplaceWindow.setVisible(false); -} - -function toggleMarketplace() { - if (marketplaceWindow.visible) { - hideMarketplace(); - } else { - showMarketplace(); - } -} - -var toolBar = Toolbars.getToolbar("com.highfidelity.interface.toolbar.system"); - -var browseExamplesButton = toolBar.addButton({ - imageURL: toolIconUrl + "market.svg", - objectName: "marketplace", - buttonState: 1, - defaultState: 1, - hoverState: 3, - alpha: 0.9 -}); - -function onExamplesWindowVisibilityChanged() { - browseExamplesButton.writeProperty('buttonState', marketplaceWindow.visible ? 0 : 1); - browseExamplesButton.writeProperty('defaultState', marketplaceWindow.visible ? 0 : 1); - browseExamplesButton.writeProperty('hoverState', marketplaceWindow.visible ? 2 : 3); -} -function onClick() { - toggleMarketplace(); -} -browseExamplesButton.clicked.connect(onClick); -marketplaceWindow.visibleChanged.connect(onExamplesWindowVisibilityChanged); - -Script.scriptEnding.connect(function () { - toolBar.removeButton("marketplace"); - browseExamplesButton.clicked.disconnect(onClick); - marketplaceWindow.visibleChanged.disconnect(onExamplesWindowVisibilityChanged); -}); From 2d38d47bcca4e88e12714351cc2f8f00375cb6b6 Mon Sep 17 00:00:00 2001 From: elisa-lj11 Date: Tue, 23 Aug 2016 11:24:03 -0700 Subject: [PATCH 31/31] separated clara.js from marketplace.js --- scripts/system/marketplaces/clara.js | 79 ++++++++++++++++++++++ scripts/system/marketplaces/marketplace.js | 77 +++++++++++++++++++++ 2 files changed, 156 insertions(+) create mode 100644 scripts/system/marketplaces/clara.js create mode 100644 scripts/system/marketplaces/marketplace.js diff --git a/scripts/system/marketplaces/clara.js b/scripts/system/marketplaces/clara.js new file mode 100644 index 0000000000..7b48f49135 --- /dev/null +++ b/scripts/system/marketplaces/clara.js @@ -0,0 +1,79 @@ +// +// clara.js +// +// Created by Eric Levin on 8 Jan 2016 +// Edited by Elisa Lupin-Jimenez on 23 Aug 2016 +// Copyright 2016 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +var toolIconUrl = Script.resolvePath("../assets/images/tools/"); +var qml = Script.resolvePath("../../../resources/qml/MarketplaceComboBox.qml") + +var MARKETPLACE_URL = "https://metaverse.highfidelity.com/marketplace"; + +var marketplaceWindow = new OverlayWindow({ + title: "Marketplace", + source: qml, + width: 900, + height: 700, + toolWindow: false, + visible: false, +}); + +var toolHeight = 50; +var toolWidth = 50; +var TOOLBAR_MARGIN_Y = 0; + + +function showMarketplace(marketplaceID) { + var url = MARKETPLACE_URL; + if (marketplaceID) { + url = url + "/items/" + marketplaceID; + } + marketplaceWindow.setVisible(true); + + UserActivityLogger.openedMarketplace(); +} + +function hideMarketplace() { + marketplaceWindow.setVisible(false); +} + +function toggleMarketplace() { + if (marketplaceWindow.visible) { + hideMarketplace(); + } else { + showMarketplace(); + } +} + +var toolBar = Toolbars.getToolbar("com.highfidelity.interface.toolbar.system"); + +var browseExamplesButton = toolBar.addButton({ + imageURL: toolIconUrl + "market.svg", + objectName: "marketplace", + buttonState: 1, + defaultState: 1, + hoverState: 3, + alpha: 0.9 +}); + +function onExamplesWindowVisibilityChanged() { + browseExamplesButton.writeProperty('buttonState', marketplaceWindow.visible ? 0 : 1); + browseExamplesButton.writeProperty('defaultState', marketplaceWindow.visible ? 0 : 1); + browseExamplesButton.writeProperty('hoverState', marketplaceWindow.visible ? 2 : 3); +} +function onClick() { + toggleMarketplace(); +} +browseExamplesButton.clicked.connect(onClick); +marketplaceWindow.visibleChanged.connect(onExamplesWindowVisibilityChanged); + +Script.scriptEnding.connect(function () { + toolBar.removeButton("marketplace"); + browseExamplesButton.clicked.disconnect(onClick); + marketplaceWindow.visibleChanged.disconnect(onExamplesWindowVisibilityChanged); +}); diff --git a/scripts/system/marketplaces/marketplace.js b/scripts/system/marketplaces/marketplace.js new file mode 100644 index 0000000000..a43ef6c977 --- /dev/null +++ b/scripts/system/marketplaces/marketplace.js @@ -0,0 +1,77 @@ +// +// marketplace.js +// +// Created by Eric Levin on 8 Jan 2016 +// Copyright 2016 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +var toolIconUrl = Script.resolvePath("../assets/images/tools/"); + +var MARKETPLACE_URL = "https://metaverse.highfidelity.com/marketplace"; +var marketplaceWindow = new OverlayWebWindow({ + title: "Marketplace", + source: "about:blank", + width: 900, + height: 700, + visible: false +}); + +var toolHeight = 50; +var toolWidth = 50; +var TOOLBAR_MARGIN_Y = 0; + + +function showMarketplace(marketplaceID) { + var url = MARKETPLACE_URL; + if (marketplaceID) { + url = url + "/items/" + marketplaceID; + } + marketplaceWindow.setURL(url); + marketplaceWindow.setVisible(true); + + UserActivityLogger.openedMarketplace(); +} + +function hideMarketplace() { + marketplaceWindow.setVisible(false); + marketplaceWindow.setURL("about:blank"); +} + +function toggleMarketplace() { + if (marketplaceWindow.visible) { + hideMarketplace(); + } else { + showMarketplace(); + } +} + +var toolBar = Toolbars.getToolbar("com.highfidelity.interface.toolbar.system"); + +var browseExamplesButton = toolBar.addButton({ + imageURL: toolIconUrl + "market.svg", + objectName: "marketplace", + buttonState: 1, + defaultState: 1, + hoverState: 3, + alpha: 0.9 +}); + +function onExamplesWindowVisibilityChanged() { + browseExamplesButton.writeProperty('buttonState', marketplaceWindow.visible ? 0 : 1); + browseExamplesButton.writeProperty('defaultState', marketplaceWindow.visible ? 0 : 1); + browseExamplesButton.writeProperty('hoverState', marketplaceWindow.visible ? 2 : 3); +} +function onClick() { + toggleMarketplace(); +} +browseExamplesButton.clicked.connect(onClick); +marketplaceWindow.visibleChanged.connect(onExamplesWindowVisibilityChanged); + +Script.scriptEnding.connect(function () { + toolBar.removeButton("marketplace"); + browseExamplesButton.clicked.disconnect(onClick); + marketplaceWindow.visibleChanged.disconnect(onExamplesWindowVisibilityChanged); +}); \ No newline at end of file