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;
|
||||
QPointer<QAbstractButton> m_button; // Owned by configuration widget
|
||||
QPointer<QGroupBox> m_groupBox; // For BoolAspects handling GroupBox check boxes
|
||||
bool m_buttonIsAdopted = false;
|
||||
};
|
||||
|
||||
class ColorAspectPrivate
|
||||
@@ -1446,8 +1447,10 @@ BoolAspect::~BoolAspect() = default;
|
||||
*/
|
||||
void BoolAspect::addToLayout(Layouting::LayoutItem &parent)
|
||||
{
|
||||
QTC_CHECK(!d->m_button);
|
||||
d->m_button = createSubWidget<QCheckBox>();
|
||||
if (!d->m_buttonIsAdopted) {
|
||||
QTC_CHECK(!d->m_button);
|
||||
d->m_button = createSubWidget<QCheckBox>();
|
||||
}
|
||||
switch (d->m_labelPlacement) {
|
||||
case LabelPlacement::AtCheckBoxWithoutDummyLabel:
|
||||
d->m_button->setText(labelText());
|
||||
@@ -1474,6 +1477,15 @@ void BoolAspect::addToLayout(Layouting::LayoutItem &parent)
|
||||
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()
|
||||
{
|
||||
return [this](QObject *target) {
|
||||
|
||||
Reference in New Issue
Block a user