diff options
| author | 2023-06-21 03:29:20 -0400 | |
|---|---|---|
| committer | 2023-07-21 10:56:55 -0400 | |
| commit | 21723879e7631b2d81d3c3ff14f93c834bc1cdd8 (patch) | |
| tree | ca8a5f8e23f36a207fa04669e3399cd501d03c58 | |
| parent | settings: Define specializations for settings (diff) | |
| download | yuzu-21723879e7631b2d81d3c3ff14f93c834bc1cdd8.tar.gz yuzu-21723879e7631b2d81d3c3ff14f93c834bc1cdd8.tar.xz yuzu-21723879e7631b2d81d3c3ff14f93c834bc1cdd8.zip | |
configuration: Use specialization of settings
Reduces some ugliness in frontend code.
Diffstat (limited to '')
| -rw-r--r-- | src/yuzu/configuration/configure_audio.cpp | 8 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_graphics.cpp | 8 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_system.cpp | 7 | ||||
| -rw-r--r-- | src/yuzu/configuration/shared_widget.cpp | 31 |
4 files changed, 36 insertions, 18 deletions
diff --git a/src/yuzu/configuration/configure_audio.cpp b/src/yuzu/configuration/configure_audio.cpp index 6db47fd61..cdb89ccda 100644 --- a/src/yuzu/configuration/configure_audio.cpp +++ b/src/yuzu/configuration/configure_audio.cpp | |||
| @@ -44,18 +44,12 @@ void ConfigureAudio::Setup(const ConfigurationShared::Builder& builder) { | |||
| 44 | 44 | ||
| 45 | for (auto* setting : settings) { | 45 | for (auto* setting : settings) { |
| 46 | auto* widget = [&]() { | 46 | auto* widget = [&]() { |
| 47 | // TODO (lat9nq): Let the system manage sink_id | ||
| 47 | if (setting->Id() == Settings::values.volume.Id()) { | 48 | if (setting->Id() == Settings::values.volume.Id()) { |
| 48 | // volume needs to be a slider (default is line edit) | 49 | // volume needs to be a slider (default is line edit) |
| 49 | return builder.BuildWidget(setting, apply_funcs, nullptr, | 50 | return builder.BuildWidget(setting, apply_funcs, nullptr, |
| 50 | ConfigurationShared::RequestType::Slider, | 51 | ConfigurationShared::RequestType::Slider, |
| 51 | tr("%1%", "Volume percentage (e.g. 50%)")); | 52 | tr("%1%", "Volume percentage (e.g. 50%)")); |
| 52 | } else if (setting->Id() == Settings::values.audio_output_device_id.Id() || | ||
| 53 | setting->Id() == Settings::values.audio_input_device_id.Id() || | ||
| 54 | setting->Id() == Settings::values.sink_id.Id()) { | ||
| 55 | // These need to be unmanaged comboboxes, so we can populate them ourselves | ||
| 56 | // TODO (lat9nq): Let it manage sink_id | ||
| 57 | return builder.BuildWidget(setting, apply_funcs, | ||
| 58 | ConfigurationShared::RequestType::ComboBox, false); | ||
| 59 | } else { | 53 | } else { |
| 60 | return builder.BuildWidget(setting, apply_funcs); | 54 | return builder.BuildWidget(setting, apply_funcs); |
| 61 | } | 55 | } |
diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index 18872fa69..74449e6d4 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp | |||
| @@ -231,13 +231,7 @@ void ConfigureGraphics::Setup(const ConfigurationShared::Builder& builder) { | |||
| 231 | 231 | ||
| 232 | for (const auto setting : Settings::values.linkage.by_category[Settings::Category::Renderer]) { | 232 | for (const auto setting : Settings::values.linkage.by_category[Settings::Category::Renderer]) { |
| 233 | ConfigurationShared::Widget* widget = [&]() { | 233 | ConfigurationShared::Widget* widget = [&]() { |
| 234 | // Set managed to false on these and set up the comboboxes ourselves | 234 | if (setting->Id() == Settings::values.fsr_sharpening_slider.Id()) { |
| 235 | if (setting->Id() == Settings::values.vulkan_device.Id() || | ||
| 236 | setting->Id() == Settings::values.shader_backend.Id() || | ||
| 237 | setting->Id() == Settings::values.vsync_mode.Id()) { | ||
| 238 | return builder.BuildWidget(setting, apply_funcs, | ||
| 239 | ConfigurationShared::RequestType::ComboBox, false); | ||
| 240 | } else if (setting->Id() == Settings::values.fsr_sharpening_slider.Id()) { | ||
| 241 | // FSR needs a reversed slider | 235 | // FSR needs a reversed slider |
| 242 | return builder.BuildWidget( | 236 | return builder.BuildWidget( |
| 243 | setting, apply_funcs, ConfigurationShared::RequestType::ReverseSlider, true, | 237 | setting, apply_funcs, ConfigurationShared::RequestType::ReverseSlider, true, |
diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index 9be09244a..796ebc44f 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp | |||
| @@ -125,13 +125,12 @@ void ConfigureSystem::Setup(const ConfigurationShared::Builder& builder) { | |||
| 125 | // custom_rtc needs a DateTimeEdit (default is LineEdit), and a checkbox to manage | 125 | // custom_rtc needs a DateTimeEdit (default is LineEdit), and a checkbox to manage |
| 126 | // it and custom_rtc_enabled | 126 | // it and custom_rtc_enabled |
| 127 | return builder.BuildWidget(setting, apply_funcs, | 127 | return builder.BuildWidget(setting, apply_funcs, |
| 128 | &Settings::values.custom_rtc_enabled, | 128 | &Settings::values.custom_rtc_enabled); |
| 129 | ConfigurationShared::RequestType::DateTimeEdit); | ||
| 130 | } else if (setting->Id() == Settings::values.rng_seed.Id()) { | 129 | } else if (setting->Id() == Settings::values.rng_seed.Id()) { |
| 131 | // rng_seed needs a HexEdit (default is LineEdit), and a checkbox to manage | 130 | // rng_seed needs a HexEdit (default is LineEdit), and a checkbox to manage |
| 132 | // it and rng_seed_enabled | 131 | // it and rng_seed_enabled |
| 133 | return builder.BuildWidget(setting, apply_funcs, &Settings::values.rng_seed_enabled, | 132 | return builder.BuildWidget(setting, apply_funcs, |
| 134 | ConfigurationShared::RequestType::HexEdit); | 133 | &Settings::values.rng_seed_enabled); |
| 135 | } else if (setting->Id() == Settings::values.speed_limit.Id()) { | 134 | } else if (setting->Id() == Settings::values.speed_limit.Id()) { |
| 136 | // speed_limit needs a checkbox to set use_speed_limit, as well as a spinbox | 135 | // speed_limit needs a checkbox to set use_speed_limit, as well as a spinbox |
| 137 | return builder.BuildWidget(setting, apply_funcs, &Settings::values.use_speed_limit, | 136 | return builder.BuildWidget(setting, apply_funcs, &Settings::values.use_speed_limit, |
diff --git a/src/yuzu/configuration/shared_widget.cpp b/src/yuzu/configuration/shared_widget.cpp index dc8b31238..807d1d668 100644 --- a/src/yuzu/configuration/shared_widget.cpp +++ b/src/yuzu/configuration/shared_widget.cpp | |||
| @@ -376,6 +376,32 @@ void Widget::SetupComponent(const QString& label, std::function<void()>& load_fu | |||
| 376 | layout->addWidget(qt_label); | 376 | layout->addWidget(qt_label); |
| 377 | } | 377 | } |
| 378 | 378 | ||
| 379 | request = [&]() { | ||
| 380 | if (request != RequestType::Default) { | ||
| 381 | return request; | ||
| 382 | } | ||
| 383 | switch (setting.Specialization()) { | ||
| 384 | case Settings::Specialization::Default: | ||
| 385 | return RequestType::Default; | ||
| 386 | case Settings::Specialization::Time: | ||
| 387 | return RequestType::DateTimeEdit; | ||
| 388 | case Settings::Specialization::Hex: | ||
| 389 | return RequestType::HexEdit; | ||
| 390 | case Settings::Specialization::RuntimeList: | ||
| 391 | managed = false; | ||
| 392 | [[fallthrough]]; | ||
| 393 | case Settings::Specialization::List: | ||
| 394 | return RequestType::ComboBox; | ||
| 395 | case Settings::Specialization::Scalar: | ||
| 396 | return RequestType::Slider; | ||
| 397 | case Settings::Specialization::Countable: | ||
| 398 | return RequestType::SpinBox; | ||
| 399 | default: | ||
| 400 | break; | ||
| 401 | } | ||
| 402 | return request; | ||
| 403 | }(); | ||
| 404 | |||
| 379 | if (setting.TypeId() == typeid(bool)) { | 405 | if (setting.TypeId() == typeid(bool)) { |
| 380 | data_component = CreateCheckBox(&setting, label, serializer, restore_func, touch); | 406 | data_component = CreateCheckBox(&setting, label, serializer, restore_func, touch); |
| 381 | } else if (setting.IsEnum()) { | 407 | } else if (setting.IsEnum()) { |
| @@ -544,6 +570,11 @@ Widget* Builder::BuildWidget(Settings::BasicSetting* setting, | |||
| 544 | return nullptr; | 570 | return nullptr; |
| 545 | } | 571 | } |
| 546 | 572 | ||
| 573 | if (setting->Specialization() == Settings::Specialization::Paired) { | ||
| 574 | LOG_DEBUG(Frontend, "\"{}\" has specialization Paired: ignoring", setting->GetLabel()); | ||
| 575 | return nullptr; | ||
| 576 | } | ||
| 577 | |||
| 547 | return new Widget(setting, *translations, *combobox_translations, parent, runtime_lock, | 578 | return new Widget(setting, *translations, *combobox_translations, parent, runtime_lock, |
| 548 | apply_funcs, request, managed, multiplier, other_setting, string); | 579 | apply_funcs, request, managed, multiplier, other_setting, string); |
| 549 | } | 580 | } |