mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-26 07:35:41 +00:00
Qt: Add normalized float values to SettingWidgetBinder
This commit is contained in:
parent
9ac7b002e2
commit
a81a0c0f21
|
@ -163,6 +163,20 @@ void BindWidgetToIntSetting(QtHostInterface* hi, WidgetType* widget, const char*
|
|||
});
|
||||
}
|
||||
|
||||
template<typename WidgetType>
|
||||
void BindWidgetToNormalizedSetting(QtHostInterface* hi, WidgetType* widget, const char* setting_name, float range)
|
||||
{
|
||||
using Accessor = SettingAccessor<WidgetType>;
|
||||
|
||||
Accessor::setIntValue(widget, static_cast<int>(hi->getSettingValue(setting_name).toFloat() * range));
|
||||
|
||||
Accessor::connectValueChanged(widget, [hi, widget, setting_name, range]() {
|
||||
const float new_value = (static_cast<float>(Accessor::getIntValue(widget)) / range);
|
||||
hi->putSettingValue(setting_name, new_value);
|
||||
hi->applySettings();
|
||||
});
|
||||
}
|
||||
|
||||
template<typename WidgetType>
|
||||
void BindWidgetToStringSetting(QtHostInterface* hi, WidgetType* widget, const char* setting_name)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue