History

Add user feedback on download process

David Rowe committed 10 years ago

Commit bf2bcc01 parent b672b7e3 files · +70 −6Browse files

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

Unified · Split

interface/src/Application.cpp+52−6
@@ -5470,13 +5470,41 @@ void Application::showAssetServerWidget(QString filePath) { · 5469 unmodified lines
54705470 startUpload(nullptr, nullptr);
54715471 }
54725472
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+
54735495 void Application::addAssetToWorld(QString filePath) {
54745496 // Automatically upload and add asset to world as an alternative manual process initiated by showAssetServerWidget().
54755497
5498+ if (!_addAssetToWorldMessageBox) {
5499+ return;
5500+ }
5501+
5502+ _addAssetToWorldMessageBox->setProperty("text", "Downloading asset file");
5503+
54765504 if (!DependencyManager::get<NodeList>()->getThisNodeCanWriteAssets()) {
54775505 QString errorInfo = "Do not have permissions to write to asset server.";
54785506 qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo;
5479− OffscreenUi::warning("Error Downloading Asset", errorInfo);
5507+ addAssetToWorldError(errorInfo);
54805508 return;
54815509 }
54825510
@@ -5487,6 +5515,10 @@ void Application::addAssetToWorld(QString filePath) { · 4 unmodified lines
54875515 }
54885516
54895517 void Application::addAssetToWorldWithNewMapping(QString path, QString mapping, int copy) {
5518+ if (!_addAssetToWorldMessageBox) {
5519+ return;
5520+ }
5521+
54905522 auto request = DependencyManager::get<AssetClient>()->createGetMappingRequest(mapping);
54915523 QObject::connect(request, &GetMappingRequest::finished, this, [=](GetMappingRequest* request) mutable {
54925524 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
55035535 QString errorInfo = "Too many copies of asset name: "
55045536 + mapping.left(mapping.length() - QString::number(copy).length() - 1);
55055537 qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo;
5506− OffscreenUi::warning("Error Downloading Asset", errorInfo);
5538+ addAssetToWorldError(errorInfo);
55075539 }
55085540 request->deleteLater();
55095541 });
@@ -5512,12 +5544,16 @@ void Application::addAssetToWorldWithNewMapping(QString path, QString mapping, i · 2 unmodified lines
55125544 }
55135545
55145546 void Application::addAssetToWorldUpload(QString path, QString mapping) {
5547+ if (!_addAssetToWorldMessageBox) {
5548+ return;
5549+ }
5550+
55155551 auto upload = DependencyManager::get<AssetClient>()->createUpload(path);
55165552 QObject::connect(upload, &AssetUpload::finished, this, [=](AssetUpload* upload, const QString& hash) mutable {
55175553 if (upload->getError() != AssetUpload::NoError) {
55185554 QString errorInfo = "Could not upload asset to asset server.";
55195555 qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo;
5520− OffscreenUi::warning("Error Downloading Asset", errorInfo);
5556+ addAssetToWorldError(errorInfo);
55215557 } else {
55225558 addAssetToWorldSetMapping(mapping, hash);
55235559 }
@@ -5537,12 +5573,16 @@ void Application::addAssetToWorldUpload(QString path, QString mapping) { · 13 unmodified lines
55375573 }
55385574
55395575 void Application::addAssetToWorldSetMapping(QString mapping, QString hash) {
5576+ if (!_addAssetToWorldMessageBox) {
5577+ return;
5578+ }
5579+
55405580 auto request = DependencyManager::get<AssetClient>()->createSetMappingRequest(mapping, hash);
55415581 connect(request, &SetMappingRequest::finished, this, [=](SetMappingRequest* request) mutable {
55425582 if (request->getError() != SetMappingRequest::NoError) {
55435583 QString errorInfo = "Could not set asset mapping.";
55445584 qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo;
5545− OffscreenUi::warning("Error Downloading Asset", errorInfo);
5585+ addAssetToWorldError(errorInfo);
55465586 } else {
55475587 addAssetToWorldAddEntity(mapping);
55485588 }
@@ -5553,6 +5593,10 @@ void Application::addAssetToWorldSetMapping(QString mapping, QString hash) { · 4 unmodified lines
55535593 }
55545594
55555595 void Application::addAssetToWorldAddEntity(QString mapping) {
5596+ if (!_addAssetToWorldMessageBox) {
5597+ return;
5598+ }
5599+
55565600 EntityItemProperties properties;
55575601 properties.setType(EntityTypes::Model);
55585602 properties.setName(mapping.right(mapping.length() - 1));
@@ -5566,11 +5610,13 @@ void Application::addAssetToWorldAddEntity(QString mapping) { · 7 unmodified lines
55665610 if (result == QUuid()) {
55675611 QString errorInfo = "Could not add downloaded asset " + mapping + " to world.";
55685612 qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo;
5569− OffscreenUi::warning("Error Downloading Asset", errorInfo);
5613+ addAssetToWorldError(errorInfo);
55705614 } else {
55715615 QString successInfo = "Downloaded asset " + mapping + " added to world";
55725616 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);
55745620 }
55755621 }
55765622

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