21 import org.kde.plasma.core 0.1 as PlasmaCore
22 import "private" as Private
36 property alias stepSize: range.stepSize
44 property alias minimumValue: range.minimumValue
52 property alias maximumValue: range.maximumValue
61 property alias value: range.value
70 property int orientation: Qt.Horizontal
77 property alias pressed: mouseArea.pressed
87 property bool valueIndicatorVisible:
false
94 property string valueIndicatorText: value
104 property alias inverted: range.inverted
106 width: contents.isVertical ? theme.defaultFont.mSize.height*1.6 : 200
107 height: contents.isVertical ? 200 : theme.defaultFont.mSize.height*1.6
110 opacity: enabled ? 1.0 : 0.5
113 if (!enabled || !contents.isVertical)
122 Keys.onDownPressed: {
123 if (!enabled || !enabled)
126 if (!contents.isVertical)
135 Keys.onLeftPressed: {
136 if (!enabled || contents.isVertical)
145 Keys.onRightPressed: {
146 if (!enabled || contents.isVertical)
159 property bool animated:
true
160 property real handleWidth: contents.isVertical ? grooveSvg.elementSize(
"vertical-slider-handle").width : grooveSvg.elementSize(
"horizontal-slider-handle").width
161 property real handleHeight: contents.isVertical ? grooveSvg.elementSize(
"vertical-slider-handle").height : grooveSvg.elementSize(
"horizontal-slider-handle").height
164 property bool isVertical: orientation == Qt.Vertical
166 width: contents.isVertical ? slider.height : slider.width
167 height: contents.isVertical ? slider.width : slider.height
168 rotation: contents.isVertical ? -90 : 0
170 anchors.centerIn: parent
181 positionAtMaximum: contents.width - handle.width
186 imagePath:
"widgets/slider"
188 PlasmaCore.FrameSvgItem {
190 imagePath:
"widgets/slider"
193 height: grooveSvg.elementSize(
"groove-topleft").height + grooveSvg.elementSize(
"groove-bottomleft").height
197 verticalCenter: parent.verticalCenter
200 PlasmaCore.FrameSvgItem {
202 imagePath:
"widgets/slider"
203 prefix:
"groove-highlight"
204 height: groove.height
205 width: inverted ? groove.width - handle.x : fakeHandle.x + handle.width/2
206 x: inverted ? handle.x : 0
207 anchors.verticalCenter: parent.verticalCenter
211 enabled: !mouseArea.drag.active && contents.animated
213 duration: behavior.enabled ? 150 : 0
214 easing.type: Easing.OutSine
218 visible: range.position > 0 && slider.enabled
221 Private.RoundShadow {
223 imagePath:
"widgets/slider"
224 focusElement: contents.isVertical ?
"vertical-slider-focus" :
"horizontal-slider-focus"
225 hoverElement: contents.isVertical ?
"vertical-slider-hover" :
"horizontal-slider-hover"
226 shadowElement: contents.isVertical ?
"vertical-slider-shadow" :
"horizontal-slider-shadow"
227 state: slider.activeFocus ?
"focus" : (mouseArea.containsMouse ?
"hover" :
"shadow")
230 rotation: contents.isVertical ? 90 : 0
238 verticalCenter: groove.verticalCenter
240 width: contents.handleWidth
241 height: contents.handleHeight
243 rotation: contents.isVertical ? 90 : 0
244 svg: PlasmaCore.Svg { imagePath:
"widgets/slider" }
245 elementId: contents.isVertical ?
"vertical-slider-handle" :
"horizontal-slider-handle"
249 enabled: !mouseArea.drag.active && contents.animated
252 duration: behavior.enabled ? 150 : 0
253 easing.type: Easing.OutSine
261 height: handle.height
268 enabled: slider.enabled
272 minimumX: range.positionAtMinimum
273 maximumX: range.positionAtMaximum
279 var newX = Math.max(mouse.x, drag.minimumX)
280 newX = Math.min(newX, drag.maximumX)
284 if (Math.abs(newX - fakeHandle.x) > handle.width / 2) {
285 range.position = newX - handle.width / 2
288 slider.forceActiveFocus()
303 when: !mouseArea.drag.active
306 value: range.position