Merge pull request #7849 from spycrab/qt_modal_again

Qt: Make every messagebox modal
This commit is contained in:
Mat M 2019-03-04 17:40:27 -05:00 committed by GitHub
commit 147f7ca321
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 326 additions and 299 deletions

View File

@ -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

View File

@ -9,7 +9,6 @@
#include <QGridLayout>
#include <QLabel>
#include <QLineEdit>
#include <QMessageBox>
#include <QStringList>
#include <QTextEdit>
@ -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;
}

View File

@ -14,7 +14,6 @@
#include <QGroupBox>
#include <QLabel>
#include <QLineEdit>
#include <QMessageBox>
#include <QPushButton>
#include <QRadioButton>
#include <QScreen>
@ -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;
}

View File

@ -10,7 +10,6 @@
#include <QFileInfo>
#include <QHeaderView>
#include <QMenu>
#include <QMessageBox>
#include <QProgressDialog>
#include <QStandardItemModel>
#include <QStyleFactory>
@ -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."));
}
}

View File

@ -10,7 +10,6 @@
#include <QFile>
#include <QMenu>
#include <QMenuBar>
#include <QMessageBox>
#include <QScrollBar>
#include <QStringListModel>
#include <QTextCursor>
@ -20,6 +19,7 @@
#include <QWhatsThis>
#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()

13
Source/Core/DolphinQt/Config/GeckoCodeWidget.cpp Executable file → Normal file
View File

@ -9,7 +9,6 @@
#include <QHBoxLayout>
#include <QLabel>
#include <QListWidget>
#include <QMessageBox>
#include <QPushButton>
#include <QTextEdit>
#include <QVBoxLayout>
@ -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)));
}

View File

@ -10,7 +10,6 @@
#include <QGroupBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QMessageBox>
#include <QRadioButton>
#include <QSignalBlocker>
#include <QVBoxLayout>
@ -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 "

View File

@ -10,7 +10,6 @@
#include <QAction>
#include <QDateTime>
#include <QMessageBox>
#include <QPainter>
#include <QTimer>
@ -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);
}

View File

@ -9,7 +9,6 @@
#include <QDialogButtonBox>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QMessageBox>
#include <QPushButton>
#include <QTabWidget>
#include <QVBoxLayout>
@ -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"));

View File

@ -9,13 +9,13 @@
#include <QGroupBox>
#include <QLabel>
#include <QLineEdit>
#include <QMessageBox>
#include <QPushButton>
#include <QRadioButton>
#include <QScrollArea>
#include <QVBoxLayout>
#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;

View File

@ -11,7 +11,6 @@
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QMessageBox>
#include <QPushButton>
#include <QRadioButton>
#include <QScrollArea>
@ -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)));
}
}

View File

@ -11,11 +11,11 @@
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QMessageBox>
#include <QRadioButton>
#include <QVBoxLayout>
#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();

View File

@ -7,7 +7,7 @@
#include <cstring>
#include <utility>
#include <QMessageBox>
#include "DolphinQt/QtUtils/ModalMessageBox.h"
RegisterColumn::RegisterColumn(RegisterType type, std::function<u64()> get,
std::function<void(u64)> 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);

View File

@ -4,6 +4,12 @@
#include "DolphinQt/Debugger/WatchWidget.h"
#include <QHeaderView>
#include <QMenu>
#include <QTableWidget>
#include <QToolBar>
#include <QVBoxLayout>
#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 <QHeaderView>
#include <QMenu>
#include <QMessageBox>
#include <QTableWidget>
#include <QToolBar>
#include <QVBoxLayout>
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;
}

View File

@ -154,6 +154,7 @@
<QtMoc Include="QtUtils\DoubleClickEventFilter.h" />
<QtMoc Include="QtUtils\ElidedButton.h" />
<QtMoc Include="QtUtils\FlowLayout.h" />
<QtMoc Include="QtUtils\ModalMessageBox.h" />
<QtMoc Include="QtUtils\WindowActivationEventFilter.h" />
<QtMoc Include="QtUtils\WrapInScrollArea.h" />
<QtMoc Include="RenderWidget.h" />
@ -245,6 +246,7 @@
<ClCompile Include="$(QtMocOutPrefix)MemoryViewWidget.cpp" />
<ClCompile Include="$(QtMocOutPrefix)MemoryWidget.cpp" />
<ClCompile Include="$(QtMocOutPrefix)MenuBar.cpp" />
<ClCompile Include="$(QtMocOutPrefix)ModalMessageBox.cpp" />
<ClCompile Include="$(QtMocOutPrefix)NetPlayDialog.cpp" />
<ClCompile Include="$(QtMocOutPrefix)NetPlaySetupDialog.cpp" />
<ClCompile Include="$(QtMocOutPrefix)NewBreakpointDialog.cpp" />
@ -371,6 +373,7 @@
<ClCompile Include="QtUtils\ElidedButton.cpp" />
<ClCompile Include="QtUtils\FlowLayout.cpp" />
<ClCompile Include="QtUtils\ImageConverter.cpp" />
<ClCompile Include="QtUtils\ModalMessageBox.cpp" />
<ClCompile Include="QtUtils\WindowActivationEventFilter.cpp" />
<ClCompile Include="QtUtils\WrapInScrollArea.cpp" />
<ClCompile Include="RenderWidget.cpp" />
@ -491,4 +494,4 @@
<Message Text="Copy: @(BinaryFiles) -&gt; $(BinaryOutputDir)" Importance="High" />
<Copy SourceFiles="@(BinaryFiles)" DestinationFolder="$(BinaryOutputDir)" />
</Target>
</Project>
</Project>

View File

@ -10,7 +10,6 @@
#include <QLabel>
#include <QLineEdit>
#include <QListWidget>
#include <QMessageBox>
#include <QPushButton>
#include <QSplitter>
#include <QTextBrowser>

View File

@ -10,7 +10,6 @@
#include <QGroupBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QMessageBox>
#include <QPushButton>
#include <QSpinBox>
#include <QTabWidget>
@ -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."));
}
}

View File

@ -15,7 +15,6 @@
#include <QImage>
#include <QLabel>
#include <QLineEdit>
#include <QMessageBox>
#include <QPixmap>
#include <QPushButton>
#include <QTableWidget>
@ -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);

View File

@ -20,7 +20,6 @@
#include <QListView>
#include <QMap>
#include <QMenu>
#include <QMessageBox>
#include <QProgressDialog>
#include <QShortcut>
#include <QSortFilterProxyModel>
@ -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 "

View File

@ -12,30 +12,33 @@
#include <OptionParser.h>
#include <QAbstractEventDispatcher>
#include <QApplication>
#include <QMessageBox>
#include <QObject>
#include <QPushButton>
#include <QWidget>
#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<bool> 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(

View File

@ -11,7 +11,6 @@
#include <QFileDialog>
#include <QFileInfo>
#include <QIcon>
#include <QMessageBox>
#include <QMimeData>
#include <QProgressDialog>
#include <QStackedWidget>
@ -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<BootParameters> 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<BootParameters>&& 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 "

View File

@ -12,7 +12,6 @@
#include <QFontDialog>
#include <QInputDialog>
#include <QMap>
#include <QMessageBox>
#include <QUrl>
#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<int>(count)));
ModalMessageBox::information(this, tr("Save Export"),
tr("Exported %n save(s)", "", static_cast<int>(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;
}

View File

@ -16,7 +16,6 @@
#include <QLabel>
#include <QLineEdit>
#include <QMenu>
#include <QMessageBox>
#include <QProgressDialog>
#include <QPushButton>
#include <QSignalBlocker>
@ -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:

View File

@ -11,7 +11,6 @@
#include <QLabel>
#include <QLineEdit>
#include <QListWidget>
#include <QMessageBox>
#include <QPushButton>
#include <QSignalBlocker>
#include <QSpinBox>
@ -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),

View File

@ -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 <QApplication>
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);
}

View File

@ -0,0 +1,23 @@
// Copyright 2019 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <QMessageBox>
// 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);
};

View File

@ -10,7 +10,6 @@
#include <QGuiApplication>
#include <QIcon>
#include <QKeyEvent>
#include <QMessageBox>
#include <QMimeData>
#include <QMouseEvent>
#include <QPalette>
@ -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;
}

View File

@ -8,12 +8,12 @@
#include <QDialogButtonBox>
#include <QGridLayout>
#include <QHeaderView>
#include <QMessageBox>
#include <QPushButton>
#include <QTableWidget>
#include <QUrl>
#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);

View File

@ -12,7 +12,6 @@
#include <QGroupBox>
#include <QInputDialog>
#include <QLabel>
#include <QMessageBox>
#include <QPushButton>
#include <QVBoxLayout>
@ -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;
}
}

View File

@ -11,7 +11,6 @@
#include <QFormLayout>
#include <QGroupBox>
#include <QLabel>
#include <QMessageBox>
#include <QPushButton>
#include <QRadioButton>
#include <QSlider>
@ -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();

View File

@ -10,7 +10,6 @@
#include <QFormLayout>
#include <QGroupBox>
#include <QLabel>
#include <QMessageBox>
#include <QVBoxLayout>
#include <QWidget>
@ -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();

View File

@ -13,7 +13,6 @@
#include <QLabel>
#include <QLineEdit>
#include <QListWidget>
#include <QMessageBox>
#include <QPushButton>
#include <QTimer>
#include <QVBoxLayout>
@ -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);

View File

@ -6,7 +6,6 @@
#include <QApplication>
#include <QLocale>
#include <QMessageBox>
#include <QTranslator>
#include <algorithm>
#include <cstring>
@ -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();

View File

@ -8,7 +8,6 @@
#include <QDialog>
#include <QDialogButtonBox>
#include <QLabel>
#include <QMessageBox>
#include <QPushButton>
#include <QTextBrowser>
#include <QVBoxLayout>

View File

@ -8,7 +8,6 @@
#include <future>
#include <QCloseEvent>
#include <QMessageBox>
#include <QObject>
#include <QProgressDialog>
#include <QPushButton>
@ -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)