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,18 +1391,22 @@ 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);
if (isAutoApply()) {
connect(button, &QAbstractButton::clicked, this, [this, i] { connect(button, &QAbstractButton::clicked, this, [this, i] {
setValue(i); setValue(i);
}); });
} }
}
break; break;
case DisplayStyle::ComboBox: case DisplayStyle::ComboBox:
setLabelText(displayName()); setLabelText(displayName());
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);
if (isAutoApply()) {
connect(d->m_comboBox.data(), QOverload<int>::of(&QComboBox::activated), connect(d->m_comboBox.data(), QOverload<int>::of(&QComboBox::activated),
this, &SelectionAspect::setValue); 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;