forked from qt-creator/qt-creator
Utils: Fix setting up spinbox for IntegerAspect
setValue() has to be called after setRange(), otherwise the value will by cut at the initial default 99 maximum. Change-Id: Id4a7cf1db0e3044f32022d6de8f66810f9cd6b4e Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -645,8 +645,8 @@ public:
|
|||||||
class IntegerAspectPrivate
|
class IntegerAspectPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QVariant m_minimumValue;
|
Utils::optional<qint64> m_minimumValue;
|
||||||
QVariant m_maximumValue;
|
Utils::optional<qint64> m_maximumValue;
|
||||||
int m_displayIntegerBase = 10;
|
int m_displayIntegerBase = 10;
|
||||||
qint64 m_displayScaleFactor = 1;
|
qint64 m_displayScaleFactor = 1;
|
||||||
QString m_prefix;
|
QString m_prefix;
|
||||||
@@ -1554,15 +1554,15 @@ void IntegerAspect::addToLayout(LayoutBuilder &builder)
|
|||||||
{
|
{
|
||||||
QTC_CHECK(!d->m_spinBox);
|
QTC_CHECK(!d->m_spinBox);
|
||||||
d->m_spinBox = createSubWidget<QSpinBox>();
|
d->m_spinBox = createSubWidget<QSpinBox>();
|
||||||
d->m_spinBox->setValue(int(value() / d->m_displayScaleFactor));
|
|
||||||
d->m_spinBox->setDisplayIntegerBase(d->m_displayIntegerBase);
|
d->m_spinBox->setDisplayIntegerBase(d->m_displayIntegerBase);
|
||||||
d->m_spinBox->setPrefix(d->m_prefix);
|
d->m_spinBox->setPrefix(d->m_prefix);
|
||||||
d->m_spinBox->setSuffix(d->m_suffix);
|
d->m_spinBox->setSuffix(d->m_suffix);
|
||||||
d->m_spinBox->setSingleStep(d->m_singleStep);
|
d->m_spinBox->setSingleStep(d->m_singleStep);
|
||||||
d->m_spinBox->setSpecialValueText(d->m_specialValueText);
|
d->m_spinBox->setSpecialValueText(d->m_specialValueText);
|
||||||
if (d->m_maximumValue.isValid() && d->m_maximumValue.isValid())
|
if (d->m_maximumValue && d->m_maximumValue)
|
||||||
d->m_spinBox->setRange(int(d->m_minimumValue.toLongLong() / d->m_displayScaleFactor),
|
d->m_spinBox->setRange(int(d->m_minimumValue.value() / d->m_displayScaleFactor),
|
||||||
int(d->m_maximumValue.toLongLong() / d->m_displayScaleFactor));
|
int(d->m_maximumValue.value() / d->m_displayScaleFactor));
|
||||||
|
d->m_spinBox->setValue(int(value() / d->m_displayScaleFactor)); // Must happen after setRange()
|
||||||
addLabeledItem(builder, d->m_spinBox);
|
addLabeledItem(builder, d->m_spinBox);
|
||||||
|
|
||||||
if (isAutoApply()) {
|
if (isAutoApply()) {
|
||||||
@@ -1674,13 +1674,13 @@ void DoubleAspect::addToLayout(LayoutBuilder &builder)
|
|||||||
{
|
{
|
||||||
QTC_CHECK(!d->m_spinBox);
|
QTC_CHECK(!d->m_spinBox);
|
||||||
d->m_spinBox = createSubWidget<QDoubleSpinBox>();
|
d->m_spinBox = createSubWidget<QDoubleSpinBox>();
|
||||||
d->m_spinBox->setValue(value());
|
|
||||||
d->m_spinBox->setPrefix(d->m_prefix);
|
d->m_spinBox->setPrefix(d->m_prefix);
|
||||||
d->m_spinBox->setSuffix(d->m_suffix);
|
d->m_spinBox->setSuffix(d->m_suffix);
|
||||||
d->m_spinBox->setSingleStep(d->m_singleStep);
|
d->m_spinBox->setSingleStep(d->m_singleStep);
|
||||||
d->m_spinBox->setSpecialValueText(d->m_specialValueText);
|
d->m_spinBox->setSpecialValueText(d->m_specialValueText);
|
||||||
if (d->m_maximumValue && d->m_maximumValue)
|
if (d->m_maximumValue && d->m_maximumValue)
|
||||||
d->m_spinBox->setRange(d->m_minimumValue.value(), d->m_maximumValue.value());
|
d->m_spinBox->setRange(d->m_minimumValue.value(), d->m_maximumValue.value());
|
||||||
|
d->m_spinBox->setValue(value()); // Must happen after setRange()!
|
||||||
addLabeledItem(builder, d->m_spinBox);
|
addLabeledItem(builder, d->m_spinBox);
|
||||||
|
|
||||||
if (isAutoApply()) {
|
if (isAutoApply()) {
|
||||||
|
Reference in New Issue
Block a user