Index: sources/gui/qml/components/Slider.qml =================================================================== diff -u -r79bf4dda5c027044ebd0014e7deac42a058a7fcf -rcd7de5f6d239a11615ba8c6c03339a10996486ca --- sources/gui/qml/components/Slider.qml (.../Slider.qml) (revision 79bf4dda5c027044ebd0014e7deac42a058a7fcf) +++ sources/gui/qml/components/Slider.qml (.../Slider.qml) (revision cd7de5f6d239a11615ba8c6c03339a10996486ca) @@ -25,11 +25,12 @@ RangeRect { id: _root property alias value : _progressRect.value property int step : 1 + property bool ticks : false property alias color : _progressRect.color property alias bgColor : _root.color - property real handlerWidth: 34 + property real handlerWidth: 35 height : Variables.progressbarHeight touchMargin : 25 @@ -38,13 +39,13 @@ maximum : 0 minText { - visible : true + visible : true anchors.topMargin: Variables.sliderTextMargin font.pixelSize : Fonts.fontPixelSliderMarker font.bold : false } maxText { - visible : true + visible : true anchors.topMargin: Variables.sliderTextMargin font.pixelSize : Fonts.fontPixelSliderMarker font.bold : false @@ -61,11 +62,11 @@ if ( x > width ) { value = maximum } else - if (step === 1) { // only for performance othewise formula works perfectly fine. - value = getPosition(x) - } else { - value = Math.floor((getPosition(x) - minimum) / step) * step + minimum - } + if (step === 1) { // only for performance othewise formula works perfectly fine for any step. + value = getPosition(x) + } else { + value = Math.round((getPosition(x) - minimum) / step) * step + minimum + } } ProgressRect { id: _progressRect @@ -85,6 +86,18 @@ } } + // used loader for performance since it may not always be required. + // and can be a heavy Component + Loader { id: _ticksLoader + active : ticks + anchors.fill : parent + sourceComponent : TickMarks { + minimum : _root.minimum + maximum : _root.maximum + step : _root.step + } + } + onDragged: { setValue(vMouseEvent.x) } @@ -102,13 +115,9 @@ height : diameter radius : diameter color : "white" - Rectangle { - property real diameter : parent.diameter - 8 - anchors.centerIn: parent - width : diameter - height : diameter - radius : diameter - color : Colors.highlightProgressBar + border { + width: 4 + color: Colors.highlightProgressBar } } }