Showing the changes to interface/src/Application.cpp (1 of 3 files). Show all
Unified · Split
| @@ -5470,13 +5470,41 @@ void Application::showAssetServerWidget(QString filePath) { · 5469 unmodified lines | |||
| 5470 | startUpload(nullptr, nullptr); | 5470 | startUpload(nullptr, nullptr); |
| 5471 | } | 5471 | } |
| 5472 | 5472 | ||
| 5473 | void Application::addAssetToWorldInitiate() { | ||
| 5474 | qCDebug(interfaceapp) << "Start downloading asset file"; | ||
| 5475 | |||
| 5476 | if (!_addAssetToWorldMessageBox) { | ||
| 5477 | _addAssetToWorldMessageBox = DependencyManager::get<OffscreenUi>()->createMessageBox(OffscreenUi::ICON_INFORMATION, | ||
| 5478 | "Downloading Asset", "Preparing asset for download", QMessageBox::Cancel, QMessageBox::NoButton); | ||
| 5479 | } | ||
| 5480 | |||
| 5481 | connect(_addAssetToWorldMessageBox, SIGNAL(destroyed()), this, SLOT(onAssetToWorldMessageBoxClosed())); | ||
| 5482 | } | ||
| 5483 | |||
| 5484 | void Application::onAssetToWorldMessageBoxClosed() { | ||
| 5485 | disconnect(_addAssetToWorldMessageBox); | ||
| 5486 | _addAssetToWorldMessageBox = nullptr; | ||
| 5487 | } | ||
| 5488 | |||
| 5489 | void Application::addAssetToWorldError(QString errorText) { | ||
| 5490 | _addAssetToWorldMessageBox->setProperty("title", "Error Downloading Asset"); | ||
| 5491 | _addAssetToWorldMessageBox->setProperty("icon", OffscreenUi::ICON_CRITICAL); | ||
| 5492 | _addAssetToWorldMessageBox->setProperty("text", errorText); | ||
| 5493 | } | ||
| 5494 | |||
| 5473 | void Application::addAssetToWorld(QString filePath) { | 5495 | void Application::addAssetToWorld(QString filePath) { |
| 5474 | // Automatically upload and add asset to world as an alternative manual process initiated by showAssetServerWidget(). | 5496 | // Automatically upload and add asset to world as an alternative manual process initiated by showAssetServerWidget(). |
| 5475 | 5497 | ||
| 5498 | if (!_addAssetToWorldMessageBox) { | ||
| 5499 | return; | ||
| 5500 | } | ||
| 5501 | |||
| 5502 | _addAssetToWorldMessageBox->setProperty("text", "Downloading asset file"); | ||
| 5503 | |||
| 5476 | if (!DependencyManager::get<NodeList>()->getThisNodeCanWriteAssets()) { | 5504 | if (!DependencyManager::get<NodeList>()->getThisNodeCanWriteAssets()) { |
| 5477 | QString errorInfo = "Do not have permissions to write to asset server."; | 5505 | QString errorInfo = "Do not have permissions to write to asset server."; |
| 5478 | qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo; | 5506 | qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo; |
| 5479 | OffscreenUi::warning("Error Downloading Asset", errorInfo); | 5507 | addAssetToWorldError(errorInfo); |
| 5480 | return; | 5508 | return; |
| 5481 | } | 5509 | } |
| 5482 | 5510 | ||
| @@ -5487,6 +5515,10 @@ void Application::addAssetToWorld(QString filePath) { · 4 unmodified lines | |||
| 5487 | } | 5515 | } |
| 5488 | 5516 | ||
| 5489 | void Application::addAssetToWorldWithNewMapping(QString path, QString mapping, int copy) { | 5517 | void Application::addAssetToWorldWithNewMapping(QString path, QString mapping, int copy) { |
| 5518 | if (!_addAssetToWorldMessageBox) { | ||
| 5519 | return; | ||
| 5520 | } | ||
| 5521 | |||
| 5490 | auto request = DependencyManager::get<AssetClient>()->createGetMappingRequest(mapping); | 5522 | auto request = DependencyManager::get<AssetClient>()->createGetMappingRequest(mapping); |
| 5491 | QObject::connect(request, &GetMappingRequest::finished, this, [=](GetMappingRequest* request) mutable { | 5523 | QObject::connect(request, &GetMappingRequest::finished, this, [=](GetMappingRequest* request) mutable { |
| 5492 | const int MAX_COPY_COUNT = 100; // Limit number of duplicate assets; recursion guard. | 5524 | const int MAX_COPY_COUNT = 100; // Limit number of duplicate assets; recursion guard. |
| @@ -5503,7 +5535,7 @@ void Application::addAssetToWorldWithNewMapping(QString path, QString mapping, i · 10 unmodified lines | |||
| 5503 | QString errorInfo = "Too many copies of asset name: " | 5535 | QString errorInfo = "Too many copies of asset name: " |
| 5504 | + mapping.left(mapping.length() - QString::number(copy).length() - 1); | 5536 | + mapping.left(mapping.length() - QString::number(copy).length() - 1); |
| 5505 | qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo; | 5537 | qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo; |
| 5506 | OffscreenUi::warning("Error Downloading Asset", errorInfo); | 5538 | addAssetToWorldError(errorInfo); |
| 5507 | } | 5539 | } |
| 5508 | request->deleteLater(); | 5540 | request->deleteLater(); |
| 5509 | }); | 5541 | }); |
| @@ -5512,12 +5544,16 @@ void Application::addAssetToWorldWithNewMapping(QString path, QString mapping, i · 2 unmodified lines | |||
| 5512 | } | 5544 | } |
| 5513 | 5545 | ||
| 5514 | void Application::addAssetToWorldUpload(QString path, QString mapping) { | 5546 | void Application::addAssetToWorldUpload(QString path, QString mapping) { |
| 5547 | if (!_addAssetToWorldMessageBox) { | ||
| 5548 | return; | ||
| 5549 | } | ||
| 5550 | |||
| 5515 | auto upload = DependencyManager::get<AssetClient>()->createUpload(path); | 5551 | auto upload = DependencyManager::get<AssetClient>()->createUpload(path); |
| 5516 | QObject::connect(upload, &AssetUpload::finished, this, [=](AssetUpload* upload, const QString& hash) mutable { | 5552 | QObject::connect(upload, &AssetUpload::finished, this, [=](AssetUpload* upload, const QString& hash) mutable { |
| 5517 | if (upload->getError() != AssetUpload::NoError) { | 5553 | if (upload->getError() != AssetUpload::NoError) { |
| 5518 | QString errorInfo = "Could not upload asset to asset server."; | 5554 | QString errorInfo = "Could not upload asset to asset server."; |
| 5519 | qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo; | 5555 | qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo; |
| 5520 | OffscreenUi::warning("Error Downloading Asset", errorInfo); | 5556 | addAssetToWorldError(errorInfo); |
| 5521 | } else { | 5557 | } else { |
| 5522 | addAssetToWorldSetMapping(mapping, hash); | 5558 | addAssetToWorldSetMapping(mapping, hash); |
| 5523 | } | 5559 | } |
| @@ -5537,12 +5573,16 @@ void Application::addAssetToWorldUpload(QString path, QString mapping) { · 13 unmodified lines | |||
| 5537 | } | 5573 | } |
| 5538 | 5574 | ||
| 5539 | void Application::addAssetToWorldSetMapping(QString mapping, QString hash) { | 5575 | void Application::addAssetToWorldSetMapping(QString mapping, QString hash) { |
| 5576 | if (!_addAssetToWorldMessageBox) { | ||
| 5577 | return; | ||
| 5578 | } | ||
| 5579 | |||
| 5540 | auto request = DependencyManager::get<AssetClient>()->createSetMappingRequest(mapping, hash); | 5580 | auto request = DependencyManager::get<AssetClient>()->createSetMappingRequest(mapping, hash); |
| 5541 | connect(request, &SetMappingRequest::finished, this, [=](SetMappingRequest* request) mutable { | 5581 | connect(request, &SetMappingRequest::finished, this, [=](SetMappingRequest* request) mutable { |
| 5542 | if (request->getError() != SetMappingRequest::NoError) { | 5582 | if (request->getError() != SetMappingRequest::NoError) { |
| 5543 | QString errorInfo = "Could not set asset mapping."; | 5583 | QString errorInfo = "Could not set asset mapping."; |
| 5544 | qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo; | 5584 | qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo; |
| 5545 | OffscreenUi::warning("Error Downloading Asset", errorInfo); | 5585 | addAssetToWorldError(errorInfo); |
| 5546 | } else { | 5586 | } else { |
| 5547 | addAssetToWorldAddEntity(mapping); | 5587 | addAssetToWorldAddEntity(mapping); |
| 5548 | } | 5588 | } |
| @@ -5553,6 +5593,10 @@ void Application::addAssetToWorldSetMapping(QString mapping, QString hash) { · 4 unmodified lines | |||
| 5553 | } | 5593 | } |
| 5554 | 5594 | ||
| 5555 | void Application::addAssetToWorldAddEntity(QString mapping) { | 5595 | void Application::addAssetToWorldAddEntity(QString mapping) { |
| 5596 | if (!_addAssetToWorldMessageBox) { | ||
| 5597 | return; | ||
| 5598 | } | ||
| 5599 | |||
| 5556 | EntityItemProperties properties; | 5600 | EntityItemProperties properties; |
| 5557 | properties.setType(EntityTypes::Model); | 5601 | properties.setType(EntityTypes::Model); |
| 5558 | properties.setName(mapping.right(mapping.length() - 1)); | 5602 | properties.setName(mapping.right(mapping.length() - 1)); |
| @@ -5566,11 +5610,13 @@ void Application::addAssetToWorldAddEntity(QString mapping) { · 7 unmodified lines | |||
| 5566 | if (result == QUuid()) { | 5610 | if (result == QUuid()) { |
| 5567 | QString errorInfo = "Could not add downloaded asset " + mapping + " to world."; | 5611 | QString errorInfo = "Could not add downloaded asset " + mapping + " to world."; |
| 5568 | qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo; | 5612 | qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo; |
| 5569 | OffscreenUi::warning("Error Downloading Asset", errorInfo); | 5613 | addAssetToWorldError(errorInfo); |
| 5570 | } else { | 5614 | } else { |
| 5571 | QString successInfo = "Downloaded asset " + mapping + " added to world"; | 5615 | QString successInfo = "Downloaded asset " + mapping + " added to world"; |
| 5572 | qCDebug(interfaceapp) << "Downloading asset completed: " + successInfo; | 5616 | qCDebug(interfaceapp) << "Downloading asset completed: " + successInfo; |
| 5573 | OffscreenUi::information("Downloading Asset Completed", successInfo); | 5617 | _addAssetToWorldMessageBox->setProperty("text", "Downloading asset completed"); |
| 5618 | _addAssetToWorldMessageBox->setProperty("buttons", QMessageBox::Ok); | ||
| 5619 | _addAssetToWorldMessageBox->setProperty("defaultButton", QMessageBox::Ok); | ||
| 5574 | } | 5620 | } |
| 5575 | } | 5621 | } |
| 5576 | 5622 | ||