diff options
Diffstat (limited to 'src/controls/Slider.qml')
-rw-r--r-- | src/controls/Slider.qml | 47 |
1 files changed, 19 insertions, 28 deletions
diff --git a/src/controls/Slider.qml b/src/controls/Slider.qml index 711c449b..64dcfff1 100644 --- a/src/controls/Slider.qml +++ b/src/controls/Slider.qml @@ -108,9 +108,16 @@ Control { /*! \qmlproperty bool Slider::pressed - This property indicates if slider handle is currently being pressed. + This property indicates whether the slider handle is being pressed. */ - property alias pressed: mouseArea.pressed + readonly property alias pressed: mouseArea.pressed + + /*! + \qmlproperty bool Slider::hovered + + This property indicates whether the control is being hovered. + */ + readonly property alias hovered: mouseArea.containsMouse /*! \qmlproperty real Slider::stepSize @@ -145,7 +152,7 @@ Control { /*! \qmlproperty bool Slider::activeFocusOnPress - This property indicates if the Slider should receive active focus when + This property indicates whether the Slider should receive active focus when pressed. */ property bool activeFocusOnPress: false @@ -153,7 +160,7 @@ Control { /*! \qmlproperty bool Slider::tickmarksEnabled - This property indicates if the Slider should display tickmarks + This property indicates whether the Slider should display tickmarks at step intervals. The default value is \c false. @@ -161,9 +168,6 @@ Control { property bool tickmarksEnabled: false /*! \internal */ - property bool __containsMouse: mouseArea.containsMouse - - /*! \internal */ property bool __horizontal: orientation === Qt.Horizontal /*! \internal */ @@ -174,19 +178,6 @@ Control { Accessible.role: Accessible.Slider Accessible.name: value - /*! - \qmlmethod Slider::formatValue - - This method returns the current slider value in a way that is more suitable - for user display, such as the \l value rounded to only two decimal places. - - By default this function returns the nearest \c int value. - */ - - function formatValue(v) { - return Math.round(v); - } - style: Qt.createComponent(Settings.style + "/SliderStyle.qml", slider) Keys.onRightPressed: value += (maximumValue - minimumValue)/10.0 @@ -210,6 +201,14 @@ Control { anchors.horizontalCenter: !__horizontal ? parent.horizontalCenter : undefined width: __panel.handleWidth height: __panel.handleHeight + + function updatePos() { + if (updateValueWhileDragging && !mouseArea.drag.active) + range.position = __horizontal ? x : y + } + + onXChanged: updatePos(); + onYChanged: updatePos(); } MouseArea { @@ -260,14 +259,6 @@ Control { } } - // Range position normally follows handle, except when - // 'updateValueWhileDragging' is false. - Binding { - when: updateValueWhileDragging && !mouseArea.drag.active - target: range - property: "position" - value: __horizontal ? fakeHandle.x : fakeHandle.y - } // During the drag, we simply ignore the position set from the range, this // means that setting a value while dragging will not "interrupt" the |