Index: sources/gui/qml/compounds/ValueAdjuster.qml =================================================================== diff -u -rea4de12b2c7d6306a9cb89ff23eb95ccd25077a1 -r40ddf63592b60608ae34aeb3099fe4e62ae45054 --- sources/gui/qml/compounds/ValueAdjuster.qml (.../ValueAdjuster.qml) (revision ea4de12b2c7d6306a9cb89ff23eb95ccd25077a1) +++ sources/gui/qml/compounds/ValueAdjuster.qml (.../ValueAdjuster.qml) (revision 40ddf63592b60608ae34aeb3099fe4e62ae45054) @@ -24,41 +24,46 @@ property real minimum : 0 property real maximum : 0 property real value : 0 - property real defaultValue : 0 + property real defaultValue: 0 property real step : 0 - + property real actualValue : 0 property bool active : false property bool editable : true + property bool allowOff : false + property bool synchronize : false - property bool canIncrement : active ? value < maximum : true - property bool canDecrement : active ? allowOff ? value > 0 : - value > minimum : true - - property bool allowOff : false - // fix floating-point precision issue readonly property real stepVal : Math.round(step * 100) / 100 readonly property real minVal : Math.round(minimum * 100) / 100 readonly property real val : Math.round(value * 100) / 100 - onActiveChanged : if ( active ) { _root.value = _root.defaultValue } + readonly property bool canIncrement : active ? value < maximum : true + readonly property bool canDecrement : active ? allowOff ? value > 0 : + value > minimum : true - function clear() { _root.active = false } + onActiveChanged : { + // use actual value not default value to synchronize + if ( synchronize ) { synchronize = false; return; } + if ( active ) { _root.value = _root.defaultValue } + } + + function sync () { value = actualValue; synchronize = true } + + function clear() { _root.active = false } + function increment() { - if ( ! active ) { active = true } - else { - if ( allowOff ) { value = val < minVal ? minVal : val + stepVal } - else { value += stepVal } - } + if ( ! active ) { active = true; return; } + + if ( allowOff ) { value = val < minVal ? minVal : val + stepVal } + else { value += stepVal } } function decrement() { - if ( ! active ) { active = true } - else { - if ( allowOff ) { value = val > minVal ? val - stepVal : 0 } - else { value -= stepVal } - } + if ( ! active ) { active = true; return; } + + if ( allowOff ) { value = val > minVal ? val - stepVal : 0 } + else { value -= stepVal } } Text { id: _text @@ -118,10 +123,7 @@ pressAndHoldInterval: 0 onClicked: { - if ( _root.editable ) { - active = true - focus = true - } + if ( _root.editable ) { active = true; focus = true } _slider.opacity = 0 } @@ -133,10 +135,7 @@ } onPressAndHold: { - if ( _root.editable ) { - active = true - focus = true - } + if ( _root.editable ) { active = true; focus = true } _sliderMouseArea.grabbed = true }