diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu/configuration/config.cpp | 6 | ||||
| -rw-r--r-- | src/yuzu/configuration/config.h | 1 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_dialog.cpp | 6 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_general.cpp | 23 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_general.h | 6 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_general.ui | 48 | ||||
| -rw-r--r-- | src/yuzu/main.cpp | 43 | ||||
| -rw-r--r-- | src/yuzu/uisettings.h | 1 |
8 files changed, 111 insertions, 23 deletions
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 0ea508acd..eb58bfa5b 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp | |||
| @@ -1632,12 +1632,6 @@ void Config::Save() { | |||
| 1632 | SaveValues(); | 1632 | SaveValues(); |
| 1633 | } | 1633 | } |
| 1634 | 1634 | ||
| 1635 | void Config::ResetDefaults() { | ||
| 1636 | FS::Delete(qt_config_loc); | ||
| 1637 | FS::CreateFullPath(qt_config_loc); | ||
| 1638 | Reload(); | ||
| 1639 | } | ||
| 1640 | |||
| 1641 | void Config::ReadControlPlayerValue(std::size_t player_index) { | 1635 | void Config::ReadControlPlayerValue(std::size_t player_index) { |
| 1642 | qt_config->beginGroup(QStringLiteral("Controls")); | 1636 | qt_config->beginGroup(QStringLiteral("Controls")); |
| 1643 | ReadPlayerValue(player_index); | 1637 | ReadPlayerValue(player_index); |
diff --git a/src/yuzu/configuration/config.h b/src/yuzu/configuration/config.h index cd68d7b4d..ce3355588 100644 --- a/src/yuzu/configuration/config.h +++ b/src/yuzu/configuration/config.h | |||
| @@ -28,7 +28,6 @@ public: | |||
| 28 | 28 | ||
| 29 | void Reload(); | 29 | void Reload(); |
| 30 | void Save(); | 30 | void Save(); |
| 31 | void ResetDefaults(); | ||
| 32 | 31 | ||
| 33 | void ReadControlPlayerValue(std::size_t player_index); | 32 | void ReadControlPlayerValue(std::size_t player_index); |
| 34 | void SaveControlPlayerValue(std::size_t player_index); | 33 | void SaveControlPlayerValue(std::size_t player_index); |
diff --git a/src/yuzu/configuration/configure_dialog.cpp b/src/yuzu/configuration/configure_dialog.cpp index 6028135c5..167323831 100644 --- a/src/yuzu/configuration/configure_dialog.cpp +++ b/src/yuzu/configuration/configure_dialog.cpp | |||
| @@ -16,6 +16,10 @@ | |||
| 16 | #include "yuzu/configuration/configure_input_player.h" | 16 | #include "yuzu/configuration/configure_input_player.h" |
| 17 | #include "yuzu/hotkeys.h" | 17 | #include "yuzu/hotkeys.h" |
| 18 | 18 | ||
| 19 | static void CloseDialog(ConfigureDialog *dialog) { | ||
| 20 | dialog->close(); | ||
| 21 | } | ||
| 22 | |||
| 19 | ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry, | 23 | ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry, |
| 20 | InputCommon::InputSubsystem* input_subsystem) | 24 | InputCommon::InputSubsystem* input_subsystem) |
| 21 | : QDialog(parent), ui(new Ui::ConfigureDialog), registry(registry) { | 25 | : QDialog(parent), ui(new Ui::ConfigureDialog), registry(registry) { |
| @@ -27,6 +31,8 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry, | |||
| 27 | 31 | ||
| 28 | ui->inputTab->Initialize(input_subsystem); | 32 | ui->inputTab->Initialize(input_subsystem); |
| 29 | 33 | ||
| 34 | ui->generalTab->SetResetCallback(&CloseDialog, this); | ||
| 35 | |||
| 30 | SetConfiguration(); | 36 | SetConfiguration(); |
| 31 | PopulateSelectionList(); | 37 | PopulateSelectionList(); |
| 32 | 38 | ||
diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp index a107cd3e1..28aaf47be 100644 --- a/src/yuzu/configuration/configure_general.cpp +++ b/src/yuzu/configuration/configure_general.cpp | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <QCheckBox> | 5 | #include <QCheckBox> |
| 6 | #include <QSpinBox> | ||
| 7 | #include <QMessageBox> | 6 | #include <QMessageBox> |
| 7 | #include <QSpinBox> | ||
| 8 | #include "common/settings.h" | 8 | #include "common/settings.h" |
| 9 | #include "core/core.h" | 9 | #include "core/core.h" |
| 10 | #include "ui_configure_general.h" | 10 | #include "ui_configure_general.h" |
| 11 | #include "yuzu/configuration/config.h" | ||
| 11 | #include "yuzu/configuration/configuration_shared.h" | 12 | #include "yuzu/configuration/configuration_shared.h" |
| 12 | #include "yuzu/configuration/configure_general.h" | 13 | #include "yuzu/configuration/configure_general.h" |
| 13 | #include "yuzu/configuration/config.h" | ||
| 14 | #include "yuzu/uisettings.h" | 14 | #include "yuzu/uisettings.h" |
| 15 | 15 | ||
| 16 | ConfigureGeneral::ConfigureGeneral(QWidget* parent) | 16 | ConfigureGeneral::ConfigureGeneral(QWidget* parent) |
| @@ -46,6 +46,8 @@ void ConfigureGeneral::SetConfiguration() { | |||
| 46 | ui->toggle_frame_limit->setChecked(Settings::values.use_frame_limit.GetValue()); | 46 | ui->toggle_frame_limit->setChecked(Settings::values.use_frame_limit.GetValue()); |
| 47 | ui->frame_limit->setValue(Settings::values.frame_limit.GetValue()); | 47 | ui->frame_limit->setValue(Settings::values.frame_limit.GetValue()); |
| 48 | 48 | ||
| 49 | ui->button_reset_defaults->setEnabled(runtime_lock); | ||
| 50 | |||
| 49 | if (Settings::IsConfiguringGlobal()) { | 51 | if (Settings::IsConfiguringGlobal()) { |
| 50 | ui->frame_limit->setEnabled(Settings::values.use_frame_limit.GetValue()); | 52 | ui->frame_limit->setEnabled(Settings::values.use_frame_limit.GetValue()); |
| 51 | } else { | 53 | } else { |
| @@ -54,13 +56,24 @@ void ConfigureGeneral::SetConfiguration() { | |||
| 54 | } | 56 | } |
| 55 | } | 57 | } |
| 56 | 58 | ||
| 59 | // Called to set the callback when resetting settings to defaults | ||
| 60 | void ConfigureGeneral::SetResetCallback(void (*callback)(ConfigureDialog*), | ||
| 61 | ConfigureDialog* param) { | ||
| 62 | ResetCallback = callback; | ||
| 63 | reset_callback_param = param; | ||
| 64 | } | ||
| 65 | |||
| 57 | void ConfigureGeneral::ResetDefaults() { | 66 | void ConfigureGeneral::ResetDefaults() { |
| 58 | QMessageBox::StandardButton answer = QMessageBox::question( | 67 | QMessageBox::StandardButton answer = QMessageBox::question( |
| 59 | this, tr("yuzu"), tr("Are you sure you want to <b>reset your settings</b>?"), | 68 | this, tr("yuzu"), |
| 69 | tr("This reset all settings and remove all per-game configurations. This will not delete " | ||
| 70 | "game directories, profiles, or input profiles. Proceed?"), | ||
| 60 | QMessageBox::Yes | QMessageBox::No, QMessageBox::No); | 71 | QMessageBox::Yes | QMessageBox::No, QMessageBox::No); |
| 61 | if (answer == QMessageBox::No) | 72 | if (answer == QMessageBox::No) |
| 62 | return; | 73 | return; |
| 63 | UISettings::values. | 74 | UISettings::values.reset_to_defaults = true; |
| 75 | UISettings::values.is_game_list_reload_pending.exchange(true); | ||
| 76 | (*ResetCallback)(reset_callback_param); | ||
| 64 | } | 77 | } |
| 65 | 78 | ||
| 66 | void ConfigureGeneral::ApplyConfiguration() { | 79 | void ConfigureGeneral::ApplyConfiguration() { |
| @@ -119,6 +132,8 @@ void ConfigureGeneral::SetupPerGameUI() { | |||
| 119 | ui->toggle_background_pause->setVisible(false); | 132 | ui->toggle_background_pause->setVisible(false); |
| 120 | ui->toggle_hide_mouse->setVisible(false); | 133 | ui->toggle_hide_mouse->setVisible(false); |
| 121 | 134 | ||
| 135 | ui->button_reset_defaults->setVisible(false); | ||
| 136 | |||
| 122 | ConfigurationShared::SetColoredTristate(ui->toggle_frame_limit, | 137 | ConfigurationShared::SetColoredTristate(ui->toggle_frame_limit, |
| 123 | Settings::values.use_frame_limit, use_frame_limit); | 138 | Settings::values.use_frame_limit, use_frame_limit); |
| 124 | ConfigurationShared::SetColoredTristate(ui->use_multi_core, Settings::values.use_multi_core, | 139 | ConfigurationShared::SetColoredTristate(ui->use_multi_core, Settings::values.use_multi_core, |
diff --git a/src/yuzu/configuration/configure_general.h b/src/yuzu/configuration/configure_general.h index 3d8a1dae0..2a7741ad9 100644 --- a/src/yuzu/configuration/configure_general.h +++ b/src/yuzu/configuration/configure_general.h | |||
| @@ -7,6 +7,8 @@ | |||
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include <QWidget> | 8 | #include <QWidget> |
| 9 | 9 | ||
| 10 | class ConfigureDialog; | ||
| 11 | |||
| 10 | namespace ConfigurationShared { | 12 | namespace ConfigurationShared { |
| 11 | enum class CheckState; | 13 | enum class CheckState; |
| 12 | } | 14 | } |
| @@ -24,6 +26,7 @@ public: | |||
| 24 | explicit ConfigureGeneral(QWidget* parent = nullptr); | 26 | explicit ConfigureGeneral(QWidget* parent = nullptr); |
| 25 | ~ConfigureGeneral() override; | 27 | ~ConfigureGeneral() override; |
| 26 | 28 | ||
| 29 | void SetResetCallback(void (*callback)(ConfigureDialog*), ConfigureDialog *param); | ||
| 27 | void ResetDefaults(); | 30 | void ResetDefaults(); |
| 28 | void ApplyConfiguration(); | 31 | void ApplyConfiguration(); |
| 29 | 32 | ||
| @@ -35,6 +38,9 @@ private: | |||
| 35 | 38 | ||
| 36 | void SetupPerGameUI(); | 39 | void SetupPerGameUI(); |
| 37 | 40 | ||
| 41 | void (*ResetCallback)(ConfigureDialog*); | ||
| 42 | ConfigureDialog *reset_callback_param; | ||
| 43 | |||
| 38 | std::unique_ptr<Ui::ConfigureGeneral> ui; | 44 | std::unique_ptr<Ui::ConfigureGeneral> ui; |
| 39 | 45 | ||
| 40 | ConfigurationShared::CheckState use_frame_limit; | 46 | ConfigurationShared::CheckState use_frame_limit; |
diff --git a/src/yuzu/configuration/configure_general.ui b/src/yuzu/configuration/configure_general.ui index ae8ed5ca5..bc7041090 100644 --- a/src/yuzu/configuration/configure_general.ui +++ b/src/yuzu/configuration/configure_general.ui | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | <rect> | 6 | <rect> |
| 7 | <x>0</x> | 7 | <x>0</x> |
| 8 | <y>0</y> | 8 | <y>0</y> |
| 9 | <width>300</width> | 9 | <width>329</width> |
| 10 | <height>407</height> | 10 | <height>407</height> |
| 11 | </rect> | 11 | </rect> |
| 12 | </property> | 12 | </property> |
| @@ -91,13 +91,6 @@ | |||
| 91 | </layout> | 91 | </layout> |
| 92 | </widget> | 92 | </widget> |
| 93 | </item> | 93 | </item> |
| 94 | <item alignment="Qt::AlignRight"> | ||
| 95 | <widget class="QPushButton" name="button_reset_defaults"> | ||
| 96 | <property name="text"> | ||
| 97 | <string>Reset All Settings</string> | ||
| 98 | </property> | ||
| 99 | </widget> | ||
| 100 | </item> | ||
| 101 | <item> | 94 | <item> |
| 102 | <spacer name="verticalSpacer"> | 95 | <spacer name="verticalSpacer"> |
| 103 | <property name="orientation"> | 96 | <property name="orientation"> |
| @@ -111,6 +104,45 @@ | |||
| 111 | </property> | 104 | </property> |
| 112 | </spacer> | 105 | </spacer> |
| 113 | </item> | 106 | </item> |
| 107 | <item> | ||
| 108 | <layout class="QHBoxLayout" name="layout_reset"> | ||
| 109 | <property name="spacing"> | ||
| 110 | <number>6</number> | ||
| 111 | </property> | ||
| 112 | <property name="leftMargin"> | ||
| 113 | <number>5</number> | ||
| 114 | </property> | ||
| 115 | <property name="topMargin"> | ||
| 116 | <number>5</number> | ||
| 117 | </property> | ||
| 118 | <property name="rightMargin"> | ||
| 119 | <number>5</number> | ||
| 120 | </property> | ||
| 121 | <property name="bottomMargin"> | ||
| 122 | <number>5</number> | ||
| 123 | </property> | ||
| 124 | <item> | ||
| 125 | <widget class="QPushButton" name="button_reset_defaults"> | ||
| 126 | <property name="text"> | ||
| 127 | <string>Reset All Settings</string> | ||
| 128 | </property> | ||
| 129 | </widget> | ||
| 130 | </item> | ||
| 131 | <item> | ||
| 132 | <spacer name="spacer_reset"> | ||
| 133 | <property name="orientation"> | ||
| 134 | <enum>Qt::Horizontal</enum> | ||
| 135 | </property> | ||
| 136 | <property name="sizeHint" stdset="0"> | ||
| 137 | <size> | ||
| 138 | <width>40</width> | ||
| 139 | <height>20</height> | ||
| 140 | </size> | ||
| 141 | </property> | ||
| 142 | </spacer> | ||
| 143 | </item> | ||
| 144 | </layout> | ||
| 145 | </item> | ||
| 114 | </layout> | 146 | </layout> |
| 115 | </item> | 147 | </item> |
| 116 | </layout> | 148 | </layout> |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 838bb6926..e5a2fdf8c 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -2587,14 +2587,49 @@ void GMainWindow::OnConfigure() { | |||
| 2587 | &GMainWindow::OnLanguageChanged); | 2587 | &GMainWindow::OnLanguageChanged); |
| 2588 | 2588 | ||
| 2589 | const auto result = configure_dialog.exec(); | 2589 | const auto result = configure_dialog.exec(); |
| 2590 | if (result != QDialog::Accepted && !UISettings::values.configuration_applied) { | 2590 | if (result != QDialog::Accepted && !UISettings::values.configuration_applied && |
| 2591 | !UISettings::values.reset_to_defaults) { | ||
| 2592 | // Runs if the user hit Cancel or closed the window, and did not ever press the Apply button | ||
| 2593 | // or `Reset to Defaults` button | ||
| 2591 | return; | 2594 | return; |
| 2592 | } else if (result == QDialog::Accepted) { | 2595 | } else if (result == QDialog::Accepted) { |
| 2596 | // Only apply new changes if user hit Okay | ||
| 2597 | // This is here to avoid applying changes if the user hit Apply, made some changes, then hit | ||
| 2598 | // Cancel | ||
| 2593 | configure_dialog.ApplyConfiguration(); | 2599 | configure_dialog.ApplyConfiguration(); |
| 2594 | controller_dialog->refreshConfiguration(); | 2600 | } else if (UISettings::values.reset_to_defaults) { |
| 2595 | } | 2601 | LOG_INFO(Frontend, "Resetting all settings to defaults"); |
| 2602 | if (!Common::FS::RemoveFile(config->GetConfigFilePath())) { | ||
| 2603 | LOG_WARNING(Frontend, "Failed to remove configuration file"); | ||
| 2604 | } | ||
| 2605 | if (!Common::FS::RemoveDirContentsRecursively( | ||
| 2606 | Common::FS::GetYuzuPath(Common::FS::YuzuPath::ConfigDir) / "custom")) { | ||
| 2607 | LOG_WARNING(Frontend, "Failed to remove custom configuration files"); | ||
| 2608 | } | ||
| 2609 | if (!Common::FS::RemoveDirRecursively( | ||
| 2610 | Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir) / "game_list")) { | ||
| 2611 | LOG_WARNING(Frontend, "Failed to remove game metadata cache files"); | ||
| 2612 | } | ||
| 2613 | |||
| 2614 | // Explicitly save the game directories, since reinitializing config does not do so. | ||
| 2615 | QVector<UISettings::GameDir> old_game_dirs = UISettings::values.game_dirs; | ||
| 2616 | QVector<u64> old_favorited_ids = UISettings::values.favorited_ids; | ||
| 2596 | 2617 | ||
| 2597 | configure_dialog.ApplyConfiguration(); | 2618 | Settings::values.disabled_addons.clear(); |
| 2619 | |||
| 2620 | config = std::make_unique<Config>(); | ||
| 2621 | UISettings::values.reset_to_defaults = false; | ||
| 2622 | |||
| 2623 | UISettings::values.game_dirs = old_game_dirs; | ||
| 2624 | UISettings::values.favorited_ids = old_favorited_ids; | ||
| 2625 | |||
| 2626 | InitializeRecentFileMenuActions(); | ||
| 2627 | |||
| 2628 | SetDefaultUIGeometry(); | ||
| 2629 | RestoreUIState(); | ||
| 2630 | |||
| 2631 | ShowTelemetryCallout(); | ||
| 2632 | } | ||
| 2598 | controller_dialog->refreshConfiguration(); | 2633 | controller_dialog->refreshConfiguration(); |
| 2599 | InitializeHotkeys(); | 2634 | InitializeHotkeys(); |
| 2600 | 2635 | ||
diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h index 49122ec32..cdcb83f9f 100644 --- a/src/yuzu/uisettings.h +++ b/src/yuzu/uisettings.h | |||
| @@ -97,6 +97,7 @@ struct Values { | |||
| 97 | bool cache_game_list; | 97 | bool cache_game_list; |
| 98 | 98 | ||
| 99 | bool configuration_applied; | 99 | bool configuration_applied; |
| 100 | bool reset_to_defaults; | ||
| 100 | }; | 101 | }; |
| 101 | 102 | ||
| 102 | extern Values values; | 103 | extern Values values; |