diff options
author | lat9nq <22451773+lat9nq@users.noreply.github.com> | 2021-05-26 04:14:55 +0200 |
---|---|---|
committer | lat9nq <22451773+lat9nq@users.noreply.github.com> | 2021-06-01 23:22:06 +0200 |
commit | c17e1bd7a8df8c26ca1334faec3e41ce239a5650 (patch) | |
tree | a7c58c2c58c2b8f5971e8ec473267266c07ef320 /src | |
parent | yuzu: Add settings reset button to general configuration (diff) | |
download | yuzu-c17e1bd7a8df8c26ca1334faec3e41ce239a5650.tar yuzu-c17e1bd7a8df8c26ca1334faec3e41ce239a5650.tar.gz yuzu-c17e1bd7a8df8c26ca1334faec3e41ce239a5650.tar.bz2 yuzu-c17e1bd7a8df8c26ca1334faec3e41ce239a5650.tar.lz yuzu-c17e1bd7a8df8c26ca1334faec3e41ce239a5650.tar.xz yuzu-c17e1bd7a8df8c26ca1334faec3e41ce239a5650.tar.zst yuzu-c17e1bd7a8df8c26ca1334faec3e41ce239a5650.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/yuzu/configuration/configure_dialog.cpp | 6 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_general.cpp | 13 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_general.h | 6 | ||||
-rw-r--r-- | src/yuzu/main.cpp | 11 |
4 files changed, 17 insertions, 19 deletions
diff --git a/src/yuzu/configuration/configure_dialog.cpp b/src/yuzu/configuration/configure_dialog.cpp index 167323831..371bc01b1 100644 --- a/src/yuzu/configuration/configure_dialog.cpp +++ b/src/yuzu/configuration/configure_dialog.cpp @@ -16,10 +16,6 @@ #include "yuzu/configuration/configure_input_player.h" #include "yuzu/hotkeys.h" -static void CloseDialog(ConfigureDialog *dialog) { - dialog->close(); -} - ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry, InputCommon::InputSubsystem* input_subsystem) : QDialog(parent), ui(new Ui::ConfigureDialog), registry(registry) { @@ -31,7 +27,7 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry, ui->inputTab->Initialize(input_subsystem); - ui->generalTab->SetResetCallback(&CloseDialog, this); + ui->generalTab->SetResetCallback([&] { this->close(); }); SetConfiguration(); PopulateSelectionList(); diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp index 28aaf47be..38edb4d8d 100644 --- a/src/yuzu/configuration/configure_general.cpp +++ b/src/yuzu/configuration/configure_general.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include <functional> +#include <utility> #include <QCheckBox> #include <QMessageBox> #include <QSpinBox> @@ -57,10 +59,8 @@ void ConfigureGeneral::SetConfiguration() { } // Called to set the callback when resetting settings to defaults -void ConfigureGeneral::SetResetCallback(void (*callback)(ConfigureDialog*), - ConfigureDialog* param) { - ResetCallback = callback; - reset_callback_param = param; +void ConfigureGeneral::SetResetCallback(std::function<void()> callback) { + reset_callback = std::move(callback); } void ConfigureGeneral::ResetDefaults() { @@ -69,11 +69,12 @@ void ConfigureGeneral::ResetDefaults() { tr("This reset all settings and remove all per-game configurations. This will not delete " "game directories, profiles, or input profiles. Proceed?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No); - if (answer == QMessageBox::No) + if (answer == QMessageBox::No) { return; + } UISettings::values.reset_to_defaults = true; UISettings::values.is_game_list_reload_pending.exchange(true); - (*ResetCallback)(reset_callback_param); + reset_callback(); } void ConfigureGeneral::ApplyConfiguration() { diff --git a/src/yuzu/configuration/configure_general.h b/src/yuzu/configuration/configure_general.h index 2a7741ad9..a0fd52492 100644 --- a/src/yuzu/configuration/configure_general.h +++ b/src/yuzu/configuration/configure_general.h @@ -4,6 +4,7 @@ #pragma once +#include <functional> #include <memory> #include <QWidget> @@ -26,7 +27,7 @@ public: explicit ConfigureGeneral(QWidget* parent = nullptr); ~ConfigureGeneral() override; - void SetResetCallback(void (*callback)(ConfigureDialog*), ConfigureDialog *param); + void SetResetCallback(std::function<void()> callback); void ResetDefaults(); void ApplyConfiguration(); @@ -38,8 +39,7 @@ private: void SetupPerGameUI(); - void (*ResetCallback)(ConfigureDialog*); - ConfigureDialog *reset_callback_param; + std::function<void()> reset_callback; std::unique_ptr<Ui::ConfigureGeneral> ui; 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<UISettings::GameDir> old_game_dirs = UISettings::values.game_dirs; - QVector<u64> old_favorited_ids = UISettings::values.favorited_ids; + // Explicitly save the game directories, since reinitializing config does not explicitly do + // so. + QVector<UISettings::GameDir> old_game_dirs = std::move(UISettings::values.game_dirs); + QVector<u64> old_favorited_ids = std::move(UISettings::values.favorited_ids); Settings::values.disabled_addons.clear(); config = std::make_unique<Config>(); 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(); |