Gui: [skip ci] fix bug when keyboard tracking for QuantitySpinBox is disabled and value is changed by mouse wheel or the spin buttons

This commit is contained in:
wmayer
2020-06-07 23:38:03 +02:00
parent 07d40a3140
commit 9a67154e73
2 changed files with 13 additions and 5 deletions

View File

@@ -629,6 +629,11 @@ void QuantitySpinBox::finishFormulaDialog()
}
void QuantitySpinBox::handlePendingEmit()
{
updateFromCache(true);
}
void QuantitySpinBox::updateFromCache(bool notify)
{
Q_D(QuantitySpinBox);
if (d->pendingEmit) {
@@ -639,9 +644,11 @@ void QuantitySpinBox::handlePendingEmit()
d->quantity = res;
// signaling
d->pendingEmit = false;
valueChanged(res);
valueChanged(res.getValue());
if (notify) {
d->pendingEmit = false;
valueChanged(res);
valueChanged(res.getValue());
}
}
}
@@ -791,8 +798,7 @@ QAbstractSpinBox::StepEnabled QuantitySpinBox::stepEnabled() const
void QuantitySpinBox::stepBy(int steps)
{
Q_D(QuantitySpinBox);
handlePendingEmit();
updateFromCache(false);
double step = d->singleStep * steps;
double val = d->unitValue + step;
@@ -802,6 +808,7 @@ void QuantitySpinBox::stepBy(int steps)
val = d->minimum;
lineEdit()->setText(QString::fromUtf8("%L1 %2").arg(val).arg(d->unitStr));
updateFromCache(true);
update();
selectNumber();
}

View File

@@ -159,6 +159,7 @@ protected:
private:
void updateText(const Base::Quantity&);
void updateFromCache(bool);
QString getUserString(const Base::Quantity& val, double& factor, QString& unitString) const;
QString getUserString(const Base::Quantity& val) const;