Utils: Make BoolAspects also notify their changed values

... when triggered via base class setValue().

The pattern would probably be useful for other aspects, too, but e.g.
for actions in a menu (like switching on/off FakeVim) this already
covers most cases.

Change-Id: I7886f4b845883edb6d337df0fa53f989ae893f65
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
hjk
2021-03-01 06:35:08 +01:00
parent 383e756dc3
commit b7acf45c13
2 changed files with 15 additions and 1 deletions

View File

@@ -137,8 +137,10 @@ QVariant BaseAspect::value() const
*/
void BaseAspect::setValue(const QVariant &value)
{
if (setValueQuietly(value))
if (setValueQuietly(value)) {
emit changed();
emitChangedValue();
}
}
/*!
@@ -1218,6 +1220,10 @@ void BoolAspect::addToLayout(LayoutBuilder &builder)
break;
}
d->m_checkBox->setChecked(value());
builder.addItem(d->m_checkBox.data());
connect(d->m_checkBox.data(), &QAbstractButton::clicked, this, [this] {
setValue(d->m_checkBox->isChecked());
});
if (isAutoApply()) {
connect(d->m_checkBox.data(), &QAbstractButton::clicked,
this, [this](bool val) { setValue(val); });
@@ -1252,6 +1258,12 @@ void BoolAspect::setVolatileValue(const QVariant &val)
d->m_checkBox->setChecked(val.toBool());
}
void BoolAspect::emitChangedValue()
{
emit valueChanged(value());
}
/*!
\reimp
*/