Gui: add new PrefCheckableGroupBox widget

This commit is contained in:
Furgo
2025-06-11 01:51:40 +02:00
parent 7388758ad9
commit 5362c818c8
4 changed files with 62 additions and 0 deletions

View File

@@ -864,4 +864,37 @@ void PrefFontBox::savePreferences()
getWindowParameter()->SetASCII(entryName(), currName.toUtf8());
}
// --------------------------------------------------------------------
PrefCheckableGroupBox::PrefCheckableGroupBox(QWidget* parent)
: QGroupBox(parent), PrefWidget()
{
}
PrefCheckableGroupBox::~PrefCheckableGroupBox() = default;
void PrefCheckableGroupBox::restorePreferences()
{
if (getWindowParameter().isNull() || entryName().isEmpty()) {
failedToRestore(objectName());
return;
}
// Default value is the current state of the checkbox (usually from .ui on first load)
bool defaultValueInUi = isChecked();
bool actualValue = getWindowParameter()->GetBool(entryName(), defaultValueInUi);
setChecked(actualValue);
}
void PrefCheckableGroupBox::savePreferences()
{
if (getWindowParameter().isNull() || entryName().isEmpty())
{
failedToSave(objectName());
return;
}
getWindowParameter()->SetBool(entryName(), isChecked());
}
#include "moc_PrefWidgets.cpp"