From 8aeb42566968053d1a74f50f8453930cfdf2c42c Mon Sep 17 00:00:00 2001 From: fearlessTobi Date: Tue, 25 May 2021 20:48:02 -0400 Subject: configuration: Initial work to reset all settings This commit does not compile. Initial work to add and connect a Reset to Defaults button to the configure_general tab. Co-authored-by: german77 --- src/yuzu/main.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/yuzu/main.cpp') diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 0f0e228b0..838bb6926 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -2593,7 +2593,11 @@ void GMainWindow::OnConfigure() { configure_dialog.ApplyConfiguration(); controller_dialog->refreshConfiguration(); } + + configure_dialog.ApplyConfiguration(); + controller_dialog->refreshConfiguration(); InitializeHotkeys(); + if (UISettings::values.theme != old_theme) { UpdateUITheme(); } -- cgit v1.2.3 From 4a3d57e469c5604631b5768c4fa917f199ce7854 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 25 May 2021 20:49:42 -0400 Subject: yuzu: Add settings reset button to general configuration Builds on german77's work to reset all settings back to their defaults. This include UISettings and Settings values structs, but does not affect save profiles, input profiles, and game directories. This works from a button input in configure_general. When activated, it calls a callback to close the whole configure dialog, then GMainWindow deletes the old configuration, both on disk and in memory, and reinitalizes a new one. It also resets a portion of the UI and calls the telemetry window prompt. --- src/yuzu/main.cpp | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) (limited to 'src/yuzu/main.cpp') 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() { &GMainWindow::OnLanguageChanged); const auto result = configure_dialog.exec(); - if (result != QDialog::Accepted && !UISettings::values.configuration_applied) { + if (result != QDialog::Accepted && !UISettings::values.configuration_applied && + !UISettings::values.reset_to_defaults) { + // Runs if the user hit Cancel or closed the window, and did not ever press the Apply button + // or `Reset to Defaults` button return; } else if (result == QDialog::Accepted) { + // Only apply new changes if user hit Okay + // This is here to avoid applying changes if the user hit Apply, made some changes, then hit + // Cancel configure_dialog.ApplyConfiguration(); - controller_dialog->refreshConfiguration(); - } + } else if (UISettings::values.reset_to_defaults) { + LOG_INFO(Frontend, "Resetting all settings to defaults"); + if (!Common::FS::RemoveFile(config->GetConfigFilePath())) { + LOG_WARNING(Frontend, "Failed to remove configuration file"); + } + if (!Common::FS::RemoveDirContentsRecursively( + Common::FS::GetYuzuPath(Common::FS::YuzuPath::ConfigDir) / "custom")) { + LOG_WARNING(Frontend, "Failed to remove custom configuration files"); + } + if (!Common::FS::RemoveDirRecursively( + Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir) / "game_list")) { + LOG_WARNING(Frontend, "Failed to remove game metadata cache files"); + } + + // Explicitly save the game directories, since reinitializing config does not do so. + QVector old_game_dirs = UISettings::values.game_dirs; + QVector old_favorited_ids = UISettings::values.favorited_ids; - configure_dialog.ApplyConfiguration(); + Settings::values.disabled_addons.clear(); + + config = std::make_unique(); + UISettings::values.reset_to_defaults = false; + + UISettings::values.game_dirs = old_game_dirs; + UISettings::values.favorited_ids = old_favorited_ids; + + InitializeRecentFileMenuActions(); + + SetDefaultUIGeometry(); + RestoreUIState(); + + ShowTelemetryCallout(); + } controller_dialog->refreshConfiguration(); InitializeHotkeys(); -- cgit v1.2.3 From c17e1bd7a8df8c26ca1334faec3e41ce239a5650 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 25 May 2021 22:14:55 -0400 Subject: yuzu qt: Use lambda and std::function for reset callback Also makes use of std::move, and performs a clang-format cleanup. This addresses review comments. Co-authored-by: LC --- src/yuzu/main.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/yuzu/main.cpp') diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index e5a2fdf8c..c5dec215d 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -2611,17 +2611,18 @@ void GMainWindow::OnConfigure() { LOG_WARNING(Frontend, "Failed to remove game metadata cache files"); } - // Explicitly save the game directories, since reinitializing config does not do so. - QVector old_game_dirs = UISettings::values.game_dirs; - QVector old_favorited_ids = UISettings::values.favorited_ids; + // Explicitly save the game directories, since reinitializing config does not explicitly do + // so. + QVector old_game_dirs = std::move(UISettings::values.game_dirs); + QVector old_favorited_ids = std::move(UISettings::values.favorited_ids); Settings::values.disabled_addons.clear(); config = std::make_unique(); UISettings::values.reset_to_defaults = false; - UISettings::values.game_dirs = old_game_dirs; - UISettings::values.favorited_ids = old_favorited_ids; + UISettings::values.game_dirs = std::move(old_game_dirs); + UISettings::values.favorited_ids = std::move(old_favorited_ids); InitializeRecentFileMenuActions(); -- cgit v1.2.3