summaryrefslogtreecommitdiffstats
path: root/kdeui/knuminput.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kdeui/knuminput.cpp')
-rw-r--r--kdeui/knuminput.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/kdeui/knuminput.cpp b/kdeui/knuminput.cpp
index 238eeee7a..ca34be6bf 100644
--- a/kdeui/knuminput.cpp
+++ b/kdeui/knuminput.cpp
@@ -1054,13 +1054,28 @@ void KDoubleSpinBox::setPrecision( int precision ) {
}
void KDoubleSpinBox::setPrecision( int precision, bool force ) {
- if ( precision < 1 ) return;
+ if ( precision < 0 ) return;
if ( !force ) {
int maxPrec = maxPrecision();
if ( precision > maxPrec )
+ {
precision = maxPrec;
+ }
}
+ // Update minValue, maxValue, value and lineStep to match the precision change
+ int oldPrecision = d->mPrecision;
+ double oldValue = value();
+ double oldMinValue = minValue();
+ double oldMaxValue = maxValue();
+ double oldLineStep = lineStep();
d->mPrecision = precision;
+ if (precision != oldPrecision)
+ {
+ setMinValue(oldMinValue);
+ setMaxValue(oldMaxValue);
+ setValue(oldValue);
+ setLineStep(oldLineStep);
+ }
updateValidator();
}