From 51dcde7c171cc32d3d417852bc7fe7272d56429f Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 1 Mar 2026 14:11:39 +1000 Subject: [PATCH] Qt: Remove some unused setting binders Eww, null terminated arrays. --- src/duckstation-qt/settingwidgetbinder.h | 132 ----------------------- 1 file changed, 132 deletions(-) diff --git a/src/duckstation-qt/settingwidgetbinder.h b/src/duckstation-qt/settingwidgetbinder.h index 514bea0e5..d583bab1e 100644 --- a/src/duckstation-qt/settingwidgetbinder.h +++ b/src/duckstation-qt/settingwidgetbinder.h @@ -1254,138 +1254,6 @@ inline void BindMenuToEnumSetting(QMenu* menu, std::string section, std::string } } -template -inline void BindWidgetToEnumSetting(SettingsInterface* sif, WidgetType* widget, std::string section, std::string key, - const char** enum_names, DataType default_value) -{ - using Accessor = SettingAccessor; - using UnderlyingType = std::underlying_type_t; - - const std::string value(Core::GetBaseStringSettingValue(section.c_str(), key.c_str(), - enum_names[static_cast(default_value)])); - - UnderlyingType enum_index = static_cast(default_value); - for (UnderlyingType i = 0; enum_names[i] != nullptr; i++) - { - if (value == enum_names[i]) - { - enum_index = i; - break; - } - } - - if (sif) - { - Accessor::makeNullableInt(widget, static_cast(enum_index)); - - std::string sif_value; - std::optional sif_int_value; - if (sif->GetStringValue(section.c_str(), key.c_str(), &sif_value)) - { - for (UnderlyingType i = 0; enum_names[i] != nullptr; i++) - { - if (sif_value == enum_names[i]) - { - sif_int_value = static_cast(i); - break; - } - } - } - Accessor::setNullableIntValue(widget, sif_int_value); - - Accessor::connectValueChanged( - widget, [sif, widget, section = std::move(section), key = std::move(key), enum_names]() { - if (std::optional new_value = Accessor::getNullableIntValue(widget); new_value.has_value()) - sif->SetStringValue(section.c_str(), key.c_str(), enum_names[new_value.value()]); - else - sif->DeleteValue(section.c_str(), key.c_str()); - - QtHost::SaveGameSettings(sif, true); - g_core_thread->reloadGameSettings(); - }); - } - else - { - Accessor::setIntValue(widget, static_cast(enum_index)); - - Accessor::connectValueChanged(widget, [widget, section = std::move(section), key = std::move(key), enum_names]() { - const UnderlyingType value = static_cast(Accessor::getIntValue(widget)); - Core::SetBaseStringSettingValue(section.c_str(), key.c_str(), enum_names[value]); - Host::CommitBaseSettingChanges(); - g_core_thread->applySettings(); - }); - } -} - -template -inline void BindWidgetToEnumSetting(SettingsInterface* sif, WidgetType* widget, std::string section, std::string key, - const char** enum_names, const char** enum_values, const char* default_value, - const char* translation_ctx = nullptr) -{ - using Accessor = SettingAccessor; - - const std::string value = Core::GetBaseStringSettingValue(section.c_str(), key.c_str(), default_value); - - for (int i = 0; enum_names[i] != nullptr; i++) - { - widget->addItem(translation_ctx ? qApp->translate(translation_ctx, enum_names[i]) : - QString::fromUtf8(enum_names[i])); - } - - int enum_index = -1; - for (int i = 0; enum_values[i] != nullptr; i++) - { - if (value == enum_values[i]) - { - enum_index = i; - break; - } - } - - if (sif) - { - Accessor::makeNullableInt(widget, enum_index); - - std::string sif_value; - std::optional sif_int_value; - if (sif->GetStringValue(section.c_str(), key.c_str(), &sif_value)) - { - for (int i = 0; enum_values[i] != nullptr; i++) - { - if (sif_value == enum_values[i]) - { - sif_int_value = i; - break; - } - } - } - Accessor::setNullableIntValue(widget, sif_int_value); - - Accessor::connectValueChanged( - widget, [sif, widget, section = std::move(section), key = std::move(key), enum_values]() { - if (std::optional new_value = Accessor::getNullableIntValue(widget); new_value.has_value()) - sif->SetStringValue(section.c_str(), key.c_str(), enum_values[new_value.value()]); - else - sif->DeleteValue(section.c_str(), key.c_str()); - - QtHost::SaveGameSettings(sif, true); - g_core_thread->reloadGameSettings(); - }); - } - else - { - if (enum_index >= 0) - Accessor::setIntValue(widget, enum_index); - - Accessor::connectValueChanged(widget, [widget, section = std::move(section), key = std::move(key), enum_values]() { - const int value = Accessor::getIntValue(widget); - Core::SetBaseStringSettingValue(section.c_str(), key.c_str(), enum_values[value]); - Host::CommitBaseSettingChanges(); - g_core_thread->applySettings(); - }); - } -} - inline void BindWidgetToFolderSetting(SettingsInterface* sif, QLineEdit* widget, QAbstractButton* browse_button, QString browse_title, QAbstractButton* open_button, QAbstractButton* reset_button, std::string section, std::string key, std::string default_value,