shared_widget: Refactor helpers

Makes checkbox creation an option as opposed to a label.
This commit is contained in:
lat9nq
2023-06-09 16:53:26 -04:00
parent 4c4bc134a9
commit 4ff8255e4a
6 changed files with 277 additions and 243 deletions

View File

@ -117,17 +117,18 @@ void ConfigureSystem::Setup() {
push(Settings::values.linkage.by_category[Settings::Category::System]);
for (auto setting : settings) {
[[maybe_unused]] std::string label = setting->GetLabel();
ConfigurationShared::Widget* widget = [=]() {
if (setting->Id() == Settings::values.custom_rtc_enabled.Id()) {
if (setting->Id() == Settings::values.custom_rtc.Id()) {
return new ConfigurationShared::Widget(
setting, translations, this, runtime_lock, apply_funcs,
ConfigurationShared::RequestType::DateTimeEdit, true, 1.0f,
&Settings::values.custom_rtc);
} else if (setting->Id() == Settings::values.rng_seed_enabled.Id()) {
return new ConfigurationShared::Widget(setting, translations, this, runtime_lock,
apply_funcs,
ConfigurationShared::RequestType::HexEdit,
true, 1.0f, &Settings::values.rng_seed);
&Settings::values.custom_rtc_enabled);
} else if (setting->Id() == Settings::values.rng_seed.Id()) {
return new ConfigurationShared::Widget(
setting, translations, this, runtime_lock, apply_funcs,
ConfigurationShared::RequestType::HexEdit, true, 1.0f,
&Settings::values.rng_seed_enabled);
} else {
return new ConfigurationShared::Widget(setting, translations, this, runtime_lock,
@ -140,14 +141,12 @@ void ConfigureSystem::Setup() {
continue;
}
if (setting->Id() == Settings::values.rng_seed_enabled.Id()) {
if (setting->Id() == Settings::values.rng_seed.Id()) {
rng_seed_checkbox = widget->checkbox;
rng_seed_edit = widget->line_edit;
if (!Settings::values.rng_seed_enabled.GetValue()) {
rng_seed_edit->setEnabled(false);
}
} else if (setting->Id() == Settings::values.custom_rtc_enabled.Id()) {
rng_seed_edit->setEnabled(Settings::values.rng_seed_enabled.GetValue());
} else if (setting->Id() == Settings::values.custom_rtc.Id()) {
custom_rtc_checkbox = widget->checkbox;
custom_rtc_edit = widget->date_time_edit;