use new range for combobox, remove obsolete code

This commit is contained in:
Megamouse 2017-08-06 09:56:50 +02:00 committed by Ivan
parent 54d2e8bfdd
commit ae440a92ac
3 changed files with 18 additions and 24 deletions

View File

@ -207,11 +207,23 @@ void emu_settings::SaveSettings()
config.write(out.c_str(), out.size());
}
void emu_settings::EnhanceComboBox(QComboBox* combobox, SettingsType type)
void emu_settings::EnhanceComboBox(QComboBox* combobox, SettingsType type, bool is_ranged)
{
for (QString setting : GetSettingOptions(type))
if (is_ranged)
{
combobox->addItem(tr(setting.toStdString().c_str()), QVariant(setting));
QStringList range = GetSettingOptions(type);
for (int i = range.first().toInt(); i <= range.last().toInt(); i++)
{
combobox->addItem(QString::number(i), QVariant(QString::number(i)));
}
}
else
{
for (QString setting : GetSettingOptions(type))
{
combobox->addItem(tr(setting.toStdString().c_str()), QVariant(setting));
}
}
QString selected = qstr(GetSetting(type));

View File

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

View File

@ -123,27 +123,9 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> xSettings, const
// Comboboxes
// TODO implement enhancement for combobox / spinbox with proper range
//xemu_settings->EnhanceComboBox(ui->preferredSPUThreads, emu_settings::PreferredSPUThreads);
const QString Auto = tr("Auto");
xemu_settings->EnhanceComboBox(ui->preferredSPUThreads, emu_settings::PreferredSPUThreads, true);
ui->preferredSPUThreads->setToolTip(json_cpu_cbo["preferredSPUThreads"].toString());
for (int i = 0; i <= 6; i++)
{
ui->preferredSPUThreads->addItem( i == 0 ? Auto : QString::number(i), QVariant(i) );
}
const QString valueOf_PreferredSPUThreads = qstr(xemu_settings->GetSetting(emu_settings::PreferredSPUThreads));
int index = ui->preferredSPUThreads->findData(valueOf_PreferredSPUThreads == "0" ? Auto : valueOf_PreferredSPUThreads);
if (index == -1)
{
LOG_WARNING(GENERAL, "Current setting not found while creating preferredSPUThreads");
}
else
{
ui->preferredSPUThreads->setCurrentIndex(index);
}
connect(ui->preferredSPUThreads, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [=](int index) {
xemu_settings->SetSetting(emu_settings::PreferredSPUThreads, std::to_string(ui->preferredSPUThreads->itemData(index).toInt()));
});
ui->preferredSPUThreads->setItemText(ui->preferredSPUThreads->findData("0"), tr("Auto"));
// PPU tool tips
ui->ppu_precise->setToolTip(json_cpu_ppu["precise"].toString());