From d1cb79f644cade8f763e7ad7c465ff69ae9a49ce Mon Sep 17 00:00:00 2001 From: spycrab Date: Mon, 4 Mar 2019 20:48:40 +0100 Subject: [PATCH 1/2] QtUtils: Add ModalMessageBox --- Source/Core/DolphinQt/CMakeLists.txt | 1 + Source/Core/DolphinQt/DolphinQt.vcxproj | 5 +- .../DolphinQt/QtUtils/ModalMessageBox.cpp | 54 +++++++++++++++++++ .../Core/DolphinQt/QtUtils/ModalMessageBox.h | 23 ++++++++ 4 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 Source/Core/DolphinQt/QtUtils/ModalMessageBox.cpp create mode 100644 Source/Core/DolphinQt/QtUtils/ModalMessageBox.h diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt index 04100f7465..85bc526ae6 100644 --- a/Source/Core/DolphinQt/CMakeLists.txt +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -104,6 +104,7 @@ add_executable(dolphin-emu QtUtils/DoubleClickEventFilter.cpp QtUtils/ElidedButton.cpp QtUtils/FlowLayout.cpp + QtUtils/ModalMessageBox.cpp QtUtils/ImageConverter.cpp QtUtils/SignalDaemon.cpp QtUtils/WindowActivationEventFilter.cpp diff --git a/Source/Core/DolphinQt/DolphinQt.vcxproj b/Source/Core/DolphinQt/DolphinQt.vcxproj index 0dde566e5a..e2fefa340c 100644 --- a/Source/Core/DolphinQt/DolphinQt.vcxproj +++ b/Source/Core/DolphinQt/DolphinQt.vcxproj @@ -154,6 +154,7 @@ + @@ -245,6 +246,7 @@ + @@ -371,6 +373,7 @@ + @@ -491,4 +494,4 @@ - \ No newline at end of file + diff --git a/Source/Core/DolphinQt/QtUtils/ModalMessageBox.cpp b/Source/Core/DolphinQt/QtUtils/ModalMessageBox.cpp new file mode 100644 index 0000000000..25d10de729 --- /dev/null +++ b/Source/Core/DolphinQt/QtUtils/ModalMessageBox.cpp @@ -0,0 +1,54 @@ +// Copyright 2019 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "DolphinQt/QtUtils/ModalMessageBox.h" + +#include + +ModalMessageBox::ModalMessageBox(QWidget* parent) : QMessageBox(parent) +{ + setWindowModality(Qt::WindowModal); + + // No parent is still preferable to showing a hidden parent here. + if (parent != nullptr && !parent->isVisible()) + setParent(nullptr); +} + +static inline int ExecMessageBox(ModalMessageBox::Icon icon, QWidget* parent, const QString& title, + const QString& text, ModalMessageBox::StandardButtons buttons, + ModalMessageBox::StandardButton default_button) +{ + ModalMessageBox msg(parent); + msg.setIcon(icon); + msg.setWindowTitle(title); + msg.setText(text); + msg.setStandardButtons(buttons); + msg.setDefaultButton(default_button); + + return msg.exec(); +} + +int ModalMessageBox::critical(QWidget* parent, const QString& title, const QString& text, + StandardButtons buttons, StandardButton default_button) +{ + return ExecMessageBox(QMessageBox::Critical, parent, title, text, buttons, default_button); +} + +int ModalMessageBox::information(QWidget* parent, const QString& title, const QString& text, + StandardButtons buttons, StandardButton default_button) +{ + return ExecMessageBox(QMessageBox::Information, parent, title, text, buttons, default_button); +} + +int ModalMessageBox::question(QWidget* parent, const QString& title, const QString& text, + StandardButtons buttons, StandardButton default_button) +{ + return ExecMessageBox(QMessageBox::Critical, parent, title, text, buttons, default_button); +} + +int ModalMessageBox::warning(QWidget* parent, const QString& title, const QString& text, + StandardButtons buttons, StandardButton default_button) +{ + return ExecMessageBox(QMessageBox::Warning, parent, title, text, buttons, default_button); +} diff --git a/Source/Core/DolphinQt/QtUtils/ModalMessageBox.h b/Source/Core/DolphinQt/QtUtils/ModalMessageBox.h new file mode 100644 index 0000000000..5eb3c597a3 --- /dev/null +++ b/Source/Core/DolphinQt/QtUtils/ModalMessageBox.h @@ -0,0 +1,23 @@ +// Copyright 2019 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include + +// Helper for making message boxes modal by default +class ModalMessageBox : public QMessageBox +{ +public: + explicit ModalMessageBox(QWidget* parent); + + static int critical(QWidget* parent, const QString& title, const QString& text, + StandardButtons buttons = Ok, StandardButton default_button = NoButton); + static int information(QWidget* parent, const QString& title, const QString& text, + StandardButtons buttons = Ok, StandardButton default_button = NoButton); + static int question(QWidget* parent, const QString& title, const QString& text, + StandardButtons buttons = Yes | No, StandardButton default_button = NoButton); + static int warning(QWidget* parent, const QString& title, const QString& text, + StandardButtons buttons = Ok, StandardButton default_button = NoButton); +}; From 70da86f1c3c933ce28d122f95f34ff6c24f89d80 Mon Sep 17 00:00:00 2001 From: spycrab Date: Mon, 4 Mar 2019 20:49:00 +0100 Subject: [PATCH 2/2] Qt: Use ModalMessageBox everywhere --- .../Core/DolphinQt/Config/CheatCodeEditor.cpp | 29 ++++--- .../DolphinQt/Config/ControllersWindow.cpp | 19 ++-- .../DolphinQt/Config/FilesystemWidget.cpp | 25 +++--- .../Core/DolphinQt/Config/GameConfigEdit.cpp | 6 +- .../Core/DolphinQt/Config/GeckoCodeWidget.cpp | 13 +-- .../Config/Graphics/GeneralWidget.cpp | 5 +- .../Config/Mapping/MappingIndicator.cpp | 10 +-- .../Config/Mapping/MappingWindow.cpp | 10 +-- .../Core/DolphinQt/Config/NewPatchDialog.cpp | 6 +- .../Core/DolphinQt/Debugger/MemoryWidget.cpp | 16 ++-- .../Debugger/NewBreakpointDialog.cpp | 5 +- .../DolphinQt/Debugger/RegisterColumn.cpp | 4 +- .../Core/DolphinQt/Debugger/WatchWidget.cpp | 16 ++-- Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp | 1 - .../Core/DolphinQt/FIFO/FIFOPlayerWindow.cpp | 7 +- Source/Core/DolphinQt/GCMemcardManager.cpp | 35 ++------ Source/Core/DolphinQt/GameList/GameList.cpp | 48 ++++------- Source/Core/DolphinQt/Main.cpp | 12 +-- Source/Core/DolphinQt/MainWindow.cpp | 50 +++++------ Source/Core/DolphinQt/MenuBar.cpp | 86 +++++++++---------- .../Core/DolphinQt/NetPlay/NetPlayDialog.cpp | 24 +++--- .../DolphinQt/NetPlay/NetPlaySetupDialog.cpp | 6 +- Source/Core/DolphinQt/RenderWidget.cpp | 4 +- Source/Core/DolphinQt/ResourcePackManager.cpp | 8 +- .../Core/DolphinQt/Settings/GameCubePane.cpp | 13 +-- .../Core/DolphinQt/Settings/GeneralPane.cpp | 5 +- .../Core/DolphinQt/Settings/InterfacePane.cpp | 11 +-- .../USBDeviceAddToWhitelistDialog.cpp | 15 +--- Source/Core/DolphinQt/Translation.cpp | 5 +- Source/Core/DolphinQt/Updater.cpp | 1 - Source/Core/DolphinQt/WiiUpdate.cpp | 47 +++++----- 31 files changed, 244 insertions(+), 298 deletions(-) mode change 100755 => 100644 Source/Core/DolphinQt/Config/GeckoCodeWidget.cpp diff --git a/Source/Core/DolphinQt/Config/CheatCodeEditor.cpp b/Source/Core/DolphinQt/Config/CheatCodeEditor.cpp index a72e4781be..1292e0272d 100644 --- a/Source/Core/DolphinQt/Config/CheatCodeEditor.cpp +++ b/Source/Core/DolphinQt/Config/CheatCodeEditor.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include @@ -17,6 +16,8 @@ #include "Core/ActionReplay.h" #include "Core/GeckoCodeConfig.h" +#include "DolphinQt/QtUtils/ModalMessageBox.h" + CheatCodeEditor::CheatCodeEditor(QWidget* parent) : QDialog(parent) { setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); @@ -167,7 +168,7 @@ bool CheatCodeEditor::AcceptAR() if (!good) { - auto result = QMessageBox::warning( + auto result = ModalMessageBox::warning( this, tr("Parsing Error"), tr("Unable to parse line %1 of the entered AR code as a valid " "encrypted or decrypted code. Make sure you typed it correctly.\n\n" @@ -184,7 +185,7 @@ bool CheatCodeEditor::AcceptAR() { if (!entries.empty()) { - auto result = QMessageBox::warning( + auto result = ModalMessageBox::warning( this, tr("Invalid Mixed Code"), tr("This Action Replay code contains both encrypted and unencrypted lines; " "you should check that you have entered it correctly.\n\n" @@ -213,8 +214,8 @@ bool CheatCodeEditor::AcceptAR() if (entries.empty()) { - QMessageBox::critical(this, tr("Error"), - tr("The resulting decrypted AR code doesn't contain any lines.")); + ModalMessageBox::critical(this, tr("Error"), + tr("The resulting decrypted AR code doesn't contain any lines.")); return false; } @@ -253,13 +254,13 @@ bool CheatCodeEditor::AcceptGecko() if (!good) { - auto result = - QMessageBox::warning(this, tr("Parsing Error"), - tr("Unable to parse line %1 of the entered Gecko code as a valid " - "code. Make sure you typed it correctly.\n\n" - "Would you like to ignore this line and continue parsing?") - .arg(i + 1), - QMessageBox::Ok | QMessageBox::Abort); + auto result = ModalMessageBox::warning( + this, tr("Parsing Error"), + tr("Unable to parse line %1 of the entered Gecko code as a valid " + "code. Make sure you typed it correctly.\n\n" + "Would you like to ignore this line and continue parsing?") + .arg(i + 1), + QMessageBox::Ok | QMessageBox::Abort); if (result == QMessageBox::Abort) return false; @@ -277,8 +278,8 @@ bool CheatCodeEditor::AcceptGecko() if (entries.empty()) { - QMessageBox::critical(this, tr("Error"), - tr("The resulting decrypted AR code doesn't contain any lines.")); + ModalMessageBox::critical(this, tr("Error"), + tr("The resulting decrypted AR code doesn't contain any lines.")); return false; } diff --git a/Source/Core/DolphinQt/Config/ControllersWindow.cpp b/Source/Core/DolphinQt/Config/ControllersWindow.cpp index fbedd80b03..75d99495a8 100644 --- a/Source/Core/DolphinQt/Config/ControllersWindow.cpp +++ b/Source/Core/DolphinQt/Config/ControllersWindow.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -34,6 +33,7 @@ #include "DolphinQt/Config/Mapping/GCPadWiiUConfigDialog.h" #include "DolphinQt/Config/Mapping/MappingWindow.h" +#include "DolphinQt/QtUtils/ModalMessageBox.h" #include "DolphinQt/QtUtils/WrapInScrollArea.h" #include "DolphinQt/Settings.h" @@ -328,12 +328,9 @@ void ControllersWindow::OnBluetoothPassthroughResetPressed() if (!ios) { - QMessageBox error(this); - error.setIcon(QMessageBox::Warning); - error.setWindowModality(Qt::WindowModal); - error.setWindowTitle(tr("Warning")); - error.setText(tr("Saved Wii Remote pairings can only be reset when a Wii game is running.")); - error.exec(); + ModalMessageBox::warning( + this, tr("Warning"), + tr("Saved Wii Remote pairings can only be reset when a Wii game is running.")); return; } @@ -350,12 +347,8 @@ void ControllersWindow::OnBluetoothPassthroughSyncPressed() if (!ios) { - QMessageBox error(this); - error.setIcon(QMessageBox::Warning); - error.setWindowModality(Qt::WindowModal); - error.setWindowTitle(tr("Warning")); - error.setText(tr("A sync can only be triggered when a Wii game is running.")); - error.exec(); + ModalMessageBox::warning(this, tr("Warning"), + tr("A sync can only be triggered when a Wii game is running.")); return; } diff --git a/Source/Core/DolphinQt/Config/FilesystemWidget.cpp b/Source/Core/DolphinQt/Config/FilesystemWidget.cpp index 8f274c3bf9..3ff72d8e06 100644 --- a/Source/Core/DolphinQt/Config/FilesystemWidget.cpp +++ b/Source/Core/DolphinQt/Config/FilesystemWidget.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -23,6 +22,7 @@ #include "DiscIO/Filesystem.h" #include "DiscIO/Volume.h" +#include "DolphinQt/QtUtils/ModalMessageBox.h" #include "DolphinQt/Resources.h" #include "UICommon/UICommon.h" @@ -199,9 +199,10 @@ void FilesystemWidget::ShowContextMenu(const QPoint&) return; if (ExtractSystemData(partition, folder)) - QMessageBox::information(this, tr("Success"), tr("Successfully extracted system data.")); + ModalMessageBox::information(this, tr("Success"), + tr("Successfully extracted system data.")); else - QMessageBox::critical(this, tr("Error"), tr("Failed to extract system data.")); + ModalMessageBox::critical(this, tr("Error"), tr("Failed to extract system data.")); }); } @@ -323,9 +324,9 @@ void FilesystemWidget::ExtractFile(const DiscIO::Partition& partition, const QSt *m_volume, partition, filesystem->FindFileInfo(path.toStdString()).get(), out.toStdString()); if (success) - QMessageBox::information(this, tr("Success"), tr("Successfully extracted file.")); + ModalMessageBox::information(this, tr("Success"), tr("Successfully extracted file.")); else - QMessageBox::critical(this, tr("Error"), tr("Failed to extract file.")); + ModalMessageBox::critical(this, tr("Error"), tr("Failed to extract file.")); } void FilesystemWidget::CheckIntegrity(const DiscIO::Partition& partition) @@ -348,10 +349,14 @@ void FilesystemWidget::CheckIntegrity(const DiscIO::Partition& partition) dialog->close(); if (is_valid.get()) - QMessageBox::information(this, tr("Success"), - tr("Integrity check completed. No errors have been found.")); + { + ModalMessageBox::information(this, tr("Success"), + tr("Integrity check completed. No errors have been found.")); + } else - QMessageBox::critical(this, tr("Error"), - tr("Integrity check for partition failed. The disc image is most " - "likely corrupted or has been patched incorrectly.")); + { + ModalMessageBox::critical(this, tr("Error"), + tr("Integrity check for partition failed. The disc image is most " + "likely corrupted or has been patched incorrectly.")); + } } diff --git a/Source/Core/DolphinQt/Config/GameConfigEdit.cpp b/Source/Core/DolphinQt/Config/GameConfigEdit.cpp index 3d0474a02f..71712defbf 100644 --- a/Source/Core/DolphinQt/Config/GameConfigEdit.cpp +++ b/Source/Core/DolphinQt/Config/GameConfigEdit.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -20,6 +19,7 @@ #include #include "DolphinQt/Config/GameConfigHighlighter.h" +#include "DolphinQt/QtUtils/ModalMessageBox.h" GameConfigEdit::GameConfigEdit(QWidget* parent, const QString& path, bool read_only) : m_path(path), m_read_only(read_only) @@ -122,14 +122,14 @@ void GameConfigEdit::SaveFile() if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) { - QMessageBox::warning(this, tr("Warning"), tr("Failed to open config file!")); + ModalMessageBox::warning(this, tr("Warning"), tr("Failed to open config file!")); return; } const QByteArray contents = m_edit->toPlainText().toUtf8(); if (file.write(contents) == -1) - QMessageBox::warning(this, tr("Warning"), tr("Failed to write config file!")); + ModalMessageBox::warning(this, tr("Warning"), tr("Failed to write config file!")); } void GameConfigEdit::ConnectWidgets() diff --git a/Source/Core/DolphinQt/Config/GeckoCodeWidget.cpp b/Source/Core/DolphinQt/Config/GeckoCodeWidget.cpp old mode 100755 new mode 100644 index e320b32347..69295680d0 --- a/Source/Core/DolphinQt/Config/GeckoCodeWidget.cpp +++ b/Source/Core/DolphinQt/Config/GeckoCodeWidget.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -22,6 +21,7 @@ #include "DolphinQt/Config/CheatCodeEditor.h" #include "DolphinQt/Config/CheatWarningWidget.h" +#include "DolphinQt/QtUtils/ModalMessageBox.h" #include "UICommon/GameFile.h" @@ -255,13 +255,13 @@ void GeckoCodeWidget::DownloadCodes() if (!success) { - QMessageBox::critical(this, tr("Error"), tr("Failed to download codes.")); + ModalMessageBox::critical(this, tr("Error"), tr("Failed to download codes.")); return; } if (codes.empty()) { - QMessageBox::critical(this, tr("Error"), tr("File contained no codes.")); + ModalMessageBox::critical(this, tr("Error"), tr("File contained no codes.")); return; } @@ -281,7 +281,8 @@ void GeckoCodeWidget::DownloadCodes() UpdateList(); SaveCodes(); - QMessageBox::information(this, tr("Download complete"), - tr("Downloaded %1 codes. (added %2)") - .arg(QString::number(codes.size()), QString::number(added_count))); + ModalMessageBox::information( + this, tr("Download complete"), + tr("Downloaded %1 codes. (added %2)") + .arg(QString::number(codes.size()), QString::number(added_count))); } diff --git a/Source/Core/DolphinQt/Config/Graphics/GeneralWidget.cpp b/Source/Core/DolphinQt/Config/Graphics/GeneralWidget.cpp index 7ca5e61e54..3b7a3d3166 100644 --- a/Source/Core/DolphinQt/Config/Graphics/GeneralWidget.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/GeneralWidget.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -23,6 +22,7 @@ #include "DolphinQt/Config/Graphics/GraphicsChoice.h" #include "DolphinQt/Config/Graphics/GraphicsRadio.h" #include "DolphinQt/Config/Graphics/GraphicsWindow.h" +#include "DolphinQt/QtUtils/ModalMessageBox.h" #include "DolphinQt/Settings.h" #include "UICommon/VideoUtils.h" @@ -172,10 +172,9 @@ void GeneralWidget::SaveSettings() { if (current_backend == "Software Renderer") { - QMessageBox confirm_sw(this); + ModalMessageBox confirm_sw(this); confirm_sw.setIcon(QMessageBox::Warning); - confirm_sw.setWindowModality(Qt::WindowModal); confirm_sw.setStandardButtons(QMessageBox::Yes | QMessageBox::No); confirm_sw.setWindowTitle(tr("Confirm backend change")); confirm_sw.setText(tr("The software renderer is significantly slower than other " diff --git a/Source/Core/DolphinQt/Config/Mapping/MappingIndicator.cpp b/Source/Core/DolphinQt/Config/Mapping/MappingIndicator.cpp index 0e03543dc7..09cc4657e5 100644 --- a/Source/Core/DolphinQt/Config/Mapping/MappingIndicator.cpp +++ b/Source/Core/DolphinQt/Config/Mapping/MappingIndicator.cpp @@ -10,7 +10,6 @@ #include #include -#include #include #include @@ -23,6 +22,7 @@ #include "InputCommon/ControllerEmu/Setting/NumericSetting.h" #include "InputCommon/ControllerInterface/Device.h" +#include "DolphinQt/QtUtils/ModalMessageBox.h" #include "DolphinQt/Settings.h" // Color constants to keep things looking consistent: @@ -480,11 +480,9 @@ CalibrationWidget::CalibrationWidget(ControllerEmu::ReshapableInput& input, if (*std::max_element(m_calibration_data.begin(), m_calibration_data.end()) > 0.5) return; - QMessageBox msg(QMessageBox::Information, tr("Calibration"), - tr("For best results please slowly move your input to all possible regions."), - QMessageBox::Ok, this); - msg.setWindowModality(Qt::WindowModal); - msg.exec(); + ModalMessageBox::information( + this, tr("Calibration"), + tr("For best results please slowly move your input to all possible regions.")); }); m_informative_timer->setSingleShot(true); } diff --git a/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp b/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp index f902de35e5..bbbdbfb4ee 100644 --- a/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp +++ b/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -36,6 +35,7 @@ #include "DolphinQt/Config/Mapping/WiimoteEmuExtension.h" #include "DolphinQt/Config/Mapping/WiimoteEmuGeneral.h" #include "DolphinQt/Config/Mapping/WiimoteEmuMotionControl.h" +#include "DolphinQt/QtUtils/ModalMessageBox.h" #include "DolphinQt/QtUtils/WrapInScrollArea.h" #include "DolphinQt/Settings.h" @@ -161,19 +161,17 @@ void MappingWindow::OnDeleteProfilePressed() if (!File::Exists(profile_path.toStdString())) { - QMessageBox error(this); + ModalMessageBox error(this); error.setIcon(QMessageBox::Critical); - error.setWindowModality(Qt::WindowModal); error.setWindowTitle(tr("Error")); error.setText(tr("The profile '%1' does not exist").arg(profile_name)); error.exec(); return; } - QMessageBox confirm(this); + ModalMessageBox confirm(this); confirm.setIcon(QMessageBox::Warning); - confirm.setWindowModality(Qt::WindowModal); confirm.setWindowTitle(tr("Confirm")); confirm.setText(tr("Are you sure that you want to delete '%1'?").arg(profile_name)); confirm.setInformativeText(tr("This cannot be undone!")); @@ -188,7 +186,7 @@ void MappingWindow::OnDeleteProfilePressed() File::Delete(profile_path.toStdString()); - QMessageBox result(this); + ModalMessageBox result(this); result.setIcon(QMessageBox::Information); result.setWindowModality(Qt::WindowModal); result.setWindowTitle(tr("Success")); diff --git a/Source/Core/DolphinQt/Config/NewPatchDialog.cpp b/Source/Core/DolphinQt/Config/NewPatchDialog.cpp index 4b786b693d..429cab888d 100644 --- a/Source/Core/DolphinQt/Config/NewPatchDialog.cpp +++ b/Source/Core/DolphinQt/Config/NewPatchDialog.cpp @@ -9,13 +9,13 @@ #include #include #include -#include #include #include #include #include #include "Core/PatchEngine.h" +#include "DolphinQt/QtUtils/ModalMessageBox.h" NewPatchDialog::NewPatchDialog(QWidget* parent, PatchEngine::Patch& patch) : QDialog(parent), m_patch(patch) @@ -191,7 +191,7 @@ void NewPatchDialog::accept() { if (m_name_edit->text().isEmpty()) { - QMessageBox::critical(this, tr("Error"), tr("You have to enter a name.")); + ModalMessageBox::critical(this, tr("Error"), tr("You have to enter a name.")); return; } @@ -206,7 +206,7 @@ void NewPatchDialog::accept() if (!valid) { - QMessageBox::critical( + ModalMessageBox::critical( this, tr("Error"), tr("Some values you provided are invalid.\nPlease check the highlighted values.")); return; diff --git a/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp b/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp index 7cc88e8a23..4996560ae3 100644 --- a/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -27,6 +26,7 @@ #include "Core/HW/Memmap.h" #include "Core/PowerPC/PowerPC.h" #include "DolphinQt/Debugger/MemoryViewWidget.h" +#include "DolphinQt/QtUtils/ModalMessageBox.h" #include "DolphinQt/Settings.h" MemoryWidget::MemoryWidget(QWidget* parent) : QDockWidget(parent) @@ -399,13 +399,13 @@ void MemoryWidget::OnSetValue() if (!good_address) { - QMessageBox::critical(this, tr("Error"), tr("Bad address provided.")); + ModalMessageBox::critical(this, tr("Error"), tr("Bad address provided.")); return; } if (m_data_edit->text().isEmpty()) { - QMessageBox::critical(this, tr("Error"), tr("No value provided.")); + ModalMessageBox::critical(this, tr("Error"), tr("No value provided.")); return; } @@ -423,7 +423,7 @@ void MemoryWidget::OnSetValue() if (!good_value) { - QMessageBox::critical(this, tr("Error"), tr("Bad value provided.")); + ModalMessageBox::critical(this, tr("Error"), tr("Bad value provided.")); return; } @@ -455,7 +455,7 @@ static void DumpArray(const std::string& filename, const u8* data, size_t length if (!f) { - QMessageBox::critical( + ModalMessageBox::critical( nullptr, QObject::tr("Error"), QObject::tr("Failed to dump %1: Can't open file").arg(QString::fromStdString(filename))); return; @@ -463,9 +463,9 @@ static void DumpArray(const std::string& filename, const u8* data, size_t length if (!f.WriteBytes(data, length)) { - QMessageBox::critical(nullptr, QObject::tr("Error"), - QObject::tr("Failed to dump %1: Failed to write to file") - .arg(QString::fromStdString(filename))); + ModalMessageBox::critical(nullptr, QObject::tr("Error"), + QObject::tr("Failed to dump %1: Failed to write to file") + .arg(QString::fromStdString(filename))); } } diff --git a/Source/Core/DolphinQt/Debugger/NewBreakpointDialog.cpp b/Source/Core/DolphinQt/Debugger/NewBreakpointDialog.cpp index 6cf68babab..6271be807a 100644 --- a/Source/Core/DolphinQt/Debugger/NewBreakpointDialog.cpp +++ b/Source/Core/DolphinQt/Debugger/NewBreakpointDialog.cpp @@ -11,11 +11,11 @@ #include #include #include -#include #include #include #include "DolphinQt/Debugger/BreakpointWidget.h" +#include "DolphinQt/QtUtils/ModalMessageBox.h" NewBreakpointDialog::NewBreakpointDialog(BreakpointWidget* parent) : QDialog(parent), m_parent(parent) @@ -138,7 +138,8 @@ void NewBreakpointDialog::OnAddressTypeChanged() void NewBreakpointDialog::accept() { auto invalid_input = [this](QString field) { - QMessageBox::critical(this, tr("Error"), tr("Invalid input for the field \"%1\"").arg(field)); + ModalMessageBox::critical(this, tr("Error"), + tr("Invalid input for the field \"%1\"").arg(field)); }; bool instruction = m_instruction_bp->isChecked(); diff --git a/Source/Core/DolphinQt/Debugger/RegisterColumn.cpp b/Source/Core/DolphinQt/Debugger/RegisterColumn.cpp index 09c1b2562b..2aff88ef8d 100644 --- a/Source/Core/DolphinQt/Debugger/RegisterColumn.cpp +++ b/Source/Core/DolphinQt/Debugger/RegisterColumn.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include "DolphinQt/QtUtils/ModalMessageBox.h" RegisterColumn::RegisterColumn(RegisterType type, std::function get, std::function set) @@ -84,7 +84,7 @@ void RegisterColumn::SetValue() } if (!valid) - QMessageBox::critical(nullptr, QObject::tr("Error"), QObject::tr("Invalid input provided")); + ModalMessageBox::critical(nullptr, QObject::tr("Error"), QObject::tr("Invalid input provided")); else m_set_register(value); diff --git a/Source/Core/DolphinQt/Debugger/WatchWidget.cpp b/Source/Core/DolphinQt/Debugger/WatchWidget.cpp index d4bc8ae65a..a4c215fea9 100644 --- a/Source/Core/DolphinQt/Debugger/WatchWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/WatchWidget.cpp @@ -4,6 +4,12 @@ #include "DolphinQt/Debugger/WatchWidget.h" +#include +#include +#include +#include +#include + #include "Common/FileUtil.h" #include "Common/IniFile.h" #include "Core/ConfigManager.h" @@ -11,16 +17,10 @@ #include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PowerPC.h" +#include "DolphinQt/QtUtils/ModalMessageBox.h" #include "DolphinQt/Resources.h" #include "DolphinQt/Settings.h" -#include -#include -#include -#include -#include -#include - WatchWidget::WatchWidget(QWidget* parent) : QDockWidget(parent) { // i18n: This kind of "watch" is used for watching emulated memory. @@ -306,7 +306,7 @@ void WatchWidget::OnItemChanged(QTableWidgetItem* item) } else { - QMessageBox::critical(this, tr("Error"), tr("Invalid input provided")); + ModalMessageBox::critical(this, tr("Error"), tr("Invalid input provided")); } break; } diff --git a/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp b/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp index f71625bdb7..db3da8be27 100644 --- a/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp +++ b/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include diff --git a/Source/Core/DolphinQt/FIFO/FIFOPlayerWindow.cpp b/Source/Core/DolphinQt/FIFO/FIFOPlayerWindow.cpp index 9f4d8e281c..511a245e51 100644 --- a/Source/Core/DolphinQt/FIFO/FIFOPlayerWindow.cpp +++ b/Source/Core/DolphinQt/FIFO/FIFOPlayerWindow.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -25,6 +24,7 @@ #include "Core/FifoPlayer/FifoRecorder.h" #include "DolphinQt/FIFO/FIFOAnalyzer.h" +#include "DolphinQt/QtUtils/ModalMessageBox.h" #include "DolphinQt/QtUtils/QueueOnObject.h" #include "DolphinQt/Settings.h" @@ -205,10 +205,7 @@ void FIFOPlayerWindow::SaveRecording() if (!result) { - QMessageBox msg(QMessageBox::Critical, tr("Error"), tr("Failed to save FIFO log."), - QMessageBox::Ok, this); - msg.setWindowModality(Qt::WindowModal); - msg.exec(); + ModalMessageBox::critical(this, tr("Error"), tr("Failed to save FIFO log.")); } } diff --git a/Source/Core/DolphinQt/GCMemcardManager.cpp b/Source/Core/DolphinQt/GCMemcardManager.cpp index a130e4c333..b6e2a6fb2a 100644 --- a/Source/Core/DolphinQt/GCMemcardManager.cpp +++ b/Source/Core/DolphinQt/GCMemcardManager.cpp @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -27,6 +26,8 @@ #include "Core/HW/GCMemcard/GCMemcard.h" +#include "DolphinQt/QtUtils/ModalMessageBox.h" + constexpr u32 BANNER_WIDTH = 96; constexpr u32 ANIM_FRAME_WIDTH = 32; constexpr u32 IMAGE_HEIGHT = 32; @@ -306,10 +307,7 @@ void GCMemcardManager::ExportFiles(bool prompt) QString text = count == 1 ? tr("Successfully exported the save file.") : tr("Successfully exported the %1 save files.").arg(count); - QMessageBox msg(QMessageBox::Information, tr("Success"), text, QMessageBox::Ok, this); - msg.setWindowModality(Qt::WindowModal); - - msg.exec(); + ModalMessageBox::information(this, tr("Success"), text); } void GCMemcardManager::ExportAllFiles() @@ -333,10 +331,7 @@ void GCMemcardManager::ImportFile() if (result != SUCCESS) { - QMessageBox msg(QMessageBox::Critical, tr("Import failed"), - tr("Failed to import \"%1\".").arg(path), QMessageBox::Ok, this); - msg.setWindowModality(Qt::WindowModal); - msg.exec(); + ModalMessageBox::critical(this, tr("Import failed"), tr("Failed to import \"%1\".").arg(path)); return; } @@ -362,10 +357,7 @@ void GCMemcardManager::CopyFiles() if (result != SUCCESS) { - QMessageBox msg(QMessageBox::Warning, tr("Copy failed"), tr("Failed to copy file"), - QMessageBox::Ok, this); - msg.setWindowModality(Qt::WindowModal); - msg.exec(); + ModalMessageBox::warning(this, tr("Copy failed"), tr("Failed to copy file")); } } @@ -391,11 +383,8 @@ void GCMemcardManager::DeleteFiles() QString text = count == 1 ? tr("Do you want to delete the selected save file?") : tr("Do you want to delete the %1 selected save files?").arg(count); - QMessageBox msg(QMessageBox::Warning, tr("Question"), text, - QMessageBox::Yes | QMessageBox::Abort, this); - msg.setWindowModality(Qt::WindowModal); - - auto response = msg.exec(); + auto response = ModalMessageBox::question(this, tr("Question"), text); + ; if (response == QMessageBox::Abort) return; @@ -412,10 +401,7 @@ void GCMemcardManager::DeleteFiles() { if (memcard->RemoveFile(file_index) != SUCCESS) { - QMessageBox msg(QMessageBox::Warning, tr("Remove failed"), tr("Failed to remove file"), - QMessageBox::Ok, this); - msg.setWindowModality(Qt::WindowModal); - msg.exec(); + ModalMessageBox::warning(this, tr("Remove failed"), tr("Failed to remove file")); } } @@ -425,10 +411,7 @@ void GCMemcardManager::DeleteFiles() } else { - QMessageBox msg(QMessageBox::Information, tr("Success"), tr("Successfully deleted files."), - QMessageBox::Ok, this); - msg.setWindowModality(Qt::WindowModal); - msg.exec(); + ModalMessageBox::information(this, tr("Success"), tr("Successfully deleted files.")); } UpdateSlotTable(m_active_slot); diff --git a/Source/Core/DolphinQt/GameList/GameList.cpp b/Source/Core/DolphinQt/GameList/GameList.cpp index bcc6cf330b..3f92637640 100644 --- a/Source/Core/DolphinQt/GameList/GameList.cpp +++ b/Source/Core/DolphinQt/GameList/GameList.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -44,6 +43,7 @@ #include "DolphinQt/GameList/ListProxyModel.h" #include "DolphinQt/MenuBar.h" #include "DolphinQt/QtUtils/DoubleClickEventFilter.h" +#include "DolphinQt/QtUtils/ModalMessageBox.h" #include "DolphinQt/Resources.h" #include "DolphinQt/Settings.h" #include "DolphinQt/WiiUpdate.h" @@ -442,19 +442,12 @@ void GameList::ExportWiiSave() QString failed_str; for (const std::string& str : failed) failed_str.append(QStringLiteral("\n")).append(QString::fromStdString(str)); - QMessageBox msg(QMessageBox::Critical, tr("Save Export"), - tr("Failed to export the following save files:") + failed_str, QMessageBox::Ok, - this); - - msg.setWindowModality(Qt::WindowModal); - msg.exec(); + ModalMessageBox::critical(this, tr("Save Export"), + tr("Failed to export the following save files:") + failed_str); } else { - QMessageBox msg(QMessageBox::Information, tr("Save Export"), - tr("Successfully exported save files"), QMessageBox::Ok, this); - msg.setWindowModality(Qt::WindowModal); - msg.exec(); + ModalMessageBox::information(this, tr("Save Export"), tr("Successfully exported save files")); } } @@ -493,9 +486,8 @@ void GameList::CompressISO(bool decompress) if (!wii_warning_given && !decompress && file->GetPlatform() == DiscIO::Platform::WiiDisc) { - QMessageBox wii_warning(this); + ModalMessageBox wii_warning(this); wii_warning.setIcon(QMessageBox::Warning); - wii_warning.setWindowModality(Qt::WindowModal); wii_warning.setWindowTitle(tr("Confirm")); wii_warning.setText(tr("Are you sure?")); wii_warning.setInformativeText(tr( @@ -554,9 +546,8 @@ void GameList::CompressISO(bool decompress) QFileInfo dst_info = QFileInfo(dst_path); if (dst_info.exists()) { - QMessageBox confirm_replace(this); + ModalMessageBox confirm_replace(this); confirm_replace.setIcon(QMessageBox::Warning); - confirm_replace.setWindowModality(Qt::WindowModal); confirm_replace.setWindowTitle(tr("Confirm")); confirm_replace.setText(tr("The file %1 already exists.\n" "Do you wish to replace it?") @@ -602,13 +593,10 @@ void GameList::CompressISO(bool decompress) } } - QMessageBox msg(QMessageBox::Information, tr("Success"), - decompress ? tr("Successfully decompressed %n image(s).", "", files.size()) : - tr("Successfully compressed %n image(s).", "", files.size()), - QMessageBox::Ok, this); - - msg.setWindowModality(Qt::WindowModal); - msg.exec(); + ModalMessageBox::information(this, tr("Success"), + decompress ? + tr("Successfully decompressed %n image(s).", "", files.size()) : + tr("Successfully compressed %n image(s).", "", files.size())); } void GameList::InstallWAD() @@ -617,12 +605,11 @@ void GameList::InstallWAD() if (!game) return; - QMessageBox result_dialog(this); + ModalMessageBox result_dialog(this); const bool success = WiiUtils::InstallWAD(game->GetFilePath()); result_dialog.setIcon(success ? QMessageBox::Information : QMessageBox::Critical); - result_dialog.setWindowModality(Qt::WindowModal); result_dialog.setWindowTitle(success ? tr("Success") : tr("Failure")); result_dialog.setText(success ? tr("Successfully installed this title to the NAND.") : tr("Failed to install this title to the NAND.")); @@ -635,10 +622,9 @@ void GameList::UninstallWAD() if (!game) return; - QMessageBox warning_dialog(this); + ModalMessageBox warning_dialog(this); warning_dialog.setIcon(QMessageBox::Information); - warning_dialog.setWindowModality(Qt::WindowModal); warning_dialog.setWindowTitle(tr("Confirm")); warning_dialog.setText(tr("Uninstalling the WAD will remove the currently installed version of " "this title from the NAND without deleting its save data. Continue?")); @@ -647,12 +633,11 @@ void GameList::UninstallWAD() if (warning_dialog.exec() == QMessageBox::No) return; - QMessageBox result_dialog(this); + ModalMessageBox result_dialog(this); const bool success = WiiUtils::UninstallTitle(game->GetTitleID()); result_dialog.setIcon(success ? QMessageBox::Information : QMessageBox::Critical); - result_dialog.setWindowModality(Qt::WindowModal); result_dialog.setWindowTitle(success ? tr("Success") : tr("Failure")); result_dialog.setText(success ? tr("Successfully removed this title from the NAND.") : tr("Failed to remove this title from the NAND.")); @@ -692,12 +677,10 @@ void GameList::OpenSaveFolder() void GameList::DeleteFile() { - QMessageBox confirm_dialog(this); + ModalMessageBox confirm_dialog(this); confirm_dialog.setIcon(QMessageBox::Warning); - confirm_dialog.setWindowModality(Qt::WindowModal); confirm_dialog.setWindowTitle(tr("Confirm")); - confirm_dialog.setWindowModality(Qt::WindowModal); confirm_dialog.setText(tr("Are you sure you want to delete this file?")); confirm_dialog.setInformativeText(tr("This cannot be undone!")); confirm_dialog.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel); @@ -718,10 +701,9 @@ void GameList::DeleteFile() } else { - QMessageBox error_dialog(this); + ModalMessageBox error_dialog(this); error_dialog.setIcon(QMessageBox::Critical); - error_dialog.setWindowModality(Qt::WindowModal); error_dialog.setWindowTitle(tr("Failure")); error_dialog.setText(tr("Failed to delete the selected file.")); error_dialog.setInformativeText(tr("Check whether you have the permissions required to " diff --git a/Source/Core/DolphinQt/Main.cpp b/Source/Core/DolphinQt/Main.cpp index 96379c2476..7e5d0f5c25 100644 --- a/Source/Core/DolphinQt/Main.cpp +++ b/Source/Core/DolphinQt/Main.cpp @@ -12,30 +12,33 @@ #include #include #include -#include #include #include #include #include "Common/MsgHandler.h" + #include "Core/Analytics.h" #include "Core/Boot/Boot.h" #include "Core/ConfigManager.h" #include "Core/Core.h" + #include "DolphinQt/Host.h" #include "DolphinQt/MainWindow.h" +#include "DolphinQt/QtUtils/ModalMessageBox.h" #include "DolphinQt/QtUtils/RunOnObject.h" #include "DolphinQt/Resources.h" #include "DolphinQt/Settings.h" #include "DolphinQt/Translation.h" #include "DolphinQt/Updater.h" + #include "UICommon/CommandLineParse.h" #include "UICommon/UICommon.h" static bool QtMsgAlertHandler(const char* caption, const char* text, bool yes_no, MsgType style) { std::optional r = RunOnObject(QApplication::instance(), [&] { - QMessageBox message_box(QApplication::activeWindow()); + ModalMessageBox message_box(QApplication::activeWindow()); message_box.setWindowTitle(QString::fromUtf8(caption)); message_box.setText(QString::fromUtf8(text)); @@ -162,7 +165,7 @@ int main(int argc, char* argv[]) } else { - QMessageBox::critical(nullptr, QObject::tr("Error"), QObject::tr("Invalid title ID.")); + ModalMessageBox::critical(nullptr, QObject::tr("Error"), QObject::tr("Invalid title ID.")); } } else if (!args.empty()) @@ -183,10 +186,9 @@ int main(int argc, char* argv[]) #if defined(USE_ANALYTICS) && USE_ANALYTICS if (!SConfig::GetInstance().m_analytics_permission_asked) { - QMessageBox analytics_prompt(&win); + ModalMessageBox analytics_prompt(&win); analytics_prompt.setIcon(QMessageBox::Question); - analytics_prompt.setWindowModality(Qt::WindowModal); analytics_prompt.setStandardButtons(QMessageBox::Yes | QMessageBox::No); analytics_prompt.setWindowTitle(QObject::tr("Allow Usage Statistics Reporting")); analytics_prompt.setText( diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index b615e6a693..c1c95a2612 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -83,6 +82,7 @@ #include "DolphinQt/MenuBar.h" #include "DolphinQt/NetPlay/NetPlayDialog.h" #include "DolphinQt/NetPlay/NetPlaySetupDialog.h" +#include "DolphinQt/QtUtils/ModalMessageBox.h" #include "DolphinQt/QtUtils/QueueOnObject.h" #include "DolphinQt/QtUtils/RunOnObject.h" #include "DolphinQt/QtUtils/WindowActivationEventFilter.h" @@ -142,7 +142,7 @@ static WindowSystemType GetWindowSystemType() else if (platform_name == QStringLiteral("wayland")) return WindowSystemType::Wayland; - QMessageBox::critical( + ModalMessageBox::critical( nullptr, QStringLiteral("Error"), QString::asprintf("Unknown Qt platform: %s", platform_name.toStdString().c_str())); return WindowSystemType::Headless; @@ -227,16 +227,17 @@ MainWindow::MainWindow(std::unique_ptr boot_parameters) : QMainW Settings::Instance().RefreshWidgetVisibility(); if (!ResourcePack::Init()) - QMessageBox::critical(this, tr("Error"), tr("Error occured while loading some texture packs")); + ModalMessageBox::critical(this, tr("Error"), + tr("Error occured while loading some texture packs")); for (auto& pack : ResourcePack::GetPacks()) { if (!pack.IsValid()) { - QMessageBox::critical(this, tr("Error"), - tr("Invalid Pack %1 provided: %2") - .arg(QString::fromStdString(pack.GetPath())) - .arg(QString::fromStdString(pack.GetError()))); + ModalMessageBox::critical(this, tr("Error"), + tr("Invalid Pack %1 provided: %2") + .arg(QString::fromStdString(pack.GetPath())) + .arg(QString::fromStdString(pack.GetError()))); return; } } @@ -759,13 +760,12 @@ bool MainWindow::RequestStop() if (pause) Core::SetState(Core::State::Paused); - QMessageBox::StandardButton confirm; - confirm = QMessageBox::question(this, tr("Confirm"), - m_stop_requested ? - tr("A shutdown is already in progress. Unsaved data " - "may be lost if you stop the current emulation " - "before it completes. Force stop?") : - tr("Do you want to stop the current emulation?")); + auto confirm = ModalMessageBox::question( + this, tr("Confirm"), + m_stop_requested ? tr("A shutdown is already in progress. Unsaved data " + "may be lost if you stop the current emulation " + "before it completes. Force stop?") : + tr("Do you want to stop the current emulation?")); if (confirm != QMessageBox::Yes) { @@ -908,7 +908,7 @@ void MainWindow::StartGame(std::unique_ptr&& parameters) if (!BootManager::BootCore(std::move(parameters), GetWindowSystemInfo(m_render_widget->windowHandle()))) { - QMessageBox::critical(this, tr("Error"), tr("Failed to init core"), QMessageBox::Ok); + ModalMessageBox::critical(this, tr("Error"), tr("Failed to init core"), QMessageBox::Ok); HideRenderWidget(); return; } @@ -1231,7 +1231,7 @@ bool MainWindow::NetPlayJoin() { if (Core::IsRunning()) { - QMessageBox::critical( + ModalMessageBox::critical( nullptr, QObject::tr("Error"), QObject::tr("Can't start a NetPlay Session while a game is still running!")); return false; @@ -1239,8 +1239,8 @@ bool MainWindow::NetPlayJoin() if (m_netplay_dialog->isVisible()) { - QMessageBox::critical(nullptr, QObject::tr("Error"), - QObject::tr("A NetPlay Session is already in progress!")); + ModalMessageBox::critical(nullptr, QObject::tr("Error"), + QObject::tr("A NetPlay Session is already in progress!")); return false; } @@ -1302,7 +1302,7 @@ bool MainWindow::NetPlayHost(const QString& game_id) { if (Core::IsRunning()) { - QMessageBox::critical( + ModalMessageBox::critical( nullptr, QObject::tr("Error"), QObject::tr("Can't start a NetPlay Session while a game is still running!")); return false; @@ -1310,8 +1310,8 @@ bool MainWindow::NetPlayHost(const QString& game_id) if (m_netplay_dialog->isVisible()) { - QMessageBox::critical(nullptr, QObject::tr("Error"), - QObject::tr("A NetPlay Session is already in progress!")); + ModalMessageBox::critical(nullptr, QObject::tr("Error"), + QObject::tr("A NetPlay Session is already in progress!")); return false; } @@ -1334,7 +1334,7 @@ bool MainWindow::NetPlayHost(const QString& game_id) if (!Settings::Instance().GetNetPlayServer()->is_connected) { - QMessageBox::critical( + ModalMessageBox::critical( nullptr, QObject::tr("Failed to open server"), QObject::tr( "Failed to listen on port %1. Is another instance of the NetPlay server running?") @@ -1404,7 +1404,7 @@ void MainWindow::dropEvent(QDropEvent* event) if (!file_info.exists() || !file_info.isReadable()) { - QMessageBox::critical(this, tr("Error"), tr("Failed to open '%1'").arg(path)); + ModalMessageBox::critical(this, tr("Error"), tr("Failed to open '%1'").arg(path)); return; } @@ -1424,7 +1424,7 @@ void MainWindow::dropEvent(QDropEvent* event) { if (show_confirm) { - if (QMessageBox::question( + if (ModalMessageBox::question( this, tr("Confirm"), tr("Do you want to add \"%1\" to the list of Game Paths?").arg(folder)) != QMessageBox::Yes) @@ -1447,7 +1447,7 @@ void MainWindow::OnBootGameCubeIPL(DiscIO::Region region) void MainWindow::OnImportNANDBackup() { - auto response = QMessageBox::question( + auto response = ModalMessageBox::question( this, tr("Question"), tr("Merging a new NAND over your currently selected NAND will overwrite any channels " "and savegames that already exist. This process is not reversible, so it is " diff --git a/Source/Core/DolphinQt/MenuBar.cpp b/Source/Core/DolphinQt/MenuBar.cpp index 8b38e6abe2..3a6bef079b 100644 --- a/Source/Core/DolphinQt/MenuBar.cpp +++ b/Source/Core/DolphinQt/MenuBar.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include "Common/CommonPaths.h" @@ -49,6 +48,7 @@ #include "DolphinQt/AboutDialog.h" #include "DolphinQt/Host.h" +#include "DolphinQt/QtUtils/ModalMessageBox.h" #include "DolphinQt/Settings.h" #include "DolphinQt/Updater.h" @@ -519,7 +519,7 @@ void MenuBar::InstallUpdateManually() if (!updater->CheckForUpdate()) { - QMessageBox::information( + ModalMessageBox::information( this, tr("Update"), tr("You are running the latest version available on this update track.")); } @@ -969,23 +969,18 @@ void MenuBar::InstallWAD() if (wad_file.isEmpty()) return; - QMessageBox result_dialog(this); + ModalMessageBox result_dialog(this); if (WiiUtils::InstallWAD(wad_file.toStdString())) { Settings::Instance().NANDRefresh(); - result_dialog.setIcon(QMessageBox::Information); - result_dialog.setWindowTitle(tr("Success")); - result_dialog.setText(tr("Successfully installed this title to the NAND.")); + ModalMessageBox::information(this, tr("Success"), + tr("Successfully installed this title to the NAND.")); } else { - result_dialog.setIcon(QMessageBox::Critical); - result_dialog.setWindowTitle(tr("Failure")); - result_dialog.setText(tr("Failed to install this title to the NAND.")); + ModalMessageBox::critical(this, tr("Failure"), tr("Failed to install this title to the NAND.")); } - - result_dialog.exec(); } void MenuBar::ImportWiiSave() @@ -999,7 +994,7 @@ void MenuBar::ImportWiiSave() bool cancelled = false; auto can_overwrite = [&] { - bool yes = QMessageBox::question( + bool yes = ModalMessageBox::question( this, tr("Save Import"), tr("Save data for this title already exists in the NAND. Consider backing up " "the current data before overwriting.\nOverwrite now?")) == QMessageBox::Yes; @@ -1007,9 +1002,9 @@ void MenuBar::ImportWiiSave() return yes; }; if (WiiSave::Import(file.toStdString(), can_overwrite)) - QMessageBox::information(this, tr("Save Import"), tr("Successfully imported save files.")); + ModalMessageBox::information(this, tr("Save Import"), tr("Successfully imported save files.")); else if (!cancelled) - QMessageBox::critical(this, tr("Save Import"), tr("Failed to import save files.")); + ModalMessageBox::critical(this, tr("Save Import"), tr("Failed to import save files.")); } void MenuBar::ExportWiiSaves() @@ -1021,8 +1016,8 @@ void MenuBar::ExportWiiSaves() return; const size_t count = WiiSave::ExportAll(export_dir.toStdString()); - QMessageBox::information(this, tr("Save Export"), - tr("Exported %n save(s)", "", static_cast(count))); + ModalMessageBox::information(this, tr("Save Export"), + tr("Exported %n save(s)", "", static_cast(count))); } void MenuBar::CheckNAND() @@ -1031,7 +1026,7 @@ void MenuBar::CheckNAND() WiiUtils::NANDCheckResult result = WiiUtils::CheckNAND(ios); if (!result.bad) { - QMessageBox::information(this, tr("NAND Check"), tr("No issues have been detected.")); + ModalMessageBox::information(this, tr("NAND Check"), tr("No issues have been detected.")); return; } @@ -1075,30 +1070,30 @@ void MenuBar::CheckNAND() .arg(QString::fromStdString(title_listings)); } - if (QMessageBox::question(this, tr("NAND Check"), message) != QMessageBox::Yes) + if (ModalMessageBox::question(this, tr("NAND Check"), message) != QMessageBox::Yes) return; if (WiiUtils::RepairNAND(ios)) { - QMessageBox::information(this, tr("NAND Check"), tr("The NAND has been repaired.")); + ModalMessageBox::information(this, tr("NAND Check"), tr("The NAND has been repaired.")); return; } - QMessageBox::critical(this, tr("NAND Check"), - tr("The NAND could not be repaired. It is recommended to back up " - "your current data and start over with a fresh NAND.")); + ModalMessageBox::critical(this, tr("NAND Check"), + tr("The NAND could not be repaired. It is recommended to back up " + "your current data and start over with a fresh NAND.")); } void MenuBar::NANDExtractCertificates() { if (DiscIO::NANDImporter().ExtractCertificates(File::GetUserPath(D_WIIROOT_IDX))) { - QMessageBox::information(this, tr("Success"), - tr("Successfully extracted certificates from NAND")); + ModalMessageBox::information(this, tr("Success"), + tr("Successfully extracted certificates from NAND")); } else { - QMessageBox::critical(this, tr("Error"), tr("Failed to extract certificates from NAND")); + ModalMessageBox::critical(this, tr("Error"), tr("Failed to extract certificates from NAND")); } } @@ -1133,9 +1128,9 @@ void MenuBar::ChangeDebugFont() void MenuBar::ClearSymbols() { - auto result = QMessageBox::warning(this, tr("Confirmation"), - tr("Do you want to clear the list of symbol names?"), - QMessageBox::Yes | QMessageBox::Cancel); + auto result = ModalMessageBox::warning(this, tr("Confirmation"), + tr("Do you want to clear the list of symbol names?"), + QMessageBox::Yes | QMessageBox::Cancel); if (result == QMessageBox::Cancel) return; @@ -1157,14 +1152,14 @@ void MenuBar::GenerateSymbolsFromSignatureDB() if (db.Load(File::GetSysDirectory() + TOTALDB)) { db.Apply(&g_symbolDB); - QMessageBox::information( + ModalMessageBox::information( this, tr("Information"), tr("Generated symbol names from '%1'").arg(QString::fromStdString(TOTALDB))); db.List(); } else { - QMessageBox::critical( + ModalMessageBox::critical( this, tr("Error"), tr("'%1' not found, no symbol names generated").arg(QString::fromStdString(TOTALDB))); } @@ -1180,7 +1175,7 @@ void MenuBar::GenerateSymbolsFromRSO() if (!good) { - QMessageBox::warning(this, tr("Error"), tr("Invalid RSO module address: %1").arg(text)); + ModalMessageBox::warning(this, tr("Error"), tr("Invalid RSO module address: %1").arg(text)); return; } @@ -1192,7 +1187,7 @@ void MenuBar::GenerateSymbolsFromRSO() } else { - QMessageBox::warning(this, tr("Error"), tr("Failed to load RSO module at %1").arg(text)); + ModalMessageBox::warning(this, tr("Error"), tr("Failed to load RSO module at %1").arg(text)); } } @@ -1209,9 +1204,9 @@ void MenuBar::LoadSymbolMap() if (db.Load(File::GetSysDirectory() + TOTALDB)) db.Apply(&g_symbolDB); - QMessageBox::warning(this, tr("Warning"), - tr("'%1' not found, scanning for common functions instead") - .arg(QString::fromStdString(writable_map_file))); + ModalMessageBox::warning(this, tr("Warning"), + tr("'%1' not found, scanning for common functions instead") + .arg(QString::fromStdString(writable_map_file))); } else { @@ -1220,8 +1215,8 @@ void MenuBar::LoadSymbolMap() if (!TryLoadMapFile(existing_map_file_path)) return; - QMessageBox::information(this, tr("Information"), - tr("Loaded symbols from '%1'").arg(existing_map_file_path)); + ModalMessageBox::information(this, tr("Information"), + tr("Loaded symbols from '%1'").arg(existing_map_file_path)); } HLE::PatchFunctions(); @@ -1292,7 +1287,7 @@ void MenuBar::SaveCode() if (!g_symbolDB.SaveCodeMap(path)) { - QMessageBox::warning( + ModalMessageBox::warning( this, tr("Error"), tr("Failed to save code map to path '%1'").arg(QString::fromStdString(path))); } @@ -1302,7 +1297,7 @@ bool MenuBar::TryLoadMapFile(const QString& path, const bool bad) { if (!g_symbolDB.LoadMap(path.toStdString(), bad)) { - QMessageBox::warning(this, tr("Error"), tr("Failed to load map file '%1'").arg(path)); + ModalMessageBox::warning(this, tr("Error"), tr("Failed to load map file '%1'").arg(path)); return false; } @@ -1314,7 +1309,8 @@ void MenuBar::TrySaveSymbolMap(const QString& path) if (g_symbolDB.SaveSymbolMap(path.toStdString())) return; - QMessageBox::warning(this, tr("Error"), tr("Failed to save symbol map to path '%1'").arg(path)); + ModalMessageBox::warning(this, tr("Error"), + tr("Failed to save symbol map to path '%1'").arg(path)); } void MenuBar::CreateSignatureFile() @@ -1334,7 +1330,7 @@ void MenuBar::CreateSignatureFile() if (!db.Save(save_path)) { - QMessageBox::warning(this, tr("Error"), tr("Failed to save signature file '%1'").arg(file)); + ModalMessageBox::warning(this, tr("Error"), tr("Failed to save signature file '%1'").arg(file)); return; } @@ -1359,8 +1355,8 @@ void MenuBar::AppendSignatureFile() db.Load(signature_path); if (!db.Save(signature_path)) { - QMessageBox::warning(this, tr("Error"), - tr("Failed to append to signature file '%1'").arg(file)); + ModalMessageBox::warning(this, tr("Error"), + tr("Failed to append to signature file '%1'").arg(file)); return; } @@ -1412,8 +1408,8 @@ void MenuBar::CombineSignatureFiles() db.Load(load_pathSecondaryFile); if (!db.Save(save_path)) { - QMessageBox::warning(this, tr("Error"), - tr("Failed to save to signature file '%1'").arg(saveFile)); + ModalMessageBox::warning(this, tr("Error"), + tr("Failed to save to signature file '%1'").arg(saveFile)); return; } diff --git a/Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp b/Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp index 9353e1a843..f281e40bfd 100644 --- a/Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp +++ b/Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -48,6 +47,7 @@ #include "DolphinQt/NetPlay/MD5Dialog.h" #include "DolphinQt/NetPlay/PadMappingDialog.h" #include "DolphinQt/QtUtils/FlowLayout.h" +#include "DolphinQt/QtUtils/ModalMessageBox.h" #include "DolphinQt/QtUtils/QueueOnObject.h" #include "DolphinQt/QtUtils/RunOnObject.h" #include "DolphinQt/Resources.h" @@ -383,15 +383,15 @@ void NetPlayDialog::OnStart() { if (!Settings::Instance().GetNetPlayClient()->DoAllPlayersHaveGame()) { - if (QMessageBox::question(this, tr("Warning"), - tr("Not all players have the game. Do you really want to start?")) == - QMessageBox::No) + if (ModalMessageBox::question( + this, tr("Warning"), + tr("Not all players have the game. Do you really want to start?")) == QMessageBox::No) return; } if (m_strict_settings_sync_box->isChecked() && Config::Get(Config::GFX_EFB_SCALE) == 0) { - QMessageBox::critical( + ModalMessageBox::critical( this, tr("Error"), tr("Auto internal resolution is not allowed in strict sync mode, as it depends on window " "size.\n\nPlease select a specific internal resolution.")); @@ -491,8 +491,8 @@ void NetPlayDialog::OnStart() void NetPlayDialog::reject() { - if (QMessageBox::question(this, tr("Confirmation"), - tr("Are you sure you want to quit NetPlay?")) == QMessageBox::Yes) + if (ModalMessageBox::question(this, tr("Confirmation"), + tr("Are you sure you want to quit NetPlay?")) == QMessageBox::Yes) { QDialog::reject(); } @@ -922,8 +922,8 @@ void NetPlayDialog::OnConnectionLost() void NetPlayDialog::OnConnectionError(const std::string& message) { QueueOnObject(this, [this, message] { - QMessageBox::critical(this, tr("Error"), - tr("Failed to connect to server: %1").arg(tr(message.c_str()))); + ModalMessageBox::critical(this, tr("Error"), + tr("Failed to connect to server: %1").arg(tr(message.c_str()))); }); } @@ -933,12 +933,12 @@ void NetPlayDialog::OnTraversalError(TraversalClient::FailureReason error) switch (error) { case TraversalClient::FailureReason::BadHost: - QMessageBox::critical(this, tr("Traversal Error"), tr("Couldn't look up central server")); + ModalMessageBox::critical(this, tr("Traversal Error"), tr("Couldn't look up central server")); QDialog::reject(); break; case TraversalClient::FailureReason::VersionTooOld: - QMessageBox::critical(this, tr("Traversal Error"), - tr("Dolphin is too old for traversal server")); + ModalMessageBox::critical(this, tr("Traversal Error"), + tr("Dolphin is too old for traversal server")); QDialog::reject(); break; case TraversalClient::FailureReason::ServerForgotAboutUs: diff --git a/Source/Core/DolphinQt/NetPlay/NetPlaySetupDialog.cpp b/Source/Core/DolphinQt/NetPlay/NetPlaySetupDialog.cpp index e6b34cbe5c..b960a99dd5 100644 --- a/Source/Core/DolphinQt/NetPlay/NetPlaySetupDialog.cpp +++ b/Source/Core/DolphinQt/NetPlay/NetPlaySetupDialog.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -20,6 +19,7 @@ #include "Core/Config/NetplaySettings.h" #include "DolphinQt/GameList/GameListModel.h" +#include "DolphinQt/QtUtils/ModalMessageBox.h" #include "DolphinQt/Settings.h" NetPlaySetupDialog::NetPlaySetupDialog(QWidget* parent) @@ -269,7 +269,7 @@ void NetPlaySetupDialog::accept() auto items = m_host_games->selectedItems(); if (items.empty()) { - QMessageBox::critical(this, tr("Error"), tr("You must select a game to host!")); + ModalMessageBox::critical(this, tr("Error"), tr("You must select a game to host!")); return; } @@ -310,7 +310,7 @@ void NetPlaySetupDialog::ResetTraversalHost() Config::SetBaseOrCurrent(Config::NETPLAY_TRAVERSAL_PORT, Config::NETPLAY_TRAVERSAL_PORT.default_value); - QMessageBox::information( + ModalMessageBox::information( this, tr("Reset Traversal Server"), tr("Reset Traversal Server to %1:%2") .arg(QString::fromStdString(Config::NETPLAY_TRAVERSAL_SERVER.default_value), diff --git a/Source/Core/DolphinQt/RenderWidget.cpp b/Source/Core/DolphinQt/RenderWidget.cpp index 460a983da4..d501370843 100644 --- a/Source/Core/DolphinQt/RenderWidget.cpp +++ b/Source/Core/DolphinQt/RenderWidget.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -24,6 +23,7 @@ #include "Core/State.h" #include "DolphinQt/Host.h" +#include "DolphinQt/QtUtils/ModalMessageBox.h" #include "DolphinQt/RenderWidget.h" #include "DolphinQt/Resources.h" #include "DolphinQt/Settings.h" @@ -112,7 +112,7 @@ void RenderWidget::dropEvent(QDropEvent* event) if (!file_info.exists() || !file_info.isReadable()) { - QMessageBox::critical(this, tr("Error"), tr("Failed to open '%1'").arg(path)); + ModalMessageBox::critical(this, tr("Error"), tr("Failed to open '%1'").arg(path)); return; } diff --git a/Source/Core/DolphinQt/ResourcePackManager.cpp b/Source/Core/DolphinQt/ResourcePackManager.cpp index 719a4257b0..7e2adb7675 100644 --- a/Source/Core/DolphinQt/ResourcePackManager.cpp +++ b/Source/Core/DolphinQt/ResourcePackManager.cpp @@ -8,12 +8,12 @@ #include #include #include -#include #include #include #include #include "Common/FileUtil.h" +#include "DolphinQt/QtUtils/ModalMessageBox.h" #include "UICommon/ResourcePack/Manager.h" ResourcePackManager::ResourcePackManager(QWidget* widget) : QDialog(widget) @@ -196,7 +196,7 @@ void ResourcePackManager::Install() if (!success) { - QMessageBox::critical( + ModalMessageBox::critical( this, tr("Error"), tr("Failed to install pack: %1").arg(QString::fromStdString(item.GetError()))); } @@ -217,7 +217,7 @@ void ResourcePackManager::Uninstall() if (!success) { - QMessageBox::critical( + ModalMessageBox::critical( this, tr("Error"), tr("Failed to uninstall pack: %1").arg(QString::fromStdString(item.GetError()))); } @@ -232,7 +232,7 @@ void ResourcePackManager::Remove() if (items.empty()) return; - QMessageBox box(this); + ModalMessageBox box(this); box.setWindowTitle(tr("Confirmation")); box.setText(tr("Are you sure you want to delete this pack?")); box.setIcon(QMessageBox::Warning); diff --git a/Source/Core/DolphinQt/Settings/GameCubePane.cpp b/Source/Core/DolphinQt/Settings/GameCubePane.cpp index 3c9f1657bb..444e493e64 100644 --- a/Source/Core/DolphinQt/Settings/GameCubePane.cpp +++ b/Source/Core/DolphinQt/Settings/GameCubePane.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include @@ -29,6 +28,7 @@ #include "Core/HW/GCMemcard/GCMemcard.h" #include "DolphinQt/Config/Mapping/MappingWindow.h" +#include "DolphinQt/QtUtils/ModalMessageBox.h" enum { @@ -216,10 +216,10 @@ void GameCubePane::OnConfigPressed(int slot) if (!mc.IsValid()) { - QMessageBox::critical(this, tr("Error"), - tr("Cannot use that file as a memory card.\n%1\n" - "is not a valid GameCube memory card file") - .arg(filename)); + ModalMessageBox::critical(this, tr("Error"), + tr("Cannot use that file as a memory card.\n%1\n" + "is not a valid GameCube memory card file") + .arg(filename)); return; } @@ -237,7 +237,8 @@ void GameCubePane::OnConfigPressed(int slot) if (path_abs == path_b) { - QMessageBox::critical(this, tr("Error"), tr("The same file can't be used in both slots.")); + ModalMessageBox::critical(this, tr("Error"), + tr("The same file can't be used in both slots.")); return; } } diff --git a/Source/Core/DolphinQt/Settings/GeneralPane.cpp b/Source/Core/DolphinQt/Settings/GeneralPane.cpp index 791c024618..ff2c4a4a25 100644 --- a/Source/Core/DolphinQt/Settings/GeneralPane.cpp +++ b/Source/Core/DolphinQt/Settings/GeneralPane.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -25,6 +24,7 @@ #include "Core/Core.h" #include "Core/PowerPC/PowerPC.h" +#include "DolphinQt/QtUtils/ModalMessageBox.h" #include "DolphinQt/Settings.h" #include "UICommon/AutoUpdate.h" @@ -324,9 +324,8 @@ void GeneralPane::GenerateNewIdentity() { DolphinAnalytics::Instance()->GenerateNewIdentity(); DolphinAnalytics::Instance()->ReloadConfig(); - QMessageBox message_box(this); + ModalMessageBox message_box(this); message_box.setIcon(QMessageBox::Information); - message_box.setWindowModality(Qt::WindowModal); message_box.setWindowTitle(tr("Identity Generation")); message_box.setText(tr("New identity generated.")); message_box.exec(); diff --git a/Source/Core/DolphinQt/Settings/InterfacePane.cpp b/Source/Core/DolphinQt/Settings/InterfacePane.cpp index 747f185bbe..7c5ade5225 100644 --- a/Source/Core/DolphinQt/Settings/InterfacePane.cpp +++ b/Source/Core/DolphinQt/Settings/InterfacePane.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include @@ -24,6 +23,7 @@ #include "Core/ConfigManager.h" #include "DolphinQt/GameList/GameListModel.h" +#include "DolphinQt/QtUtils/ModalMessageBox.h" #include "DolphinQt/Settings.h" #include "UICommon/GameFile.h" @@ -269,12 +269,9 @@ void InterfacePane::OnSaveConfig() if (new_language != SConfig::GetInstance().m_InterfaceLanguage) { SConfig::GetInstance().m_InterfaceLanguage = new_language; - QMessageBox msg(QMessageBox::Information, tr("Restart Required"), - tr("You must restart Dolphin in order for the change to take effect."), - QMessageBox::Ok, this); - - msg.setWindowModality(Qt::WindowModal); - msg.exec(); + ModalMessageBox::information( + this, tr("Restart Required"), + tr("You must restart Dolphin in order for the change to take effect.")); } const bool use_covers = m_checkbox_use_covers->isChecked(); diff --git a/Source/Core/DolphinQt/Settings/USBDeviceAddToWhitelistDialog.cpp b/Source/Core/DolphinQt/Settings/USBDeviceAddToWhitelistDialog.cpp index 05811bc34b..1340fccb14 100644 --- a/Source/Core/DolphinQt/Settings/USBDeviceAddToWhitelistDialog.cpp +++ b/Source/Core/DolphinQt/Settings/USBDeviceAddToWhitelistDialog.cpp @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -23,6 +22,7 @@ #include "Core/ConfigManager.h" +#include "DolphinQt/QtUtils/ModalMessageBox.h" #include "DolphinQt/Settings/WiiPane.h" #include "UICommon/USBUtils.h" @@ -129,9 +129,8 @@ void USBDeviceAddToWhitelistDialog::AddUSBDeviceToWhitelist() if (!IsValidUSBIDString(vid_string)) { // i18n: Here, VID means Vendor ID (for a USB device). - QMessageBox vid_warning_box(this); + ModalMessageBox vid_warning_box(this); vid_warning_box.setIcon(QMessageBox::Warning); - vid_warning_box.setWindowModality(Qt::WindowModal); vid_warning_box.setWindowTitle(tr("USB Whitelist Error")); // i18n: Here, VID means Vendor ID (for a USB device). vid_warning_box.setText(tr("The entered VID is invalid.")); @@ -142,9 +141,8 @@ void USBDeviceAddToWhitelistDialog::AddUSBDeviceToWhitelist() if (!IsValidUSBIDString(pid_string)) { // i18n: Here, PID means Product ID (for a USB device). - QMessageBox pid_warning_box(this); + ModalMessageBox pid_warning_box(this); pid_warning_box.setIcon(QMessageBox::Warning); - pid_warning_box.setWindowModality(Qt::WindowModal); pid_warning_box.setWindowTitle(tr("USB Whitelist Error")); // i18n: Here, PID means Product ID (for a USB device). pid_warning_box.setText(tr("The entered PID is invalid.")); @@ -158,12 +156,7 @@ void USBDeviceAddToWhitelistDialog::AddUSBDeviceToWhitelist() if (SConfig::GetInstance().IsUSBDeviceWhitelisted({vid, pid})) { - QMessageBox error_box(this); - error_box.setIcon(QMessageBox::Warning); - error_box.setWindowModality(Qt::WindowModal); - error_box.setWindowTitle(tr("USB Whitelist Error")); - error_box.setText(tr("This USB device is already whitelisted.")); - error_box.exec(); + ModalMessageBox::critical(this, tr("Error"), tr("This USB device is already whitelisted.")); return; } SConfig::GetInstance().m_usb_passthrough_devices.emplace(vid, pid); diff --git a/Source/Core/DolphinQt/Translation.cpp b/Source/Core/DolphinQt/Translation.cpp index e7c5ec1c65..6b484139a6 100644 --- a/Source/Core/DolphinQt/Translation.cpp +++ b/Source/Core/DolphinQt/Translation.cpp @@ -6,7 +6,6 @@ #include #include -#include #include #include #include @@ -20,6 +19,8 @@ #include "Core/ConfigManager.h" +#include "DolphinQt/QtUtils/ModalMessageBox.h" + #include "UICommon/UICommon.h" constexpr u32 MO_MAGIC_NUMBER = 0x950412de; @@ -300,7 +301,7 @@ void Translation::Initialize() if (TryInstallTranslator(QString::fromStdString(configured_language))) return; - QMessageBox::warning( + ModalMessageBox::warning( nullptr, QObject::tr("Error"), QObject::tr("Error loading selected language. Falling back to system default.")); configured_language.clear(); diff --git a/Source/Core/DolphinQt/Updater.cpp b/Source/Core/DolphinQt/Updater.cpp index b93e587a73..788c5d8c0f 100644 --- a/Source/Core/DolphinQt/Updater.cpp +++ b/Source/Core/DolphinQt/Updater.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include diff --git a/Source/Core/DolphinQt/WiiUpdate.cpp b/Source/Core/DolphinQt/WiiUpdate.cpp index 7eef30460c..78a8f9f5d5 100644 --- a/Source/Core/DolphinQt/WiiUpdate.cpp +++ b/Source/Core/DolphinQt/WiiUpdate.cpp @@ -8,7 +8,6 @@ #include #include -#include #include #include #include @@ -21,6 +20,7 @@ #include "DiscIO/NANDImporter.h" +#include "DolphinQt/QtUtils/ModalMessageBox.h" #include "DolphinQt/QtUtils/QueueOnObject.h" namespace WiiUpdate @@ -30,47 +30,48 @@ static void ShowResult(QWidget* parent, WiiUtils::UpdateResult result) switch (result) { case WiiUtils::UpdateResult::Succeeded: - QMessageBox::information(parent, QObject::tr("Update completed"), - QObject::tr("The emulated Wii console has been updated.")); + ModalMessageBox::information(parent, QObject::tr("Update completed"), + QObject::tr("The emulated Wii console has been updated.")); DiscIO::NANDImporter().ExtractCertificates(File::GetUserPath(D_WIIROOT_IDX)); break; case WiiUtils::UpdateResult::AlreadyUpToDate: - QMessageBox::information(parent, QObject::tr("Update completed"), - QObject::tr("The emulated Wii console is already up-to-date.")); + ModalMessageBox::information(parent, QObject::tr("Update completed"), + QObject::tr("The emulated Wii console is already up-to-date.")); DiscIO::NANDImporter().ExtractCertificates(File::GetUserPath(D_WIIROOT_IDX)); break; case WiiUtils::UpdateResult::ServerFailed: - QMessageBox::critical(parent, QObject::tr("Update failed"), - QObject::tr("Could not download update information from Nintendo. " - "Please check your Internet connection and try again.")); + ModalMessageBox::critical(parent, QObject::tr("Update failed"), + QObject::tr("Could not download update information from Nintendo. " + "Please check your Internet connection and try again.")); break; case WiiUtils::UpdateResult::DownloadFailed: - QMessageBox::critical(parent, QObject::tr("Update failed"), - QObject::tr("Could not download update files from Nintendo. " - "Please check your Internet connection and try again.")); + ModalMessageBox::critical(parent, QObject::tr("Update failed"), + QObject::tr("Could not download update files from Nintendo. " + "Please check your Internet connection and try again.")); break; case WiiUtils::UpdateResult::ImportFailed: - QMessageBox::critical(parent, QObject::tr("Update failed"), - QObject::tr("Could not install an update to the Wii system memory. " - "Please refer to logs for more information.")); + ModalMessageBox::critical(parent, QObject::tr("Update failed"), + QObject::tr("Could not install an update to the Wii system memory. " + "Please refer to logs for more information.")); break; case WiiUtils::UpdateResult::Cancelled: - QMessageBox::warning( + ModalMessageBox::warning( parent, QObject::tr("Update cancelled"), QObject::tr("The update has been cancelled. It is strongly recommended to " "finish it in order to avoid inconsistent system software versions.")); break; case WiiUtils::UpdateResult::RegionMismatch: - QMessageBox::critical(parent, QObject::tr("Update failed"), - QObject::tr("The game's region does not match your console's. " - "To avoid issues with the system menu, it is not possible " - "to update the emulated console using this disc.")); + ModalMessageBox::critical( + parent, QObject::tr("Update failed"), + QObject::tr("The game's region does not match your console's. " + "To avoid issues with the system menu, it is not possible " + "to update the emulated console using this disc.")); break; case WiiUtils::UpdateResult::MissingUpdatePartition: case WiiUtils::UpdateResult::DiscReadFailed: - QMessageBox::critical(parent, QObject::tr("Update failed"), - QObject::tr("The game disc does not contain any usable " - "update information.")); + ModalMessageBox::critical(parent, QObject::tr("Update failed"), + QObject::tr("The game disc does not contain any usable " + "update information.")); break; } } @@ -133,7 +134,7 @@ static WiiUtils::UpdateResult ShowProgress(QWidget* parent, Callable function, A void PerformOnlineUpdate(const std::string& region, QWidget* parent) { - const int confirm = QMessageBox::question( + const int confirm = ModalMessageBox::question( parent, QObject::tr("Confirm"), QObject::tr("Connect to the Internet and perform an online system update?")); if (confirm != QMessageBox::Yes)