Qt: Fix Resolution combobox default value

This commit is contained in:
Megamouse 2020-10-30 23:37:48 +01:00 committed by Ivan
parent b5014d56ab
commit 5ca2b1200d

View file

@ -342,16 +342,22 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> gui_settings, std
} }
} }
} }
const int res_index = ui->resBox->findData("1280x720"); for (int i = 0; i < ui->resBox->count(); i++)
if (res_index >= 0)
{ {
// Rename the default resolution for users const QVariantList var_list = ui->resBox->itemData(i).toList();
ui->resBox->setItemText(res_index, tr("1280x720 (Recommended)", "Resolution")); ASSERT(var_list.size() == 2 && var_list[0].canConvert<QString>());
// Set the current selection to the default if the original setting wasn't valid if (var_list[0].toString() == "1280x720")
if (saved_index_removed)
{ {
ui->resBox->setCurrentIndex(res_index); // Rename the default resolution for users
ui->resBox->setItemText(i, tr("1280x720 (Recommended)", "Resolution"));
// Set the current selection to the default if the original setting wasn't valid
if (saved_index_removed)
{
ui->resBox->setCurrentIndex(i);
}
break;
} }
} }