Adding apply/discard/reset functionality to settings dialog

This commit is contained in:
Dan Paulat 2022-12-22 00:16:59 -06:00
parent a6974e31a2
commit 87f611e026
10 changed files with 276 additions and 13 deletions

View file

@ -122,6 +122,19 @@ void SettingsVariable<T>::SetValueToDefault()
p->value_ = p->default_;
}
template<class T>
void SettingsVariable<T>::StageDefault()
{
if (p->value_ != p->default_)
{
p->staged_ = p->default_;
}
else
{
p->staged_.reset();
}
}
template<class T>
bool SettingsVariable<T>::StageValue(const T& value)
{
@ -144,13 +157,18 @@ bool SettingsVariable<T>::StageValue(const T& value)
}
template<class T>
void SettingsVariable<T>::Commit()
bool SettingsVariable<T>::Commit()
{
bool committed = false;
if (p->staged_.has_value())
{
p->value_ = std::move(*p->staged_);
p->staged_.reset();
committed = true;
}
return committed;
}
template<class T>