From c3d943ff72a2aea26e5dec70249496b9328b9a66 Mon Sep 17 00:00:00 2001 From: Elisa Lupin-Jimenez Date: Wed, 26 Jul 2017 18:57:19 -0700 Subject: [PATCH] Drag zip folder works --- interface/src/Application.cpp | 36 +++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index be926cd7ac..b52c3321b6 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2788,7 +2788,7 @@ void Application::onPresent(quint32 frameCount) { bool Application::importFromZIP(const QString& filePath) { qDebug() << "A zip file has been dropped in: " << filePath; QUrl empty = ""; - qApp->getFileDownloadInterface()->runUnzip(filePath, empty, false, true); + qApp->getFileDownloadInterface()->runUnzip(filePath, empty, true, true); return true; } @@ -6266,6 +6266,38 @@ void Application::addAssetToWorldUnzipFailure(QString filePath) { void Application::addAssetToWorld(QString filePath, QString zipFile, bool isBlocks) { // Automatically upload and add asset to world as an alternative manual process initiated by showAssetServerWidget(). + qCDebug(interfaceapp) << "File about to be uploaded: " << filePath; + qCDebug(interfaceapp) << "Original zip folder: " << zipFile; + QString mapping; + QString path = filePath; + QString filename = filenameFromPath(filePath); + if (isBlocks) { + QString assetFolder = zipFile.section("/", -1); + assetFolder.remove(".zip"); + mapping = "/" + assetFolder + "/" + filenameFromPath(filename); + } + else { + path = QUrl(filePath).toLocalFile(); + filename = filenameFromPath(path); + mapping = "/" + filename; + } + + // Test repeated because possibly different code paths. + if (!DependencyManager::get()->getThisNodeCanWriteAssets()) { + QString errorInfo = "You do not have permissions to write to the Asset Server."; + qWarning(interfaceapp) << "Error downloading model: " + errorInfo; + addAssetToWorldError(filename, errorInfo); + return; + } + + addAssetToWorldInfo(filename, "Adding " + mapping.mid(1) + " to the Asset Server."); + + addAssetToWorldWithNewMapping(path, mapping, 0); +} + +/**void Application::addAssetToWorld(QString filePath, QString zipFile, bool isBlocks) { + // Automatically upload and add asset to world as an alternative manual process initiated by showAssetServerWidget(). + qCDebug(interfaceapp) << "File about to be uploaded: " << filePath; qCDebug(interfaceapp) << "Original zip folder: " << zipFile; QString path = QUrl(filePath).toLocalFile(); @@ -6290,7 +6322,7 @@ void Application::addAssetToWorld(QString filePath, QString zipFile, bool isBloc addAssetToWorldInfo(filename, "Adding " + mapping.mid(1) + " to the Asset Server."); addAssetToWorldWithNewMapping(path, mapping, 0); -} +}*/ void Application::addAssetToWorldWithNewMapping(QString filePath, QString mapping, int copy) { auto request = DependencyManager::get()->createGetMappingRequest(mapping);