mirror of
https://github.com/stenzek/duckstation.git
synced 2026-02-13 01:44:33 +00:00
Qt: Convert more message boxes to window modal
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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("<h3>Game settings are currently disabled.</h3><p>This is <strong>not</strong> 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("<h3>Cheats are not currently enabled for this game.</h3><p>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("<h3>Cheats are not currently enabled for this game.</h3><p>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);
|
||||
|
||||
const int res = mbox.exec();
|
||||
if (res == QMessageBox::No)
|
||||
m_master_enable_ignored = cb->isChecked();
|
||||
else
|
||||
m_ui.enableCheats->setChecked(true);
|
||||
connect(mbox, &QMessageBox::accepted, this, [this]() { m_ui.enableCheats->setChecked(true); });
|
||||
connect(mbox, &QMessageBox::rejected, this, [this, cb]() { m_master_enable_ignored = cb->isChecked(); });
|
||||
|
||||
mbox->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
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);
|
||||
msgbox.exec();
|
||||
result = (msgbox.clickedButton() == yes_button);
|
||||
}
|
||||
QPushButton* const yes_button = msgbox->addButton(yes_text, QMessageBox::AcceptRole);
|
||||
msgbox->addButton(no_text, QMessageBox::RejectRole);
|
||||
|
||||
callback(result);
|
||||
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);
|
||||
});
|
||||
}
|
||||
if (needs_pause)
|
||||
{
|
||||
Host::RunOnCPUThread([]() {
|
||||
if (System::IsValid())
|
||||
System::PauseSystem(false);
|
||||
});
|
||||
}
|
||||
});
|
||||
msgbox->exec();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user