Utils: Only set SelectionAspect value automatically if requested

This is in line with what the other aspects do. Without this,
non-auto-apply aspects behave as auto-apply, even if marked with
setAutoApply(false).

Change-Id: I39192f63bb3b6e47ee181527938c19ee5044a5ec
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
hjk
2021-03-22 17:59:39 +01:00
parent c3ab90e30f
commit bc97b10488

View File

@@ -1391,9 +1391,11 @@ void SelectionAspect::addToLayout(LayoutBuilder &builder)
builder.addItems({{}, button}); builder.addItems({{}, button});
d->m_buttons.append(button); d->m_buttons.append(button);
d->m_buttonGroup->addButton(button, i); d->m_buttonGroup->addButton(button, i);
connect(button, &QAbstractButton::clicked, this, [this, i] { if (isAutoApply()) {
setValue(i); connect(button, &QAbstractButton::clicked, this, [this, i] {
}); setValue(i);
});
}
} }
break; break;
case DisplayStyle::ComboBox: case DisplayStyle::ComboBox:
@@ -1401,8 +1403,10 @@ void SelectionAspect::addToLayout(LayoutBuilder &builder)
d->m_comboBox = createSubWidget<QComboBox>(); d->m_comboBox = createSubWidget<QComboBox>();
for (int i = 0, n = d->m_options.size(); i < n; ++i) for (int i = 0, n = d->m_options.size(); i < n; ++i)
d->m_comboBox->addItem(d->m_options.at(i).displayName); d->m_comboBox->addItem(d->m_options.at(i).displayName);
connect(d->m_comboBox.data(), QOverload<int>::of(&QComboBox::activated), if (isAutoApply()) {
this, &SelectionAspect::setValue); connect(d->m_comboBox.data(), QOverload<int>::of(&QComboBox::activated),
this, &SelectionAspect::setValue);
}
d->m_comboBox->setCurrentIndex(value()); d->m_comboBox->setCurrentIndex(value());
addLabeledItem(builder, d->m_comboBox); addLabeledItem(builder, d->m_comboBox);
break; break;