Libplasma

RangeSlider.qml
1/*
2 SPDX-FileCopyrightText: 2016 Marco Martin <mart@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7import QtQuick
8import QtQuick.Templates as T
9import org.kde.ksvg as KSvg
10//NOTE: importing PlasmaCore is necessary in order to make KSvg load the current Plasma Theme
11import org.kde.plasma.core as PlasmaCore
12import org.kde.kirigami as Kirigami
13import "private" as Private
14
15T.RangeSlider {
16 id: control
17
18 implicitWidth: control.orientation === Qt.Horizontal ? Kirigami.Units.gridUnit * 12 : Kirigami.Units.gridUnit * 1.6
19 implicitHeight: control.orientation === Qt.Horizontal ? Kirigami.Units.gridUnit * 1.6 : Kirigami.Units.gridUnit * 12
20
21 KSvg.Svg {
22 id: grooveSvg
23 imagePath: "widgets/slider"
24 // FIXME
25 colorSet: control.Kirigami.Theme.colorSet
26 }
27 first.handle: Item {
28 property bool horizontal: control.orientation === Qt.Horizontal
29 x: Math.round(control.leftPadding + (horizontal ? control.first.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2))
30 y: Math.round(control.topPadding + (horizontal ? (control.availableHeight - height) / 2 : control.first.visualPosition * (control.availableHeight - height)))
31
32 width: grooveSvg.hasElement("hint-handle-size") ? grooveSvg.elementSize("hint-handle-size").width : firstHandle.width
33 height: grooveSvg.hasElement("hint-handle-size") ? grooveSvg.elementSize("hint-handle-size").height : firstHandle.height
34
35 Private.RoundShadow {
36 anchors.fill: firstHandle
37 imagePath: "widgets/slider"
38 focusElement: parent.horizontal ? "horizontal-slider-focus" : "vertical-slider-focus"
39 hoverElement: parent.horizontal ? "horizontal-slider-hover" : "vertical-slider-hover"
40 shadowElement: parent.horizontal ? "horizontal-slider-shadow" : "vertical-slider-shadow"
41 state: control.activeFocus ? "focus" : (control.hovered ? "hover" : "shadow")
42 }
44 id: firstHandle
45 anchors.centerIn: parent
46 width: naturalSize.width
47 height: naturalSize.height
48 svg: grooveSvg
49 elementId: parent.horizontal ? "horizontal-slider-handle" : "vertical-slider-handle"
50 }
51 }
52
53 second.handle: Item {
54 property bool horizontal: control.orientation === Qt.Horizontal
55 x: control.leftPadding + (horizontal ? control.second.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2)
56 y: control.topPadding + (horizontal ? (control.availableHeight - height) / 2 : control.second.visualPosition * (control.availableHeight - height))
57
58 width: grooveSvg.hasElement("hint-handle-size") ? grooveSvg.elementSize("hint-handle-size").width : secondHandle.width
59 height: grooveSvg.hasElement("hint-handle-size") ? grooveSvg.elementSize("hint-handle-size").height : secondHandle.height
60
61 Private.RoundShadow {
62 anchors.fill: secondHandle
63 imagePath: "widgets/slider"
64 focusElement: parent.horizontal ? "horizontal-slider-focus" : "vertical-slider-focus"
65 hoverElement: parent.horizontal ? "horizontal-slider-hover" : "vertical-slider-hover"
66 shadowElement: parent.horizontal ? "horizontal-slider-shadow" : "vertical-slider-shadow"
67 state: control.activeFocus ? "focus" : (control.hovered ? "hover" : "shadow")
68 }
70 id: secondHandle
71 anchors.centerIn: parent
72 width: naturalSize.width
73 height: naturalSize.height
74 svg: grooveSvg
75 elementId: parent.horizontal ? "horizontal-slider-handle" : "vertical-slider-handle"
76 }
77 }
78
79 background: KSvg.FrameSvgItem {
80 imagePath: "widgets/slider"
81 prefix: "groove"
82 readonly property bool horizontal: control.orientation === Qt.Horizontal
83 implicitWidth: horizontal ? Kirigami.Units.gridUnit * 8 : margins.left + margins.right
84 implicitHeight: horizontal ? margins.top + margins.bottom : Kirigami.Units.gridUnit * 8
85 width: horizontal ? control.availableWidth : implicitWidth
86 height: horizontal ? implicitHeight : control.availableHeight
87 anchors.centerIn: parent
88 scale: horizontal && control.mirrored ? -1 : 1
89 opacity: control.enabled ? 1 : 0.6
90
92 imagePath: "widgets/slider"
93 prefix: "groove-highlight"
94 x: parent.horizontal ? control.first.position * parent.width : 0
95 y: parent.horizontal ? 0 : control.second.visualPosition * parent.height
96 width: parent.horizontal ? control.second.position * parent.width - control.first.position * parent.width : parent.width
97 height: parent.horizontal ? parent.height : control.second.position * parent.height - control.first.position * parent.height
98 }
99 }
100}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:34:35 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.