From d3b94d64d492407dcd43acf79cd1e94d57630109 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Fri, 5 May 2023 23:30:59 -0400 Subject: [PATCH] configuration: Add base class to tabs Tabs that largely configure SwitchableSetting's are now Tabs and grouped together. --- .../configuration/configuration_shared.cpp | 10 +++++-- src/yuzu/configuration/configuration_shared.h | 8 +++++- src/yuzu/configuration/configure_audio.cpp | 6 +++-- src/yuzu/configuration/configure_audio.h | 17 +++++------- src/yuzu/configuration/configure_cpu.cpp | 8 ++++-- src/yuzu/configuration/configure_cpu.h | 17 +++++------- src/yuzu/configuration/configure_dialog.cpp | 14 +++++----- src/yuzu/configuration/configure_dialog.h | 3 +++ src/yuzu/configuration/configure_general.cpp | 6 +++-- src/yuzu/configuration/configure_general.h | 18 +++++-------- src/yuzu/configuration/configure_graphics.cpp | 12 ++++----- src/yuzu/configuration/configure_graphics.h | 14 ++++------ .../configure_graphics_advanced.cpp | 6 +++-- .../configure_graphics_advanced.h | 18 ++++++------- src/yuzu/configuration/configure_per_game.cpp | 27 +++++++++---------- src/yuzu/configuration/configure_per_game.h | 4 ++- src/yuzu/configuration/configure_system.cpp | 6 +++-- src/yuzu/configuration/configure_system.h | 17 +++++------- 18 files changed, 110 insertions(+), 101 deletions(-) diff --git a/src/yuzu/configuration/configuration_shared.cpp b/src/yuzu/configuration/configuration_shared.cpp index ce12f55a2..72b7957e0 100644 --- a/src/yuzu/configuration/configuration_shared.cpp +++ b/src/yuzu/configuration/configuration_shared.cpp @@ -1,6 +1,7 @@ // SPDX-FileCopyrightText: 2016 Citra Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include #include #include #include @@ -11,9 +12,14 @@ namespace ConfigurationShared { -Tab::Tab(QWidget* parent) : QWidget(parent) {} +Tab::Tab(std::shared_ptr> group_, QWidget* parent) + : QWidget(parent), group{group_} { + if (group != nullptr) { + group->push_front(this); + } +} -Tab::~Tab() {} +Tab::~Tab() = default; } // namespace ConfigurationShared diff --git a/src/yuzu/configuration/configuration_shared.h b/src/yuzu/configuration/configuration_shared.h index ea8b18755..1a3a2a985 100644 --- a/src/yuzu/configuration/configuration_shared.h +++ b/src/yuzu/configuration/configuration_shared.h @@ -3,6 +3,9 @@ #pragma once +#include +#include +#include #include #include #include @@ -15,11 +18,14 @@ class Tab : public QWidget { Q_OBJECT public: - explicit Tab(QWidget* parent = nullptr); + explicit Tab(std::shared_ptr> group_, QWidget* parent = nullptr); ~Tab(); virtual void ApplyConfiguration() = 0; virtual void SetConfiguration() = 0; + +private: + std::shared_ptr> group; }; constexpr int USE_GLOBAL_INDEX = 0; diff --git a/src/yuzu/configuration/configure_audio.cpp b/src/yuzu/configuration/configure_audio.cpp index fcd6d61a0..335662144 100644 --- a/src/yuzu/configuration/configure_audio.cpp +++ b/src/yuzu/configuration/configure_audio.cpp @@ -12,8 +12,10 @@ #include "yuzu/configuration/configure_audio.h" #include "yuzu/uisettings.h" -ConfigureAudio::ConfigureAudio(const Core::System& system_, QWidget* parent) - : QWidget(parent), ui(std::make_unique()), system{system_} { +ConfigureAudio::ConfigureAudio(const Core::System& system_, + std::shared_ptr> group, + QWidget* parent) + : Tab(group, parent), ui(std::make_unique()), system{system_} { ui->setupUi(this); InitializeAudioSinkComboBox(); diff --git a/src/yuzu/configuration/configure_audio.h b/src/yuzu/configuration/configure_audio.h index 0d03aae1d..d134ac957 100644 --- a/src/yuzu/configuration/configure_audio.h +++ b/src/yuzu/configuration/configure_audio.h @@ -5,28 +5,25 @@ #include #include +#include "yuzu/configuration/configuration_shared.h" namespace Core { class System; } -namespace ConfigurationShared { -enum class CheckState; -} - namespace Ui { class ConfigureAudio; } -class ConfigureAudio : public QWidget { - Q_OBJECT - +class ConfigureAudio : public ConfigurationShared::Tab { public: - explicit ConfigureAudio(const Core::System& system_, QWidget* parent = nullptr); + explicit ConfigureAudio(const Core::System& system_, + std::shared_ptr> group, + QWidget* parent = nullptr); ~ConfigureAudio() override; - void ApplyConfiguration(); - void SetConfiguration(); + void ApplyConfiguration() override; + void SetConfiguration() override; private: void changeEvent(QEvent* event) override; diff --git a/src/yuzu/configuration/configure_cpu.cpp b/src/yuzu/configuration/configure_cpu.cpp index 3d69fb03f..ecaeb1a6b 100644 --- a/src/yuzu/configuration/configure_cpu.cpp +++ b/src/yuzu/configuration/configure_cpu.cpp @@ -1,6 +1,8 @@ // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include +#include #include "common/common_types.h" #include "common/settings.h" #include "core/core.h" @@ -8,8 +10,10 @@ #include "yuzu/configuration/configuration_shared.h" #include "yuzu/configuration/configure_cpu.h" -ConfigureCpu::ConfigureCpu(const Core::System& system_, QWidget* parent) - : QWidget(parent), ui{std::make_unique()}, system{system_} { +ConfigureCpu::ConfigureCpu(const Core::System& system_, + std::shared_ptr> group, + QWidget* parent) + : Tab(group, parent), ui{std::make_unique()}, system{system_} { ui->setupUi(this); SetupPerGameUI(); diff --git a/src/yuzu/configuration/configure_cpu.h b/src/yuzu/configuration/configure_cpu.h index 86d928ca3..187d080b6 100644 --- a/src/yuzu/configuration/configure_cpu.h +++ b/src/yuzu/configuration/configure_cpu.h @@ -5,28 +5,25 @@ #include #include +#include "yuzu/configuration/configuration_shared.h" namespace Core { class System; } -namespace ConfigurationShared { -enum class CheckState; -} - namespace Ui { class ConfigureCpu; } -class ConfigureCpu : public QWidget { - Q_OBJECT - +class ConfigureCpu : public ConfigurationShared::Tab { public: - explicit ConfigureCpu(const Core::System& system_, QWidget* parent = nullptr); + explicit ConfigureCpu(const Core::System& system_, + std::shared_ptr> group, + QWidget* parent = nullptr); ~ConfigureCpu() override; - void ApplyConfiguration(); - void SetConfiguration(); + void ApplyConfiguration() override; + void SetConfiguration() override; private: void changeEvent(QEvent* event) override; diff --git a/src/yuzu/configuration/configure_dialog.cpp b/src/yuzu/configuration/configure_dialog.cpp index bdf83ebfe..2cc9f3621 100644 --- a/src/yuzu/configuration/configure_dialog.cpp +++ b/src/yuzu/configuration/configure_dialog.cpp @@ -32,21 +32,21 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry_, std::vector& vk_device_records, Core::System& system_, bool enable_web_config) : QDialog(parent), ui{std::make_unique()}, - registry(registry_), system{system_}, audio_tab{std::make_unique(system_, - this)}, - cpu_tab{std::make_unique(system_, this)}, + registry(registry_), system{system_}, audio_tab{std::make_unique( + system_, nullptr, this)}, + cpu_tab{std::make_unique(system_, nullptr, this)}, debug_tab_tab{std::make_unique(system_, this)}, filesystem_tab{std::make_unique(this)}, - general_tab{std::make_unique(system_, this)}, - graphics_advanced_tab{std::make_unique(system_, this)}, + general_tab{std::make_unique(system_, nullptr, this)}, + graphics_advanced_tab{std::make_unique(system_, nullptr, this)}, graphics_tab{std::make_unique( system_, vk_device_records, [&]() { graphics_advanced_tab->ExposeComputeOption(); }, - this)}, + nullptr, this)}, hotkeys_tab{std::make_unique(system_.HIDCore(), this)}, input_tab{std::make_unique(system_, this)}, network_tab{std::make_unique(system_, this)}, profile_tab{std::make_unique(system_, this)}, - system_tab{std::make_unique(system_, this)}, + system_tab{std::make_unique(system_, nullptr, this)}, ui_tab{std::make_unique(system_, this)}, web_tab{std::make_unique( this)} { Settings::SetConfiguringGlobal(true); diff --git a/src/yuzu/configuration/configure_dialog.h b/src/yuzu/configuration/configure_dialog.h index 2a08b7fee..8ee89a192 100644 --- a/src/yuzu/configuration/configure_dialog.h +++ b/src/yuzu/configuration/configure_dialog.h @@ -3,9 +3,11 @@ #pragma once +#include #include #include #include +#include "configuration/configuration_shared.h" #include "yuzu/vk_device_info.h" namespace Core { @@ -69,6 +71,7 @@ private: HotkeyRegistry& registry; Core::System& system; + std::forward_list tab_group; std::unique_ptr audio_tab; std::unique_ptr cpu_tab; diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp index 2f55159f5..03261992a 100644 --- a/src/yuzu/configuration/configure_general.cpp +++ b/src/yuzu/configuration/configure_general.cpp @@ -11,8 +11,10 @@ #include "yuzu/configuration/configure_general.h" #include "yuzu/uisettings.h" -ConfigureGeneral::ConfigureGeneral(const Core::System& system_, QWidget* parent) - : QWidget(parent), ui{std::make_unique()}, system{system_} { +ConfigureGeneral::ConfigureGeneral( + const Core::System& system_, + std::shared_ptr> group, QWidget* parent) + : Tab(group, parent), ui{std::make_unique()}, system{system_} { ui->setupUi(this); SetupPerGameUI(); diff --git a/src/yuzu/configuration/configure_general.h b/src/yuzu/configuration/configure_general.h index 7ff63f425..0aad69f0a 100644 --- a/src/yuzu/configuration/configure_general.h +++ b/src/yuzu/configuration/configure_general.h @@ -6,34 +6,30 @@ #include #include #include +#include "yuzu/configuration/configuration_shared.h" namespace Core { class System; } class ConfigureDialog; - -namespace ConfigurationShared { -enum class CheckState; -} - class HotkeyRegistry; namespace Ui { class ConfigureGeneral; } -class ConfigureGeneral : public QWidget { - Q_OBJECT - +class ConfigureGeneral : public ConfigurationShared::Tab { public: - explicit ConfigureGeneral(const Core::System& system_, QWidget* parent = nullptr); + explicit ConfigureGeneral(const Core::System& system_, + std::shared_ptr> group, + QWidget* parent = nullptr); ~ConfigureGeneral() override; void SetResetCallback(std::function callback); void ResetDefaults(); - void ApplyConfiguration(); - void SetConfiguration(); + void ApplyConfiguration() override; + void SetConfiguration() override; private: void changeEvent(QEvent* event) override; diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index e70781357..a8c5b1d9f 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp @@ -70,12 +70,12 @@ static constexpr Settings::VSyncMode PresentModeToSetting(VkPresentModeKHR mode) } } -ConfigureGraphics::ConfigureGraphics(const Core::System& system_, - std::vector& records_, - const std::function& expose_compute_option_, - QWidget* parent) - : QWidget(parent), ui{std::make_unique()}, records{records_}, - expose_compute_option{expose_compute_option_}, system{system_} { +ConfigureGraphics::ConfigureGraphics( + const Core::System& system_, std::vector& records_, + const std::function& expose_compute_option_, + std::shared_ptr> group, QWidget* parent) + : ConfigurationShared::Tab(group, parent), ui{std::make_unique()}, + records{records_}, expose_compute_option{expose_compute_option_}, system{system_} { vulkan_device = Settings::values.vulkan_device.GetValue(); RetrieveVulkanDevices(); diff --git a/src/yuzu/configuration/configure_graphics.h b/src/yuzu/configuration/configure_graphics.h index be9310b74..adc3faffa 100644 --- a/src/yuzu/configuration/configure_graphics.h +++ b/src/yuzu/configuration/configure_graphics.h @@ -13,6 +13,7 @@ #include #include "common/common_types.h" #include "vk_device_info.h" +#include "yuzu/configuration/configuration_shared.h" class QEvent; class QObject; @@ -27,26 +28,21 @@ namespace Core { class System; } -namespace ConfigurationShared { -enum class CheckState; -} - namespace Ui { class ConfigureGraphics; } -class ConfigureGraphics : public QWidget { - Q_OBJECT - +class ConfigureGraphics : public ConfigurationShared::Tab { public: explicit ConfigureGraphics(const Core::System& system_, std::vector& records, const std::function& expose_compute_option_, + std::shared_ptr> group, QWidget* parent = nullptr); ~ConfigureGraphics() override; - void ApplyConfiguration(); - void SetConfiguration(); + void ApplyConfiguration() override; + void SetConfiguration() override; private: void changeEvent(QEvent* event) override; diff --git a/src/yuzu/configuration/configure_graphics_advanced.cpp b/src/yuzu/configuration/configure_graphics_advanced.cpp index e5c99f742..d332c9b7b 100644 --- a/src/yuzu/configuration/configure_graphics_advanced.cpp +++ b/src/yuzu/configuration/configure_graphics_advanced.cpp @@ -7,8 +7,10 @@ #include "yuzu/configuration/configuration_shared.h" #include "yuzu/configuration/configure_graphics_advanced.h" -ConfigureGraphicsAdvanced::ConfigureGraphicsAdvanced(const Core::System& system_, QWidget* parent) - : QWidget(parent), ui{std::make_unique()}, system{system_} { +ConfigureGraphicsAdvanced::ConfigureGraphicsAdvanced( + const Core::System& system_, + std::shared_ptr> group, QWidget* parent) + : Tab(group, parent), ui{std::make_unique()}, system{system_} { ui->setupUi(this); diff --git a/src/yuzu/configuration/configure_graphics_advanced.h b/src/yuzu/configuration/configure_graphics_advanced.h index 369a7c83e..585b9cb50 100644 --- a/src/yuzu/configuration/configure_graphics_advanced.h +++ b/src/yuzu/configuration/configure_graphics_advanced.h @@ -5,28 +5,26 @@ #include #include +#include "yuzu/configuration/configuration_shared.h" namespace Core { class System; } -namespace ConfigurationShared { -enum class CheckState; -} - namespace Ui { class ConfigureGraphicsAdvanced; } -class ConfigureGraphicsAdvanced : public QWidget { - Q_OBJECT - +class ConfigureGraphicsAdvanced : public ConfigurationShared::Tab { public: - explicit ConfigureGraphicsAdvanced(const Core::System& system_, QWidget* parent = nullptr); + explicit ConfigureGraphicsAdvanced( + const Core::System& system_, + std::shared_ptr> group, + QWidget* parent = nullptr); ~ConfigureGraphicsAdvanced() override; - void ApplyConfiguration(); - void SetConfiguration(); + void ApplyConfiguration() override; + void SetConfiguration() override; void ExposeComputeOption(); diff --git a/src/yuzu/configuration/configure_per_game.cpp b/src/yuzu/configuration/configure_per_game.cpp index eb96e6068..c54d7e76f 100644 --- a/src/yuzu/configuration/configure_per_game.cpp +++ b/src/yuzu/configuration/configure_per_game.cpp @@ -24,6 +24,7 @@ #include "core/loader/loader.h" #include "ui_configure_per_game.h" #include "yuzu/configuration/config.h" +#include "yuzu/configuration/configuration_shared.h" #include "yuzu/configuration/configure_audio.h" #include "yuzu/configuration/configure_cpu.h" #include "yuzu/configuration/configure_general.h" @@ -40,22 +41,23 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::string& file_name, std::vector& vk_device_records, Core::System& system_) - : QDialog(parent), - ui(std::make_unique()), title_id{title_id_}, system{system_} { + : QDialog(parent), ui(std::make_unique()), title_id{title_id_}, + system{system_}, group{std::make_shared>()} { const auto file_path = std::filesystem::path(Common::FS::ToU8String(file_name)); const auto config_file_name = title_id == 0 ? Common::FS::PathToUTF8String(file_path.filename()) : fmt::format("{:016X}", title_id); game_config = std::make_unique(config_file_name, Config::ConfigType::PerGameConfig); addons_tab = std::make_unique(system_, this); - audio_tab = std::make_unique(system_, this); - cpu_tab = std::make_unique(system_, this); - general_tab = std::make_unique(system_, this); - graphics_advanced_tab = std::make_unique(system_, this); + audio_tab = std::make_unique(system_, group, this); + cpu_tab = std::make_unique(system_, group, this); + general_tab = std::make_unique(system_, group, this); + graphics_advanced_tab = std::make_unique(system_, group, this); graphics_tab = std::make_unique( - system_, vk_device_records, [&]() { graphics_advanced_tab->ExposeComputeOption(); }, this); + system_, vk_device_records, [&]() { graphics_advanced_tab->ExposeComputeOption(); }, group, + this); input_tab = std::make_unique(system_, game_config.get(), this); - system_tab = std::make_unique(system_, this); + system_tab = std::make_unique(system_, group, this); ui->setupUi(this); @@ -88,13 +90,10 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::st ConfigurePerGame::~ConfigurePerGame() = default; void ConfigurePerGame::ApplyConfiguration() { + for (const auto tab : *group) { + tab->ApplyConfiguration(); + } addons_tab->ApplyConfiguration(); - general_tab->ApplyConfiguration(); - cpu_tab->ApplyConfiguration(); - system_tab->ApplyConfiguration(); - graphics_tab->ApplyConfiguration(); - graphics_advanced_tab->ApplyConfiguration(); - audio_tab->ApplyConfiguration(); input_tab->ApplyConfiguration(); system.ApplySettings(); diff --git a/src/yuzu/configuration/configure_per_game.h b/src/yuzu/configuration/configure_per_game.h index 7ec1ded06..5326e70e6 100644 --- a/src/yuzu/configuration/configure_per_game.h +++ b/src/yuzu/configuration/configure_per_game.h @@ -3,6 +3,7 @@ #pragma once +#include #include #include #include @@ -13,6 +14,7 @@ #include "core/file_sys/vfs_types.h" #include "vk_device_info.h" #include "yuzu/configuration/config.h" +#include "yuzu/configuration/configuration_shared.h" namespace Core { class System; @@ -73,7 +75,7 @@ private: std::unique_ptr game_config; Core::System& system; - + std::shared_ptr> group; std::unique_ptr addons_tab; std::unique_ptr audio_tab; std::unique_ptr cpu_tab; diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index c892635b8..4872a475b 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -37,8 +37,10 @@ static bool IsValidLocale(u32 region_index, u32 language_index) { return ((LOCALE_BLOCKLIST.at(region_index) >> language_index) & 1) == 0; } -ConfigureSystem::ConfigureSystem(Core::System& system_, QWidget* parent) - : QWidget(parent), ui{std::make_unique()}, system{system_} { +ConfigureSystem::ConfigureSystem( + Core::System& system_, std::shared_ptr> group, + QWidget* parent) + : Tab(group, parent), ui{std::make_unique()}, system{system_} { ui->setupUi(this); connect(ui->rng_seed_checkbox, &QCheckBox::stateChanged, this, [this](int state) { diff --git a/src/yuzu/configuration/configure_system.h b/src/yuzu/configuration/configure_system.h index ce1a91601..6064b5b40 100644 --- a/src/yuzu/configuration/configure_system.h +++ b/src/yuzu/configuration/configure_system.h @@ -6,28 +6,25 @@ #include #include +#include "yuzu/configuration/configuration_shared.h" namespace Core { class System; } -namespace ConfigurationShared { -enum class CheckState; -} - namespace Ui { class ConfigureSystem; } -class ConfigureSystem : public QWidget { - Q_OBJECT - +class ConfigureSystem : public ConfigurationShared::Tab { public: - explicit ConfigureSystem(Core::System& system_, QWidget* parent = nullptr); + explicit ConfigureSystem(Core::System& system_, + std::shared_ptr> group, + QWidget* parent = nullptr); ~ConfigureSystem() override; - void ApplyConfiguration(); - void SetConfiguration(); + void ApplyConfiguration() override; + void SetConfiguration() override; private: void changeEvent(QEvent* event) override;