From eb19f293c4762291d5b93ed0ef8abf2d0d5d88c2 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Mon, 25 Jan 2016 14:04:06 -0800 Subject: [PATCH 1/3] Fix askToSetAvatarUrl dialogs to use new style. --- interface/src/Application.cpp | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index a7bac40033..a28334e7a3 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -4253,12 +4253,7 @@ bool Application::askToSetAvatarUrl(const QString& url) { QUrl realUrl(url); if (realUrl.isLocalFile()) { QString message = "You can not use local files for avatar components."; - - QMessageBox msgBox; - msgBox.setText(message); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setIcon(QMessageBox::Warning); - msgBox.exec(); + OffscreenUi::warning("", message); return false; } @@ -4267,32 +4262,22 @@ bool Application::askToSetAvatarUrl(const QString& url) { FSTReader::ModelType modelType = FSTReader::predictModelType(fstMapping); - QMessageBox msgBox; - msgBox.setIcon(QMessageBox::Question); - msgBox.setWindowTitle("Set Avatar"); - QPushButton* bodyAndHeadButton = NULL; - QString modelName = fstMapping["name"].toString(); - QString message; - QString typeInfo; + bool ok = false; switch (modelType) { case FSTReader::HEAD_AND_BODY_MODEL: - message = QString("Would you like to use '") + modelName + QString("' for your avatar?"); - bodyAndHeadButton = msgBox.addButton(tr("Yes"), QMessageBox::ActionRole); + ok = QMessageBox::Ok == OffscreenUi::question("Set Avatar", + QString("Would you like to use '") + modelName + "' for your avatar?", + QMessageBox::Ok | QMessageBox::Cancel); break; default: - message = QString(modelName + QString("Does not support a head and body as required.")); + OffscreenUi::warning("", modelName + "Does not support a head and body as required."); break; } - msgBox.setText(message); - msgBox.addButton(QMessageBox::Cancel); - - msgBox.exec(); - - if (msgBox.clickedButton() == bodyAndHeadButton) { + if (ok) { getMyAvatar()->useFullAvatarURL(url, modelName); emit fullAvatarURLChanged(url, modelName); } else { From 69289844489df777812bddae20f5755e6f8780cc Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Mon, 25 Jan 2016 14:45:26 -0800 Subject: [PATCH 2/3] remaining Application message boxes, EXCEPT asset upload, which has a checkbox. --- interface/src/Application.cpp | 48 +++++++++-------------------------- 1 file changed, 12 insertions(+), 36 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index a28334e7a3..a295cd8a6e 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2374,12 +2374,8 @@ bool Application::acceptSnapshot(const QString& urlString) { DependencyManager::get()->handleLookupString(snapshotData->getURL().toString()); } } else { - QMessageBox msgBox; - msgBox.setText("No location details were found in the file " - + snapshotPath + ", try dragging in an authentic Hifi snapshot."); - - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.exec(); + OffscreenUi::warning("", "No location details were found in the file\n" + + snapshotPath + "\nTry dragging in an authentic Hifi snapshot."); } return true; } @@ -4252,8 +4248,7 @@ void Application::setSessionUUID(const QUuid& sessionUUID) { bool Application::askToSetAvatarUrl(const QString& url) { QUrl realUrl(url); if (realUrl.isLocalFile()) { - QString message = "You can not use local files for avatar components."; - OffscreenUi::warning("", message); + OffscreenUi::warning("", "You can not use local files for avatar components."); return false; } @@ -4268,7 +4263,7 @@ bool Application::askToSetAvatarUrl(const QString& url) { case FSTReader::HEAD_AND_BODY_MODEL: ok = QMessageBox::Ok == OffscreenUi::question("Set Avatar", - QString("Would you like to use '") + modelName + "' for your avatar?", + "Would you like to use '" + modelName + "' for your avatar?", QMessageBox::Ok | QMessageBox::Cancel); break; @@ -4441,27 +4436,16 @@ bool Application::askToWearAvatarAttachmentUrl(const QString& url) { void Application::displayAvatarAttachmentWarning(const QString& message) const { auto avatarAttachmentWarningTitle = tr("Avatar Attachment Failure"); - QMessageBox msgBox; - msgBox.setIcon(QMessageBox::Warning); - msgBox.setWindowTitle(avatarAttachmentWarningTitle); - msgBox.setText(message); - msgBox.exec(); - msgBox.addButton(QMessageBox::Ok); - msgBox.exec(); + OffscreenUi::warning(avatarAttachmentWarningTitle, message); } bool Application::displayAvatarAttachmentConfirmationDialog(const QString& name) const { auto avatarAttachmentConfirmationTitle = tr("Avatar Attachment Confirmation"); - auto avatarAttachmentConfirmationMessage = tr("Would you like to wear '%1' on your avatar?"); - QMessageBox msgBox; - msgBox.setIcon(QMessageBox::Question); - msgBox.setWindowTitle(avatarAttachmentConfirmationTitle); - QPushButton* button = msgBox.addButton(tr("Yes"), QMessageBox::ActionRole); - QString message = avatarAttachmentConfirmationMessage.arg(name); - msgBox.setText(message); - msgBox.addButton(QMessageBox::Cancel); - msgBox.exec(); - if (msgBox.clickedButton() == button) { + auto avatarAttachmentConfirmationMessage = tr("Would you like to wear '%1' on your avatar?").arg(name); + auto reply = OffscreenUi::question(avatarAttachmentConfirmationTitle, + avatarAttachmentConfirmationMessage, + QMessageBox::Ok | QMessageBox::Cancel); + if (QMessageBox::Ok == reply) { return true; } else { return false; @@ -4625,11 +4609,7 @@ void Application::notifyPacketVersionMismatch() { QString message = "The location you are visiting is running an incompatible server version.\n"; message += "Content may not display properly."; - QMessageBox msgBox; - msgBox.setText(message); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setIcon(QMessageBox::Warning); - msgBox.exec(); + OffscreenUi::warning("", message); } } @@ -4638,11 +4618,7 @@ void Application::checkSkeleton() { qCDebug(interfaceapp) << "MyAvatar model has no skeleton"; QString message = "Your selected avatar body has no skeleton.\n\nThe default body will be loaded..."; - QMessageBox msgBox; - msgBox.setText(message); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setIcon(QMessageBox::Warning); - msgBox.exec(); + OffscreenUi::warning("", message); getMyAvatar()->useFullAvatarURL(AvatarData::defaultFullAvatarModelUrl(), DEFAULT_FULL_AVATAR_MODEL_NAME); } else { From cd44094efafeb4eb069fcc1bdfdef736afc56fdb Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Mon, 25 Jan 2016 14:46:11 -0800 Subject: [PATCH 3/3] When user is asked about disk cache, allow them to say no. --- interface/src/ui/DiskCacheEditor.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/interface/src/ui/DiskCacheEditor.cpp b/interface/src/ui/DiskCacheEditor.cpp index 62917007d3..d3a40e6439 100644 --- a/interface/src/ui/DiskCacheEditor.cpp +++ b/interface/src/ui/DiskCacheEditor.cpp @@ -138,9 +138,10 @@ void DiskCacheEditor::refresh() { void DiskCacheEditor::clear() { QMessageBox::StandardButton buttonClicked = OffscreenUi::question(_dialog, "Clearing disk cache", - "You are about to erase all the content of the disk cache," - "are you sure you want to do that?"); - if (buttonClicked == QMessageBox::Yes) { + "You are about to erase all the content of the disk cache, " + "are you sure you want to do that?", + QMessageBox::Ok | QMessageBox::Cancel); + if (buttonClicked == QMessageBox::Ok) { if (auto cache = NetworkAccessManager::getInstance().cache()) { qDebug() << "DiskCacheEditor::clear(): Clearing disk cache."; cache->clear();