Qt: Disable incompatible settings in game properties

This commit is contained in:
Stenzek
2024-07-21 16:04:05 +10:00
parent ad374ef5e2
commit 022b2fc013
6 changed files with 111 additions and 20 deletions

View File

@@ -1283,4 +1283,39 @@ static inline void BindWidgetToFolderSetting(SettingsInterface* sif, QLineEdit*
widget->connect(widget, &QLineEdit::editingFinished, widget, std::move(value_changed));
}
template<typename WidgetType>
static inline void SetAvailability(WidgetType* widget, bool available)
{
if (available)
return;
widget->disconnect();
if constexpr (std::is_same_v<WidgetType, QComboBox>)
{
widget->clear();
widget->addItem(qApp->translate("SettingWidgetBinder", "Incompatible with this game."));
}
else if constexpr (std::is_same_v<WidgetType, QLineEdit>)
{
widget->setText(qApp->translate("SettingWidgetBinder", "Incompatible with this game."));
}
else if constexpr (std::is_same_v<WidgetType, QCheckBox>)
{
widget->setText(widget->text() + qApp->translate("SettingWidgetBinder", " [incompatible]"));
widget->setCheckState(Qt::Unchecked);
}
else if constexpr (std::is_same_v<WidgetType, QSlider>)
{
widget->setTickPosition(0);
}
else if constexpr (std::is_same_v<WidgetType, QSpinBox> || std::is_same_v<WidgetType, QDoubleSpinBox>)
{
widget->setValue(0);
}
widget->setEnabled(false);
}
} // namespace SettingWidgetBinder