configuration: Add base class to tabs

Tabs that largely configure SwitchableSetting's are now Tabs and grouped
together.
This commit is contained in:
lat9nq 2023-05-05 23:30:59 -04:00
parent e5b981e1e4
commit d3b94d64d4
18 changed files with 110 additions and 101 deletions

View File

@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: 2016 Citra Emulator Project // SPDX-FileCopyrightText: 2016 Citra Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include <memory>
#include <QCheckBox> #include <QCheckBox>
#include <QObject> #include <QObject>
#include <QString> #include <QString>
@ -11,9 +12,14 @@
namespace ConfigurationShared { 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 } // namespace ConfigurationShared

View File

@ -3,6 +3,9 @@
#pragma once #pragma once
#include <forward_list>
#include <iterator>
#include <memory>
#include <QCheckBox> #include <QCheckBox>
#include <QComboBox> #include <QComboBox>
#include <QWidget> #include <QWidget>
@ -15,11 +18,14 @@ class Tab : public QWidget {
Q_OBJECT Q_OBJECT
public: public:
explicit Tab(QWidget* parent = nullptr); explicit Tab(std::shared_ptr<std::forward_list<Tab*>> group_, QWidget* parent = nullptr);
~Tab(); ~Tab();
virtual void ApplyConfiguration() = 0; virtual void ApplyConfiguration() = 0;
virtual void SetConfiguration() = 0; virtual void SetConfiguration() = 0;
private:
std::shared_ptr<std::forward_list<Tab*>> group;
}; };
constexpr int USE_GLOBAL_INDEX = 0; constexpr int USE_GLOBAL_INDEX = 0;

View File

@ -12,8 +12,10 @@
#include "yuzu/configuration/configure_audio.h" #include "yuzu/configuration/configure_audio.h"
#include "yuzu/uisettings.h" #include "yuzu/uisettings.h"
ConfigureAudio::ConfigureAudio(const Core::System& system_, QWidget* parent) ConfigureAudio::ConfigureAudio(const Core::System& system_,
: QWidget(parent), ui(std::make_unique<Ui::ConfigureAudio>()), 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); ui->setupUi(this);
InitializeAudioSinkComboBox(); InitializeAudioSinkComboBox();

View File

@ -5,28 +5,25 @@
#include <memory> #include <memory>
#include <QWidget> #include <QWidget>
#include "yuzu/configuration/configuration_shared.h"
namespace Core { namespace Core {
class System; class System;
} }
namespace ConfigurationShared {
enum class CheckState;
}
namespace Ui { namespace Ui {
class ConfigureAudio; class ConfigureAudio;
} }
class ConfigureAudio : public QWidget { class ConfigureAudio : public ConfigurationShared::Tab {
Q_OBJECT
public: 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; ~ConfigureAudio() override;
void ApplyConfiguration(); void ApplyConfiguration() override;
void SetConfiguration(); void SetConfiguration() override;
private: private:
void changeEvent(QEvent* event) override; void changeEvent(QEvent* event) override;

View File

@ -1,6 +1,8 @@
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include <forward_list>
#include <memory>
#include "common/common_types.h" #include "common/common_types.h"
#include "common/settings.h" #include "common/settings.h"
#include "core/core.h" #include "core/core.h"
@ -8,8 +10,10 @@
#include "yuzu/configuration/configuration_shared.h" #include "yuzu/configuration/configuration_shared.h"
#include "yuzu/configuration/configure_cpu.h" #include "yuzu/configuration/configure_cpu.h"
ConfigureCpu::ConfigureCpu(const Core::System& system_, QWidget* parent) ConfigureCpu::ConfigureCpu(const Core::System& system_,
: QWidget(parent), ui{std::make_unique<Ui::ConfigureCpu>()}, 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); ui->setupUi(this);
SetupPerGameUI(); SetupPerGameUI();

View File

@ -5,28 +5,25 @@
#include <memory> #include <memory>
#include <QWidget> #include <QWidget>
#include "yuzu/configuration/configuration_shared.h"
namespace Core { namespace Core {
class System; class System;
} }
namespace ConfigurationShared {
enum class CheckState;
}
namespace Ui { namespace Ui {
class ConfigureCpu; class ConfigureCpu;
} }
class ConfigureCpu : public QWidget { class ConfigureCpu : public ConfigurationShared::Tab {
Q_OBJECT
public: 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; ~ConfigureCpu() override;
void ApplyConfiguration(); void ApplyConfiguration() override;
void SetConfiguration(); void SetConfiguration() override;
private: private:
void changeEvent(QEvent* event) override; void changeEvent(QEvent* event) override;

View File

@ -32,21 +32,21 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry_,
std::vector<VkDeviceInfo::Record>& vk_device_records, std::vector<VkDeviceInfo::Record>& vk_device_records,
Core::System& system_, bool enable_web_config) Core::System& system_, bool enable_web_config)
: QDialog(parent), ui{std::make_unique<Ui::ConfigureDialog>()}, : QDialog(parent), ui{std::make_unique<Ui::ConfigureDialog>()},
registry(registry_), system{system_}, audio_tab{std::make_unique<ConfigureAudio>(system_, registry(registry_), system{system_}, audio_tab{std::make_unique<ConfigureAudio>(
this)}, system_, nullptr, this)},
cpu_tab{std::make_unique<ConfigureCpu>(system_, this)}, cpu_tab{std::make_unique<ConfigureCpu>(system_, nullptr, this)},
debug_tab_tab{std::make_unique<ConfigureDebugTab>(system_, this)}, debug_tab_tab{std::make_unique<ConfigureDebugTab>(system_, this)},
filesystem_tab{std::make_unique<ConfigureFilesystem>(this)}, filesystem_tab{std::make_unique<ConfigureFilesystem>(this)},
general_tab{std::make_unique<ConfigureGeneral>(system_, this)}, general_tab{std::make_unique<ConfigureGeneral>(system_, nullptr, this)},
graphics_advanced_tab{std::make_unique<ConfigureGraphicsAdvanced>(system_, this)}, graphics_advanced_tab{std::make_unique<ConfigureGraphicsAdvanced>(system_, nullptr, this)},
graphics_tab{std::make_unique<ConfigureGraphics>( graphics_tab{std::make_unique<ConfigureGraphics>(
system_, vk_device_records, [&]() { graphics_advanced_tab->ExposeComputeOption(); }, system_, vk_device_records, [&]() { graphics_advanced_tab->ExposeComputeOption(); },
this)}, nullptr, this)},
hotkeys_tab{std::make_unique<ConfigureHotkeys>(system_.HIDCore(), this)}, hotkeys_tab{std::make_unique<ConfigureHotkeys>(system_.HIDCore(), this)},
input_tab{std::make_unique<ConfigureInput>(system_, this)}, input_tab{std::make_unique<ConfigureInput>(system_, this)},
network_tab{std::make_unique<ConfigureNetwork>(system_, this)}, network_tab{std::make_unique<ConfigureNetwork>(system_, this)},
profile_tab{std::make_unique<ConfigureProfileManager>(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>( ui_tab{std::make_unique<ConfigureUi>(system_, this)}, web_tab{std::make_unique<ConfigureWeb>(
this)} { this)} {
Settings::SetConfiguringGlobal(true); Settings::SetConfiguringGlobal(true);

View File

@ -3,9 +3,11 @@
#pragma once #pragma once
#include <forward_list>
#include <memory> #include <memory>
#include <vector> #include <vector>
#include <QDialog> #include <QDialog>
#include "configuration/configuration_shared.h"
#include "yuzu/vk_device_info.h" #include "yuzu/vk_device_info.h"
namespace Core { namespace Core {
@ -69,6 +71,7 @@ private:
HotkeyRegistry& registry; HotkeyRegistry& registry;
Core::System& system; Core::System& system;
std::forward_list<ConfigurationShared::Tab*> tab_group;
std::unique_ptr<ConfigureAudio> audio_tab; std::unique_ptr<ConfigureAudio> audio_tab;
std::unique_ptr<ConfigureCpu> cpu_tab; std::unique_ptr<ConfigureCpu> cpu_tab;

View File

@ -11,8 +11,10 @@
#include "yuzu/configuration/configure_general.h" #include "yuzu/configuration/configure_general.h"
#include "yuzu/uisettings.h" #include "yuzu/uisettings.h"
ConfigureGeneral::ConfigureGeneral(const Core::System& system_, QWidget* parent) ConfigureGeneral::ConfigureGeneral(
: QWidget(parent), ui{std::make_unique<Ui::ConfigureGeneral>()}, system{system_} { 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); ui->setupUi(this);
SetupPerGameUI(); SetupPerGameUI();

View File

@ -6,34 +6,30 @@
#include <functional> #include <functional>
#include <memory> #include <memory>
#include <QWidget> #include <QWidget>
#include "yuzu/configuration/configuration_shared.h"
namespace Core { namespace Core {
class System; class System;
} }
class ConfigureDialog; class ConfigureDialog;
namespace ConfigurationShared {
enum class CheckState;
}
class HotkeyRegistry; class HotkeyRegistry;
namespace Ui { namespace Ui {
class ConfigureGeneral; class ConfigureGeneral;
} }
class ConfigureGeneral : public QWidget { class ConfigureGeneral : public ConfigurationShared::Tab {
Q_OBJECT
public: 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; ~ConfigureGeneral() override;
void SetResetCallback(std::function<void()> callback); void SetResetCallback(std::function<void()> callback);
void ResetDefaults(); void ResetDefaults();
void ApplyConfiguration(); void ApplyConfiguration() override;
void SetConfiguration(); void SetConfiguration() override;
private: private:
void changeEvent(QEvent* event) override; void changeEvent(QEvent* event) override;

View File

@ -70,12 +70,12 @@ static constexpr Settings::VSyncMode PresentModeToSetting(VkPresentModeKHR mode)
} }
} }
ConfigureGraphics::ConfigureGraphics(const Core::System& system_, ConfigureGraphics::ConfigureGraphics(
std::vector<VkDeviceInfo::Record>& records_, const Core::System& system_, std::vector<VkDeviceInfo::Record>& records_,
const std::function<void()>& expose_compute_option_, const std::function<void()>& expose_compute_option_,
QWidget* parent) std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, QWidget* parent)
: QWidget(parent), ui{std::make_unique<Ui::ConfigureGraphics>()}, records{records_}, : ConfigurationShared::Tab(group, parent), ui{std::make_unique<Ui::ConfigureGraphics>()},
expose_compute_option{expose_compute_option_}, system{system_} { records{records_}, expose_compute_option{expose_compute_option_}, system{system_} {
vulkan_device = Settings::values.vulkan_device.GetValue(); vulkan_device = Settings::values.vulkan_device.GetValue();
RetrieveVulkanDevices(); RetrieveVulkanDevices();

View File

@ -13,6 +13,7 @@
#include <vulkan/vulkan_core.h> #include <vulkan/vulkan_core.h>
#include "common/common_types.h" #include "common/common_types.h"
#include "vk_device_info.h" #include "vk_device_info.h"
#include "yuzu/configuration/configuration_shared.h"
class QEvent; class QEvent;
class QObject; class QObject;
@ -27,26 +28,21 @@ namespace Core {
class System; class System;
} }
namespace ConfigurationShared {
enum class CheckState;
}
namespace Ui { namespace Ui {
class ConfigureGraphics; class ConfigureGraphics;
} }
class ConfigureGraphics : public QWidget { class ConfigureGraphics : public ConfigurationShared::Tab {
Q_OBJECT
public: public:
explicit ConfigureGraphics(const Core::System& system_, explicit ConfigureGraphics(const Core::System& system_,
std::vector<VkDeviceInfo::Record>& records, std::vector<VkDeviceInfo::Record>& records,
const std::function<void()>& expose_compute_option_, const std::function<void()>& expose_compute_option_,
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group,
QWidget* parent = nullptr); QWidget* parent = nullptr);
~ConfigureGraphics() override; ~ConfigureGraphics() override;
void ApplyConfiguration(); void ApplyConfiguration() override;
void SetConfiguration(); void SetConfiguration() override;
private: private:
void changeEvent(QEvent* event) override; void changeEvent(QEvent* event) override;

View File

@ -7,8 +7,10 @@
#include "yuzu/configuration/configuration_shared.h" #include "yuzu/configuration/configuration_shared.h"
#include "yuzu/configuration/configure_graphics_advanced.h" #include "yuzu/configuration/configure_graphics_advanced.h"
ConfigureGraphicsAdvanced::ConfigureGraphicsAdvanced(const Core::System& system_, QWidget* parent) ConfigureGraphicsAdvanced::ConfigureGraphicsAdvanced(
: QWidget(parent), ui{std::make_unique<Ui::ConfigureGraphicsAdvanced>()}, system{system_} { 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); ui->setupUi(this);

View File

@ -5,28 +5,26 @@
#include <memory> #include <memory>
#include <QWidget> #include <QWidget>
#include "yuzu/configuration/configuration_shared.h"
namespace Core { namespace Core {
class System; class System;
} }
namespace ConfigurationShared {
enum class CheckState;
}
namespace Ui { namespace Ui {
class ConfigureGraphicsAdvanced; class ConfigureGraphicsAdvanced;
} }
class ConfigureGraphicsAdvanced : public QWidget { class ConfigureGraphicsAdvanced : public ConfigurationShared::Tab {
Q_OBJECT
public: 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; ~ConfigureGraphicsAdvanced() override;
void ApplyConfiguration(); void ApplyConfiguration() override;
void SetConfiguration(); void SetConfiguration() override;
void ExposeComputeOption(); void ExposeComputeOption();

View File

@ -24,6 +24,7 @@
#include "core/loader/loader.h" #include "core/loader/loader.h"
#include "ui_configure_per_game.h" #include "ui_configure_per_game.h"
#include "yuzu/configuration/config.h" #include "yuzu/configuration/config.h"
#include "yuzu/configuration/configuration_shared.h"
#include "yuzu/configuration/configure_audio.h" #include "yuzu/configuration/configure_audio.h"
#include "yuzu/configuration/configure_cpu.h" #include "yuzu/configuration/configure_cpu.h"
#include "yuzu/configuration/configure_general.h" #include "yuzu/configuration/configure_general.h"
@ -40,22 +41,23 @@
ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::string& file_name, ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::string& file_name,
std::vector<VkDeviceInfo::Record>& vk_device_records, std::vector<VkDeviceInfo::Record>& vk_device_records,
Core::System& system_) Core::System& system_)
: QDialog(parent), : QDialog(parent), ui(std::make_unique<Ui::ConfigurePerGame>()), title_id{title_id_},
ui(std::make_unique<Ui::ConfigurePerGame>()), title_id{title_id_}, system{system_} { 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 file_path = std::filesystem::path(Common::FS::ToU8String(file_name));
const auto config_file_name = title_id == 0 ? Common::FS::PathToUTF8String(file_path.filename()) const auto config_file_name = title_id == 0 ? Common::FS::PathToUTF8String(file_path.filename())
: fmt::format("{:016X}", title_id); : fmt::format("{:016X}", title_id);
game_config = std::make_unique<Config>(config_file_name, Config::ConfigType::PerGameConfig); game_config = std::make_unique<Config>(config_file_name, Config::ConfigType::PerGameConfig);
addons_tab = std::make_unique<ConfigurePerGameAddons>(system_, this); addons_tab = std::make_unique<ConfigurePerGameAddons>(system_, this);
audio_tab = std::make_unique<ConfigureAudio>(system_, this); audio_tab = std::make_unique<ConfigureAudio>(system_, group, this);
cpu_tab = std::make_unique<ConfigureCpu>(system_, this); cpu_tab = std::make_unique<ConfigureCpu>(system_, group, this);
general_tab = std::make_unique<ConfigureGeneral>(system_, this); general_tab = std::make_unique<ConfigureGeneral>(system_, group, this);
graphics_advanced_tab = std::make_unique<ConfigureGraphicsAdvanced>(system_, this); graphics_advanced_tab = std::make_unique<ConfigureGraphicsAdvanced>(system_, group, this);
graphics_tab = std::make_unique<ConfigureGraphics>( 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); 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); ui->setupUi(this);
@ -88,13 +90,10 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::st
ConfigurePerGame::~ConfigurePerGame() = default; ConfigurePerGame::~ConfigurePerGame() = default;
void ConfigurePerGame::ApplyConfiguration() { void ConfigurePerGame::ApplyConfiguration() {
for (const auto tab : *group) {
tab->ApplyConfiguration();
}
addons_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(); input_tab->ApplyConfiguration();
system.ApplySettings(); system.ApplySettings();

View File

@ -3,6 +3,7 @@
#pragma once #pragma once
#include <forward_list>
#include <memory> #include <memory>
#include <string> #include <string>
#include <vector> #include <vector>
@ -13,6 +14,7 @@
#include "core/file_sys/vfs_types.h" #include "core/file_sys/vfs_types.h"
#include "vk_device_info.h" #include "vk_device_info.h"
#include "yuzu/configuration/config.h" #include "yuzu/configuration/config.h"
#include "yuzu/configuration/configuration_shared.h"
namespace Core { namespace Core {
class System; class System;
@ -73,7 +75,7 @@ private:
std::unique_ptr<Config> game_config; std::unique_ptr<Config> game_config;
Core::System& system; Core::System& system;
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group;
std::unique_ptr<ConfigurePerGameAddons> addons_tab; std::unique_ptr<ConfigurePerGameAddons> addons_tab;
std::unique_ptr<ConfigureAudio> audio_tab; std::unique_ptr<ConfigureAudio> audio_tab;
std::unique_ptr<ConfigureCpu> cpu_tab; std::unique_ptr<ConfigureCpu> cpu_tab;

View File

@ -37,8 +37,10 @@ static bool IsValidLocale(u32 region_index, u32 language_index) {
return ((LOCALE_BLOCKLIST.at(region_index) >> language_index) & 1) == 0; return ((LOCALE_BLOCKLIST.at(region_index) >> language_index) & 1) == 0;
} }
ConfigureSystem::ConfigureSystem(Core::System& system_, QWidget* parent) ConfigureSystem::ConfigureSystem(
: QWidget(parent), ui{std::make_unique<Ui::ConfigureSystem>()}, system{system_} { 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); ui->setupUi(this);
connect(ui->rng_seed_checkbox, &QCheckBox::stateChanged, this, [this](int state) { connect(ui->rng_seed_checkbox, &QCheckBox::stateChanged, this, [this](int state) {

View File

@ -6,28 +6,25 @@
#include <memory> #include <memory>
#include <QWidget> #include <QWidget>
#include "yuzu/configuration/configuration_shared.h"
namespace Core { namespace Core {
class System; class System;
} }
namespace ConfigurationShared {
enum class CheckState;
}
namespace Ui { namespace Ui {
class ConfigureSystem; class ConfigureSystem;
} }
class ConfigureSystem : public QWidget { class ConfigureSystem : public ConfigurationShared::Tab {
Q_OBJECT
public: 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; ~ConfigureSystem() override;
void ApplyConfiguration(); void ApplyConfiguration() override;
void SetConfiguration(); void SetConfiguration() override;
private: private:
void changeEvent(QEvent* event) override; void changeEvent(QEvent* event) override;