Qt: Fix incorrect dropdown value in game properties

This commit is contained in:
Connor McLaughlin 2022-03-07 20:09:37 +10:00 committed by lightningterror
parent a8ee746c39
commit f4acff1321
1 changed files with 3 additions and 3 deletions

View File

@ -120,7 +120,7 @@ namespace SettingWidgetBinder
}
static std::optional<int> getNullableIntValue(const QComboBox* widget)
{
return isNullValue(widget) ? std::nullopt : std::optional<int>(widget->currentIndex() + 1);
return isNullValue(widget) ? std::nullopt : std::optional<int>(widget->currentIndex() - 1);
}
static void setNullableIntValue(QComboBox* widget, std::optional<int> value)
{
@ -439,9 +439,9 @@ namespace SettingWidgetBinder
else
Accessor::setNullableIntValue(widget, std::nullopt);
Accessor::connectValueChanged(widget, [sif, widget, section = std::move(section), key = std::move(key)]() {
Accessor::connectValueChanged(widget, [sif, widget, section = std::move(section), key = std::move(key), option_offset]() {
if (std::optional<int> new_value = Accessor::getNullableIntValue(widget); new_value.has_value())
sif->SetIntValue(section.c_str(), key.c_str(), new_value.value());
sif->SetIntValue(section.c_str(), key.c_str(), new_value.value() + option_offset);
else
sif->DeleteValue(section.c_str(), key.c_str());