From 68e9d335cdf29b1c65e77514a7222d80e5a3e7e5 Mon Sep 17 00:00:00 2001 From: vladest Date: Thu, 10 Aug 2017 10:45:11 +0200 Subject: [PATCH] Added async information and critical dialogs --- interface/src/assets/ATPAssetMigrator.cpp | 2 +- interface/src/ui/AddressBarDialog.cpp | 4 ++-- libraries/ui/src/OffscreenUi.cpp | 13 ++++++++++++- libraries/ui/src/OffscreenUi.h | 16 ++++++++++++++++ 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/interface/src/assets/ATPAssetMigrator.cpp b/interface/src/assets/ATPAssetMigrator.cpp index b3711a2707..45459683e8 100644 --- a/interface/src/assets/ATPAssetMigrator.cpp +++ b/interface/src/assets/ATPAssetMigrator.cpp @@ -354,7 +354,7 @@ void ATPAssetMigrator::saveEntityServerFile() { infoMessage += "You can re-attempt migration on those models\nby restarting this process with the newly saved file."; } - OffscreenUi::information(_dialogParent, "Success", infoMessage); + OffscreenUi::asyncInformation(_dialogParent, "Success", infoMessage); } else { OffscreenUi::asyncWarning(_dialogParent, "Error", "Could not gzip JSON data for new entities file."); } diff --git a/interface/src/ui/AddressBarDialog.cpp b/interface/src/ui/AddressBarDialog.cpp index 8aaaac1a57..d7b59ba912 100644 --- a/interface/src/ui/AddressBarDialog.cpp +++ b/interface/src/ui/AddressBarDialog.cpp @@ -73,11 +73,11 @@ void AddressBarDialog::loadForward() { } void AddressBarDialog::displayAddressOfflineMessage() { - OffscreenUi::critical("", "That user or place is currently offline"); + OffscreenUi::asyncCritical("", "That user or place is currently offline"); } void AddressBarDialog::displayAddressNotFoundMessage() { - OffscreenUi::critical("", "There is no address information for that user or place"); + OffscreenUi::asyncCritical("", "There is no address information for that user or place"); } void AddressBarDialog::observeShownChanged(bool visible) { diff --git a/libraries/ui/src/OffscreenUi.cpp b/libraries/ui/src/OffscreenUi.cpp index 75f13b0dbd..fd557d74c6 100644 --- a/libraries/ui/src/OffscreenUi.cpp +++ b/libraries/ui/src/OffscreenUi.cpp @@ -172,7 +172,7 @@ protected: virtual QVariant waitForResult() { while (!_finished) { - QCoreApplication::processEvents(); + QCoreApplication::processEvents(QEventLoop::AllEvents, 100); } return _result; } @@ -295,6 +295,17 @@ QMessageBox::StandardButton OffscreenUi::information(const QString& title, const QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) { return DependencyManager::get()->messageBox(OffscreenUi::Icon::ICON_INFORMATION, title, text, buttons, defaultButton); } + +void OffscreenUi::asyncCritical(const QString& title, const QString& text, + QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) { + DependencyManager::get()->asyncMessageBox(OffscreenUi::Icon::ICON_CRITICAL, title, text, buttons, defaultButton); +} + +void OffscreenUi::asyncInformation(const QString& title, const QString& text, + QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) { + DependencyManager::get()->asyncMessageBox(OffscreenUi::Icon::ICON_INFORMATION, title, text, buttons, defaultButton); +} + QMessageBox::StandardButton OffscreenUi::question(const QString& title, const QString& text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) { return DependencyManager::get()->messageBox(OffscreenUi::Icon::ICON_QUESTION, title, text, buttons, defaultButton); diff --git a/libraries/ui/src/OffscreenUi.h b/libraries/ui/src/OffscreenUi.h index 726b7897a0..09f5d0b863 100644 --- a/libraries/ui/src/OffscreenUi.h +++ b/libraries/ui/src/OffscreenUi.h @@ -89,6 +89,16 @@ public: QMessageBox::StandardButton defaultButton = QMessageBox::NoButton) { return information(title, text, buttons, defaultButton); } + static void asyncCritical(void* ignored, const QString& title, const QString& text, + QMessageBox::StandardButtons buttons = QMessageBox::Ok, + QMessageBox::StandardButton defaultButton = QMessageBox::NoButton) { + return asyncCritical(title, text, buttons, defaultButton); + } + static void asyncInformation(void* ignored, const QString& title, const QString& text, + QMessageBox::StandardButtons buttons = QMessageBox::Ok, + QMessageBox::StandardButton defaultButton = QMessageBox::NoButton) { + return asyncInformation(title, text, buttons, defaultButton); + } /// Same design as QMessageBox::question(), will block, returns result static QMessageBox::StandardButton question(void* ignored, const QString& title, const QString& text, QMessageBox::StandardButtons buttons = QMessageBox::Yes | QMessageBox::No, @@ -119,6 +129,12 @@ public: static QMessageBox::StandardButton information(const QString& title, const QString& text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton); + static void asyncCritical(const QString& title, const QString& text, + QMessageBox::StandardButtons buttons = QMessageBox::Ok, + QMessageBox::StandardButton defaultButton = QMessageBox::NoButton); + static void asyncInformation(const QString& title, const QString& text, + QMessageBox::StandardButtons buttons = QMessageBox::Ok, + QMessageBox::StandardButton defaultButton = QMessageBox::NoButton); static QMessageBox::StandardButton question(const QString& title, const QString& text, QMessageBox::StandardButtons buttons = QMessageBox::Yes | QMessageBox::No, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);