forked from qt-creator/qt-creator
Utils: Allow a BoolAspect to adopt an external button
This will be used by the apply machinery and allows more complex setups than the automatically generated internal CheckBox button. Change-Id: I237a9283253f11bcb76e0366a0b6c5a0346fdfd8 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -587,6 +587,7 @@ public:
|
|||||||
BoolAspect::LabelPlacement m_labelPlacement = BoolAspect::LabelPlacement::AtCheckBox;
|
BoolAspect::LabelPlacement m_labelPlacement = BoolAspect::LabelPlacement::AtCheckBox;
|
||||||
QPointer<QAbstractButton> m_button; // 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
|
||||||
|
bool m_buttonIsAdopted = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ColorAspectPrivate
|
class ColorAspectPrivate
|
||||||
@@ -1446,8 +1447,10 @@ BoolAspect::~BoolAspect() = default;
|
|||||||
*/
|
*/
|
||||||
void BoolAspect::addToLayout(Layouting::LayoutItem &parent)
|
void BoolAspect::addToLayout(Layouting::LayoutItem &parent)
|
||||||
{
|
{
|
||||||
|
if (!d->m_buttonIsAdopted) {
|
||||||
QTC_CHECK(!d->m_button);
|
QTC_CHECK(!d->m_button);
|
||||||
d->m_button = createSubWidget<QCheckBox>();
|
d->m_button = createSubWidget<QCheckBox>();
|
||||||
|
}
|
||||||
switch (d->m_labelPlacement) {
|
switch (d->m_labelPlacement) {
|
||||||
case LabelPlacement::AtCheckBoxWithoutDummyLabel:
|
case LabelPlacement::AtCheckBoxWithoutDummyLabel:
|
||||||
d->m_button->setText(labelText());
|
d->m_button->setText(labelText());
|
||||||
@@ -1474,6 +1477,15 @@ void BoolAspect::addToLayout(Layouting::LayoutItem &parent)
|
|||||||
this, &BoolAspect::volatileValueChanged);
|
this, &BoolAspect::volatileValueChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BoolAspect::adoptButton(QAbstractButton *button)
|
||||||
|
{
|
||||||
|
QTC_ASSERT(button, return);
|
||||||
|
QTC_CHECK(!d->m_button);
|
||||||
|
d->m_button = button;
|
||||||
|
d->m_buttonIsAdopted = true;
|
||||||
|
registerSubWidget(button);
|
||||||
|
}
|
||||||
|
|
||||||
std::function<void (QObject *)> BoolAspect::groupChecker()
|
std::function<void (QObject *)> BoolAspect::groupChecker()
|
||||||
{
|
{
|
||||||
return [this](QObject *target) {
|
return [this](QObject *target) {
|
||||||
|
|||||||
@@ -240,6 +240,8 @@ public:
|
|||||||
LabelPlacement labelPlacement = LabelPlacement::InExtraLabel);
|
LabelPlacement labelPlacement = LabelPlacement::InExtraLabel);
|
||||||
void setLabelPlacement(LabelPlacement labelPlacement);
|
void setLabelPlacement(LabelPlacement labelPlacement);
|
||||||
|
|
||||||
|
void adoptButton(QAbstractButton *button);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void valueChanged(bool newValue);
|
void valueChanged(bool newValue);
|
||||||
void volatileValueChanged(bool newValue);
|
void volatileValueChanged(bool newValue);
|
||||||
|
|||||||
Reference in New Issue
Block a user