Utils: Improve handling of BoolAspects used for checked QGroupBoxes

Make the group box a registered subwidget of the BoolAspect, so it
properly triggers the necessary behavior in BaseAspect::isDirty.

Change-Id: I9f6291d87ef7ce4067e0d235de8b5be24de79a93
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2021-04-06 11:51:14 +02:00
parent b63b84b83c
commit ba06114afa
3 changed files with 20 additions and 5 deletions

View File

@@ -41,6 +41,7 @@
#include <QComboBox>
#include <QDebug>
#include <QFormLayout>
#include <QGroupBox>
#include <QLabel>
#include <QLineEdit>
#include <QListWidget>
@@ -566,6 +567,7 @@ class BoolAspectPrivate
public:
BoolAspect::LabelPlacement m_labelPlacement = BoolAspect::LabelPlacement::AtCheckBox;
QPointer<QCheckBox> m_checkBox; // Owned by configuration widget
QPointer<QGroupBox> m_groupBox; // For BoolAspects handling GroupBox check boxes
};
class SelectionAspectPrivate
@@ -1278,8 +1280,12 @@ QAction *BoolAspect::action()
QVariant BoolAspect::volatileValue() const
{
QTC_CHECK(!isAutoApply());
QTC_ASSERT(d->m_checkBox, return {});
return d->m_checkBox->isChecked();
if (d->m_checkBox)
return d->m_checkBox->isChecked();
if (d->m_groupBox)
return d->m_groupBox->isChecked();
QTC_CHECK(false);
return {};
}
void BoolAspect::setVolatileValue(const QVariant &val)
@@ -1287,6 +1293,8 @@ void BoolAspect::setVolatileValue(const QVariant &val)
QTC_CHECK(!isAutoApply());
if (d->m_checkBox)
d->m_checkBox->setChecked(val.toBool());
else if (d->m_groupBox)
d->m_groupBox->setChecked(val.toBool());
}
void BoolAspect::emitChangedValue()
@@ -1337,6 +1345,12 @@ void BoolAspect::setLabelPlacement(BoolAspect::LabelPlacement labelPlacement)
d->m_labelPlacement = labelPlacement;
}
void BoolAspect::setHandlesGroup(QGroupBox *box)
{
registerSubWidget(box);
d->m_groupBox = box;
}
/*!
\class Utils::SelectionAspect
\inmodule QtCreator