diff --git a/src/duckstation-qt/consolesettingswidget.cpp b/src/duckstation-qt/consolesettingswidget.cpp index 029159724..0c755f7cc 100644 --- a/src/duckstation-qt/consolesettingswidget.cpp +++ b/src/duckstation-qt/consolesettingswidget.cpp @@ -190,10 +190,9 @@ void ConsoleSettingsWidget::onEnableCPUClockSpeedControlChecked(int state) "system requirements.\n\nBy enabling this option you are agreeing to not create any bug reports unless you " "have confirmed the bug also occurs with overclocking disabled.\n\nThis warning will only be shown once."); - QMessageBox* mb = - new QMessageBox(QMessageBox::Warning, tr("CPU Overclocking Warning"), message, QMessageBox::NoButton, this); + QMessageBox* const mb = QtUtils::NewMessageBox(QMessageBox::Warning, tr("CPU Overclocking Warning"), message, + QMessageBox::NoButton, QMessageBox::NoButton, Qt::WindowModal, this); mb->setAttribute(Qt::WA_DeleteOnClose, true); - mb->setWindowModality(Qt::WindowModal); const QPushButton* const yes_button = mb->addButton(tr("Yes, I will confirm bugs without overclocking before reporting."), QMessageBox::YesRole); const QPushButton* const no_button = mb->addButton(tr("No, take me back to safety."), QMessageBox::NoRole); diff --git a/src/duckstation-qt/gamecheatsettingswidget.cpp b/src/duckstation-qt/gamecheatsettingswidget.cpp index f19e04035..d6c123cb7 100644 --- a/src/duckstation-qt/gamecheatsettingswidget.cpp +++ b/src/duckstation-qt/gamecheatsettingswidget.cpp @@ -395,58 +395,42 @@ void GameCheatSettingsWidget::checkForMasterDisable() if (!game_settings_enabled) { - QMessageBox mbox(this); - mbox.setIcon(QMessageBox::Warning); - mbox.setWindowTitle(tr("Confirm Game Settings Enable")); - mbox.setWindowIcon(QtHost::GetAppIcon()); - mbox.setTextFormat(Qt::RichText); - mbox.setText( + QMessageBox* mbox = QtUtils::NewMessageBox( + QMessageBox::Warning, tr("Confirm Game Settings Enable"), tr("
This is not the default. Enabling this " - "cheat will not have any effect until game settings are enabled. Do you want to do this now?")); - - mbox.addButton(QMessageBox::Yes); - mbox.addButton(QMessageBox::No); - - QCheckBox* cb = new QCheckBox(&mbox); + "cheat will not have any effect until game settings are enabled. Do you want to do this now?"), + QMessageBox::Yes | QMessageBox::No, QMessageBox::NoButton, Qt::WindowModal, this); + QCheckBox* cb = new QCheckBox(mbox); + cb->setAttribute(Qt::WA_DeleteOnClose, true); cb->setText(tr("Do not show again")); - mbox.setCheckBox(cb); + mbox->setCheckBox(cb); - const int res = mbox.exec(); - if (res == QMessageBox::No) - { - m_master_enable_ignored = cb->isChecked(); - } - else - { + connect(mbox, &QMessageBox::accepted, this, []() { Host::SetBaseBoolSettingValue("Main", "ApplyGameSettings", true); Host::CommitBaseSettingChanges(); g_emu_thread->applySettings(false); - } + }); + + mbox->show(); } if (!cheats_enabled) { - QMessageBox mbox(this); - mbox.setIcon(QMessageBox::Warning); - mbox.setWindowTitle(tr("Confirm Cheat Enable")); - mbox.setWindowIcon(QtHost::GetAppIcon()); - mbox.setTextFormat(Qt::RichText); - mbox.setText(tr("
Enabling this cheat will not have any " - "effect until cheats are enabled for this game. Do you want to do this now?")); - - mbox.addButton(QMessageBox::Yes); - mbox.addButton(QMessageBox::No); - - QCheckBox* cb = new QCheckBox(&mbox); + QMessageBox* mbox = QtUtils::NewMessageBox( + QMessageBox::Warning, tr("Confirm Cheat Enable"), + tr("
Enabling this cheat will not have any " + "effect until cheats are enabled for this game. Do you want to do this now?"), + QMessageBox::Yes | QMessageBox::No, QMessageBox::NoButton, Qt::WindowModal, this); + QCheckBox* cb = new QCheckBox(mbox); + cb->setAttribute(Qt::WA_DeleteOnClose, true); cb->setText(tr("Do not show again")); cb->setChecked(m_master_enable_ignored); - mbox.setCheckBox(cb); + mbox->setCheckBox(cb); + + connect(mbox, &QMessageBox::accepted, this, [this]() { m_ui.enableCheats->setChecked(true); }); + connect(mbox, &QMessageBox::rejected, this, [this, cb]() { m_master_enable_ignored = cb->isChecked(); }); - const int res = mbox.exec(); - if (res == QMessageBox::No) - m_master_enable_ignored = cb->isChecked(); - else - m_ui.enableCheats->setChecked(true); + mbox->show(); } } diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index e030b2f2e..aae177c32 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -1273,29 +1273,36 @@ void MainWindow::startFileOrChangeDisc(const QString& qpath) void MainWindow::promptForDiscChange(const QString& path) { + if (m_was_disc_change_request || System::IsGPUDumpPath(path.toStdString())) + { + switchToEmulationView(); + g_emu_thread->changeDisc(path, false, true); + } + SystemLock lock(pauseAndLockSystem()); - bool reset_system = false; - if (!m_was_disc_change_request && !System::IsGPUDumpPath(path.toStdString())) - { - QMessageBox mb(QMessageBox::Question, tr("Confirm Disc Change"), - tr("Do you want to swap discs or boot the new image (via system reset)?"), QMessageBox::NoButton, - this); - /*const QAbstractButton* const swap_button = */ mb.addButton(tr("Swap Disc"), QMessageBox::YesRole); - const QAbstractButton* const reset_button = mb.addButton(tr("Reset"), QMessageBox::NoRole); - const QAbstractButton* const cancel_button = mb.addButton(tr("Cancel"), QMessageBox::RejectRole); - mb.exec(); + QMessageBox* const mb = + QtUtils::NewMessageBox(QMessageBox::Question, tr("Confirm Disc Change"), + tr("Do you want to swap discs or boot the new image (via system reset)?"), + QMessageBox::NoButton, QMessageBox::NoButton, Qt::WindowModal, lock.getDialogParent()); + mb->setAttribute(Qt::WA_DeleteOnClose, true); - const QAbstractButton* const clicked_button = mb.clickedButton(); + /*const QAbstractButton* const swap_button = */ mb->addButton(tr("Swap Disc"), QMessageBox::YesRole); + const QAbstractButton* const reset_button = mb->addButton(tr("Reset"), QMessageBox::NoRole); + const QAbstractButton* const cancel_button = mb->addButton(tr("Cancel"), QMessageBox::RejectRole); + + connect(mb, &QMessageBox::finished, this, [this, mb, reset_button, cancel_button, path, lock = std::move(lock)]() { + const QAbstractButton* const clicked_button = mb->clickedButton(); if (!clicked_button || clicked_button == cancel_button) return; - reset_system = (clicked_button == reset_button); - } + const bool reset_system = (clicked_button == reset_button); + switchToEmulationView(); - switchToEmulationView(); + g_emu_thread->changeDisc(path, reset_system, true); + }); - g_emu_thread->changeDisc(path, reset_system, true); + mb->show(); } void MainWindow::onStartDiscActionTriggered() @@ -3038,20 +3045,15 @@ void MainWindow::requestShutdown(bool allow_confirm, bool allow_save_to_state, b SystemLock lock(pauseAndLockSystem()); - QMessageBox* msgbox = new QMessageBox(lock.getDialogParent()); - msgbox->setWindowTitle(tr("Confirm Shutdown")); - msgbox->setWindowModality(Qt::WindowModal); + QMessageBox* msgbox = QtUtils::NewMessageBox( + QMessageBox::Question, tr("Confirm Shutdown"), tr("Are you sure you want to shut down the virtual machine?"), + QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes, Qt::WindowModal, lock.getDialogParent()); msgbox->setAttribute(Qt::WA_DeleteOnClose, true); - msgbox->setIcon(QMessageBox::Question); - msgbox->setText(tr("Are you sure you want to shut down the virtual machine?")); QCheckBox* const save_cb = new QCheckBox(tr("Save State For Resume"), msgbox); save_cb->setChecked(allow_save_to_state && save_state); save_cb->setEnabled(allow_save_to_state); msgbox->setCheckBox(save_cb); - msgbox->addButton(QMessageBox::Yes); - msgbox->addButton(QMessageBox::No); - msgbox->setDefaultButton(QMessageBox::Yes); connect(msgbox, &QMessageBox::finished, this, [this, lock = std::move(lock), save_cb, allow_save_to_state, check_safety, check_pause, exit_fullscreen_ui, quit_afterwards](int result) mutable { diff --git a/src/duckstation-qt/qthost.cpp b/src/duckstation-qt/qthost.cpp index 25f105e64..8b99b5a43 100644 --- a/src/duckstation-qt/qthost.cpp +++ b/src/duckstation-qt/qthost.cpp @@ -2165,28 +2165,28 @@ void Host::ConfirmMessageAsync(std::string_view title, std::string_view message, no_text = QtUtils::StringViewToQString(no_text), needs_pause]() mutable { auto lock = g_main_window->pauseAndLockSystem(); - bool result; - { - QMessageBox msgbox(lock.getDialogParent()); - msgbox.setIcon(QMessageBox::Question); - msgbox.setWindowTitle(title); - msgbox.setText(message); - - QPushButton* const yes_button = msgbox.addButton(yes_text, QMessageBox::AcceptRole); - msgbox.addButton(no_text, QMessageBox::RejectRole); - msgbox.exec(); - result = (msgbox.clickedButton() == yes_button); - } - - callback(result); - - if (needs_pause) - { - Host::RunOnCPUThread([]() { - if (System::IsValid()) - System::PauseSystem(false); - }); - } + QMessageBox* const msgbox = + QtUtils::NewMessageBox(QMessageBox::Question, title, message, QMessageBox::NoButton, QMessageBox::NoButton, + Qt::WindowModal, lock.getDialogParent()); + msgbox->setAttribute(Qt::WA_DeleteOnClose, true); + + QPushButton* const yes_button = msgbox->addButton(yes_text, QMessageBox::AcceptRole); + msgbox->addButton(no_text, QMessageBox::RejectRole); + + QObject::connect(msgbox, &QMessageBox::finished, lock.getDialogParent(), + [msgbox, yes_button, callback = std::move(callback), needs_pause]() { + const bool result = (msgbox->clickedButton() == yes_button); + callback(result); + + if (needs_pause) + { + Host::RunOnCPUThread([]() { + if (System::IsValid()) + System::PauseSystem(false); + }); + } + }); + msgbox->exec(); }); } }