diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index a7bac40033..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,13 +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."; - - QMessageBox msgBox; - msgBox.setText(message); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setIcon(QMessageBox::Warning); - msgBox.exec(); + OffscreenUi::warning("", "You can not use local files for avatar components."); return false; } @@ -4267,32 +4257,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", + "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 { @@ -4456,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; @@ -4640,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); } } @@ -4653,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 { 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();