From 413316560784348b8ea2684d272b974fd0428267 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Mon, 5 Jun 2023 20:41:50 -0400 Subject: settings,core,config_sys: Remove optional type from custom_rtc, rng_seed core: Fix MSVC errors --- src/yuzu/configuration/configure_system.cpp | 40 ++++++++++++++--------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'src/yuzu/configuration/configure_system.cpp') diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index f1ae312c6..c892635b8 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -95,19 +95,20 @@ void ConfigureSystem::RetranslateUI() { void ConfigureSystem::SetConfiguration() { enabled = !system.IsPoweredOn(); - const auto rng_seed = - QStringLiteral("%1") - .arg(Settings::values.rng_seed.GetValue().value_or(0), 8, 16, QLatin1Char{'0'}) - .toUpper(); - const auto rtc_time = Settings::values.custom_rtc.value_or(QDateTime::currentSecsSinceEpoch()); - - ui->rng_seed_checkbox->setChecked(Settings::values.rng_seed.GetValue().has_value()); - ui->rng_seed_edit->setEnabled(Settings::values.rng_seed.GetValue().has_value() && + const auto rng_seed = QStringLiteral("%1") + .arg(Settings::values.rng_seed.GetValue(), 8, 16, QLatin1Char{'0'}) + .toUpper(); + const auto rtc_time = Settings::values.custom_rtc_enabled + ? Settings::values.custom_rtc.GetValue() + : QDateTime::currentSecsSinceEpoch(); + + ui->rng_seed_checkbox->setChecked(Settings::values.rng_seed_enabled.GetValue()); + ui->rng_seed_edit->setEnabled(Settings::values.rng_seed_enabled.GetValue() && Settings::values.rng_seed.UsingGlobal()); ui->rng_seed_edit->setText(rng_seed); - ui->custom_rtc_checkbox->setChecked(Settings::values.custom_rtc.has_value()); - ui->custom_rtc_edit->setEnabled(Settings::values.custom_rtc.has_value()); + ui->custom_rtc_checkbox->setChecked(Settings::values.custom_rtc_enabled.GetValue()); + ui->custom_rtc_edit->setEnabled(Settings::values.custom_rtc_enabled.GetValue()); ui->custom_rtc_edit->setDateTime(QDateTime::fromSecsSinceEpoch(rtc_time)); ui->device_name_edit->setText( QString::fromUtf8(Settings::values.device_name.GetValue().c_str())); @@ -142,13 +143,15 @@ void ConfigureSystem::ApplyConfiguration() { // to allow in-game time to be fast forwarded if (Settings::IsConfiguringGlobal()) { if (ui->custom_rtc_checkbox->isChecked()) { + Settings::values.custom_rtc_enabled = true; Settings::values.custom_rtc = ui->custom_rtc_edit->dateTime().toSecsSinceEpoch(); if (system.IsPoweredOn()) { - const s64 posix_time{*Settings::values.custom_rtc}; + const s64 posix_time{Settings::values.custom_rtc.GetValue() + + Service::Time::TimeManager::GetExternalTimeZoneOffset()}; system.GetTimeManager().UpdateLocalSystemClockTime(posix_time); } } else { - Settings::values.custom_rtc = std::nullopt; + Settings::values.custom_rtc_enabled = false; } } @@ -169,26 +172,23 @@ void ConfigureSystem::ApplyConfiguration() { if (Settings::IsConfiguringGlobal()) { // Guard if during game and set to game-specific value if (Settings::values.rng_seed.UsingGlobal()) { + Settings::values.rng_seed_enabled = ui->rng_seed_checkbox->isChecked(); if (ui->rng_seed_checkbox->isChecked()) { Settings::values.rng_seed.SetValue(ui->rng_seed_edit->text().toUInt(nullptr, 16)); - } else { - Settings::values.rng_seed.SetValue(std::nullopt); } } } else { switch (use_rng_seed) { case ConfigurationShared::CheckState::On: case ConfigurationShared::CheckState::Off: + Settings::values.rng_seed_enabled.SetGlobal(false); Settings::values.rng_seed.SetGlobal(false); if (ui->rng_seed_checkbox->isChecked()) { Settings::values.rng_seed.SetValue(ui->rng_seed_edit->text().toUInt(nullptr, 16)); - } else { - Settings::values.rng_seed.SetValue(std::nullopt); } break; case ConfigurationShared::CheckState::Global: - Settings::values.rng_seed.SetGlobal(false); - Settings::values.rng_seed.SetValue(std::nullopt); + Settings::values.rng_seed_enabled.SetGlobal(true); Settings::values.rng_seed.SetGlobal(true); break; case ConfigurationShared::CheckState::Count: @@ -217,8 +217,8 @@ void ConfigureSystem::SetupPerGameUI() { ConfigurationShared::SetColoredTristate( ui->rng_seed_checkbox, Settings::values.rng_seed.UsingGlobal(), - Settings::values.rng_seed.GetValue().has_value(), - Settings::values.rng_seed.GetValue(true).has_value(), use_rng_seed); + Settings::values.rng_seed_enabled.GetValue(), + Settings::values.rng_seed_enabled.GetValue(true), use_rng_seed); ConfigurationShared::SetColoredTristate(ui->use_unsafe_extended_memory_layout, Settings::values.use_unsafe_extended_memory_layout, -- cgit v1.2.3 From d3b94d64d492407dcd43acf79cd1e94d57630109 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Fri, 5 May 2023 23:30:59 -0400 Subject: configuration: Add base class to tabs Tabs that largely configure SwitchableSetting's are now Tabs and grouped together. --- src/yuzu/configuration/configure_system.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/yuzu/configuration/configure_system.cpp') diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index c892635b8..4872a475b 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -37,8 +37,10 @@ static bool IsValidLocale(u32 region_index, u32 language_index) { return ((LOCALE_BLOCKLIST.at(region_index) >> language_index) & 1) == 0; } -ConfigureSystem::ConfigureSystem(Core::System& system_, QWidget* parent) - : QWidget(parent), ui{std::make_unique()}, system{system_} { +ConfigureSystem::ConfigureSystem( + Core::System& system_, std::shared_ptr> group, + QWidget* parent) + : Tab(group, parent), ui{std::make_unique()}, system{system_} { ui->setupUi(this); connect(ui->rng_seed_checkbox, &QCheckBox::stateChanged, this, [this](int state) { -- cgit v1.2.3 From 8e151460265f04c7bf4a981b5f97f252a0444c27 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 10 May 2023 17:57:25 -0400 Subject: configure_system: Implement with for loop --- src/yuzu/configuration/configure_system.cpp | 232 ++++++++++++---------------- 1 file changed, 96 insertions(+), 136 deletions(-) (limited to 'src/yuzu/configuration/configure_system.cpp') diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index 4872a475b..dedbad57f 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -2,17 +2,22 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include +#include #include +#include #include #include +#include #include #include "common/settings.h" #include "core/core.h" #include "core/hle/service/time/time_manager.h" #include "ui_configure_system.h" +#include "yuzu/configuration/config.h" #include "yuzu/configuration/configuration_shared.h" #include "yuzu/configuration/configure_system.h" +#include "yuzu/configuration/shared_widget.h" constexpr std::array LOCALE_BLOCKLIST{ // pzzefezrpnkzeidfej @@ -39,44 +44,42 @@ static bool IsValidLocale(u32 region_index, u32 language_index) { ConfigureSystem::ConfigureSystem( Core::System& system_, std::shared_ptr> group, - QWidget* parent) - : Tab(group, parent), ui{std::make_unique()}, system{system_} { + ConfigurationShared::TranslationMap& translations_, QWidget* parent) + : Tab(group, parent), ui{std::make_unique()}, system{system_}, + translations{translations_} { ui->setupUi(this); - connect(ui->rng_seed_checkbox, &QCheckBox::stateChanged, this, [this](int state) { - ui->rng_seed_edit->setEnabled(state == Qt::Checked); + Setup(); + + connect(rng_seed_checkbox, &QCheckBox::stateChanged, this, [this](int state) { + rng_seed_edit->setEnabled(state == Qt::Checked); if (state != Qt::Checked) { - ui->rng_seed_edit->setText(QStringLiteral("00000000")); + rng_seed_edit->setText(QStringLiteral("00000000")); } }); - connect(ui->custom_rtc_checkbox, &QCheckBox::stateChanged, this, [this](int state) { - ui->custom_rtc_edit->setEnabled(state == Qt::Checked); + connect(custom_rtc_checkbox, &QCheckBox::stateChanged, this, [this](int state) { + custom_rtc_edit->setEnabled(state == Qt::Checked); if (state != Qt::Checked) { - ui->custom_rtc_edit->setDateTime(QDateTime::currentDateTime()); + custom_rtc_edit->setDateTime(QDateTime::currentDateTime()); } }); const auto locale_check = [this](int index) { - const auto region_index = ConfigurationShared::GetComboboxIndex( - Settings::values.region_index.GetValue(true), ui->combo_region); - const auto language_index = ConfigurationShared::GetComboboxIndex( - Settings::values.language_index.GetValue(true), ui->combo_language); + const auto region_index = combo_region->currentIndex(); + const auto language_index = combo_language->currentIndex(); const bool valid_locale = IsValidLocale(region_index, language_index); ui->label_warn_invalid_locale->setVisible(!valid_locale); if (!valid_locale) { ui->label_warn_invalid_locale->setText( tr("Warning: \"%1\" is not a valid language for region \"%2\"") - .arg(ui->combo_language->currentText()) - .arg(ui->combo_region->currentText())); + .arg(combo_language->currentText()) + .arg(combo_region->currentText())); } }; - connect(ui->combo_language, qOverload(&QComboBox::currentIndexChanged), this, - locale_check); - connect(ui->combo_region, qOverload(&QComboBox::currentIndexChanged), this, locale_check); - - SetupPerGameUI(); + connect(combo_language, qOverload(&QComboBox::currentIndexChanged), this, locale_check); + connect(combo_region, qOverload(&QComboBox::currentIndexChanged), this, locale_check); SetConfiguration(); } @@ -95,137 +98,94 @@ void ConfigureSystem::RetranslateUI() { ui->retranslateUi(this); } -void ConfigureSystem::SetConfiguration() { - enabled = !system.IsPoweredOn(); - const auto rng_seed = QStringLiteral("%1") - .arg(Settings::values.rng_seed.GetValue(), 8, 16, QLatin1Char{'0'}) - .toUpper(); - const auto rtc_time = Settings::values.custom_rtc_enabled - ? Settings::values.custom_rtc.GetValue() - : QDateTime::currentSecsSinceEpoch(); - - ui->rng_seed_checkbox->setChecked(Settings::values.rng_seed_enabled.GetValue()); - ui->rng_seed_edit->setEnabled(Settings::values.rng_seed_enabled.GetValue() && - Settings::values.rng_seed.UsingGlobal()); - ui->rng_seed_edit->setText(rng_seed); - - ui->custom_rtc_checkbox->setChecked(Settings::values.custom_rtc_enabled.GetValue()); - ui->custom_rtc_edit->setEnabled(Settings::values.custom_rtc_enabled.GetValue()); - ui->custom_rtc_edit->setDateTime(QDateTime::fromSecsSinceEpoch(rtc_time)); - ui->device_name_edit->setText( - QString::fromUtf8(Settings::values.device_name.GetValue().c_str())); - ui->use_unsafe_extended_memory_layout->setEnabled(enabled); - ui->use_unsafe_extended_memory_layout->setChecked( - Settings::values.use_unsafe_extended_memory_layout.GetValue()); - - if (Settings::IsConfiguringGlobal()) { - ui->combo_language->setCurrentIndex(Settings::values.language_index.GetValue()); - ui->combo_region->setCurrentIndex(Settings::values.region_index.GetValue()); - ui->combo_time_zone->setCurrentIndex(Settings::values.time_zone_index.GetValue()); - } else { - ConfigurationShared::SetPerGameSetting(ui->combo_language, - &Settings::values.language_index); - ConfigurationShared::SetPerGameSetting(ui->combo_region, &Settings::values.region_index); - ConfigurationShared::SetPerGameSetting(ui->combo_time_zone, - &Settings::values.time_zone_index); - - ConfigurationShared::SetHighlight(ui->label_language, - !Settings::values.language_index.UsingGlobal()); - ConfigurationShared::SetHighlight(ui->label_region, - !Settings::values.region_index.UsingGlobal()); - ConfigurationShared::SetHighlight(ui->label_timezone, - !Settings::values.time_zone_index.UsingGlobal()); - } -} +void ConfigureSystem::Setup() { + const bool runtime_lock = !system.IsPoweredOn(); + auto& core_layout = *ui->core_widget->layout(); + auto& system_layout = *ui->system_widget->layout(); -void ConfigureSystem::ReadSystemSettings() {} + std::map core_hold{}; + std::map> system_hold{}; -void ConfigureSystem::ApplyConfiguration() { - // Allow setting custom RTC even if system is powered on, - // to allow in-game time to be fast forwarded - if (Settings::IsConfiguringGlobal()) { - if (ui->custom_rtc_checkbox->isChecked()) { - Settings::values.custom_rtc_enabled = true; - Settings::values.custom_rtc = ui->custom_rtc_edit->dateTime().toSecsSinceEpoch(); - if (system.IsPoweredOn()) { - const s64 posix_time{Settings::values.custom_rtc.GetValue() + - Service::Time::TimeManager::GetExternalTimeZoneOffset()}; - system.GetTimeManager().UpdateLocalSystemClockTime(posix_time); - } - } else { - Settings::values.custom_rtc_enabled = false; + std::forward_list settings; + auto push = [&settings](std::forward_list& list) { + for (auto setting : list) { + settings.push_front(setting); } - } + }; - Settings::values.device_name = ui->device_name_edit->text().toStdString(); + push(Settings::values.linkage.by_category[Settings::Category::Core]); + push(Settings::values.linkage.by_category[Settings::Category::System]); + + for (auto setting : settings) { + ConfigurationShared::Widget* widget = [=]() { + if (setting->Id() == Settings::values.custom_rtc_enabled.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); + } else { + return new ConfigurationShared::Widget(setting, translations, this, runtime_lock, + + apply_funcs); + } + }(); - if (!enabled) { - return; - } + if (!widget->Valid()) { + delete widget; + continue; + } + + if (setting->Id() == Settings::values.rng_seed_enabled.Id()) { + rng_seed_checkbox = widget->checkbox; + rng_seed_edit = widget->line_edit; - ConfigurationShared::ApplyPerGameSetting(&Settings::values.language_index, ui->combo_language); - ConfigurationShared::ApplyPerGameSetting(&Settings::values.region_index, ui->combo_region); - ConfigurationShared::ApplyPerGameSetting(&Settings::values.time_zone_index, - ui->combo_time_zone); - ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_unsafe_extended_memory_layout, - ui->use_unsafe_extended_memory_layout, - use_unsafe_extended_memory_layout); - - if (Settings::IsConfiguringGlobal()) { - // Guard if during game and set to game-specific value - if (Settings::values.rng_seed.UsingGlobal()) { - Settings::values.rng_seed_enabled = ui->rng_seed_checkbox->isChecked(); - if (ui->rng_seed_checkbox->isChecked()) { - Settings::values.rng_seed.SetValue(ui->rng_seed_edit->text().toUInt(nullptr, 16)); + if (!Settings::values.rng_seed_enabled.GetValue()) { + rng_seed_edit->setEnabled(false); } + } else if (setting->Id() == Settings::values.custom_rtc_enabled.Id()) { + 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()) { + + combo_region = widget->combobox; + } else if (setting->Id() == Settings::values.language_index.Id()) { + combo_language = widget->combobox; } - } else { - switch (use_rng_seed) { - case ConfigurationShared::CheckState::On: - case ConfigurationShared::CheckState::Off: - Settings::values.rng_seed_enabled.SetGlobal(false); - Settings::values.rng_seed.SetGlobal(false); - if (ui->rng_seed_checkbox->isChecked()) { - Settings::values.rng_seed.SetValue(ui->rng_seed_edit->text().toUInt(nullptr, 16)); - } - break; - case ConfigurationShared::CheckState::Global: - Settings::values.rng_seed_enabled.SetGlobal(true); - Settings::values.rng_seed.SetGlobal(true); + + switch (setting->Category()) { + case Settings::Category::Core: + core_hold[setting->GetLabel()] = widget; break; - case ConfigurationShared::CheckState::Count: + case Settings::Category::System: + system_hold[setting->IsEnum()].insert(std::pair{setting->GetLabel(), widget}); break; + default: + delete widget; } } + for (const auto& [label, widget] : core_hold) { + core_layout.addWidget(widget); + } + for (const auto& [label, widget] : system_hold[true]) { + system_layout.addWidget(widget); + } + for (const auto& [label, widget] : system_hold[false]) { + system_layout.addWidget(widget); + } } -void ConfigureSystem::SetupPerGameUI() { - if (Settings::IsConfiguringGlobal()) { - ui->combo_language->setEnabled(Settings::values.language_index.UsingGlobal()); - ui->combo_region->setEnabled(Settings::values.region_index.UsingGlobal()); - ui->combo_time_zone->setEnabled(Settings::values.time_zone_index.UsingGlobal()); - ui->rng_seed_checkbox->setEnabled(Settings::values.rng_seed.UsingGlobal()); - ui->rng_seed_edit->setEnabled(Settings::values.rng_seed.UsingGlobal()); +void ConfigureSystem::SetConfiguration() {} - return; +void ConfigureSystem::ApplyConfiguration() { + const bool powered_on = system.IsPoweredOn(); + for (const auto& func : apply_funcs) { + func(powered_on); } - - ConfigurationShared::SetColoredComboBox(ui->combo_language, ui->label_language, - Settings::values.language_index.GetValue(true)); - ConfigurationShared::SetColoredComboBox(ui->combo_region, ui->label_region, - Settings::values.region_index.GetValue(true)); - ConfigurationShared::SetColoredComboBox(ui->combo_time_zone, ui->label_timezone, - Settings::values.time_zone_index.GetValue(true)); - - ConfigurationShared::SetColoredTristate( - ui->rng_seed_checkbox, Settings::values.rng_seed.UsingGlobal(), - Settings::values.rng_seed_enabled.GetValue(), - Settings::values.rng_seed_enabled.GetValue(true), use_rng_seed); - - ConfigurationShared::SetColoredTristate(ui->use_unsafe_extended_memory_layout, - Settings::values.use_unsafe_extended_memory_layout, - use_unsafe_extended_memory_layout); - - ui->custom_rtc_checkbox->setVisible(false); - ui->custom_rtc_edit->setVisible(false); } -- cgit v1.2.3 From 4ff8255e4a985e69046e453a9bd38adf80346548 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Fri, 9 Jun 2023 16:53:26 -0400 Subject: shared_widget: Refactor helpers Makes checkbox creation an option as opposed to a label. --- src/yuzu/configuration/configure_system.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'src/yuzu/configuration/configure_system.cpp') diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index dedbad57f..128860800 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -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; -- cgit v1.2.3 From c5a3642cb62b4676d0c8b98949daec20e7c02e6b Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Thu, 18 May 2023 22:17:36 -0400 Subject: configuration: Use a mapping of setting value to name Makes comboboxes always correspond to the value of the setting they're modifying. --- src/yuzu/configuration/configure_system.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/yuzu/configuration/configure_system.cpp') diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index 128860800..40d0be8ca 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -44,9 +44,10 @@ static bool IsValidLocale(u32 region_index, u32 language_index) { ConfigureSystem::ConfigureSystem( Core::System& system_, std::shared_ptr> group, - ConfigurationShared::TranslationMap& translations_, QWidget* parent) + const ConfigurationShared::TranslationMap& translations_, + const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent) : Tab(group, parent), ui{std::make_unique()}, system{system_}, - translations{translations_} { + translations{translations_}, combobox_translations{combobox_translations_} { ui->setupUi(this); Setup(); @@ -121,18 +122,17 @@ void ConfigureSystem::Setup() { ConfigurationShared::Widget* widget = [=]() { if (setting->Id() == Settings::values.custom_rtc.Id()) { return new ConfigurationShared::Widget( - setting, translations, this, runtime_lock, apply_funcs, + 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()) { return new ConfigurationShared::Widget( - setting, translations, this, runtime_lock, apply_funcs, + setting, translations, combobox_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, - - apply_funcs); + return new ConfigurationShared::Widget(setting, translations, combobox_translations, + this, runtime_lock, apply_funcs); } }(); -- cgit v1.2.3 From 217fa040809c083a8b680962589da264f8d8e4c4 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Thu, 18 May 2023 23:05:21 -0400 Subject: configuration: Clean up includes a bit --- src/yuzu/configuration/configure_system.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/yuzu/configuration/configure_system.cpp') diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index 40d0be8ca..5fe3c4a7f 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -5,6 +5,8 @@ #include #include +#include +#include #include #include #include -- cgit v1.2.3 From 81860b431753719322e98435577d0981d55ea6d7 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Mon, 5 Jun 2023 16:03:45 -0400 Subject: configure_system: Hide locale warn at start --- src/yuzu/configuration/configure_system.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/yuzu/configuration/configure_system.cpp') diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index 5fe3c4a7f..ae59d2ee7 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -68,7 +68,7 @@ ConfigureSystem::ConfigureSystem( } }); - const auto locale_check = [this](int index) { + const auto locale_check = [this]() { const auto region_index = combo_region->currentIndex(); const auto language_index = combo_language->currentIndex(); const bool valid_locale = IsValidLocale(region_index, language_index); @@ -84,6 +84,9 @@ ConfigureSystem::ConfigureSystem( connect(combo_language, qOverload(&QComboBox::currentIndexChanged), this, locale_check); connect(combo_region, qOverload(&QComboBox::currentIndexChanged), this, locale_check); + ui->label_warn_invalid_locale->setVisible(false); + locale_check(); + SetConfiguration(); } -- cgit v1.2.3 From 9e3c94bb3dd1a9065977930a985be43f6052044c Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 6 Jun 2023 22:30:02 -0400 Subject: configuration: Use IDs to sort holds --- src/yuzu/configuration/configure_system.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/yuzu/configuration/configure_system.cpp') diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index ae59d2ee7..4b0e0a649 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -109,8 +109,8 @@ void ConfigureSystem::Setup() { auto& core_layout = *ui->core_widget->layout(); auto& system_layout = *ui->system_widget->layout(); - std::map core_hold{}; - std::map> system_hold{}; + std::map core_hold{}; + std::map system_hold{}; std::forward_list settings; auto push = [&settings](std::forward_list& list) { @@ -165,10 +165,10 @@ void ConfigureSystem::Setup() { switch (setting->Category()) { case Settings::Category::Core: - core_hold[setting->GetLabel()] = widget; + core_hold.emplace(setting->Id(), widget); break; case Settings::Category::System: - system_hold[setting->IsEnum()].insert(std::pair{setting->GetLabel(), widget}); + system_hold.emplace(setting->Id(), widget); break; default: delete widget; @@ -177,10 +177,7 @@ void ConfigureSystem::Setup() { for (const auto& [label, widget] : core_hold) { core_layout.addWidget(widget); } - for (const auto& [label, widget] : system_hold[true]) { - system_layout.addWidget(widget); - } - for (const auto& [label, widget] : system_hold[false]) { + for (const auto& [id, widget] : system_hold) { system_layout.addWidget(widget); } } -- cgit v1.2.3 From 81e9cf09349119cb84c5f52e2d7b64f0fe2482b8 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Fri, 9 Jun 2023 17:40:25 -0400 Subject: configuration: Document odd widget cases Explain why we need to do things differently at times, to serve as a reference. --- src/yuzu/configuration/configure_system.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/yuzu/configuration/configure_system.cpp') diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index 4b0e0a649..ffcbab6d9 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -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; -- cgit v1.2.3 From 79024bb9554ba676a654ff76335008e37181be1c Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sat, 10 Jun 2023 16:40:38 -0400 Subject: FIXME configuration: Avoid unnecessary allocations ConfigurationShared::Widget needs to be created with a builder. This would avoid some duplicated code. --- src/yuzu/configuration/configure_system.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/yuzu/configuration/configure_system.cpp') diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index ffcbab6d9..b9d58b083 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -123,6 +123,10 @@ void ConfigureSystem::Setup() { push(Settings::values.linkage.by_category[Settings::Category::System]); for (auto setting : settings) { + if (!Settings::IsConfiguringGlobal() && !setting->Switchable()) { + continue; + } + [[maybe_unused]] std::string label = setting->GetLabel(); ConfigurationShared::Widget* widget = [=]() { if (setting->Id() == Settings::values.custom_rtc.Id()) { -- cgit v1.2.3 From a7ee9d999f612dcf5e9fcf68b410a3b49039d8ed Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Thu, 15 Jun 2023 16:45:42 -0400 Subject: configuration: Use shorter constructor as needed Reduces some confusion hopefully, since some parameters specified were not specific to the setting in question. --- src/yuzu/configuration/configure_system.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/yuzu/configuration/configure_system.cpp') diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index b9d58b083..f78ed7c24 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -134,15 +134,14 @@ void ConfigureSystem::Setup() { // 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); + &Settings::values.custom_rtc_enabled, + ConfigurationShared::RequestType::DateTimeEdit); } 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, - &Settings::values.rng_seed_enabled); + &Settings::values.rng_seed_enabled, ConfigurationShared::RequestType::HexEdit); } else { return new ConfigurationShared::Widget(setting, translations, combobox_translations, this, runtime_lock, apply_funcs); -- cgit v1.2.3 From ee32b177823b9b8499c9fd188a571884f00cf655 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sun, 18 Jun 2023 03:52:41 -0400 Subject: common,yuzu-qt: GCC warning silences Fixes -Wshadow, -Wdeprecated, and catch by copy rather than by ref. --- src/yuzu/configuration/configure_system.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/yuzu/configuration/configure_system.cpp') diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index f78ed7c24..51b0629a6 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -45,10 +45,10 @@ static bool IsValidLocale(u32 region_index, u32 language_index) { } ConfigureSystem::ConfigureSystem( - Core::System& system_, std::shared_ptr> group, + Core::System& system_, std::shared_ptr> group_, const ConfigurationShared::TranslationMap& translations_, const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent) - : Tab(group, parent), ui{std::make_unique()}, system{system_}, + : Tab(group_, parent), ui{std::make_unique()}, system{system_}, translations{translations_}, combobox_translations{combobox_translations_} { ui->setupUi(this); @@ -128,7 +128,7 @@ void ConfigureSystem::Setup() { } [[maybe_unused]] std::string label = setting->GetLabel(); - ConfigurationShared::Widget* widget = [=]() { + ConfigurationShared::Widget* widget = [this, setting, runtime_lock]() { 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 -- cgit v1.2.3 From 81a96bafe210c218efed4e3f1138510bb8a0748c Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Mon, 19 Jun 2023 16:41:25 -0400 Subject: configuration: Move speed_limit to core --- src/yuzu/configuration/configure_system.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/yuzu/configuration/configure_system.cpp') diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index 51b0629a6..6a985c515 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -142,6 +142,12 @@ void ConfigureSystem::Setup() { return new ConfigurationShared::Widget( setting, translations, combobox_translations, this, runtime_lock, apply_funcs, &Settings::values.rng_seed_enabled, ConfigurationShared::RequestType::HexEdit); + } 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, + &Settings::values.use_speed_limit, ConfigurationShared::RequestType::SpinBox, + tr("%", "Limit speed percentage (e.g. 50%)")); } else { return new ConfigurationShared::Widget(setting, translations, combobox_translations, this, runtime_lock, apply_funcs); -- cgit v1.2.3 From ad645c29a44bd117cad90bda56e1f4d6296f2666 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 21 Jun 2023 01:42:42 -0400 Subject: 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. --- src/yuzu/configuration/configure_system.cpp | 43 ++++++++++++----------------- 1 file changed, 17 insertions(+), 26 deletions(-) (limited to 'src/yuzu/configuration/configure_system.cpp') diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index 6a985c515..9be09244a 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -46,13 +46,11 @@ static bool IsValidLocale(u32 region_index, u32 language_index) { ConfigureSystem::ConfigureSystem( Core::System& system_, std::shared_ptr> group_, - const ConfigurationShared::TranslationMap& translations_, - const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent) - : Tab(group_, parent), ui{std::make_unique()}, system{system_}, - translations{translations_}, combobox_translations{combobox_translations_} { + const ConfigurationShared::Builder& builder, QWidget* parent) + : Tab(group_, parent), ui{std::make_unique()}, system{system_} { ui->setupUi(this); - Setup(); + Setup(builder); connect(rng_seed_checkbox, &QCheckBox::stateChanged, this, [this](int state) { rng_seed_edit->setEnabled(state == Qt::Checked); @@ -104,8 +102,7 @@ void ConfigureSystem::RetranslateUI() { ui->retranslateUi(this); } -void ConfigureSystem::Setup() { - const bool runtime_lock = !system.IsPoweredOn(); +void ConfigureSystem::Setup(const ConfigurationShared::Builder& builder) { auto& core_layout = *ui->core_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]); for (auto setting : settings) { - if (!Settings::IsConfiguringGlobal() && !setting->Switchable()) { - continue; - } - - [[maybe_unused]] std::string label = setting->GetLabel(); - ConfigurationShared::Widget* widget = [this, setting, runtime_lock]() { + ConfigurationShared::Widget* widget = [this, setting, &builder]() { 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, - &Settings::values.custom_rtc_enabled, - ConfigurationShared::RequestType::DateTimeEdit); + return builder.BuildWidget(setting, apply_funcs, + &Settings::values.custom_rtc_enabled, + ConfigurationShared::RequestType::DateTimeEdit); } 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, - &Settings::values.rng_seed_enabled, ConfigurationShared::RequestType::HexEdit); + return builder.BuildWidget(setting, apply_funcs, &Settings::values.rng_seed_enabled, + ConfigurationShared::RequestType::HexEdit); } 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, - &Settings::values.use_speed_limit, ConfigurationShared::RequestType::SpinBox, - tr("%", "Limit speed percentage (e.g. 50%)")); + return builder.BuildWidget(setting, apply_funcs, &Settings::values.use_speed_limit, + ConfigurationShared::RequestType::SpinBox, + tr("%", "Limit speed 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; -- cgit v1.2.3 From 21723879e7631b2d81d3c3ff14f93c834bc1cdd8 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 21 Jun 2023 03:29:20 -0400 Subject: configuration: Use specialization of settings Reduces some ugliness in frontend code. --- src/yuzu/configuration/configure_system.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/yuzu/configuration/configure_system.cpp') 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) { // custom_rtc needs a DateTimeEdit (default is LineEdit), and a checkbox to manage // it and custom_rtc_enabled return builder.BuildWidget(setting, apply_funcs, - &Settings::values.custom_rtc_enabled, - ConfigurationShared::RequestType::DateTimeEdit); + &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 builder.BuildWidget(setting, apply_funcs, &Settings::values.rng_seed_enabled, - ConfigurationShared::RequestType::HexEdit); + return builder.BuildWidget(setting, apply_funcs, + &Settings::values.rng_seed_enabled); } 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 builder.BuildWidget(setting, apply_funcs, &Settings::values.use_speed_limit, -- cgit v1.2.3 From d1de1c3bedcd2526eb78c7eaa21f2eef6041a590 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 21 Jun 2023 04:04:48 -0400 Subject: shared_widget: Internalize component restoring --- src/yuzu/configuration/configure_system.cpp | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) (limited to 'src/yuzu/configuration/configure_system.cpp') diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index 796ebc44f..ef26fb6ce 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -52,20 +52,6 @@ ConfigureSystem::ConfigureSystem( Setup(builder); - connect(rng_seed_checkbox, &QCheckBox::stateChanged, this, [this](int state) { - rng_seed_edit->setEnabled(state == Qt::Checked); - if (state != Qt::Checked) { - rng_seed_edit->setText(QStringLiteral("00000000")); - } - }); - - connect(custom_rtc_checkbox, &QCheckBox::stateChanged, this, [this](int state) { - custom_rtc_edit->setEnabled(state == Qt::Checked); - if (state != Qt::Checked) { - custom_rtc_edit->setDateTime(QDateTime::currentDateTime()); - } - }); - const auto locale_check = [this]() { const auto region_index = combo_region->currentIndex(); const auto language_index = combo_language->currentIndex(); @@ -149,19 +135,7 @@ void ConfigureSystem::Setup(const ConfigurationShared::Builder& builder) { continue; } - 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()) { + 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; -- cgit v1.2.3 From 9de50d6194027bf4d757ef58f291763eacea6bfe Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 21 Jun 2023 04:32:21 -0400 Subject: configuration: Use paired settings --- src/yuzu/configuration/configure_system.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'src/yuzu/configuration/configure_system.cpp') diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index ef26fb6ce..cb708051e 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -107,18 +107,8 @@ void ConfigureSystem::Setup(const ConfigurationShared::Builder& builder) { for (auto setting : settings) { ConfigurationShared::Widget* widget = [this, setting, &builder]() { - 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 builder.BuildWidget(setting, apply_funcs, - &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 builder.BuildWidget(setting, apply_funcs, - &Settings::values.rng_seed_enabled); - } else if (setting->Id() == Settings::values.speed_limit.Id()) { - // speed_limit needs a checkbox to set use_speed_limit, as well as a spinbox + if (setting->Id() == Settings::values.speed_limit.Id()) { + // speed_limit must be specified to translate the percentage return builder.BuildWidget(setting, apply_funcs, &Settings::values.use_speed_limit, ConfigurationShared::RequestType::SpinBox, tr("%", "Limit speed percentage (e.g. 50%)")); -- cgit v1.2.3 From 926f3e3d3e6ff57633d2d44085f02754ffe1c988 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 21 Jun 2023 05:04:21 -0400 Subject: settings,configuration: Add a default suffix --- src/yuzu/configuration/configure_system.cpp | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'src/yuzu/configuration/configure_system.cpp') diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index cb708051e..05706c4de 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -106,16 +106,7 @@ void ConfigureSystem::Setup(const ConfigurationShared::Builder& builder) { push(Settings::values.linkage.by_category[Settings::Category::System]); for (auto setting : settings) { - ConfigurationShared::Widget* widget = [this, setting, &builder]() { - if (setting->Id() == Settings::values.speed_limit.Id()) { - // speed_limit must be specified to translate the percentage - return builder.BuildWidget(setting, apply_funcs, &Settings::values.use_speed_limit, - ConfigurationShared::RequestType::SpinBox, - tr("%", "Limit speed percentage (e.g. 50%)")); - } else { - return builder.BuildWidget(setting, apply_funcs); - } - }(); + ConfigurationShared::Widget* widget = builder.BuildWidget(setting, apply_funcs); if (widget == nullptr) { continue; -- cgit v1.2.3 From 1e093767a85ee0fdce6f1619e967a6560963dcf3 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 18 Jul 2023 15:42:59 -0400 Subject: common,configure_system: Rename method to GetCategory Fixes essentially a shadowing issue. --- src/yuzu/configuration/configure_system.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/yuzu/configuration/configure_system.cpp') diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index 05706c4de..d76630bcb 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -124,7 +124,7 @@ void ConfigureSystem::Setup(const ConfigurationShared::Builder& builder) { combo_language = widget->combobox; } - switch (setting->Category()) { + switch (setting->GetCategory()) { case Settings::Category::Core: core_hold.emplace(setting->Id(), widget); break; -- cgit v1.2.3 From b54c3fba6832ed5984d803f264ffdb7c0ded3cf6 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 19 Jul 2023 13:45:16 -0400 Subject: configure_system: Use lambda template to group settings --- src/yuzu/configuration/configure_system.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/yuzu/configuration/configure_system.cpp') diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index d76630bcb..7884886c3 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -96,7 +96,7 @@ void ConfigureSystem::Setup(const ConfigurationShared::Builder& builder) { std::map system_hold{}; std::forward_list settings; - auto push = [&settings](std::forward_list& list) { + auto push = [&settings](auto& list) { for (auto setting : list) { settings.push_front(setting); } -- cgit v1.2.3 From 17b9c1e1715a16bebcdd92c02ce7f7e503212462 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Fri, 21 Jul 2023 23:09:09 -0400 Subject: common,qt-config: Remove usage of forward_list --- src/yuzu/configuration/configure_system.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/yuzu/configuration/configure_system.cpp') diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index 7884886c3..93a0a4102 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -2,8 +2,8 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include -#include #include +#include #include #include @@ -44,9 +44,9 @@ static bool IsValidLocale(u32 region_index, u32 language_index) { return ((LOCALE_BLOCKLIST.at(region_index) >> language_index) & 1) == 0; } -ConfigureSystem::ConfigureSystem( - Core::System& system_, std::shared_ptr> group_, - const ConfigurationShared::Builder& builder, QWidget* parent) +ConfigureSystem::ConfigureSystem(Core::System& system_, + std::shared_ptr> group_, + const ConfigurationShared::Builder& builder, QWidget* parent) : Tab(group_, parent), ui{std::make_unique()}, system{system_} { ui->setupUi(this); @@ -95,10 +95,10 @@ void ConfigureSystem::Setup(const ConfigurationShared::Builder& builder) { std::map core_hold{}; std::map system_hold{}; - std::forward_list settings; + std::vector settings; auto push = [&settings](auto& list) { for (auto setting : list) { - settings.push_front(setting); + settings.push_back(setting); } }; -- cgit v1.2.3 From 1d4f813c6ab59ffe41ccd9be27786aeab344a1f4 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Fri, 21 Jul 2023 23:25:22 -0400 Subject: qt/configuration: Use deleteLater --- src/yuzu/configuration/configure_system.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/yuzu/configuration/configure_system.cpp') diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index 93a0a4102..c4833f4e7 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -112,7 +112,7 @@ void ConfigureSystem::Setup(const ConfigurationShared::Builder& builder) { continue; } if (!widget->Valid()) { - delete widget; + widget->deleteLater(); continue; } @@ -132,7 +132,7 @@ void ConfigureSystem::Setup(const ConfigurationShared::Builder& builder) { system_hold.emplace(setting->Id(), widget); break; default: - delete widget; + widget->deleteLater(); } } for (const auto& [label, widget] : core_hold) { -- cgit v1.2.3