mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-29 23:06:23 -05:00
configuration: Use a builder to create widgets
This gets rid of some repeated code and sets us up to send more information to the new widget.
This commit is contained in:
parent
62ffaa730f
commit
ad645c29a4
18 changed files with 206 additions and 209 deletions
|
@ -16,23 +16,19 @@
|
||||||
#include "yuzu/configuration/shared_widget.h"
|
#include "yuzu/configuration/shared_widget.h"
|
||||||
#include "yuzu/uisettings.h"
|
#include "yuzu/uisettings.h"
|
||||||
|
|
||||||
ConfigureAudio::ConfigureAudio(
|
ConfigureAudio::ConfigureAudio(const Core::System& system_,
|
||||||
const Core::System& system_,
|
|
||||||
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_,
|
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_,
|
||||||
const ConfigurationShared::TranslationMap& translations_,
|
const ConfigurationShared::Builder& builder, QWidget* parent)
|
||||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent)
|
: Tab(group_, parent), ui(std::make_unique<Ui::ConfigureAudio>()), system{system_} {
|
||||||
: Tab(group_, parent), ui(std::make_unique<Ui::ConfigureAudio>()), system{system_},
|
|
||||||
translations{translations_}, combobox_translations{combobox_translations_} {
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
Setup();
|
Setup(builder);
|
||||||
|
|
||||||
SetConfiguration();
|
SetConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigureAudio::~ConfigureAudio() = default;
|
ConfigureAudio::~ConfigureAudio() = default;
|
||||||
|
|
||||||
void ConfigureAudio::Setup() {
|
void ConfigureAudio::Setup(const ConfigurationShared::Builder& builder) {
|
||||||
const bool runtime_lock = !system.IsPoweredOn();
|
|
||||||
auto& layout = *ui->audio_widget->layout();
|
auto& layout = *ui->audio_widget->layout();
|
||||||
|
|
||||||
std::forward_list<Settings::BasicSetting*> settings;
|
std::forward_list<Settings::BasicSetting*> settings;
|
||||||
|
@ -47,15 +43,10 @@ void ConfigureAudio::Setup() {
|
||||||
push(Settings::Category::SystemAudio);
|
push(Settings::Category::SystemAudio);
|
||||||
|
|
||||||
for (auto* setting : settings) {
|
for (auto* setting : settings) {
|
||||||
if (!Settings::IsConfiguringGlobal() && !setting->Switchable()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto* widget = [&]() {
|
auto* widget = [&]() {
|
||||||
if (setting->Id() == Settings::values.volume.Id()) {
|
if (setting->Id() == Settings::values.volume.Id()) {
|
||||||
// volume needs to be a slider (default is line edit)
|
// volume needs to be a slider (default is line edit)
|
||||||
return new ConfigurationShared::Widget(setting, translations, combobox_translations,
|
return builder.BuildWidget(setting, apply_funcs, nullptr,
|
||||||
this, runtime_lock, apply_funcs, nullptr,
|
|
||||||
ConfigurationShared::RequestType::Slider,
|
ConfigurationShared::RequestType::Slider,
|
||||||
tr("%1%", "Volume percentage (e.g. 50%)"));
|
tr("%1%", "Volume percentage (e.g. 50%)"));
|
||||||
} else if (setting->Id() == Settings::values.audio_output_device_id.Id() ||
|
} else if (setting->Id() == Settings::values.audio_output_device_id.Id() ||
|
||||||
|
@ -63,15 +54,16 @@ void ConfigureAudio::Setup() {
|
||||||
setting->Id() == Settings::values.sink_id.Id()) {
|
setting->Id() == Settings::values.sink_id.Id()) {
|
||||||
// These need to be unmanaged comboboxes, so we can populate them ourselves
|
// These need to be unmanaged comboboxes, so we can populate them ourselves
|
||||||
// TODO (lat9nq): Let it manage sink_id
|
// TODO (lat9nq): Let it manage sink_id
|
||||||
return new ConfigurationShared::Widget(
|
return builder.BuildWidget(setting, apply_funcs,
|
||||||
setting, translations, combobox_translations, this, runtime_lock, apply_funcs,
|
|
||||||
ConfigurationShared::RequestType::ComboBox, false);
|
ConfigurationShared::RequestType::ComboBox, false);
|
||||||
} else {
|
} else {
|
||||||
return new ConfigurationShared::Widget(setting, translations, combobox_translations,
|
return builder.BuildWidget(setting, apply_funcs);
|
||||||
this, runtime_lock, apply_funcs);
|
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
|
|
||||||
|
if (widget == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!widget->Valid()) {
|
if (!widget->Valid()) {
|
||||||
delete widget;
|
delete widget;
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include "yuzu/configuration/configuration_shared.h"
|
#include "yuzu/configuration/configuration_shared.h"
|
||||||
#include "yuzu/configuration/shared_translation.h"
|
|
||||||
|
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
|
|
||||||
|
@ -20,14 +19,15 @@ namespace Ui {
|
||||||
class ConfigureAudio;
|
class ConfigureAudio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace ConfigurationShared {
|
||||||
|
class Builder;
|
||||||
|
}
|
||||||
|
|
||||||
class ConfigureAudio : public ConfigurationShared::Tab {
|
class ConfigureAudio : public ConfigurationShared::Tab {
|
||||||
public:
|
public:
|
||||||
explicit ConfigureAudio(
|
explicit ConfigureAudio(const Core::System& system_,
|
||||||
const Core::System& system_,
|
|
||||||
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group,
|
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group,
|
||||||
const ConfigurationShared::TranslationMap& translations_,
|
const ConfigurationShared::Builder& builder, QWidget* parent = nullptr);
|
||||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations_,
|
|
||||||
QWidget* parent = nullptr);
|
|
||||||
~ConfigureAudio() override;
|
~ConfigureAudio() override;
|
||||||
|
|
||||||
void ApplyConfiguration() override;
|
void ApplyConfiguration() override;
|
||||||
|
@ -45,13 +45,11 @@ private:
|
||||||
void SetOutputSinkFromSinkID();
|
void SetOutputSinkFromSinkID();
|
||||||
void SetAudioDevicesFromDeviceID();
|
void SetAudioDevicesFromDeviceID();
|
||||||
|
|
||||||
void Setup();
|
void Setup(const ConfigurationShared::Builder& builder);
|
||||||
|
|
||||||
std::unique_ptr<Ui::ConfigureAudio> ui;
|
std::unique_ptr<Ui::ConfigureAudio> ui;
|
||||||
|
|
||||||
const Core::System& system;
|
const Core::System& system;
|
||||||
const ConfigurationShared::TranslationMap& translations;
|
|
||||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations;
|
|
||||||
|
|
||||||
std::forward_list<std::function<void(bool)>> apply_funcs{};
|
std::forward_list<std::function<void(bool)>> apply_funcs{};
|
||||||
|
|
||||||
|
|
|
@ -13,16 +13,14 @@
|
||||||
#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(
|
ConfigureCpu::ConfigureCpu(const Core::System& system_,
|
||||||
const Core::System& system_,
|
|
||||||
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_,
|
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_,
|
||||||
const ConfigurationShared::TranslationMap& translations_,
|
const ConfigurationShared::Builder& builder, QWidget* parent)
|
||||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent)
|
|
||||||
: Tab(group_, parent), ui{std::make_unique<Ui::ConfigureCpu>()}, system{system_},
|
: Tab(group_, parent), ui{std::make_unique<Ui::ConfigureCpu>()}, system{system_},
|
||||||
translations{translations_}, combobox_translations{combobox_translations_} {
|
combobox_translations(builder.ComboboxTranslations()) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
Setup();
|
Setup(builder);
|
||||||
|
|
||||||
SetConfiguration();
|
SetConfiguration();
|
||||||
|
|
||||||
|
@ -33,8 +31,7 @@ ConfigureCpu::ConfigureCpu(
|
||||||
ConfigureCpu::~ConfigureCpu() = default;
|
ConfigureCpu::~ConfigureCpu() = default;
|
||||||
|
|
||||||
void ConfigureCpu::SetConfiguration() {}
|
void ConfigureCpu::SetConfiguration() {}
|
||||||
void ConfigureCpu::Setup() {
|
void ConfigureCpu::Setup(const ConfigurationShared::Builder& builder) {
|
||||||
const bool runtime_lock = !system.IsPoweredOn();
|
|
||||||
auto* accuracy_layout = ui->widget_accuracy->layout();
|
auto* accuracy_layout = ui->widget_accuracy->layout();
|
||||||
auto* unsafe_layout = ui->unsafe_widget->layout();
|
auto* unsafe_layout = ui->unsafe_widget->layout();
|
||||||
std::map<std::string, QWidget*> unsafe_hold{};
|
std::map<std::string, QWidget*> unsafe_hold{};
|
||||||
|
@ -50,13 +47,11 @@ void ConfigureCpu::Setup() {
|
||||||
push(Settings::Category::CpuUnsafe);
|
push(Settings::Category::CpuUnsafe);
|
||||||
|
|
||||||
for (const auto setting : settings) {
|
for (const auto setting : settings) {
|
||||||
if (!Settings::IsConfiguringGlobal() && !setting->Switchable()) {
|
auto* widget = builder.BuildWidget(setting, apply_funcs);
|
||||||
|
|
||||||
|
if (widget == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* widget = new ConfigurationShared::Widget(setting, translations, combobox_translations,
|
|
||||||
this, runtime_lock, apply_funcs);
|
|
||||||
|
|
||||||
if (!widget->Valid()) {
|
if (!widget->Valid()) {
|
||||||
delete widget;
|
delete widget;
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -18,13 +18,15 @@ namespace Ui {
|
||||||
class ConfigureCpu;
|
class ConfigureCpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace ConfigurationShared {
|
||||||
|
class Builder;
|
||||||
|
}
|
||||||
|
|
||||||
class ConfigureCpu : public ConfigurationShared::Tab {
|
class ConfigureCpu : public ConfigurationShared::Tab {
|
||||||
public:
|
public:
|
||||||
explicit ConfigureCpu(const Core::System& system_,
|
explicit ConfigureCpu(const Core::System& system_,
|
||||||
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group,
|
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group,
|
||||||
const ConfigurationShared::TranslationMap& translations,
|
const ConfigurationShared::Builder& builder, QWidget* parent = nullptr);
|
||||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations,
|
|
||||||
QWidget* parent = nullptr);
|
|
||||||
~ConfigureCpu() override;
|
~ConfigureCpu() override;
|
||||||
|
|
||||||
void ApplyConfiguration() override;
|
void ApplyConfiguration() override;
|
||||||
|
@ -36,15 +38,13 @@ private:
|
||||||
|
|
||||||
void UpdateGroup(int index);
|
void UpdateGroup(int index);
|
||||||
|
|
||||||
void Setup();
|
void Setup(const ConfigurationShared::Builder& builder);
|
||||||
|
|
||||||
std::unique_ptr<Ui::ConfigureCpu> ui;
|
std::unique_ptr<Ui::ConfigureCpu> ui;
|
||||||
|
|
||||||
const Core::System& system;
|
const Core::System& system;
|
||||||
|
|
||||||
const ConfigurationShared::TranslationMap& translations;
|
|
||||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations;
|
const ConfigurationShared::ComboboxTranslationMap& combobox_translations;
|
||||||
|
|
||||||
std::forward_list<std::function<void(bool)>> apply_funcs{};
|
std::forward_list<std::function<void(bool)>> apply_funcs{};
|
||||||
|
|
||||||
QComboBox* accuracy_combobox;
|
QComboBox* accuracy_combobox;
|
||||||
|
|
|
@ -32,28 +32,23 @@ 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_},
|
registry(registry_), system{system_}, builder{std::make_unique<ConfigurationShared::Builder>(
|
||||||
translations{ConfigurationShared::InitializeTranslations(this)},
|
this, !system_.IsPoweredOn())},
|
||||||
combobox_translations{ConfigurationShared::ComboboxEnumeration(this)},
|
audio_tab{std::make_unique<ConfigureAudio>(system_, nullptr, *builder, this)},
|
||||||
audio_tab{std::make_unique<ConfigureAudio>(system_, nullptr, *translations,
|
cpu_tab{std::make_unique<ConfigureCpu>(system_, nullptr, *builder, this)},
|
||||||
*combobox_translations, this)},
|
|
||||||
cpu_tab{std::make_unique<ConfigureCpu>(system_, nullptr, *translations,
|
|
||||||
*combobox_translations, 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_, nullptr, *translations,
|
general_tab{std::make_unique<ConfigureGeneral>(system_, nullptr, *builder, this)},
|
||||||
*combobox_translations, this)},
|
graphics_advanced_tab{
|
||||||
graphics_advanced_tab{std::make_unique<ConfigureGraphicsAdvanced>(
|
std::make_unique<ConfigureGraphicsAdvanced>(system_, nullptr, *builder, this)},
|
||||||
system_, nullptr, *translations, *combobox_translations, 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(); },
|
||||||
nullptr, *translations, *combobox_translations, this)},
|
nullptr, *builder, 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_, nullptr, *translations,
|
system_tab{std::make_unique<ConfigureSystem>(system_, nullptr, *builder, this)},
|
||||||
*combobox_translations, 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);
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include "configuration/shared_widget.h"
|
||||||
#include "yuzu/configuration/configuration_shared.h"
|
#include "yuzu/configuration/configuration_shared.h"
|
||||||
#include "yuzu/configuration/shared_translation.h"
|
#include "yuzu/configuration/shared_translation.h"
|
||||||
#include "yuzu/vk_device_info.h"
|
#include "yuzu/vk_device_info.h"
|
||||||
|
@ -72,8 +73,7 @@ private:
|
||||||
HotkeyRegistry& registry;
|
HotkeyRegistry& registry;
|
||||||
|
|
||||||
Core::System& system;
|
Core::System& system;
|
||||||
std::unique_ptr<ConfigurationShared::TranslationMap> translations;
|
std::unique_ptr<ConfigurationShared::Builder> builder;
|
||||||
std::unique_ptr<ConfigurationShared::ComboboxTranslationMap> combobox_translations;
|
|
||||||
std::forward_list<ConfigurationShared::Tab*> tab_group;
|
std::forward_list<ConfigurationShared::Tab*> tab_group;
|
||||||
|
|
||||||
std::unique_ptr<ConfigureAudio> audio_tab;
|
std::unique_ptr<ConfigureAudio> audio_tab;
|
||||||
|
|
|
@ -15,12 +15,12 @@
|
||||||
ConfigureGeneral::ConfigureGeneral(
|
ConfigureGeneral::ConfigureGeneral(
|
||||||
const Core::System& system_,
|
const Core::System& system_,
|
||||||
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_,
|
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_,
|
||||||
const ConfigurationShared::TranslationMap& translations_,
|
const ConfigurationShared::Builder& builder, QWidget* parent)
|
||||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent)
|
: Tab(group_, parent), ui{std::make_unique<Ui::ConfigureGeneral>()}, system{system_} {
|
||||||
: Tab(group_, parent), ui{std::make_unique<Ui::ConfigureGeneral>()}, system{system_},
|
|
||||||
translations{translations_}, combobox_translations{combobox_translations_} {
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
Setup(builder);
|
||||||
|
|
||||||
SetConfiguration();
|
SetConfiguration();
|
||||||
|
|
||||||
connect(ui->button_reset_defaults, &QPushButton::clicked, this,
|
connect(ui->button_reset_defaults, &QPushButton::clicked, this,
|
||||||
|
@ -33,17 +33,20 @@ ConfigureGeneral::ConfigureGeneral(
|
||||||
|
|
||||||
ConfigureGeneral::~ConfigureGeneral() = default;
|
ConfigureGeneral::~ConfigureGeneral() = default;
|
||||||
|
|
||||||
void ConfigureGeneral::SetConfiguration() {
|
void ConfigureGeneral::SetConfiguration() {}
|
||||||
const bool runtime_lock = !system.IsPoweredOn();
|
|
||||||
|
void ConfigureGeneral::Setup(const ConfigurationShared::Builder& builder) {
|
||||||
QLayout& layout = *ui->general_widget->layout();
|
QLayout& layout = *ui->general_widget->layout();
|
||||||
|
|
||||||
std::map<u32, QWidget*> hold{};
|
std::map<u32, QWidget*> hold{};
|
||||||
|
|
||||||
for (const auto setting :
|
for (const auto setting :
|
||||||
UISettings::values.linkage.by_category[Settings::Category::UiGeneral]) {
|
UISettings::values.linkage.by_category[Settings::Category::UiGeneral]) {
|
||||||
auto* widget = new ConfigurationShared::Widget(setting, translations, combobox_translations,
|
auto* widget = builder.BuildWidget(setting, apply_funcs);
|
||||||
this, runtime_lock, apply_funcs);
|
|
||||||
|
|
||||||
|
if (widget == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!widget->Valid()) {
|
if (!widget->Valid()) {
|
||||||
delete widget;
|
delete widget;
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include "yuzu/configuration/configuration_shared.h"
|
#include "yuzu/configuration/configuration_shared.h"
|
||||||
#include "yuzu/configuration/shared_widget.h"
|
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class System;
|
class System;
|
||||||
|
@ -20,13 +19,15 @@ namespace Ui {
|
||||||
class ConfigureGeneral;
|
class ConfigureGeneral;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace ConfigurationShared {
|
||||||
|
class Builder;
|
||||||
|
}
|
||||||
|
|
||||||
class ConfigureGeneral : public ConfigurationShared::Tab {
|
class ConfigureGeneral : public ConfigurationShared::Tab {
|
||||||
public:
|
public:
|
||||||
explicit ConfigureGeneral(
|
explicit ConfigureGeneral(const Core::System& system_,
|
||||||
const Core::System& system_,
|
|
||||||
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group,
|
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group,
|
||||||
const ConfigurationShared::TranslationMap& translations_,
|
const ConfigurationShared::Builder& builder,
|
||||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations_,
|
|
||||||
QWidget* parent = nullptr);
|
QWidget* parent = nullptr);
|
||||||
~ConfigureGeneral() override;
|
~ConfigureGeneral() override;
|
||||||
|
|
||||||
|
@ -36,6 +37,8 @@ public:
|
||||||
void SetConfiguration() override;
|
void SetConfiguration() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void Setup(const ConfigurationShared::Builder& builder);
|
||||||
|
|
||||||
void changeEvent(QEvent* event) override;
|
void changeEvent(QEvent* event) override;
|
||||||
void RetranslateUI();
|
void RetranslateUI();
|
||||||
|
|
||||||
|
@ -46,6 +49,4 @@ private:
|
||||||
std::forward_list<std::function<void(bool)>> apply_funcs{};
|
std::forward_list<std::function<void(bool)>> apply_funcs{};
|
||||||
|
|
||||||
const Core::System& system;
|
const Core::System& system;
|
||||||
const ConfigurationShared::TranslationMap& translations;
|
|
||||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations;
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -81,18 +81,17 @@ ConfigureGraphics::ConfigureGraphics(
|
||||||
const Core::System& system_, 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_,
|
||||||
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_,
|
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_,
|
||||||
const ConfigurationShared::TranslationMap& translations_,
|
const ConfigurationShared::Builder& builder, QWidget* parent)
|
||||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent)
|
|
||||||
: ConfigurationShared::Tab(group_, parent), ui{std::make_unique<Ui::ConfigureGraphics>()},
|
: ConfigurationShared::Tab(group_, parent), ui{std::make_unique<Ui::ConfigureGraphics>()},
|
||||||
records{records_}, expose_compute_option{expose_compute_option_}, system{system_},
|
records{records_}, expose_compute_option{expose_compute_option_}, system{system_},
|
||||||
translations{translations_}, combobox_translations{combobox_translations_},
|
combobox_translations{builder.ComboboxTranslations()},
|
||||||
shader_mapping{combobox_translations.at(typeid(Settings::ShaderBackend))} {
|
shader_mapping{combobox_translations.at(typeid(Settings::ShaderBackend))} {
|
||||||
vulkan_device = Settings::values.vulkan_device.GetValue();
|
vulkan_device = Settings::values.vulkan_device.GetValue();
|
||||||
RetrieveVulkanDevices();
|
RetrieveVulkanDevices();
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
Setup();
|
Setup(builder);
|
||||||
|
|
||||||
for (const auto& device : vulkan_devices) {
|
for (const auto& device : vulkan_devices) {
|
||||||
vulkan_device_combobox->addItem(device);
|
vulkan_device_combobox->addItem(device);
|
||||||
|
@ -218,8 +217,7 @@ ConfigureGraphics::~ConfigureGraphics() = default;
|
||||||
|
|
||||||
void ConfigureGraphics::SetConfiguration() {}
|
void ConfigureGraphics::SetConfiguration() {}
|
||||||
|
|
||||||
void ConfigureGraphics::Setup() {
|
void ConfigureGraphics::Setup(const ConfigurationShared::Builder& builder) {
|
||||||
const bool runtime_lock = !system.IsPoweredOn();
|
|
||||||
QLayout* api_layout = ui->api_widget->layout();
|
QLayout* api_layout = ui->api_widget->layout();
|
||||||
QWidget* api_grid_widget = new QWidget(this);
|
QWidget* api_grid_widget = new QWidget(this);
|
||||||
QVBoxLayout* api_grid_layout = new QVBoxLayout(api_grid_widget);
|
QVBoxLayout* api_grid_layout = new QVBoxLayout(api_grid_widget);
|
||||||
|
@ -232,30 +230,26 @@ void ConfigureGraphics::Setup() {
|
||||||
std::forward_list<QWidget*> hold_api;
|
std::forward_list<QWidget*> hold_api;
|
||||||
|
|
||||||
for (const auto setting : Settings::values.linkage.by_category[Settings::Category::Renderer]) {
|
for (const auto setting : Settings::values.linkage.by_category[Settings::Category::Renderer]) {
|
||||||
if (!Settings::IsConfiguringGlobal() && !setting->Switchable()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigurationShared::Widget* widget = [&]() {
|
ConfigurationShared::Widget* widget = [&]() {
|
||||||
// Set managed to false on these and set up the comboboxes ourselves
|
// Set managed to false on these and set up the comboboxes ourselves
|
||||||
if (setting->Id() == Settings::values.vulkan_device.Id() ||
|
if (setting->Id() == Settings::values.vulkan_device.Id() ||
|
||||||
setting->Id() == Settings::values.shader_backend.Id() ||
|
setting->Id() == Settings::values.shader_backend.Id() ||
|
||||||
setting->Id() == Settings::values.vsync_mode.Id()) {
|
setting->Id() == Settings::values.vsync_mode.Id()) {
|
||||||
return new ConfigurationShared::Widget(
|
return builder.BuildWidget(setting, apply_funcs,
|
||||||
setting, translations, combobox_translations, this, runtime_lock, apply_funcs,
|
|
||||||
ConfigurationShared::RequestType::ComboBox, false);
|
ConfigurationShared::RequestType::ComboBox, false);
|
||||||
} else if (setting->Id() == Settings::values.fsr_sharpening_slider.Id()) {
|
} else if (setting->Id() == Settings::values.fsr_sharpening_slider.Id()) {
|
||||||
// FSR needs a reversed slider
|
// FSR needs a reversed slider
|
||||||
return new ConfigurationShared::Widget(
|
return builder.BuildWidget(
|
||||||
setting, translations, combobox_translations, this, runtime_lock, apply_funcs,
|
setting, apply_funcs, ConfigurationShared::RequestType::ReverseSlider, true,
|
||||||
ConfigurationShared::RequestType::ReverseSlider, true, 0.5f, nullptr,
|
0.5f, nullptr, tr("%1%", "FSR sharpening percentage (e.g. 50%)"));
|
||||||
tr("%1%", "FSR sharpening percentage (e.g. 50%)"));
|
|
||||||
} else {
|
} else {
|
||||||
return new ConfigurationShared::Widget(setting, translations, combobox_translations,
|
return builder.BuildWidget(setting, apply_funcs);
|
||||||
this, runtime_lock, apply_funcs);
|
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
|
|
||||||
|
if (widget == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!widget->Valid()) {
|
if (!widget->Valid()) {
|
||||||
delete widget;
|
delete widget;
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
#include <typeindex>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
@ -13,9 +14,9 @@
|
||||||
#include <qobjectdefs.h>
|
#include <qobjectdefs.h>
|
||||||
#include <vulkan/vulkan_core.h>
|
#include <vulkan/vulkan_core.h>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
#include "configuration/shared_translation.h"
|
||||||
#include "vk_device_info.h"
|
#include "vk_device_info.h"
|
||||||
#include "yuzu/configuration/configuration_shared.h"
|
#include "yuzu/configuration/configuration_shared.h"
|
||||||
#include "yuzu/configuration/shared_translation.h"
|
|
||||||
|
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
class QEvent;
|
class QEvent;
|
||||||
|
@ -36,14 +37,17 @@ namespace Ui {
|
||||||
class ConfigureGraphics;
|
class ConfigureGraphics;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace ConfigurationShared {
|
||||||
|
class Builder;
|
||||||
|
}
|
||||||
|
|
||||||
class ConfigureGraphics : public ConfigurationShared::Tab {
|
class ConfigureGraphics : public ConfigurationShared::Tab {
|
||||||
public:
|
public:
|
||||||
explicit ConfigureGraphics(
|
explicit ConfigureGraphics(const Core::System& system_,
|
||||||
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,
|
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group,
|
||||||
const ConfigurationShared::TranslationMap& translations_,
|
const ConfigurationShared::Builder& builder,
|
||||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations_,
|
|
||||||
QWidget* parent = nullptr);
|
QWidget* parent = nullptr);
|
||||||
~ConfigureGraphics() override;
|
~ConfigureGraphics() override;
|
||||||
|
|
||||||
|
@ -54,7 +58,7 @@ private:
|
||||||
void changeEvent(QEvent* event) override;
|
void changeEvent(QEvent* event) override;
|
||||||
void RetranslateUI();
|
void RetranslateUI();
|
||||||
|
|
||||||
void Setup();
|
void Setup(const ConfigurationShared::Builder& builder);
|
||||||
|
|
||||||
void PopulateVSyncModeSelection();
|
void PopulateVSyncModeSelection();
|
||||||
void UpdateBackgroundColorButton(QColor color);
|
void UpdateBackgroundColorButton(QColor color);
|
||||||
|
@ -89,7 +93,6 @@ private:
|
||||||
const std::function<void()>& expose_compute_option;
|
const std::function<void()>& expose_compute_option;
|
||||||
|
|
||||||
const Core::System& system;
|
const Core::System& system;
|
||||||
const ConfigurationShared::TranslationMap& translations;
|
|
||||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations;
|
const ConfigurationShared::ComboboxTranslationMap& combobox_translations;
|
||||||
const std::vector<std::pair<u32, QString>>& shader_mapping;
|
const std::vector<std::pair<u32, QString>>& shader_mapping;
|
||||||
|
|
||||||
|
|
|
@ -14,13 +14,13 @@
|
||||||
ConfigureGraphicsAdvanced::ConfigureGraphicsAdvanced(
|
ConfigureGraphicsAdvanced::ConfigureGraphicsAdvanced(
|
||||||
const Core::System& system_,
|
const Core::System& system_,
|
||||||
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_,
|
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_,
|
||||||
const ConfigurationShared::TranslationMap& translations_,
|
const ConfigurationShared::Builder& builder, QWidget* parent)
|
||||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent)
|
: Tab(group_, parent), ui{std::make_unique<Ui::ConfigureGraphicsAdvanced>()}, system{system_} {
|
||||||
: Tab(group_, parent), ui{std::make_unique<Ui::ConfigureGraphicsAdvanced>()}, system{system_},
|
|
||||||
translations{translations_}, combobox_translations{combobox_translations_} {
|
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
Setup(builder);
|
||||||
|
|
||||||
SetConfiguration();
|
SetConfiguration();
|
||||||
|
|
||||||
checkbox_enable_compute_pipelines->setVisible(false);
|
checkbox_enable_compute_pipelines->setVisible(false);
|
||||||
|
@ -28,20 +28,19 @@ ConfigureGraphicsAdvanced::ConfigureGraphicsAdvanced(
|
||||||
|
|
||||||
ConfigureGraphicsAdvanced::~ConfigureGraphicsAdvanced() = default;
|
ConfigureGraphicsAdvanced::~ConfigureGraphicsAdvanced() = default;
|
||||||
|
|
||||||
void ConfigureGraphicsAdvanced::SetConfiguration() {
|
void ConfigureGraphicsAdvanced::SetConfiguration() {}
|
||||||
const bool runtime_lock = !system.IsPoweredOn();
|
|
||||||
|
void ConfigureGraphicsAdvanced::Setup(const ConfigurationShared::Builder& builder) {
|
||||||
auto& layout = *ui->populate_target->layout();
|
auto& layout = *ui->populate_target->layout();
|
||||||
std::map<u32, QWidget*> hold{}; // A map will sort the data for us
|
std::map<u32, QWidget*> hold{}; // A map will sort the data for us
|
||||||
|
|
||||||
for (auto setting :
|
for (auto setting :
|
||||||
Settings::values.linkage.by_category[Settings::Category::RendererAdvanced]) {
|
Settings::values.linkage.by_category[Settings::Category::RendererAdvanced]) {
|
||||||
if (!Settings::IsConfiguringGlobal() && !setting->Switchable()) {
|
ConfigurationShared::Widget* widget = builder.BuildWidget(setting, apply_funcs);
|
||||||
|
|
||||||
|
if (widget == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigurationShared::Widget* widget = new ConfigurationShared::Widget(
|
|
||||||
setting, translations, combobox_translations, this, runtime_lock, apply_funcs);
|
|
||||||
|
|
||||||
if (!widget->Valid()) {
|
if (!widget->Valid()) {
|
||||||
delete widget;
|
delete widget;
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include "yuzu/configuration/configuration_shared.h"
|
#include "yuzu/configuration/configuration_shared.h"
|
||||||
#include "yuzu/configuration/shared_translation.h"
|
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class System;
|
class System;
|
||||||
|
@ -16,14 +15,16 @@ namespace Ui {
|
||||||
class ConfigureGraphicsAdvanced;
|
class ConfigureGraphicsAdvanced;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace ConfigurationShared {
|
||||||
|
class Builder;
|
||||||
|
}
|
||||||
|
|
||||||
class ConfigureGraphicsAdvanced : public ConfigurationShared::Tab {
|
class ConfigureGraphicsAdvanced : public ConfigurationShared::Tab {
|
||||||
public:
|
public:
|
||||||
explicit ConfigureGraphicsAdvanced(
|
explicit ConfigureGraphicsAdvanced(
|
||||||
const Core::System& system_,
|
const Core::System& system_,
|
||||||
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group,
|
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group,
|
||||||
const ConfigurationShared::TranslationMap& translations_,
|
const ConfigurationShared::Builder& builder, QWidget* parent = nullptr);
|
||||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations_,
|
|
||||||
QWidget* parent = nullptr);
|
|
||||||
~ConfigureGraphicsAdvanced() override;
|
~ConfigureGraphicsAdvanced() override;
|
||||||
|
|
||||||
void ApplyConfiguration() override;
|
void ApplyConfiguration() override;
|
||||||
|
@ -32,14 +33,14 @@ public:
|
||||||
void ExposeComputeOption();
|
void ExposeComputeOption();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void Setup(const ConfigurationShared::Builder& builder);
|
||||||
void changeEvent(QEvent* event) override;
|
void changeEvent(QEvent* event) override;
|
||||||
void RetranslateUI();
|
void RetranslateUI();
|
||||||
|
|
||||||
std::unique_ptr<Ui::ConfigureGraphicsAdvanced> ui;
|
std::unique_ptr<Ui::ConfigureGraphicsAdvanced> ui;
|
||||||
|
|
||||||
const Core::System& system;
|
const Core::System& system;
|
||||||
const ConfigurationShared::TranslationMap& translations;
|
|
||||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations;
|
|
||||||
std::forward_list<std::function<void(bool)>> apply_funcs;
|
std::forward_list<std::function<void(bool)>> apply_funcs;
|
||||||
|
|
||||||
QWidget* checkbox_enable_compute_pipelines{};
|
QWidget* checkbox_enable_compute_pipelines{};
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#include "common/fs/fs_util.h"
|
#include "common/fs/fs_util.h"
|
||||||
|
#include "configuration/shared_widget.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/file_sys/control_metadata.h"
|
#include "core/file_sys/control_metadata.h"
|
||||||
#include "core/file_sys/patch_manager.h"
|
#include "core/file_sys/patch_manager.h"
|
||||||
|
@ -42,8 +43,7 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::st
|
||||||
Core::System& system_)
|
Core::System& system_)
|
||||||
: QDialog(parent),
|
: QDialog(parent),
|
||||||
ui(std::make_unique<Ui::ConfigurePerGame>()), title_id{title_id_}, system{system_},
|
ui(std::make_unique<Ui::ConfigurePerGame>()), title_id{title_id_}, system{system_},
|
||||||
translations{ConfigurationShared::InitializeTranslations(this)},
|
builder{std::make_unique<ConfigurationShared::Builder>(this, !system_.IsPoweredOn())},
|
||||||
combobox_translations{ConfigurationShared::ComboboxEnumeration(this)},
|
|
||||||
tab_group{std::make_shared<std::forward_list<ConfigurationShared::Tab*>>()} {
|
tab_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())
|
||||||
|
@ -51,18 +51,15 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::st
|
||||||
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_, tab_group, *translations,
|
audio_tab = std::make_unique<ConfigureAudio>(system_, tab_group, *builder, this);
|
||||||
*combobox_translations, this);
|
cpu_tab = std::make_unique<ConfigureCpu>(system_, tab_group, *builder, this);
|
||||||
cpu_tab = std::make_unique<ConfigureCpu>(system_, tab_group, *translations,
|
graphics_advanced_tab =
|
||||||
*combobox_translations, this);
|
std::make_unique<ConfigureGraphicsAdvanced>(system_, tab_group, *builder, this);
|
||||||
graphics_advanced_tab = std::make_unique<ConfigureGraphicsAdvanced>(
|
|
||||||
system_, tab_group, *translations, *combobox_translations, 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(); },
|
||||||
tab_group, *translations, *combobox_translations, this);
|
tab_group, *builder, 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_, tab_group, *translations,
|
system_tab = std::make_unique<ConfigureSystem>(system_, tab_group, *builder, this);
|
||||||
*combobox_translations, this);
|
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
|
#include "configuration/shared_widget.h"
|
||||||
#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"
|
||||||
|
@ -75,8 +76,7 @@ private:
|
||||||
std::unique_ptr<Config> game_config;
|
std::unique_ptr<Config> game_config;
|
||||||
|
|
||||||
Core::System& system;
|
Core::System& system;
|
||||||
std::unique_ptr<ConfigurationShared::TranslationMap> translations;
|
std::unique_ptr<ConfigurationShared::Builder> builder;
|
||||||
std::unique_ptr<ConfigurationShared::ComboboxTranslationMap> combobox_translations;
|
|
||||||
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> tab_group;
|
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> tab_group;
|
||||||
|
|
||||||
std::unique_ptr<ConfigurePerGameAddons> addons_tab;
|
std::unique_ptr<ConfigurePerGameAddons> addons_tab;
|
||||||
|
|
|
@ -46,13 +46,11 @@ static bool IsValidLocale(u32 region_index, u32 language_index) {
|
||||||
|
|
||||||
ConfigureSystem::ConfigureSystem(
|
ConfigureSystem::ConfigureSystem(
|
||||||
Core::System& system_, std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_,
|
Core::System& system_, std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_,
|
||||||
const ConfigurationShared::TranslationMap& translations_,
|
const ConfigurationShared::Builder& builder, QWidget* parent)
|
||||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent)
|
: Tab(group_, parent), ui{std::make_unique<Ui::ConfigureSystem>()}, system{system_} {
|
||||||
: Tab(group_, parent), ui{std::make_unique<Ui::ConfigureSystem>()}, system{system_},
|
|
||||||
translations{translations_}, combobox_translations{combobox_translations_} {
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
Setup();
|
Setup(builder);
|
||||||
|
|
||||||
connect(rng_seed_checkbox, &QCheckBox::stateChanged, this, [this](int state) {
|
connect(rng_seed_checkbox, &QCheckBox::stateChanged, this, [this](int state) {
|
||||||
rng_seed_edit->setEnabled(state == Qt::Checked);
|
rng_seed_edit->setEnabled(state == Qt::Checked);
|
||||||
|
@ -104,8 +102,7 @@ void ConfigureSystem::RetranslateUI() {
|
||||||
ui->retranslateUi(this);
|
ui->retranslateUi(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureSystem::Setup() {
|
void ConfigureSystem::Setup(const ConfigurationShared::Builder& builder) {
|
||||||
const bool runtime_lock = !system.IsPoweredOn();
|
|
||||||
auto& core_layout = *ui->core_widget->layout();
|
auto& core_layout = *ui->core_widget->layout();
|
||||||
auto& system_layout = *ui->system_widget->layout();
|
auto& system_layout = *ui->system_widget->layout();
|
||||||
|
|
||||||
|
@ -123,37 +120,31 @@ void ConfigureSystem::Setup() {
|
||||||
push(Settings::values.linkage.by_category[Settings::Category::System]);
|
push(Settings::values.linkage.by_category[Settings::Category::System]);
|
||||||
|
|
||||||
for (auto setting : settings) {
|
for (auto setting : settings) {
|
||||||
if (!Settings::IsConfiguringGlobal() && !setting->Switchable()) {
|
ConfigurationShared::Widget* widget = [this, setting, &builder]() {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[maybe_unused]] std::string label = setting->GetLabel();
|
|
||||||
ConfigurationShared::Widget* widget = [this, setting, runtime_lock]() {
|
|
||||||
if (setting->Id() == Settings::values.custom_rtc.Id()) {
|
if (setting->Id() == Settings::values.custom_rtc.Id()) {
|
||||||
// custom_rtc needs a DateTimeEdit (default is LineEdit), and a checkbox to manage
|
// custom_rtc needs a DateTimeEdit (default is LineEdit), and a checkbox to manage
|
||||||
// it and custom_rtc_enabled
|
// it and custom_rtc_enabled
|
||||||
return new ConfigurationShared::Widget(
|
return builder.BuildWidget(setting, apply_funcs,
|
||||||
setting, translations, combobox_translations, this, runtime_lock, apply_funcs,
|
|
||||||
&Settings::values.custom_rtc_enabled,
|
&Settings::values.custom_rtc_enabled,
|
||||||
ConfigurationShared::RequestType::DateTimeEdit);
|
ConfigurationShared::RequestType::DateTimeEdit);
|
||||||
} else if (setting->Id() == Settings::values.rng_seed.Id()) {
|
} else if (setting->Id() == Settings::values.rng_seed.Id()) {
|
||||||
// rng_seed needs a HexEdit (default is LineEdit), and a checkbox to manage
|
// rng_seed needs a HexEdit (default is LineEdit), and a checkbox to manage
|
||||||
// it and rng_seed_enabled
|
// it and rng_seed_enabled
|
||||||
return new ConfigurationShared::Widget(
|
return builder.BuildWidget(setting, apply_funcs, &Settings::values.rng_seed_enabled,
|
||||||
setting, translations, combobox_translations, this, runtime_lock, apply_funcs,
|
ConfigurationShared::RequestType::HexEdit);
|
||||||
&Settings::values.rng_seed_enabled, ConfigurationShared::RequestType::HexEdit);
|
|
||||||
} else if (setting->Id() == Settings::values.speed_limit.Id()) {
|
} else if (setting->Id() == Settings::values.speed_limit.Id()) {
|
||||||
// speed_limit needs a checkbox to set use_speed_limit, as well as a spinbox
|
// speed_limit needs a checkbox to set use_speed_limit, as well as a spinbox
|
||||||
return new ConfigurationShared::Widget(
|
return builder.BuildWidget(setting, apply_funcs, &Settings::values.use_speed_limit,
|
||||||
setting, translations, combobox_translations, this, runtime_lock, apply_funcs,
|
ConfigurationShared::RequestType::SpinBox,
|
||||||
&Settings::values.use_speed_limit, ConfigurationShared::RequestType::SpinBox,
|
|
||||||
tr("%", "Limit speed percentage (e.g. 50%)"));
|
tr("%", "Limit speed percentage (e.g. 50%)"));
|
||||||
} else {
|
} else {
|
||||||
return new ConfigurationShared::Widget(setting, translations, combobox_translations,
|
return builder.BuildWidget(setting, apply_funcs);
|
||||||
this, runtime_lock, apply_funcs);
|
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
|
|
||||||
|
if (widget == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!widget->Valid()) {
|
if (!widget->Valid()) {
|
||||||
delete widget;
|
delete widget;
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -9,13 +9,11 @@
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include "yuzu/configuration/configuration_shared.h"
|
#include "yuzu/configuration/configuration_shared.h"
|
||||||
#include "yuzu/configuration/shared_translation.h"
|
|
||||||
|
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
class QDateTimeEdit;
|
class QDateTimeEdit;
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class System;
|
class System;
|
||||||
}
|
}
|
||||||
|
@ -24,12 +22,15 @@ namespace Ui {
|
||||||
class ConfigureSystem;
|
class ConfigureSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace ConfigurationShared {
|
||||||
|
class Builder;
|
||||||
|
}
|
||||||
|
|
||||||
class ConfigureSystem : public ConfigurationShared::Tab {
|
class ConfigureSystem : public ConfigurationShared::Tab {
|
||||||
public:
|
public:
|
||||||
explicit ConfigureSystem(
|
explicit ConfigureSystem(Core::System& system_,
|
||||||
Core::System& system_, std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group,
|
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group,
|
||||||
const ConfigurationShared::TranslationMap& translations,
|
const ConfigurationShared::Builder& builder,
|
||||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations,
|
|
||||||
QWidget* parent = nullptr);
|
QWidget* parent = nullptr);
|
||||||
~ConfigureSystem() override;
|
~ConfigureSystem() override;
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@ private:
|
||||||
void changeEvent(QEvent* event) override;
|
void changeEvent(QEvent* event) override;
|
||||||
void RetranslateUI();
|
void RetranslateUI();
|
||||||
|
|
||||||
void Setup();
|
void Setup(const ConfigurationShared::Builder& builder);
|
||||||
|
|
||||||
std::forward_list<std::function<void(bool)>> apply_funcs{};
|
std::forward_list<std::function<void(bool)>> apply_funcs{};
|
||||||
|
|
||||||
|
@ -48,8 +49,6 @@ private:
|
||||||
bool enabled = false;
|
bool enabled = false;
|
||||||
|
|
||||||
Core::System& system;
|
Core::System& system;
|
||||||
const ConfigurationShared::TranslationMap& translations;
|
|
||||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations;
|
|
||||||
|
|
||||||
QCheckBox* rng_seed_checkbox;
|
QCheckBox* rng_seed_checkbox;
|
||||||
QLineEdit* rng_seed_edit;
|
QLineEdit* rng_seed_edit;
|
||||||
|
|
|
@ -529,11 +529,34 @@ Widget::Widget(Settings::BasicSetting* setting_, const TranslationMap& translati
|
||||||
this->setToolTip(tooltip);
|
this->setToolTip(tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget::Widget(Settings::BasicSetting* setting_, const TranslationMap& translations_,
|
Builder::Builder(QWidget* parent_, bool runtime_lock_)
|
||||||
const ComboboxTranslationMap& combobox_translations, QWidget* parent_,
|
: translations{InitializeTranslations(parent_)},
|
||||||
bool runtime_lock_, std::forward_list<std::function<void(bool)>>& apply_funcs_,
|
combobox_translations{ComboboxEnumeration(parent_)}, parent{parent_}, runtime_lock{
|
||||||
Settings::BasicSetting* other_setting, RequestType request, const QString& string)
|
runtime_lock_} {}
|
||||||
: Widget(setting_, translations_, combobox_translations, parent_, runtime_lock_, apply_funcs_,
|
|
||||||
request, true, 1.0f, other_setting, string) {}
|
Builder::~Builder() = default;
|
||||||
|
|
||||||
|
Widget* Builder::BuildWidget(Settings::BasicSetting* setting,
|
||||||
|
std::forward_list<std::function<void(bool)>>& apply_funcs,
|
||||||
|
RequestType request, bool managed, float multiplier,
|
||||||
|
Settings::BasicSetting* other_setting, const QString& string) const {
|
||||||
|
if (!Settings::IsConfiguringGlobal() && !setting->Switchable()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Widget(setting, *translations, *combobox_translations, parent, runtime_lock,
|
||||||
|
apply_funcs, request, managed, multiplier, other_setting, string);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget* Builder::BuildWidget(Settings::BasicSetting* setting,
|
||||||
|
std::forward_list<std::function<void(bool)>>& apply_funcs,
|
||||||
|
Settings::BasicSetting* other_setting, RequestType request,
|
||||||
|
const QString& string) const {
|
||||||
|
return BuildWidget(setting, apply_funcs, request, true, 1.0f, other_setting, string);
|
||||||
|
}
|
||||||
|
|
||||||
|
const ComboboxTranslationMap& Builder::ComboboxTranslations() const {
|
||||||
|
return *combobox_translations;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ConfigurationShared
|
} // namespace ConfigurationShared
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include <forward_list>
|
#include <forward_list>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringLiteral>
|
#include <QStringLiteral>
|
||||||
|
@ -44,28 +45,6 @@ class Widget : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
|
||||||
* Shorter-hand version of the constructor
|
|
||||||
*
|
|
||||||
* @param setting The primary Setting to create the Widget for
|
|
||||||
* @param translations Map of translations to display on the left side label/checkbox
|
|
||||||
* @param combobox_translations Map of translations for enumerating combo boxes
|
|
||||||
* @param parent Qt parent
|
|
||||||
* @param runtime_lock Emulated guest powered on state, for use on settings that should be
|
|
||||||
* configured during guest execution
|
|
||||||
* @param apply_funcs_ List to append, functions to run to apply the widget state to the setting
|
|
||||||
* @param other_setting Second setting to modify, to replace the label with a checkbox
|
|
||||||
* @param request What type of data representation component to create -- not always respected
|
|
||||||
* for the Setting data type
|
|
||||||
* @param string Set to specify formats for Slider feedback labels or SpinBox
|
|
||||||
*/
|
|
||||||
explicit Widget(Settings::BasicSetting* setting, const TranslationMap& translations,
|
|
||||||
const ComboboxTranslationMap& combobox_translations, QWidget* parent,
|
|
||||||
bool runtime_lock, std::forward_list<std::function<void(bool)>>& apply_funcs_,
|
|
||||||
Settings::BasicSetting* other_setting,
|
|
||||||
RequestType request = RequestType::Default,
|
|
||||||
const QString& string = QStringLiteral(""));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param setting The primary Setting to create the Widget for
|
* @param setting The primary Setting to create the Widget for
|
||||||
* @param translations Map of translations to display on the left side label/checkbox
|
* @param translations Map of translations to display on the left side label/checkbox
|
||||||
|
@ -152,4 +131,31 @@ private:
|
||||||
bool runtime_lock{false};
|
bool runtime_lock{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Builder {
|
||||||
|
public:
|
||||||
|
explicit Builder(QWidget* parent, bool runtime_lock);
|
||||||
|
~Builder();
|
||||||
|
|
||||||
|
Widget* BuildWidget(Settings::BasicSetting* setting,
|
||||||
|
std::forward_list<std::function<void(bool)>>& apply_funcs,
|
||||||
|
RequestType request = RequestType::Default, bool managed = true,
|
||||||
|
float multiplier = 1.0f, Settings::BasicSetting* other_setting = nullptr,
|
||||||
|
const QString& string = QStringLiteral("")) const;
|
||||||
|
|
||||||
|
Widget* BuildWidget(Settings::BasicSetting* setting,
|
||||||
|
std::forward_list<std::function<void(bool)>>& apply_funcs,
|
||||||
|
Settings::BasicSetting* other_setting,
|
||||||
|
RequestType request = RequestType::Default,
|
||||||
|
const QString& string = QStringLiteral("")) const;
|
||||||
|
|
||||||
|
const ComboboxTranslationMap& ComboboxTranslations() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unique_ptr<TranslationMap> translations;
|
||||||
|
std::unique_ptr<ComboboxTranslationMap> combobox_translations;
|
||||||
|
|
||||||
|
QWidget* parent;
|
||||||
|
const bool runtime_lock;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace ConfigurationShared
|
} // namespace ConfigurationShared
|
||||||
|
|
Loading…
Reference in a new issue