Qt: Use window modality for message boxes

Backport from DuckStation:
86927ea3eb
This commit is contained in:
KamFretoZ 2024-04-02 14:27:49 +07:00 committed by Connor McLaughlin
parent 14a1d7a608
commit dcdb39026c
4 changed files with 11 additions and 0 deletions

View File

@ -455,6 +455,8 @@ void AutoUpdaterDialog::downloadUpdateClicked()
{
QMessageBox msgbox;
msgbox.setIcon(QMessageBox::Critical);
msgbox.setWindowModality(Qt::ApplicationModal);
msgbox.setWindowIcon(QtHost::GetAppIcon());
msgbox.setWindowTitle(tr("Savestate Warning"));
msgbox.setText(tr("<h1>WARNING</h1><p style='font-size:12pt;'>Installing this update will make your <b>save states incompatible</b>, <i>be sure to save any progress to your memory cards before proceeding</i>.</p><p>Do you wish to continue?</p>"));
msgbox.addButton(QMessageBox::Yes);

View File

@ -659,6 +659,8 @@ void MainWindow::onShowAdvancedSettingsToggled(bool checked)
{
QCheckBox* cb = new QCheckBox(tr("Do not show again"));
QMessageBox mb(this);
mb.setWindowIcon(QtHost::GetAppIcon());
mb.setWindowModality(Qt::WindowModal);
mb.setWindowTitle(tr("Show Advanced Settings"));
mb.setText(tr("Changing advanced settings can have unpredictable effects on games, including graphical glitches, lock-ups, and "
"even corrupted save files. "
@ -1182,6 +1184,8 @@ bool MainWindow::requestShutdown(bool allow_confirm, bool allow_save_to_state, b
QMessageBox msgbox(lock.getDialogParent());
msgbox.setIcon(QMessageBox::Question);
msgbox.setWindowTitle(tr("Confirm Shutdown"));
msgbox.setWindowModality(Qt::WindowModal);
msgbox.setWindowIcon(QtHost::GetAppIcon());
msgbox.setText(tr("Are you sure you want to shut down the virtual machine?"));
QCheckBox* save_cb = new QCheckBox(tr("Save State For Resume"), &msgbox);
@ -1596,6 +1600,7 @@ void MainWindow::checkForUpdates(bool display_message, bool force_check)
{
QMessageBox mbox(this);
mbox.setWindowTitle(tr("Updater Error"));
mbox.setWindowIcon(QtHost::GetAppIcon());
mbox.setTextFormat(Qt::RichText);
QString message;
@ -2687,7 +2692,9 @@ std::optional<bool> MainWindow::promptForResumeState(const QString& save_state_p
QMessageBox msgbox(this);
msgbox.setIcon(QMessageBox::Question);
msgbox.setWindowIcon(QtHost::GetAppIcon());
msgbox.setWindowTitle(tr("Load Resume State"));
msgbox.setWindowModality(Qt::WindowModal);
msgbox.setText(
tr("A resume save state was found for this game, saved at:\n\n%1.\n\nDo you want to load this state, or start from a fresh boot?")
.arg(fi.lastModified().toLocalTime().toString()));

View File

@ -267,6 +267,7 @@ void SettingsWindow::onCategoryCurrentRowChanged(int row)
void SettingsWindow::onRestoreDefaultsClicked()
{
QMessageBox msgbox(this);
msgbox.setWindowIcon(QtHost::GetAppIcon());
msgbox.setIcon(QMessageBox::Question);
msgbox.setWindowTitle(tr("Confirm Restore Defaults"));
msgbox.setText(tr("Are you sure you want to restore the default settings? Any existing preferences will be lost."));

View File

@ -354,6 +354,7 @@ bool QtHost::DownloadMissingFont(QWidget* dialog_parent, const char* font_name,
QMessageBox msgbox(dialog_parent);
msgbox.setWindowTitle(qApp->translate("MainWindow", "Missing Font File"));
msgbox.setWindowIcon(QtHost::GetAppIcon());
msgbox.setWindowModality(Qt::WindowModal);
msgbox.setIcon(QMessageBox::Critical);
msgbox.setTextFormat(Qt::RichText);
msgbox.setText(qApp->translate("MainWindow",