Changeset View
Changeset View
Standalone View
Standalone View
libs/widgets/KoUnitDoubleSpinBox.cpp
Show First 20 Lines • Show All 108 Lines • ▼ Show 20 Line(s) | 108 | #endif | |||
---|---|---|---|---|---|
109 | return QValidator::Intermediate; | 109 | return QValidator::Intermediate; | ||
110 | } | 110 | } | ||
111 | } | 111 | } | ||
112 | else | 112 | else | ||
113 | { | 113 | { | ||
114 | warnWidgets << "Not a number: " << number; | 114 | warnWidgets << "Not a number: " << number; | ||
115 | return QValidator::Invalid; | 115 | return QValidator::Invalid; | ||
116 | } | 116 | } | ||
117 | newVal = KoUnit::ptToUnit( newVal, d->unit ); | 117 | newVal = d->unit.toUserValuePrecise(newVal); | ||
118 | //input = textFromValue( newVal ); // don't overwrite for now; the effect is not exactly what I expect... | 118 | //input = textFromValue( newVal ); // don't overwrite for now; the effect is not exactly what I expect... | ||
119 | 119 | | |||
120 | return QValidator::Acceptable; | 120 | return QValidator::Acceptable; | ||
121 | } | 121 | } | ||
122 | 122 | | |||
123 | void KoUnitDoubleSpinBox::changeValue( double val ) | 123 | void KoUnitDoubleSpinBox::changeValue( double val ) | ||
124 | { | 124 | { | ||
125 | QDoubleSpinBox::setValue( d->unit.toUserValue( val ) ); | 125 | QDoubleSpinBox::setValue( d->unit.toUserValue( val ) ); | ||
Show All 18 Lines | 136 | { | |||
144 | 144 | | |||
145 | if (unit.type() == KoUnit::Pixel) { | 145 | if (unit.type() == KoUnit::Pixel) { | ||
146 | // limit the pixel step by 1.0 | 146 | // limit the pixel step by 1.0 | ||
147 | step = qMax(qreal(1.0), step); | 147 | step = qMax(qreal(1.0), step); | ||
148 | } | 148 | } | ||
149 | 149 | | |||
150 | QDoubleSpinBox::setSingleStep( step ); | 150 | QDoubleSpinBox::setSingleStep( step ); | ||
151 | d->unit = unit; | 151 | d->unit = unit; | ||
152 | QDoubleSpinBox::setValue( KoUnit::ptToUnit( oldvalue, unit ) ); | 152 | QDoubleSpinBox::setValue(unit.toUserValuePrecise(oldvalue)); | ||
153 | setSuffix(unit.symbol().prepend(QLatin1Char(' '))); | 153 | setSuffix(unit.symbol().prepend(QLatin1Char(' '))); | ||
154 | } | 154 | } | ||
155 | 155 | | |||
156 | double KoUnitDoubleSpinBox::value( ) const | 156 | double KoUnitDoubleSpinBox::value( ) const | ||
157 | { | 157 | { | ||
158 | return d->unit.fromUserValue( QDoubleSpinBox::value() ); | 158 | return d->unit.fromUserValue( QDoubleSpinBox::value() ); | ||
159 | } | 159 | } | ||
160 | 160 | | |||
▲ Show 20 Lines • Show All 61 Lines • Show Last 20 Lines |