mirror of
https://github.com/Rosalie241/RMG.git
synced 2026-07-11 01:24:01 +02:00
RMG: implement 'Ask for confirmation on exit while in-game' setting
This commit is contained in:
@@ -468,6 +468,7 @@ void SettingsDialog::loadInterfaceGeneralSettings(void)
|
||||
// select currently chosen theme in UI
|
||||
this->themeComboBox->setCurrentText(QString::fromStdString(CoreSettingsGetStringValue(SettingsID::GUI_Theme)));
|
||||
this->iconThemeComboBox->setCurrentText(QString::fromStdString(CoreSettingsGetStringValue(SettingsID::GUI_IconTheme)));
|
||||
this->confirmExitWhileInGameCheckBox->setChecked(CoreSettingsGetBoolValue(SettingsID::GUI_ConfirmExitWhileInGame));
|
||||
#ifdef UPDATER
|
||||
this->checkForUpdatesCheckBox->setChecked(CoreSettingsGetBoolValue(SettingsID::GUI_CheckForUpdates));
|
||||
#endif // UPDATER
|
||||
@@ -633,6 +634,7 @@ void SettingsDialog::loadDefaultInterfaceGeneralSettings(void)
|
||||
{
|
||||
this->themeComboBox->setCurrentText(QString::fromStdString(CoreSettingsGetDefaultStringValue(SettingsID::GUI_Theme)));
|
||||
this->iconThemeComboBox->setCurrentText(QString::fromStdString(CoreSettingsGetDefaultStringValue(SettingsID::GUI_IconTheme)));
|
||||
this->confirmExitWhileInGameCheckBox->setChecked(CoreSettingsGetDefaultBoolValue(SettingsID::GUI_ConfirmExitWhileInGame));
|
||||
#ifdef UPDATER
|
||||
this->checkForUpdatesCheckBox->setChecked(CoreSettingsGetDefaultBoolValue(SettingsID::GUI_CheckForUpdates));
|
||||
#endif // UPDATER
|
||||
@@ -876,6 +878,7 @@ void SettingsDialog::saveInterfaceGeneralSettings(void)
|
||||
{
|
||||
CoreSettingsSetValue(SettingsID::GUI_Theme, this->themeComboBox->currentText().toStdString());
|
||||
CoreSettingsSetValue(SettingsID::GUI_IconTheme, this->iconThemeComboBox->currentText().toStdString());
|
||||
CoreSettingsSetValue(SettingsID::GUI_ConfirmExitWhileInGame, this->confirmExitWhileInGameCheckBox->isChecked());
|
||||
#ifdef UPDATER
|
||||
CoreSettingsSetValue(SettingsID::GUI_CheckForUpdates, this->checkForUpdatesCheckBox->isChecked());
|
||||
#endif // UPDATER
|
||||
|
||||
@@ -116,6 +116,13 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="confirmExitWhileInGameCheckBox">
|
||||
<property name="text">
|
||||
<string>Ask for confirmation on exit while in-game</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkForUpdatesCheckBox">
|
||||
<property name="text">
|
||||
|
||||
@@ -162,11 +162,27 @@ void MainWindow::OpenROM(QString file, QString disk, bool fullscreen, bool quitA
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
bool inEmulation = this->emulationThread->isRunning();
|
||||
|
||||
if (!this->ui_ForceClose &&
|
||||
inEmulation &&
|
||||
CoreSettingsGetBoolValue(SettingsID::GUI_ConfirmExitWhileInGame))
|
||||
{
|
||||
bool skipExitConfirmation = false;
|
||||
bool ret = QtMessageBox::Question(this, "Are you sure you want to exit RMG?", "Don't ask for confirmation again", skipExitConfirmation);
|
||||
CoreSettingsSetValue(SettingsID::GUI_ConfirmExitWhileInGame, !skipExitConfirmation);
|
||||
if (!ret)
|
||||
{
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// we have to make sure we save the geomtry
|
||||
// for the ROM browser when emulation
|
||||
// isn't running (or hasn't run at all)
|
||||
if (!this->ui_QuitAfterEmulation &&
|
||||
!this->emulationThread->isRunning())
|
||||
!inEmulation)
|
||||
{
|
||||
this->storeGeometry();
|
||||
}
|
||||
@@ -1522,7 +1538,8 @@ void MainWindow::on_networkAccessManager_Finished(QNetworkReply* reply)
|
||||
}
|
||||
|
||||
#ifdef APPIMAGE_UPDATER
|
||||
this->on_Action_System_Exit();
|
||||
this->ui_ForceClose = true;
|
||||
this->close();
|
||||
#else // normal updater
|
||||
Dialog::InstallUpdateDialog installUpdateDialog(this, QCoreApplication::applicationDirPath(), downloadUpdateDialog.GetTempDirectory(), downloadUpdateDialog.GetFileName());
|
||||
ret = installUpdateDialog.exec();
|
||||
@@ -2102,6 +2119,8 @@ void MainWindow::on_Emulation_Finished(bool ret, QString error)
|
||||
{
|
||||
this->showErrorMessage("EmulationThread::run Failed", error);
|
||||
}
|
||||
|
||||
this->ui_ForceClose = true;
|
||||
this->close();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -84,10 +84,11 @@ class MainWindow : public QMainWindow, private Ui::MainWindow
|
||||
bool ui_ShowStatusbar = false;
|
||||
|
||||
bool ui_ManuallyPaused = true;
|
||||
|
||||
bool ui_ManuallySavedState = false;
|
||||
bool ui_ManuallyLoadedState = false;
|
||||
|
||||
bool ui_ForceClose = false;
|
||||
|
||||
QList<QAction*> ui_Actions;
|
||||
bool ui_AddedActions = false;
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <QAbstractButton>
|
||||
#include <QMessageBox>
|
||||
#include <QCheckBox>
|
||||
|
||||
using namespace Utilities;
|
||||
|
||||
@@ -57,3 +58,22 @@ void QtMessageBox::Error(QWidget* parent, QString text, QString details)
|
||||
show_messagebox(QMessageBox::Icon::Critical, "Error", parent, text, details);
|
||||
}
|
||||
|
||||
bool QtMessageBox::Question(QWidget* parent, QString text, QString checkBoxText, bool& checkBoxValue)
|
||||
{
|
||||
QMessageBox msgBox(parent);
|
||||
msgBox.setIcon(QMessageBox::Icon::Question);
|
||||
msgBox.setText(text);
|
||||
msgBox.addButton(QMessageBox::Button::Yes);
|
||||
msgBox.addButton(QMessageBox::Button::No);
|
||||
|
||||
QCheckBox* checkBox = new QCheckBox(&msgBox);
|
||||
checkBox->setText(checkBoxText);
|
||||
checkBox->setChecked(checkBoxValue);
|
||||
|
||||
msgBox.setCheckBox(checkBox);
|
||||
|
||||
int ret = msgBox.exec();
|
||||
checkBoxValue = checkBox->isChecked();
|
||||
return ret == QMessageBox::Button::Yes;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace QtMessageBox
|
||||
void Info(QWidget* parent, QString text, QString details = "");
|
||||
|
||||
void Error(QWidget* parent, QString text, QString details = "");
|
||||
|
||||
bool Question(QWidget* parent, QString text, QString checkBoxText, bool& checkBoxValue);
|
||||
}
|
||||
} // namespace Utilities
|
||||
|
||||
|
||||
Reference in New Issue
Block a user