9import QtQuick.Templates as T
10import org.kde.ksvg as KSvg
12import org.kde.plasma.core as PlasmaCore
13import org.kde.kirigami as Kirigami
19 implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
20 implicitHandleWidth + leftPadding + rightPadding)
21 implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
22 implicitHandleHeight + topPadding + bottomPadding)
24 snapMode: T.Slider.SnapOnRelease
27 layer.enabled: opacity < 1
28 opacity: control.enabled ? 1 : 0.5
32 imagePath:
"widgets/slider"
34 colorSet: control.Kirigami.Theme.colorSet
41 property int wheelDelta: 0
45 leftMargin: control.leftPadding
46 rightMargin: control.rightPadding
48 LayoutMirroring.enabled:
false
50 acceptedButtons:
Qt.NoButton
53 const lastValue = control.value
57 const delta = (wheel.angleDelta.y || -wheel.angleDelta.x) * (wheel.inverted ? -1 : 1)
61 while (wheelDelta >= 120) {
65 while (wheelDelta <= -120) {
69 if (lastValue !== control.value) {
76 x: Math.round(control.leftPadding + (horizontal ? control.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2))
77 y: Math.round(control.topPadding + (horizontal ? (control.availableHeight - height) / 2 : control.visualPosition * (control.availableHeight - height)))
79 implicitWidth: sliderSvg.hasElement(
"hint-handle-size") ? sliderSvg.elementSize(
"hint-handle-size").width : firstHandle.implicitWidth
80 implicitHeight: sliderSvg.hasElement(
"hint-handle-size") ? sliderSvg.elementSize(
"hint-handle-size").height : firstHandle.implicitHeight
85 anchors.centerIn: parent
86 implicitWidth: naturalSize.width
87 implicitHeight: naturalSize.height
89 elementId: control.horizontal ?
"horizontal-slider-shadow" :
"vertical-slider-shadow"
90 visible: enabled && !control.pressed
94 anchors.centerIn: parent
95 implicitWidth: naturalSize.width
96 implicitHeight: naturalSize.height
98 elementId: control.horizontal ?
"horizontal-slider-handle" :
"vertical-slider-handle"
101 anchors.centerIn: parent
102 implicitWidth: naturalSize.width
103 implicitHeight: naturalSize.height
105 elementId: control.horizontal ?
"horizontal-slider-focus" :
"vertical-slider-focus"
107 opacity: control.visualFocus
108 Behavior on opacity {
109 enabled:
Kirigami.Units.longDuration > 0
111 duration:
Kirigami.Units.longDuration
112 easing.type: Easing.OutCubic
117 anchors.centerIn: parent
118 implicitWidth: naturalSize.width
119 implicitHeight: naturalSize.height
121 elementId: control.horizontal ?
"horizontal-slider-hover" :
"vertical-slider-hover"
123 opacity: control.hovered
124 Behavior on opacity {
125 enabled: control.hovered &&
Kirigami.Units.longDuration > 0
127 duration:
Kirigami.Units.longDuration
128 easing.type: Easing.OutCubic
135 imagePath:
"widgets/slider"
137 implicitWidth: control.horizontal ?
Kirigami.Units.gridUnit * 12 : fixedMargins.left + fixedMargins.right
138 implicitHeight: control.vertical ?
Kirigami.Units.gridUnit * 12 : fixedMargins.top + fixedMargins.bottom
140 width: control.horizontal ? Math.max(fixedMargins.left + fixedMargins.right, control.availableWidth) : implicitWidth
141 height: control.vertical ? Math.max(fixedMargins.top + fixedMargins.bottom, control.availableHeight) : implicitHeight
142 x: control.leftPadding + (control.horizontal ? 0 : Math.round((control.availableWidth - width) / 2))
143 y: control.topPadding + (control.vertical ? 0 : Math.round((control.availableHeight - height) / 2))
147 imagePath:
"widgets/slider"
148 prefix:
"groove-highlight"
150 LayoutMirroring.enabled: control.mirrored
151 anchors.left: parent.left
152 anchors.bottom: parent.bottom
154 width: control.horizontal ? Math.max(fixedMargins.left + fixedMargins.right, Math.round(control.position * (control.availableWidth - control.handle.width / 2) + (control.handle.width / 2))) : parent.width
155 height: control.vertical ? Math.max(fixedMargins.top + fixedMargins.bottom, Math.round(control.position * (control.availableHeight - control.handle.height / 2) + (control.handle.height / 2))) : parent.height
160 readonly
property int stepCount: (control.to - control.from) / control.stepSize
161 visible: stepCount > 0 && stepCount <= 20
164 left: control.horizontal ? parent.left : parent.right
165 top: control.vertical ? parent.top : parent.bottom
166 leftMargin: control.horizontal ? Math.round(control.handle.width / 2) : 1
167 topMargin: control.vertical ? Math.round(control.handle.height / 2) : 1
169 width: control.horizontal ? parent.width - control.handle.width : control.background.x
170 height: control.vertical ? parent.height - control.handle.height : control.background.y
171 sourceComponent: Grid {
173 rows: control.vertical ? tickLoader.stepCount + 1 : 1
174 columns: control.horizontal ? tickLoader.stepCount + 1 : 1
175 spacing: (control.vertical ? height : width - (tickLoader.stepCount + 1)) / tickLoader.stepCount
176 LayoutMirroring.enabled: control.mirrored
178 model: tickLoader.stepCount + 1
179 delegate: Rectangle {
180 property bool withinFill: (control.horizontal ? index : stepCount - index) <= control.position * tickLoader.stepCount
181 width: control.vertical ? parent.width : 1
182 height: control.horizontal ? parent.height : 1
183 opacity: withinFill ? 1 : 0.3
184 color: withinFill ?
Kirigami.Theme.highlightColor :
Kirigami.Theme.textColor