forked from qt-creator/qt-creator
Utils: Use QAbstractButton instead of QCheckBox in BoolAspect
Opens the path to use e.g. QRadioButton. Change-Id: Idb1591c0a1486181b8aeb51edb93bc4bfecef834 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -585,7 +585,7 @@ class BoolAspectPrivate
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BoolAspect::LabelPlacement m_labelPlacement = BoolAspect::LabelPlacement::AtCheckBox;
|
BoolAspect::LabelPlacement m_labelPlacement = BoolAspect::LabelPlacement::AtCheckBox;
|
||||||
QPointer<QCheckBox> m_checkBox; // Owned by configuration widget
|
QPointer<QAbstractButton> m_button; // Owned by configuration widget
|
||||||
QPointer<QGroupBox> m_groupBox; // For BoolAspects handling GroupBox check boxes
|
QPointer<QGroupBox> m_groupBox; // For BoolAspects handling GroupBox check boxes
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1424,31 +1424,31 @@ BoolAspect::~BoolAspect() = default;
|
|||||||
*/
|
*/
|
||||||
void BoolAspect::addToLayout(Layouting::LayoutItem &parent)
|
void BoolAspect::addToLayout(Layouting::LayoutItem &parent)
|
||||||
{
|
{
|
||||||
QTC_CHECK(!d->m_checkBox);
|
QTC_CHECK(!d->m_button);
|
||||||
d->m_checkBox = createSubWidget<QCheckBox>();
|
d->m_button = createSubWidget<QCheckBox>();
|
||||||
switch (d->m_labelPlacement) {
|
switch (d->m_labelPlacement) {
|
||||||
case LabelPlacement::AtCheckBoxWithoutDummyLabel:
|
case LabelPlacement::AtCheckBoxWithoutDummyLabel:
|
||||||
d->m_checkBox->setText(labelText());
|
d->m_button->setText(labelText());
|
||||||
parent.addItem(d->m_checkBox.data());
|
parent.addItem(d->m_button.data());
|
||||||
break;
|
break;
|
||||||
case LabelPlacement::AtCheckBox: {
|
case LabelPlacement::AtCheckBox: {
|
||||||
d->m_checkBox->setText(labelText());
|
d->m_button->setText(labelText());
|
||||||
// FIXME:
|
// FIXME:
|
||||||
//if (parent.isForm())
|
//if (parent.isForm())
|
||||||
// parent.addItem(createSubWidget<QLabel>());
|
// parent.addItem(createSubWidget<QLabel>());
|
||||||
parent.addItem(d->m_checkBox.data());
|
parent.addItem(d->m_button.data());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LabelPlacement::InExtraLabel:
|
case LabelPlacement::InExtraLabel:
|
||||||
addLabeledItem(parent, d->m_checkBox);
|
addLabeledItem(parent, d->m_button);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
d->m_checkBox->setChecked(value());
|
d->m_button->setChecked(value());
|
||||||
if (isAutoApply()) {
|
if (isAutoApply()) {
|
||||||
connect(d->m_checkBox.data(), &QAbstractButton::clicked,
|
connect(d->m_button.data(), &QAbstractButton::clicked,
|
||||||
this, [this](bool val) { setValue(val); });
|
this, [this](bool val) { setValue(val); });
|
||||||
}
|
}
|
||||||
connect(d->m_checkBox.data(), &QAbstractButton::clicked,
|
connect(d->m_button.data(), &QAbstractButton::clicked,
|
||||||
this, &BoolAspect::volatileValueChanged);
|
this, &BoolAspect::volatileValueChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1486,8 +1486,8 @@ QAction *BoolAspect::action()
|
|||||||
QVariant BoolAspect::volatileValue() const
|
QVariant BoolAspect::volatileValue() const
|
||||||
{
|
{
|
||||||
QTC_CHECK(!isAutoApply());
|
QTC_CHECK(!isAutoApply());
|
||||||
if (d->m_checkBox)
|
if (d->m_button)
|
||||||
return d->m_checkBox->isChecked();
|
return d->m_button->isChecked();
|
||||||
if (d->m_groupBox)
|
if (d->m_groupBox)
|
||||||
return d->m_groupBox->isChecked();
|
return d->m_groupBox->isChecked();
|
||||||
QTC_CHECK(false);
|
QTC_CHECK(false);
|
||||||
@@ -1497,8 +1497,8 @@ QVariant BoolAspect::volatileValue() const
|
|||||||
void BoolAspect::setVolatileValue(const QVariant &val)
|
void BoolAspect::setVolatileValue(const QVariant &val)
|
||||||
{
|
{
|
||||||
QTC_CHECK(!isAutoApply());
|
QTC_CHECK(!isAutoApply());
|
||||||
if (d->m_checkBox)
|
if (d->m_button)
|
||||||
d->m_checkBox->setChecked(val.toBool());
|
d->m_button->setChecked(val.toBool());
|
||||||
else if (d->m_groupBox)
|
else if (d->m_groupBox)
|
||||||
d->m_groupBox->setChecked(val.toBool());
|
d->m_groupBox->setChecked(val.toBool());
|
||||||
}
|
}
|
||||||
@@ -1521,8 +1521,8 @@ bool BoolAspect::value() const
|
|||||||
void BoolAspect::setValue(bool value)
|
void BoolAspect::setValue(bool value)
|
||||||
{
|
{
|
||||||
if (BaseAspect::setValueQuietly(value)) {
|
if (BaseAspect::setValueQuietly(value)) {
|
||||||
if (d->m_checkBox)
|
if (d->m_button)
|
||||||
d->m_checkBox->setChecked(value);
|
d->m_button->setChecked(value);
|
||||||
//qDebug() << "SetValue: Changing" << labelText() << " to " << value;
|
//qDebug() << "SetValue: Changing" << labelText() << " to " << value;
|
||||||
emit changed();
|
emit changed();
|
||||||
//QTC_CHECK(!labelText().isEmpty());
|
//QTC_CHECK(!labelText().isEmpty());
|
||||||
|
Reference in New Issue
Block a user