forked from qt-creator/qt-creator
Utils: Implement SelectionAspect::{setV,v}olatileValue
Change-Id: Ib0b2644c1f7aae651df5af85d35b82f82bc22e8c Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -1348,7 +1348,7 @@ void SelectionAspect::addToLayout(LayoutBuilder &builder)
|
|||||||
button->setToolTip(option.tooltip);
|
button->setToolTip(option.tooltip);
|
||||||
builder.addItems({{}, button});
|
builder.addItems({{}, button});
|
||||||
d->m_buttons.append(button);
|
d->m_buttons.append(button);
|
||||||
d->m_buttonGroup->addButton(button);
|
d->m_buttonGroup->addButton(button, i);
|
||||||
connect(button, &QAbstractButton::clicked, this, [this, i] {
|
connect(button, &QAbstractButton::clicked, this, [this, i] {
|
||||||
setValue(i);
|
setValue(i);
|
||||||
});
|
});
|
||||||
@@ -1367,6 +1367,39 @@ void SelectionAspect::addToLayout(LayoutBuilder &builder)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariant SelectionAspect::volatileValue() const
|
||||||
|
{
|
||||||
|
QTC_CHECK(!isAutoApply());
|
||||||
|
switch (d->m_displayStyle) {
|
||||||
|
case DisplayStyle::RadioButtons:
|
||||||
|
QTC_ASSERT(d->m_buttonGroup, return {});
|
||||||
|
return d->m_buttonGroup->checkedId();
|
||||||
|
case DisplayStyle::ComboBox:
|
||||||
|
QTC_ASSERT(d->m_comboBox, return {});
|
||||||
|
return d->m_comboBox->currentIndex();
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
void SelectionAspect::setVolatileValue(const QVariant &val)
|
||||||
|
{
|
||||||
|
QTC_CHECK(!isAutoApply());
|
||||||
|
switch (d->m_displayStyle) {
|
||||||
|
case DisplayStyle::RadioButtons: {
|
||||||
|
if (d->m_buttonGroup) {
|
||||||
|
QAbstractButton *button = d->m_buttonGroup->button(val.toInt());
|
||||||
|
QTC_ASSERT(button, return);
|
||||||
|
button->setChecked(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DisplayStyle::ComboBox:
|
||||||
|
if (d->m_comboBox)
|
||||||
|
d->m_comboBox->setCurrentIndex(val.toInt());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SelectionAspect::setVisibleDynamic(bool visible)
|
void SelectionAspect::setVisibleDynamic(bool visible)
|
||||||
{
|
{
|
||||||
if (QLabel *l = label())
|
if (QLabel *l = label())
|
||||||
|
@@ -238,6 +238,8 @@ public:
|
|||||||
~SelectionAspect() override;
|
~SelectionAspect() override;
|
||||||
|
|
||||||
void addToLayout(LayoutBuilder &builder) override;
|
void addToLayout(LayoutBuilder &builder) override;
|
||||||
|
QVariant volatileValue() const override;
|
||||||
|
void setVolatileValue(const QVariant &val) override;
|
||||||
|
|
||||||
int value() const;
|
int value() const;
|
||||||
void setValue(int val);
|
void setValue(int val);
|
||||||
|
Reference in New Issue
Block a user