Adding Blocks Tablet App to Marketplace
Showing the changes to interface/src/Application.cpp (1 of 14 files). Show all
Unified · Split
| @@ -2851,6 +2851,18 @@ bool Application::importSVOFromURL(const QString& urlString) { · 2850 unmodified lines | |||
| 2851 | return true; | 2851 | return true; |
| 2852 | } | 2852 | } |
| 2853 | 2853 | ||
| 2854 | bool Application::importFromZIP(const QString& filePath) { | ||
| 2855 | qDebug() << "A zip file has been dropped in: " << filePath; | ||
| 2856 | QUrl empty; | ||
| 2857 | // handle Blocks download from Marketplace | ||
| 2858 | if (filePath.contains("vr.google.com/downloads")) { | ||
| 2859 | addAssetToWorldFromURL(filePath); | ||
| 2860 | } else { | ||
| 2861 | qApp->getFileDownloadInterface()->runUnzip(filePath, empty, true, true, false); | ||
| 2862 | } | ||
| 2863 | return true; | ||
| 2864 | } | ||
| 2865 | |||
| 2854 | void Application::onPresent(quint32 frameCount) { | 2866 | void Application::onPresent(quint32 frameCount) { |
| 2855 | if (shouldPaint()) { | 2867 | if (shouldPaint()) { |
| 2856 | postEvent(this, new QEvent(static_cast<QEvent::Type>(Idle)), Qt::HighEventPriority); | 2868 | postEvent(this, new QEvent(static_cast<QEvent::Type>(Idle)), Qt::HighEventPriority); |
| @@ -2858,13 +2870,6 @@ void Application::onPresent(quint32 frameCount) { · 1 unmodified line | |||
| 2858 | } | 2870 | } |
| 2859 | } | 2871 | } |
| 2860 | 2872 | ||
| 2861 | bool Application::importFromZIP(const QString& filePath) { | ||
| 2862 | qDebug() << "A zip file has been dropped in: " << filePath; | ||
| 2863 | QUrl empty; | ||
| 2864 | qApp->getFileDownloadInterface()->runUnzip(filePath, empty, true, true); | ||
| 2865 | return true; | ||
| 2866 | } | ||
| 2867 | |||
| 2868 | bool _renderRequested { false }; | 2873 | bool _renderRequested { false }; |
| 2869 | 2874 | ||
| 2870 | bool Application::event(QEvent* event) { | 2875 | bool Application::event(QEvent* event) { |
| @@ -6354,8 +6359,15 @@ void Application::showAssetServerWidget(QString filePath) { · 3483 unmodified lines | |||
| 6354 | 6359 | ||
| 6355 | void Application::addAssetToWorldFromURL(QString url) { | 6360 | void Application::addAssetToWorldFromURL(QString url) { |
| 6356 | qInfo(interfaceapp) << "Download model and add to world from" << url; | 6361 | qInfo(interfaceapp) << "Download model and add to world from" << url; |
| 6357 | 6362 | ||
| 6358 | QString filename = url.section("filename=", 1, 1); // Filename is in "?filename=" parameter at end of URL. | 6363 | QString filename; |
| 6364 | if (url.contains("filename")) { | ||
| 6365 | filename = url.section("filename=", 1, 1); // Filename is in "?filename=" parameter at end of URL. | ||
| 6366 | } | ||
| 6367 | if (url.contains("vr.google.com/downloads")) { | ||
| 6368 | filename = url.section('/', -1); | ||
| 6369 | filename.remove(".zip?noDownload=false"); | ||
| 6370 | } | ||
| 6359 | 6371 | ||
| 6360 | if (!DependencyManager::get<NodeList>()->getThisNodeCanWriteAssets()) { | 6372 | if (!DependencyManager::get<NodeList>()->getThisNodeCanWriteAssets()) { |
| 6361 | QString errorInfo = "You do not have permissions to write to the Asset Server."; | 6373 | QString errorInfo = "You do not have permissions to write to the Asset Server."; |
| @@ -6376,7 +6388,17 @@ void Application::addAssetToWorldFromURLRequestFinished() { · 14 unmodified lines | |||
| 6376 | auto url = request->getUrl().toString(); | 6388 | auto url = request->getUrl().toString(); |
| 6377 | auto result = request->getResult(); | 6389 | auto result = request->getResult(); |
| 6378 | 6390 | ||
| 6379 | QString filename = url.section("filename=", 1, 1); // Filename from trailing "?filename=" URL parameter. | 6391 | QString filename; |
| 6392 | bool isBlocks = false; | ||
| 6393 | |||
| 6394 | if (url.contains("filename")) { | ||
| 6395 | filename = url.section("filename=", 1, 1); // Filename is in "?filename=" parameter at end of URL. | ||
| 6396 | } | ||
| 6397 | if (url.contains("vr.google.com/downloads")) { | ||
| 6398 | filename = url.section('/', -1); | ||
| 6399 | filename.remove(".zip?noDownload=false"); | ||
| 6400 | isBlocks = true; | ||
| 6401 | } | ||
| 6380 | 6402 | ||
| 6381 | if (result == ResourceRequest::Success) { | 6403 | if (result == ResourceRequest::Success) { |
| 6382 | qInfo(interfaceapp) << "Downloaded model from" << url; | 6404 | qInfo(interfaceapp) << "Downloaded model from" << url; |
| @@ -6391,7 +6413,7 @@ void Application::addAssetToWorldFromURLRequestFinished() { · 8 unmodified lines | |||
| 6391 | if (tempFile.open(QIODevice::WriteOnly)) { | 6413 | if (tempFile.open(QIODevice::WriteOnly)) { |
| 6392 | tempFile.write(request->getData()); | 6414 | tempFile.write(request->getData()); |
| 6393 | addAssetToWorldInfoClear(filename); // Remove message from list; next one added will have a different key. | 6415 | addAssetToWorldInfoClear(filename); // Remove message from list; next one added will have a different key. |
| 6394 | qApp->getFileDownloadInterface()->runUnzip(downloadPath, url, true, false); | 6416 | qApp->getFileDownloadInterface()->runUnzip(downloadPath, url, true, false, isBlocks); |
| 6395 | } else { | 6417 | } else { |
| 6396 | QString errorInfo = "Couldn't open temporary file for download"; | 6418 | QString errorInfo = "Couldn't open temporary file for download"; |
| 6397 | qWarning(interfaceapp) << errorInfo; | 6419 | qWarning(interfaceapp) << errorInfo; |
| @@ -6421,7 +6443,7 @@ void Application::addAssetToWorldUnzipFailure(QString filePath) { · 23 unmodified lines | |||
| 6421 | addAssetToWorldError(filename, "Couldn't unzip file " + filename + "."); | 6443 | addAssetToWorldError(filename, "Couldn't unzip file " + filename + "."); |
| 6422 | } | 6444 | } |
| 6423 | 6445 | ||
| 6424 | void Application::addAssetToWorld(QString filePath, QString zipFile, bool isZip) { | 6446 | void Application::addAssetToWorld(QString filePath, QString zipFile, bool isZip, bool isBlocks) { |
| 6425 | // Automatically upload and add asset to world as an alternative manual process initiated by showAssetServerWidget(). | 6447 | // Automatically upload and add asset to world as an alternative manual process initiated by showAssetServerWidget(). |
| 6426 | QString mapping; | 6448 | QString mapping; |
| 6427 | QString path = filePath; | 6449 | QString path = filePath; |
| @@ -6430,6 +6452,11 @@ void Application::addAssetToWorld(QString filePath, QString zipFile, bool isZip) · 2 unmodified lines | |||
| 6430 | QString assetFolder = zipFile.section("/", -1); | 6452 | QString assetFolder = zipFile.section("/", -1); |
| 6431 | assetFolder.remove(".zip"); | 6453 | assetFolder.remove(".zip"); |
| 6432 | mapping = "/" + assetFolder + "/" + filename; | 6454 | mapping = "/" + assetFolder + "/" + filename; |
| 6455 | } else if (isBlocks) { | ||
| 6456 | qCDebug(interfaceapp) << "Path to asset folder: " << zipFile; | ||
| 6457 | QString assetFolder = zipFile.section('/', -1); | ||
| 6458 | assetFolder.remove(".zip?noDownload=false"); | ||
| 6459 | mapping = "/" + assetFolder + "/" + filename; | ||
| 6433 | } else { | 6460 | } else { |
| 6434 | mapping = "/" + filename; | 6461 | mapping = "/" + filename; |
| 6435 | } | 6462 | } |
| @@ -6809,12 +6836,12 @@ void Application::onAssetToWorldMessageBoxClosed() { · 373 unmodified lines | |||
| 6809 | } | 6836 | } |
| 6810 | 6837 | ||
| 6811 | 6838 | ||
| 6812 | void Application::handleUnzip(QString zipFile, QStringList unzipFile, bool autoAdd, bool isZip) { | 6839 | void Application::handleUnzip(QString zipFile, QStringList unzipFile, bool autoAdd, bool isZip, bool isBlocks) { |
| 6813 | if (autoAdd) { | 6840 | if (autoAdd) { |
| 6814 | if (!unzipFile.isEmpty()) { | 6841 | if (!unzipFile.isEmpty()) { |
| 6815 | for (int i = 0; i < unzipFile.length(); i++) { | 6842 | for (int i = 0; i < unzipFile.length(); i++) { |
| 6816 | qCDebug(interfaceapp) << "Preparing file for asset server: " << unzipFile.at(i); | 6843 | qCDebug(interfaceapp) << "Preparing file for asset server: " << unzipFile.at(i); |
| 6817 | addAssetToWorld(unzipFile.at(i), zipFile, isZip); | 6844 | addAssetToWorld(unzipFile.at(i), zipFile, isZip, isBlocks); |
| 6818 | } | 6845 | } |
| 6819 | } else { | 6846 | } else { |
| 6820 | addAssetToWorldUnzipFailure(zipFile); | 6847 | addAssetToWorldUnzipFailure(zipFile); |