Change EnhanceComboBox to optionally sort the settings list before adding it to the combo box

This commit is contained in:
Jordy Vieira 2019-04-13 18:42:08 -03:00 committed by Ivan
parent 136fc8cfe3
commit bad0415f05
3 changed files with 11 additions and 4 deletions

View file

@ -244,7 +244,7 @@ void emu_settings::SaveSettings()
config.close(); config.close();
} }
void emu_settings::EnhanceComboBox(QComboBox* combobox, SettingsType type, bool is_ranged, bool use_max, int max) void emu_settings::EnhanceComboBox(QComboBox* combobox, SettingsType type, bool is_ranged, bool use_max, int max, bool sorted)
{ {
if (!combobox) if (!combobox)
{ {
@ -265,7 +265,14 @@ void emu_settings::EnhanceComboBox(QComboBox* combobox, SettingsType type, bool
} }
else else
{ {
for (QString setting : GetSettingOptions(type)) QStringList settings = GetSettingOptions(type);
if (sorted)
{
settings.sort();
}
for (QString setting : settings)
{ {
combobox->addItem(tr(setting.toStdString().c_str()), QVariant(setting)); combobox->addItem(tr(setting.toStdString().c_str()), QVariant(setting));
} }

View file

@ -187,7 +187,7 @@ public:
~emu_settings(); ~emu_settings();
/** Connects a combo box with the target settings type*/ /** Connects a combo box with the target settings type*/
void EnhanceComboBox(QComboBox* combobox, SettingsType type, bool is_ranged = false, bool use_max = false, int max = 0); void EnhanceComboBox(QComboBox* combobox, SettingsType type, bool is_ranged = false, bool use_max = false, int max = 0, bool sorted = false);
/** Connects a check box with the target settings type*/ /** Connects a check box with the target settings type*/
void EnhanceCheckBox(QCheckBox* checkbox, SettingsType type); void EnhanceCheckBox(QCheckBox* checkbox, SettingsType type);

View file

@ -861,7 +861,7 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
// Comboboxes // Comboboxes
xemu_settings->EnhanceComboBox(ui->sysLangBox, emu_settings::Language); xemu_settings->EnhanceComboBox(ui->sysLangBox, emu_settings::Language, false, false, 0, true);
SubscribeTooltip(ui->sysLangBox, json_sys["sysLangBox"].toString()); SubscribeTooltip(ui->sysLangBox, json_sys["sysLangBox"].toString());
// Checkboxes // Checkboxes