Index: sources/gui/qml/components/Slider.qml =================================================================== diff -u -r22ad47530c68333209f2006f54dbdcef9efd20aa -rc80e4dade15bd769ea20f8098b37655fb22407b7 --- sources/gui/qml/components/Slider.qml (.../Slider.qml) (revision 22ad47530c68333209f2006f54dbdcef9efd20aa) +++ sources/gui/qml/components/Slider.qml (.../Slider.qml) (revision c80e4dade15bd769ea20f8098b37655fb22407b7) @@ -40,10 +40,13 @@ property alias handlerColor : _handler.color property alias handlerVisible : _handler.visible + readonly property alias handleAdjusted : _private.sliderAdjusted + property alias diameter : _handler.diameter property bool isActive : true property bool inActiveZero : false // if inActiveZero:true, when is not active (inActive or active:false) sets to zero instead of minimum + property bool showActiveDisabled : false // if showActiveDisabled: true the slider is highlighted active even if the slider is isActive:false property alias progressRectMargin : _progressRect.margin @@ -53,7 +56,6 @@ property bool isRoundedEnds : true property bool hasBorder : true - property color borderColor : Colors.borderDisableButton QtObject { id:_private // To avoid displaying and updating _root.value with intermediate values, @@ -65,6 +67,14 @@ // This value is set primarily in the update() function and checked for in // onValueChanged handler property bool isInternalValueUpdate : false + + // Indicate the active state of the slider visually (borders) + property bool isVisualActive : false + + // Indicate whether the slider have been modified/adjusted + // When property changes, update the visuals of the slider to reflect + property bool sliderAdjusted : false + onSliderAdjustedChanged: setActiveVisuals(sliderAdjusted) } onValueChanged: { @@ -112,26 +122,30 @@ update(newValue) } - function setActiveVisuals(active) { - if (active) { - color = Colors.sliderHighlightColor + function setActiveVisuals(vActive) { + // NOTE: the slider borders are set separately from here and + // based on _private.isVisualActive + + if (vActive) { + color = Colors.sliderHighlightColor // _progressRect body color handlerColor = Colors.createTreatmentActive } else { - color = Colors.createTreatmentInactive + color = Colors.createTreatmentInactive // _progressRect body color handlerColor = Colors.createTreatmentInactive } + + _private.isVisualActive = vActive } onIsActiveChanged: { - setActiveVisuals(isActive) - - // value is assigned a different value based on active-ness of the slider - // This is to resolve the use of slider with a switch and arrows enabled. - // It allows correct behavior when using arrow on a first initialize increment of - // the slider when the slider has inActiveZero to true. - _root.value = inActiveZero ? 0 : minimum // Not using update() here because slider is not active => _progressRect not visible - _progressRect.value = 0 - + if(!isActive) { + _root.value = inActiveZero ? 0 : minimum + setActiveVisuals(showActiveDisabled) + } else { + _progressRect.value = minimum + _private.sliderAdjusted = false + setActiveVisuals(false) + } activeChanged() // emit } @@ -142,7 +156,7 @@ radius : _root.isRoundedEnds ? (height/2) : Variables.rangeRectRadius border.width: _root.hasBorder ? Variables.rangeRectBorderWidth : 0 - border.color: _root.isActive ? Colors.borderButton : Colors.borderDisableButton + border.color: _private.isVisualActive ? Colors.borderButton : Colors.borderDisableButton minimum : 0 maximum : 0 @@ -185,6 +199,9 @@ // Update the _root.value / the exposed value of slider _root.value = vValue + // indicate that the slider have modified value state + _private.sliderAdjusted = true + // reset state to allow _root.value value updating externally _private.isInternalValueUpdate = false } @@ -250,7 +267,7 @@ radius : _root.isRoundedEnds ? (height/2) : Variables.rangeRectRadius border.width: _root.hasBorder ? Variables.rangeRectBorderWidth : 0 - border.color: _root.isActive ? Colors.sliderProgressBorderActive : Colors.borderDisableButton + border.color: _private.isVisualActive ? Colors.sliderProgressBorderActive : Colors.borderDisableButton // propagation is not working on drag ! onDragged: { @@ -289,7 +306,7 @@ return _root.tickMarkYDisplacement } } - color : _root.isActive ? Colors.borderButton : Colors.borderDisableButton + color : _private.isVisualActive ? Colors.borderButton : Colors.borderDisableButton } } @@ -314,7 +331,6 @@ // update slider value with rounded new value update(calculateRoundedValue(newCurrentValue)) - } }