diff options
author | lat9nq <22451773+lat9nq@users.noreply.github.com> | 2023-06-21 01:42:42 -0400 |
---|---|---|
committer | lat9nq <22451773+lat9nq@users.noreply.github.com> | 2023-07-21 10:56:55 -0400 |
commit | ad645c29a44bd117cad90bda56e1f4d6296f2666 (patch) | |
tree | 6301d2470cd09ea5ef3bd4007d1aa1c97fe7717d /src/yuzu/configuration/configure_graphics.cpp | |
parent | 62ffaa730fabd2101947dd28e50fae6d03162aa4 (diff) |
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.
Diffstat (limited to 'src/yuzu/configuration/configure_graphics.cpp')
-rw-r--r-- | src/yuzu/configuration/configure_graphics.cpp | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index 2f041cba6c..18872fa694 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp @@ -81,18 +81,17 @@ 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_, - const ConfigurationShared::TranslationMap& translations_, - const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent) + const ConfigurationShared::Builder& builder, QWidget* parent) : ConfigurationShared::Tab(group_, parent), ui{std::make_unique<Ui::ConfigureGraphics>()}, 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))} { vulkan_device = Settings::values.vulkan_device.GetValue(); RetrieveVulkanDevices(); ui->setupUi(this); - Setup(); + Setup(builder); for (const auto& device : vulkan_devices) { vulkan_device_combobox->addItem(device); @@ -218,8 +217,7 @@ ConfigureGraphics::~ConfigureGraphics() = default; void ConfigureGraphics::SetConfiguration() {} -void ConfigureGraphics::Setup() { - const bool runtime_lock = !system.IsPoweredOn(); +void ConfigureGraphics::Setup(const ConfigurationShared::Builder& builder) { QLayout* api_layout = ui->api_widget->layout(); QWidget* api_grid_widget = new QWidget(this); QVBoxLayout* api_grid_layout = new QVBoxLayout(api_grid_widget); @@ -232,30 +230,26 @@ void ConfigureGraphics::Setup() { std::forward_list<QWidget*> hold_api; for (const auto setting : Settings::values.linkage.by_category[Settings::Category::Renderer]) { - if (!Settings::IsConfiguringGlobal() && !setting->Switchable()) { - continue; - } - ConfigurationShared::Widget* widget = [&]() { // Set managed to false on these and set up the comboboxes ourselves if (setting->Id() == Settings::values.vulkan_device.Id() || setting->Id() == Settings::values.shader_backend.Id() || setting->Id() == Settings::values.vsync_mode.Id()) { - return new ConfigurationShared::Widget( - setting, translations, combobox_translations, this, runtime_lock, apply_funcs, - ConfigurationShared::RequestType::ComboBox, false); + return builder.BuildWidget(setting, apply_funcs, + ConfigurationShared::RequestType::ComboBox, false); } else if (setting->Id() == Settings::values.fsr_sharpening_slider.Id()) { // FSR needs a reversed slider - return new ConfigurationShared::Widget( - setting, translations, combobox_translations, this, runtime_lock, apply_funcs, - ConfigurationShared::RequestType::ReverseSlider, true, 0.5f, nullptr, - tr("%1%", "FSR sharpening percentage (e.g. 50%)")); + return builder.BuildWidget( + setting, apply_funcs, ConfigurationShared::RequestType::ReverseSlider, true, + 0.5f, nullptr, tr("%1%", "FSR sharpening percentage (e.g. 50%)")); } else { - return new ConfigurationShared::Widget(setting, translations, combobox_translations, - this, runtime_lock, apply_funcs); + return builder.BuildWidget(setting, apply_funcs); } }(); + if (widget == nullptr) { + continue; + } if (!widget->Valid()) { delete widget; continue; |