configuration: Document odd widget cases

Explain why we need to do things differently at times, to serve as a
reference.
This commit is contained in:
lat9nq 2023-06-09 17:40:25 -04:00
parent 163f229d26
commit 81e9cf0934
5 changed files with 25 additions and 1 deletions

View File

@ -49,6 +49,7 @@ void ConfigureAudio::Setup() {
for (auto* setting : settings) {
auto* widget = [&]() {
if (setting->Id() == Settings::values.volume.Id()) {
// volume needs to be a slider (default is line edit)
return new ConfigurationShared::Widget(
setting, translations, combobox_translations, this, runtime_lock, apply_funcs,
ConfigurationShared::RequestType::Slider, true, 1.0f, nullptr,
@ -56,6 +57,7 @@ void ConfigureAudio::Setup() {
} else if (setting->Id() == Settings::values.audio_output_device_id.Id() ||
setting->Id() == Settings::values.audio_input_device_id.Id() ||
setting->Id() == Settings::values.sink_id.Id()) {
// These need to be unmanaged comboboxes, so we can populate them ourselves
return new ConfigurationShared::Widget(
setting, translations, combobox_translations, this, runtime_lock, apply_funcs,
ConfigurationShared::RequestType::ComboBox, false);
@ -79,6 +81,8 @@ void ConfigureAudio::Setup() {
connect(sink_combo_box, qOverload<int>(&QComboBox::currentIndexChanged), this,
&ConfigureAudio::UpdateAudioDevices);
} else if (setting->Id() == Settings::values.audio_output_device_id.Id()) {
// Keep track of output (and input) device comboboxes to populate them with system
// devices, which are determined at run time
output_device_combo_box = widget->combobox;
} else if (setting->Id() == Settings::values.audio_input_device_id.Id()) {
input_device_combo_box = widget->combobox;

View File

@ -58,9 +58,11 @@ void ConfigureCpu::Setup() {
}
if (setting->Id() == Settings::values.cpu_accuracy.Id()) {
// Keep track of cpu_accuracy combobox to display/hide the unsafe settings
accuracy_layout->addWidget(widget);
accuracy_combobox = widget->combobox;
} else {
// Presently, all other settings here are unsafe checkboxes
unsafe_hold.insert({setting->GetLabel(), widget});
}
}

View File

@ -231,6 +231,7 @@ void ConfigureGraphics::Setup() {
for (const auto setting : Settings::values.linkage.by_category[Settings::Category::Renderer]) {
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()) {
@ -238,11 +239,13 @@ void ConfigureGraphics::Setup() {
setting, translations, combobox_translations, this, runtime_lock, 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%)"));
} else if (setting->Id() == Settings::values.speed_limit.Id()) {
// speed_limit needs a checkbox to set use_speed_limit, as well as a spinbox
return new ConfigurationShared::Widget(
setting, translations, combobox_translations, this, runtime_lock, apply_funcs,
ConfigurationShared::RequestType::SpinBox, true, 1.0f,
@ -269,18 +272,23 @@ void ConfigureGraphics::Setup() {
[=](bool) { UpdateAPILayout(); });
// Detach API's restore button and place it where we want
// Lets us put it on the side, and it will automatically scale if there's a second
// combobox (shader_backend, vulkan_device)
widget->layout()->removeWidget(api_restore_global_button);
api_layout->addWidget(api_restore_global_button);
}
} else if (setting->Id() == Settings::values.vulkan_device.Id()) {
// Keep track of vulkan_device's combobox so we can populate it
hold_api.push_front(widget);
vulkan_device_combobox = widget->combobox;
vulkan_device_widget = widget;
} else if (setting->Id() == Settings::values.shader_backend.Id()) {
// Keep track of shader_backend's combobox so we can populate it
hold_api.push_front(widget);
shader_backend_combobox = widget->combobox;
shader_backend_widget = widget;
} else if (setting->Id() == Settings::values.vsync_mode.Id()) {
// Keep track of vsync_mode's combobox so we can populate it
vsync_mode_combobox = widget->combobox;
hold_graphics.emplace(setting->Id(), widget);
} else {
@ -296,6 +304,8 @@ void ConfigureGraphics::Setup() {
api_grid_layout->addWidget(widget);
}
// Background color is too specific to build into the new system, so we manage it here
// (3 settings, all collected into a single widget with a QColor to manage on top)
if (Settings::IsConfiguringGlobal()) {
apply_funcs.push_front([this](bool powered_on) {
Settings::values.bg_red.SetValue(static_cast<u8>(bg_color.red()));

View File

@ -45,6 +45,7 @@ void ConfigureGraphicsAdvanced::SetConfiguration() {
hold.emplace(setting->Id(), widget);
// Keep track of enable_compute_pipelines so we can display it when needed
if (setting->Id() == Settings::values.enable_compute_pipelines.Id()) {
checkbox_enable_compute_pipelines = widget;
}

View File

@ -126,11 +126,15 @@ void ConfigureSystem::Setup() {
[[maybe_unused]] std::string label = setting->GetLabel();
ConfigurationShared::Widget* widget = [=]() {
if (setting->Id() == Settings::values.custom_rtc.Id()) {
// custom_rtc needs a DateTimeEdit (default is LineEdit), and a checkbox to manage
// it and custom_rtc_enabled
return new ConfigurationShared::Widget(
setting, translations, combobox_translations, this, runtime_lock, apply_funcs,
ConfigurationShared::RequestType::DateTimeEdit, true, 1.0f,
&Settings::values.custom_rtc_enabled);
} else if (setting->Id() == Settings::values.rng_seed.Id()) {
// rng_seed needs a HexEdit (default is LineEdit), and a checkbox to manage
// it and rng_seed_enabled
return new ConfigurationShared::Widget(
setting, translations, combobox_translations, this, runtime_lock, apply_funcs,
ConfigurationShared::RequestType::HexEdit, true, 1.0f,
@ -147,17 +151,20 @@ void ConfigureSystem::Setup() {
}
if (setting->Id() == Settings::values.rng_seed.Id()) {
// Keep track of rng_seed's widgets to reset it with the checkbox state
rng_seed_checkbox = widget->checkbox;
rng_seed_edit = widget->line_edit;
rng_seed_edit->setEnabled(Settings::values.rng_seed_enabled.GetValue());
} else if (setting->Id() == Settings::values.custom_rtc.Id()) {
// Keep track of custom_rtc's widgets to reset it with the checkbox state
custom_rtc_checkbox = widget->checkbox;
custom_rtc_edit = widget->date_time_edit;
custom_rtc_edit->setEnabled(Settings::values.custom_rtc_enabled.GetValue());
} else if (setting->Id() == Settings::values.region_index.Id()) {
// Keep track of the region_index (and langauge_index) combobox to validate the selected
// settings
combo_region = widget->combobox;
} else if (setting->Id() == Settings::values.language_index.Id()) {
combo_language = widget->combobox;