From 86927ea3eb474f397ffdf7b42931259ac4bd2778 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 31 Mar 2024 23:20:59 +1000 Subject: [PATCH] Qt: Use window modality for message boxes Stops them opening in the middle of the screen on MacOS. --- src/duckstation-qt/consolesettingswidget.cpp | 1 + src/duckstation-qt/mainwindow.cpp | 3 +++ src/duckstation-qt/qttranslations.cpp | 1 + 3 files changed, 5 insertions(+) diff --git a/src/duckstation-qt/consolesettingswidget.cpp b/src/duckstation-qt/consolesettingswidget.cpp index 4d7db9423..5cb39e275 100644 --- a/src/duckstation-qt/consolesettingswidget.cpp +++ b/src/duckstation-qt/consolesettingswidget.cpp @@ -141,6 +141,7 @@ void ConsoleSettingsWidget::onEnableCPUClockSpeedControlChecked(int state) "have confirmed the bug also occurs with overclocking disabled.\n\nThis warning will only be shown once."); QMessageBox mb(QMessageBox::Warning, tr("CPU Overclocking Warning"), message, QMessageBox::NoButton, this); + mb.setWindowModality(Qt::WindowModal); const QAbstractButton* const yes_button = mb.addButton(tr("Yes, I will confirm bugs without overclocking before reporting."), QMessageBox::YesRole); mb.addButton(tr("No, take me back to safety."), QMessageBox::NoRole); diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index 9b8ddaec3..2ec960585 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -1154,6 +1154,7 @@ std::optional MainWindow::promptForResumeState(const std::string& save_sta QMessageBox msgbox(this); msgbox.setIcon(QMessageBox::Question); 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(QDateTime::fromSecsSinceEpoch(sd.ModificationTime, Qt::UTC).toLocalTime().toString())); @@ -2749,6 +2750,7 @@ bool MainWindow::requestShutdown(bool allow_confirm /* = true */, bool allow_sav QMessageBox msgbox(lock.getDialogParent()); msgbox.setIcon(QMessageBox::Question); msgbox.setWindowTitle(tr("Confirm Shutdown")); + msgbox.setWindowModality(Qt::WindowModal); 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); @@ -2992,6 +2994,7 @@ void MainWindow::checkForUpdates(bool display_message) { QMessageBox mbox(this); mbox.setWindowTitle(tr("Updater Error")); + mbox.setWindowModality(Qt::WindowModal); mbox.setTextFormat(Qt::RichText); QString message; diff --git a/src/duckstation-qt/qttranslations.cpp b/src/duckstation-qt/qttranslations.cpp index 0ab41b7c3..fea98152a 100644 --- a/src/duckstation-qt/qttranslations.cpp +++ b/src/duckstation-qt/qttranslations.cpp @@ -304,6 +304,7 @@ bool QtHost::DownloadMissingFont(QWidget* dialog_parent, const char* font_name, { QMessageBox msgbox(dialog_parent); msgbox.setWindowTitle(qApp->translate("QtHost", "Missing Font File")); + msgbox.setWindowModality(Qt::WindowModal); msgbox.setWindowIcon(QtHost::GetAppIcon()); msgbox.setIcon(QMessageBox::Critical); msgbox.setTextFormat(Qt::RichText);