History

Merge pull request #11147 from elisa-lj11/blocks

Adding Blocks Tablet App to Marketplace

Elisa Lupin-Jimenez committed 9 years ago

Commit 44f1f342 parents 2456126 762f1a914 files · +146 −33Browse files

Showing the changes to interface/src/Application.cpp (1 of 14 files). Show all

Unified · Split

interface/src/Application.cpp+41−14
@@ -2851,6 +2851,18 @@ bool Application::importSVOFromURL(const QString& urlString) { · 2850 unmodified lines
28512851 return true;
28522852 }
28532853
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+
28542866 void Application::onPresent(quint32 frameCount) {
28552867 if (shouldPaint()) {
28562868 postEvent(this, new QEvent(static_cast<QEvent::Type>(Idle)), Qt::HighEventPriority);
@@ -2858,13 +2870,6 @@ void Application::onPresent(quint32 frameCount) { · 1 unmodified line
28582870 }
28592871 }
28602872
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−
28682873 bool _renderRequested { false };
28692874
28702875 bool Application::event(QEvent* event) {
@@ -6354,8 +6359,15 @@ void Application::showAssetServerWidget(QString filePath) { · 3483 unmodified lines
63546359
63556360 void Application::addAssetToWorldFromURL(QString url) {
63566361 qInfo(interfaceapp) << "Download model and add to world from" << url;
6357−
6358− QString filename = url.section("filename=", 1, 1); // Filename is in "?filename=" parameter at end of URL.
6362+
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+ }
63596371
63606372 if (!DependencyManager::get<NodeList>()->getThisNodeCanWriteAssets()) {
63616373 QString errorInfo = "You do not have permissions to write to the Asset Server.";
@@ -6376,7 +6388,17 @@ void Application::addAssetToWorldFromURLRequestFinished() { · 14 unmodified lines
63766388 auto url = request->getUrl().toString();
63776389 auto result = request->getResult();
63786390
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+ }
63806402
63816403 if (result == ResourceRequest::Success) {
63826404 qInfo(interfaceapp) << "Downloaded model from" << url;
@@ -6391,7 +6413,7 @@ void Application::addAssetToWorldFromURLRequestFinished() { · 8 unmodified lines
63916413 if (tempFile.open(QIODevice::WriteOnly)) {
63926414 tempFile.write(request->getData());
63936415 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);
63956417 } else {
63966418 QString errorInfo = "Couldn't open temporary file for download";
63976419 qWarning(interfaceapp) << errorInfo;
@@ -6421,7 +6443,7 @@ void Application::addAssetToWorldUnzipFailure(QString filePath) { · 23 unmodified lines
64216443 addAssetToWorldError(filename, "Couldn't unzip file " + filename + ".");
64226444 }
64236445
6424−void Application::addAssetToWorld(QString filePath, QString zipFile, bool isZip) {
6446+void Application::addAssetToWorld(QString filePath, QString zipFile, bool isZip, bool isBlocks) {
64256447 // Automatically upload and add asset to world as an alternative manual process initiated by showAssetServerWidget().
64266448 QString mapping;
64276449 QString path = filePath;
@@ -6430,6 +6452,11 @@ void Application::addAssetToWorld(QString filePath, QString zipFile, bool isZip) · 2 unmodified lines
64306452 QString assetFolder = zipFile.section("/", -1);
64316453 assetFolder.remove(".zip");
64326454 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;
64336460 } else {
64346461 mapping = "/" + filename;
64356462 }
@@ -6809,12 +6836,12 @@ void Application::onAssetToWorldMessageBoxClosed() { · 373 unmodified lines
68096836 }
68106837
68116838
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) {
68136840 if (autoAdd) {
68146841 if (!unzipFile.isEmpty()) {
68156842 for (int i = 0; i < unzipFile.length(); i++) {
68166843 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);
68186845 }
68196846 } else {
68206847 addAssetToWorldUnzipFailure(zipFile);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t