diff options
author | lat9nq <22451773+lat9nq@users.noreply.github.com> | 2023-05-06 05:30:59 +0200 |
---|---|---|
committer | lat9nq <22451773+lat9nq@users.noreply.github.com> | 2023-07-21 16:56:07 +0200 |
commit | d3b94d64d492407dcd43acf79cd1e94d57630109 (patch) | |
tree | 37c945f6aa9050c68fc8d15eabbc1049c556c3b9 /src | |
parent | configuration_shared: Create Tab base class (diff) | |
download | yuzu-d3b94d64d492407dcd43acf79cd1e94d57630109.tar yuzu-d3b94d64d492407dcd43acf79cd1e94d57630109.tar.gz yuzu-d3b94d64d492407dcd43acf79cd1e94d57630109.tar.bz2 yuzu-d3b94d64d492407dcd43acf79cd1e94d57630109.tar.lz yuzu-d3b94d64d492407dcd43acf79cd1e94d57630109.tar.xz yuzu-d3b94d64d492407dcd43acf79cd1e94d57630109.tar.zst yuzu-d3b94d64d492407dcd43acf79cd1e94d57630109.zip |
Diffstat (limited to 'src')
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 <memory> #include <QCheckBox> #include <QObject> #include <QString> @@ -11,9 +12,14 @@ namespace ConfigurationShared { -Tab::Tab(QWidget* parent) : QWidget(parent) {} +Tab::Tab(std::shared_ptr<std::forward_list<Tab*>> 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 <forward_list> +#include <iterator> +#include <memory> #include <QCheckBox> #include <QComboBox> #include <QWidget> @@ -15,11 +18,14 @@ class Tab : public QWidget { Q_OBJECT public: - explicit Tab(QWidget* parent = nullptr); + explicit Tab(std::shared_ptr<std::forward_list<Tab*>> group_, QWidget* parent = nullptr); ~Tab(); virtual void ApplyConfiguration() = 0; virtual void SetConfiguration() = 0; + +private: + std::shared_ptr<std::forward_list<Tab*>> 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<Ui::ConfigureAudio>()), system{system_} { +ConfigureAudio::ConfigureAudio(const Core::System& system_, + std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, + QWidget* parent) + : Tab(group, parent), ui(std::make_unique<Ui::ConfigureAudio>()), 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 <memory> #include <QWidget> +#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<std::forward_list<ConfigurationShared::Tab*>> 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 <forward_list> +#include <memory> #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<Ui::ConfigureCpu>()}, system{system_} { +ConfigureCpu::ConfigureCpu(const Core::System& system_, + std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, + QWidget* parent) + : Tab(group, parent), ui{std::make_unique<Ui::ConfigureCpu>()}, 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 <memory> #include <QWidget> +#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<std::forward_list<ConfigurationShared::Tab*>> 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<VkDeviceInfo::Record>& vk_device_records, Core::System& system_, bool enable_web_config) : QDialog(parent), ui{std::make_unique<Ui::ConfigureDialog>()}, - registry(registry_), system{system_}, audio_tab{std::make_unique<ConfigureAudio>(system_, - this)}, - cpu_tab{std::make_unique<ConfigureCpu>(system_, this)}, + registry(registry_), system{system_}, audio_tab{std::make_unique<ConfigureAudio>( + system_, nullptr, this)}, + cpu_tab{std::make_unique<ConfigureCpu>(system_, nullptr, this)}, debug_tab_tab{std::make_unique<ConfigureDebugTab>(system_, this)}, filesystem_tab{std::make_unique<ConfigureFilesystem>(this)}, - general_tab{std::make_unique<ConfigureGeneral>(system_, this)}, - graphics_advanced_tab{std::make_unique<ConfigureGraphicsAdvanced>(system_, this)}, + general_tab{std::make_unique<ConfigureGeneral>(system_, nullptr, this)}, + graphics_advanced_tab{std::make_unique<ConfigureGraphicsAdvanced>(system_, nullptr, this)}, graphics_tab{std::make_unique<ConfigureGraphics>( system_, vk_device_records, [&]() { graphics_advanced_tab->ExposeComputeOption(); }, - this)}, + nullptr, this)}, hotkeys_tab{std::make_unique<ConfigureHotkeys>(system_.HIDCore(), this)}, input_tab{std::make_unique<ConfigureInput>(system_, this)}, network_tab{std::make_unique<ConfigureNetwork>(system_, this)}, profile_tab{std::make_unique<ConfigureProfileManager>(system_, this)}, - system_tab{std::make_unique<ConfigureSystem>(system_, this)}, + system_tab{std::make_unique<ConfigureSystem>(system_, nullptr, this)}, ui_tab{std::make_unique<ConfigureUi>(system_, this)}, web_tab{std::make_unique<ConfigureWeb>( 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 <forward_list> #include <memory> #include <vector> #include <QDialog> +#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<ConfigurationShared::Tab*> tab_group; std::unique_ptr<ConfigureAudio> audio_tab; std::unique_ptr<ConfigureCpu> 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<Ui::ConfigureGeneral>()}, system{system_} { +ConfigureGeneral::ConfigureGeneral( + const Core::System& system_, + std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, QWidget* parent) + : Tab(group, parent), ui{std::make_unique<Ui::ConfigureGeneral>()}, 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 <functional> #include <memory> #include <QWidget> +#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<std::forward_list<ConfigurationShared::Tab*>> group, + QWidget* parent = nullptr); ~ConfigureGeneral() override; void SetResetCallback(std::function<void()> 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<VkDeviceInfo::Record>& records_, - const std::function<void()>& expose_compute_option_, - QWidget* parent) - : QWidget(parent), ui{std::make_unique<Ui::ConfigureGraphics>()}, records{records_}, - expose_compute_option{expose_compute_option_}, system{system_} { +ConfigureGraphics::ConfigureGraphics( + const Core::System& system_, std::vector<VkDeviceInfo::Record>& records_, + const std::function<void()>& expose_compute_option_, + std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, QWidget* parent) + : ConfigurationShared::Tab(group, parent), ui{std::make_unique<Ui::ConfigureGraphics>()}, + 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 <vulkan/vulkan_core.h> #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<VkDeviceInfo::Record>& records, const std::function<void()>& expose_compute_option_, + std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> 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<Ui::ConfigureGraphicsAdvanced>()}, system{system_} { +ConfigureGraphicsAdvanced::ConfigureGraphicsAdvanced( + const Core::System& system_, + std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, QWidget* parent) + : Tab(group, parent), ui{std::make_unique<Ui::ConfigureGraphicsAdvanced>()}, 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 <memory> #include <QWidget> +#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<std::forward_list<ConfigurationShared::Tab*>> 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<VkDeviceInfo::Record>& vk_device_records, Core::System& system_) - : QDialog(parent), - ui(std::make_unique<Ui::ConfigurePerGame>()), title_id{title_id_}, system{system_} { + : QDialog(parent), ui(std::make_unique<Ui::ConfigurePerGame>()), title_id{title_id_}, + system{system_}, group{std::make_shared<std::forward_list<ConfigurationShared::Tab*>>()} { 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>(config_file_name, Config::ConfigType::PerGameConfig); addons_tab = std::make_unique<ConfigurePerGameAddons>(system_, this); - audio_tab = std::make_unique<ConfigureAudio>(system_, this); - cpu_tab = std::make_unique<ConfigureCpu>(system_, this); - general_tab = std::make_unique<ConfigureGeneral>(system_, this); - graphics_advanced_tab = std::make_unique<ConfigureGraphicsAdvanced>(system_, this); + audio_tab = std::make_unique<ConfigureAudio>(system_, group, this); + cpu_tab = std::make_unique<ConfigureCpu>(system_, group, this); + general_tab = std::make_unique<ConfigureGeneral>(system_, group, this); + graphics_advanced_tab = std::make_unique<ConfigureGraphicsAdvanced>(system_, group, this); graphics_tab = std::make_unique<ConfigureGraphics>( - system_, vk_device_records, [&]() { graphics_advanced_tab->ExposeComputeOption(); }, this); + system_, vk_device_records, [&]() { graphics_advanced_tab->ExposeComputeOption(); }, group, + this); input_tab = std::make_unique<ConfigureInputPerGame>(system_, game_config.get(), this); - system_tab = std::make_unique<ConfigureSystem>(system_, this); + system_tab = std::make_unique<ConfigureSystem>(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 <forward_list> #include <memory> #include <string> #include <vector> @@ -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<Config> game_config; Core::System& system; - + std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group; std::unique_ptr<ConfigurePerGameAddons> addons_tab; std::unique_ptr<ConfigureAudio> audio_tab; std::unique_ptr<ConfigureCpu> 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<Ui::ConfigureSystem>()}, system{system_} { +ConfigureSystem::ConfigureSystem( + Core::System& system_, std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, + QWidget* parent) + : Tab(group, parent), ui{std::make_unique<Ui::ConfigureSystem>()}, 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 <memory> #include <QWidget> +#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<std::forward_list<ConfigurationShared::Tab*>> group, + QWidget* parent = nullptr); ~ConfigureSystem() override; - void ApplyConfiguration(); - void SetConfiguration(); + void ApplyConfiguration() override; + void SetConfiguration() override; private: void changeEvent(QEvent* event) override; |