Qt: Add option to reset to defaults
This commit is contained in:
parent
cf51557b7f
commit
7caa5c09dd
|
@ -1084,6 +1084,7 @@ void MainWindow::connectSignals()
|
||||||
connect(m_ui.actionGridViewRefreshCovers, &QAction::triggered, m_game_list_widget,
|
connect(m_ui.actionGridViewRefreshCovers, &QAction::triggered, m_game_list_widget,
|
||||||
&GameListWidget::refreshGridCovers);
|
&GameListWidget::refreshGridCovers);
|
||||||
|
|
||||||
|
connect(m_host_interface, &QtHostInterface::settingsResetToDefault, this, &MainWindow::onSettingsResetToDefault);
|
||||||
connect(m_host_interface, &QtHostInterface::errorReported, this, &MainWindow::reportError,
|
connect(m_host_interface, &QtHostInterface::errorReported, this, &MainWindow::reportError,
|
||||||
Qt::BlockingQueuedConnection);
|
Qt::BlockingQueuedConnection);
|
||||||
connect(m_host_interface, &QtHostInterface::messageReported, this, &MainWindow::reportMessage);
|
connect(m_host_interface, &QtHostInterface::messageReported, this, &MainWindow::reportMessage);
|
||||||
|
@ -1297,6 +1298,28 @@ void MainWindow::updateTheme()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::onSettingsResetToDefault()
|
||||||
|
{
|
||||||
|
if (m_settings_dialog)
|
||||||
|
{
|
||||||
|
const bool shown = m_settings_dialog->isVisible();
|
||||||
|
|
||||||
|
m_settings_dialog->hide();
|
||||||
|
m_settings_dialog->deleteLater();
|
||||||
|
m_settings_dialog = new SettingsDialog(m_host_interface, this);
|
||||||
|
if (shown)
|
||||||
|
{
|
||||||
|
m_settings_dialog->setModal(false);
|
||||||
|
m_settings_dialog->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateDebugMenuCPUExecutionMode();
|
||||||
|
updateDebugMenuGPURenderer();
|
||||||
|
updateDebugMenuCropMode();
|
||||||
|
updateDebugMenuVisibility();
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::saveStateToConfig()
|
void MainWindow::saveStateToConfig()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
|
|
@ -65,6 +65,7 @@ private Q_SLOTS:
|
||||||
void setTheme(const QString& theme);
|
void setTheme(const QString& theme);
|
||||||
void updateTheme();
|
void updateTheme();
|
||||||
|
|
||||||
|
void onSettingsResetToDefault();
|
||||||
void onEmulationStarting();
|
void onEmulationStarting();
|
||||||
void onEmulationStarted();
|
void onEmulationStarted();
|
||||||
void onEmulationStopped();
|
void onEmulationStopped();
|
||||||
|
|
|
@ -290,18 +290,15 @@ void QtHostInterface::setDefaultSettings()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings old_settings(std::move(g_settings));
|
SetDefaultSettings();
|
||||||
{
|
}
|
||||||
std::lock_guard<std::recursive_mutex> guard(m_settings_mutex);
|
|
||||||
SetDefaultSettings(*m_settings_interface.get());
|
|
||||||
m_settings_interface->Save();
|
|
||||||
|
|
||||||
CommonHostInterface::LoadSettings(*m_settings_interface.get());
|
void QtHostInterface::SetDefaultSettings()
|
||||||
CommonHostInterface::ApplyGameSettings(false);
|
{
|
||||||
CommonHostInterface::FixIncompatibleSettings(false);
|
CommonHostInterface::SetDefaultSettings();
|
||||||
}
|
checkRenderToMainState();
|
||||||
|
queueSettingsSave();
|
||||||
CheckForSettingsChanges(old_settings);
|
emit settingsResetToDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtHostInterface::applySettings(bool display_osd_messages /* = false */)
|
void QtHostInterface::applySettings(bool display_osd_messages /* = false */)
|
||||||
|
@ -318,7 +315,11 @@ void QtHostInterface::applySettings(bool display_osd_messages /* = false */)
|
||||||
void QtHostInterface::ApplySettings(bool display_osd_messages)
|
void QtHostInterface::ApplySettings(bool display_osd_messages)
|
||||||
{
|
{
|
||||||
CommonHostInterface::ApplySettings(display_osd_messages);
|
CommonHostInterface::ApplySettings(display_osd_messages);
|
||||||
|
checkRenderToMainState();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtHostInterface::checkRenderToMainState()
|
||||||
|
{
|
||||||
// detect when render-to-main flag changes
|
// detect when render-to-main flag changes
|
||||||
if (!System::IsShutdown())
|
if (!System::IsShutdown())
|
||||||
{
|
{
|
||||||
|
|
|
@ -127,6 +127,7 @@ Q_SIGNALS:
|
||||||
void messageReported(const QString& message);
|
void messageReported(const QString& message);
|
||||||
void debuggerMessageReported(const QString& message);
|
void debuggerMessageReported(const QString& message);
|
||||||
bool messageConfirmed(const QString& message);
|
bool messageConfirmed(const QString& message);
|
||||||
|
void settingsResetToDefault();
|
||||||
void emulationStarting();
|
void emulationStarting();
|
||||||
void emulationStarted();
|
void emulationStarted();
|
||||||
void emulationStopped();
|
void emulationStopped();
|
||||||
|
@ -213,6 +214,7 @@ protected:
|
||||||
const std::string& game_title) override;
|
const std::string& game_title) override;
|
||||||
|
|
||||||
void SetDefaultSettings(SettingsInterface& si) override;
|
void SetDefaultSettings(SettingsInterface& si) override;
|
||||||
|
void SetDefaultSettings() override;
|
||||||
void ApplySettings(bool display_osd_messages) override;
|
void ApplySettings(bool display_osd_messages) override;
|
||||||
|
|
||||||
void SetMouseMode(bool relative, bool hide_cursor) override;
|
void SetMouseMode(bool relative, bool hide_cursor) override;
|
||||||
|
@ -267,6 +269,7 @@ private:
|
||||||
void installTranslator();
|
void installTranslator();
|
||||||
void renderDisplay();
|
void renderDisplay();
|
||||||
void connectDisplaySignals(QtDisplayWidget* widget);
|
void connectDisplaySignals(QtDisplayWidget* widget);
|
||||||
|
void checkRenderToMainState();
|
||||||
void updateDisplayState();
|
void updateDisplayState();
|
||||||
void queueSettingsSave();
|
void queueSettingsSave();
|
||||||
void wakeThread();
|
void wakeThread();
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "postprocessingsettingswidget.h"
|
#include "postprocessingsettingswidget.h"
|
||||||
#include "qthostinterface.h"
|
#include "qthostinterface.h"
|
||||||
#include <QtWidgets/QTextEdit>
|
#include <QtWidgets/QTextEdit>
|
||||||
|
#include <QtWidgets/QMessageBox>
|
||||||
|
|
||||||
#ifdef WITH_CHEEVOS
|
#ifdef WITH_CHEEVOS
|
||||||
#include "achievementsettingswidget.h"
|
#include "achievementsettingswidget.h"
|
||||||
|
@ -76,6 +77,7 @@ SettingsDialog::SettingsDialog(QtHostInterface* host_interface, QWidget* parent
|
||||||
m_ui.helpText->setText(m_category_help_text[0]);
|
m_ui.helpText->setText(m_category_help_text[0]);
|
||||||
connect(m_ui.settingsCategory, &QListWidget::currentRowChanged, this, &SettingsDialog::onCategoryCurrentRowChanged);
|
connect(m_ui.settingsCategory, &QListWidget::currentRowChanged, this, &SettingsDialog::onCategoryCurrentRowChanged);
|
||||||
connect(m_ui.closeButton, &QPushButton::clicked, this, &SettingsDialog::accept);
|
connect(m_ui.closeButton, &QPushButton::clicked, this, &SettingsDialog::accept);
|
||||||
|
connect(m_ui.restoreDefaultsButton, &QPushButton::clicked, this, &SettingsDialog::onRestoreDefaultsClicked);
|
||||||
|
|
||||||
connect(m_console_settings, &ConsoleSettingsWidget::multitapModeChanged, m_controller_settings,
|
connect(m_console_settings, &ConsoleSettingsWidget::multitapModeChanged, m_controller_settings,
|
||||||
&ControllerSettingsWidget::updateMultitapControllerTitles);
|
&ControllerSettingsWidget::updateMultitapControllerTitles);
|
||||||
|
@ -143,6 +145,16 @@ void SettingsDialog::onCategoryCurrentRowChanged(int row)
|
||||||
m_ui.helpText->setText(m_category_help_text[row]);
|
m_ui.helpText->setText(m_category_help_text[row]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsDialog::onRestoreDefaultsClicked()
|
||||||
|
{
|
||||||
|
if (!QMessageBox::question(this, tr("Confirm Restore Defaults"), tr("Are you sure you want to restore the default settings? Any preferences will be lost.")))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_host_interface->setDefaultSettings();
|
||||||
|
}
|
||||||
|
|
||||||
void SettingsDialog::registerWidgetHelp(QObject* object, QString title, QString recommended_value, QString text)
|
void SettingsDialog::registerWidgetHelp(QObject* object, QString title, QString recommended_value, QString text)
|
||||||
{
|
{
|
||||||
// construct rich text with formatted description
|
// construct rich text with formatted description
|
||||||
|
|
|
@ -67,11 +67,15 @@ public:
|
||||||
void registerWidgetHelp(QObject* object, QString title, QString recommended_value, QString text);
|
void registerWidgetHelp(QObject* object, QString title, QString recommended_value, QString text);
|
||||||
bool eventFilter(QObject* object, QEvent* event) override;
|
bool eventFilter(QObject* object, QEvent* event) override;
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void settingsResetToDefaults();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void setCategory(Category category);
|
void setCategory(Category category);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onCategoryCurrentRowChanged(int row);
|
void onCategoryCurrentRowChanged(int row);
|
||||||
|
void onRestoreDefaultsClicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setCategoryHelpTexts();
|
void setCategoryHelpTexts();
|
||||||
|
|
|
@ -217,6 +217,13 @@
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" colspan="2">
|
<item row="2" column="0" colspan="2">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="restoreDefaultsButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Restore Defaults</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|
|
@ -3104,6 +3104,21 @@ void CommonHostInterface::ApplySettings(bool display_osd_messages)
|
||||||
CheckForSettingsChanges(old_settings);
|
CheckForSettingsChanges(old_settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CommonHostInterface::SetDefaultSettings()
|
||||||
|
{
|
||||||
|
Settings old_settings(std::move(g_settings));
|
||||||
|
{
|
||||||
|
std::lock_guard<std::recursive_mutex> guard(m_settings_mutex);
|
||||||
|
SetDefaultSettings(*m_settings_interface.get());
|
||||||
|
|
||||||
|
LoadSettings(*m_settings_interface.get());
|
||||||
|
ApplyGameSettings(true);
|
||||||
|
FixIncompatibleSettings(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
CheckForSettingsChanges(old_settings);
|
||||||
|
}
|
||||||
|
|
||||||
void CommonHostInterface::UpdateInputMap()
|
void CommonHostInterface::UpdateInputMap()
|
||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lock(m_settings_mutex);
|
std::lock_guard<std::recursive_mutex> lock(m_settings_mutex);
|
||||||
|
|
|
@ -426,6 +426,9 @@ protected:
|
||||||
/// Restores all settings to defaults.
|
/// Restores all settings to defaults.
|
||||||
virtual void SetDefaultSettings(SettingsInterface& si) override;
|
virtual void SetDefaultSettings(SettingsInterface& si) override;
|
||||||
|
|
||||||
|
/// Resets known settings to default.
|
||||||
|
virtual void SetDefaultSettings();
|
||||||
|
|
||||||
/// Loads settings to m_settings and any frontend-specific parameters.
|
/// Loads settings to m_settings and any frontend-specific parameters.
|
||||||
virtual void LoadSettings(SettingsInterface& si) override;
|
virtual void LoadSettings(SettingsInterface& si) override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue