diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2016-11-13 22:30:56 +0900 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2017-07-22 15:56:47 +0200 |
commit | ee1ab98d125b131445b140733b87e1ce2c0f0245 (patch) | |
tree | 19a5e17e3df2c6d49f1db45e599110d8c67f7c97 | |
parent | c888240961aaf6438d2d9475b818a5692674d8d3 (diff) | |
download | tdelibs-ee1ab98d125b131445b140733b87e1ce2c0f0245.tar.gz tdelibs-ee1ab98d125b131445b140733b87e1ce2c0f0245.zip |
tdeui: fixed handling of setPrecision() for KDoubleSpinBox. This resolves bug 2717.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
(cherry picked from commit f32bc5176289b70bf1c6e7d2825d53f190bc4096)
-rw-r--r-- | kdeui/knuminput.cpp | 17 |
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(); } |