Changeset View
Changeset View
Standalone View
Standalone View
org.kde.desktop/RangeSlider.qml
Show All 17 Lines | |||||
18 | * ensure the GNU General Public License version 2.0 requirements will be | 18 | * ensure the GNU General Public License version 2.0 requirements will be | ||
19 | * met: http://www.gnu.org/licenses/gpl-2.0.html. | 19 | * met: http://www.gnu.org/licenses/gpl-2.0.html. | ||
20 | */ | 20 | */ | ||
21 | 21 | | |||
22 | 22 | | |||
23 | import QtQuick 2.6 | 23 | import QtQuick 2.6 | ||
24 | import QtQuick.Controls 2.0 | 24 | import QtQuick.Controls 2.0 | ||
25 | import QtQuick.Templates 2.0 as T | 25 | import QtQuick.Templates 2.0 as T | ||
26 | import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate | 26 | import org.kde.kirigami 2.2 as Kirigami | ||
27 | 27 | | |||
28 | T.RangeSlider { | 28 | T.RangeSlider { | ||
29 | id: control | 29 | id: control | ||
30 | 30 | | |||
31 | implicitWidth: Math.max(background ? background.implicitWidth : 0, | 31 | implicitWidth: Math.max(background ? background.implicitWidth : 0, | ||
32 | Math.max(first.handle ? first.handle.implicitWidth : 0, | 32 | Math.max(first.handle ? first.handle.implicitWidth : 0, | ||
33 | second.handle ? second.handle.implicitWidth : 0) + leftPadding + rightPadding) | 33 | second.handle ? second.handle.implicitWidth : 0) + leftPadding + rightPadding) | ||
34 | implicitHeight: Math.max(background ? background.implicitHeight : 0, | 34 | implicitHeight: Math.max(background ? background.implicitHeight : 0, | ||
35 | Math.max(first.handle ? first.handle.implicitHeight : 0, | 35 | Math.max(first.handle ? first.handle.implicitHeight : 0, | ||
36 | second.handle ? second.handle.implicitHeight : 0) + topPadding + bottomPadding) | 36 | second.handle ? second.handle.implicitHeight : 0) + topPadding + bottomPadding) | ||
37 | 37 | | |||
38 | padding: 6 | 38 | padding: 6 | ||
39 | 39 | | |||
40 | first.handle: Rectangle { | 40 | first.handle: Rectangle { | ||
41 | property bool horizontal: control.orientation === Qt.Horizontal | 41 | property bool horizontal: control.orientation === Qt.Horizontal | ||
42 | x: control.leftPadding + (horizontal ? control.first.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2) | 42 | x: control.leftPadding + (horizontal ? control.first.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2) | ||
43 | y: control.topPadding + (horizontal ? (control.availableHeight - height) / 2 : control.first.visualPosition * (control.availableHeight - height)) | 43 | y: control.topPadding + (horizontal ? (control.availableHeight - height) / 2 : control.first.visualPosition * (control.availableHeight - height)) | ||
44 | implicitWidth: 18 | 44 | implicitWidth: 18 | ||
45 | implicitHeight: 18 | 45 | implicitHeight: 18 | ||
46 | radius: width / 2 | 46 | radius: width / 2 | ||
47 | property color borderColor: StylePrivate.SystemPaletteSingleton.text(control.enabled) | 47 | property color borderColor: Kirigami.Theme.textColor | ||
48 | border.color: control.activeFocus ? StylePrivate.SystemPaletteSingleton.highlight(control.enabled) : Qt.rgba(borderColor.r, borderColor.g, borderColor.b, 0.3) | 48 | border.color: control.activeFocus ? Kirigami.Theme.highlightColor : Qt.rgba(borderColor.r, borderColor.g, borderColor.b, 0.3) | ||
49 | color: StylePrivate.SystemPaletteSingleton.window(control.enabled) | 49 | color: Kirigami.Theme.backgroundColor | ||
50 | Rectangle { | 50 | Rectangle { | ||
51 | z: -1 | 51 | z: -1 | ||
52 | x: 1 | 52 | x: 1 | ||
53 | y: 1 | 53 | y: 1 | ||
54 | width: parent.width | 54 | width: parent.width | ||
55 | height: parent.height | 55 | height: parent.height | ||
56 | radius: width / 2 | 56 | radius: width / 2 | ||
57 | color: Qt.rgba(0, 0, 0, 0.15) | 57 | color: Qt.rgba(0, 0, 0, 0.15) | ||
58 | } | 58 | } | ||
59 | } | 59 | } | ||
60 | 60 | | |||
61 | second.handle: Rectangle { | 61 | second.handle: Rectangle { | ||
62 | property bool horizontal: control.orientation === Qt.Horizontal | 62 | property bool horizontal: control.orientation === Qt.Horizontal | ||
63 | x: control.leftPadding + (horizontal ? control.second.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2) | 63 | x: control.leftPadding + (horizontal ? control.second.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2) | ||
64 | y: control.topPadding + (horizontal ? (control.availableHeight - height) / 2 : control.second.visualPosition * (control.availableHeight - height)) | 64 | y: control.topPadding + (horizontal ? (control.availableHeight - height) / 2 : control.second.visualPosition * (control.availableHeight - height)) | ||
65 | implicitWidth: 18 | 65 | implicitWidth: 18 | ||
66 | implicitHeight: 18 | 66 | implicitHeight: 18 | ||
67 | radius: width / 2 | 67 | radius: width / 2 | ||
68 | property color borderColor: StylePrivate.SystemPaletteSingleton.text(control.enabled) | 68 | property color borderColor: Kirigami.Theme.textColor | ||
69 | border.color: control.activeFocus ? StylePrivate.SystemPaletteSingleton.highlight(control.enabled) : Qt.rgba(borderColor.r, borderColor.g, borderColor.b, 0.3) | 69 | border.color: control.activeFocus ? Kirigami.Theme.highlightColor : Qt.rgba(borderColor.r, borderColor.g, borderColor.b, 0.3) | ||
70 | color: StylePrivate.SystemPaletteSingleton.window(control.enabled) | 70 | color: Kirigami.Theme.backgroundColor | ||
71 | Rectangle { | 71 | Rectangle { | ||
72 | z: -1 | 72 | z: -1 | ||
73 | x: 1 | 73 | x: 1 | ||
74 | y: 1 | 74 | y: 1 | ||
75 | width: parent.width | 75 | width: parent.width | ||
76 | height: parent.height | 76 | height: parent.height | ||
77 | radius: width / 2 | 77 | radius: width / 2 | ||
78 | color: Qt.rgba(0, 0, 0, 0.15) | 78 | color: Qt.rgba(0, 0, 0, 0.15) | ||
79 | } | 79 | } | ||
80 | } | 80 | } | ||
81 | 81 | | |||
82 | background: Rectangle { | 82 | background: Rectangle { | ||
83 | readonly property bool horizontal: control.orientation === Qt.Horizontal | 83 | readonly property bool horizontal: control.orientation === Qt.Horizontal | ||
84 | implicitWidth: horizontal ? 200 : 6 | 84 | implicitWidth: horizontal ? 200 : 6 | ||
85 | implicitHeight: horizontal ? 6 : 200 | 85 | implicitHeight: horizontal ? 6 : 200 | ||
86 | width: horizontal ? control.availableWidth : implicitWidth | 86 | width: horizontal ? control.availableWidth : implicitWidth | ||
87 | height: horizontal ? implicitHeight : control.availableHeight | 87 | height: horizontal ? implicitHeight : control.availableHeight | ||
88 | radius: Math.round(Math.min(width/2, height/2)) | 88 | radius: Math.round(Math.min(width/2, height/2)) | ||
89 | property color bgColor: StylePrivate.SystemPaletteSingleton.text(control.enabled) | 89 | property color bgColor: Kirigami.Theme.textColor | ||
90 | color: Qt.rgba(bgColor.r, bgColor.g, bgColor.b, 0.3) | 90 | color: Qt.rgba(bgColor.r, bgColor.g, bgColor.b, 0.3) | ||
91 | anchors.centerIn: parent | 91 | anchors.centerIn: parent | ||
92 | 92 | | |||
93 | Rectangle { | 93 | Rectangle { | ||
94 | x: parent.horizontal ? control.first.position * parent.width : 0 | 94 | x: parent.horizontal ? control.first.position * parent.width : 0 | ||
95 | y: parent.horizontal ? 0 : control.second.visualPosition * parent.height + 6 | 95 | y: parent.horizontal ? 0 : control.second.visualPosition * parent.height + 6 | ||
96 | width: parent.horizontal ? control.second.position * parent.width - control.first.position * parent.width - 6 : 6 | 96 | width: parent.horizontal ? control.second.position * parent.width - control.first.position * parent.width - 6 : 6 | ||
97 | height: parent.horizontal ? 6 : control.second.position * parent.height - control.first.position * parent.height - 6 | 97 | height: parent.horizontal ? 6 : control.second.position * parent.height - control.first.position * parent.height - 6 | ||
98 | color: StylePrivate.SystemPaletteSingleton.highlight(control.enabled) | 98 | color: Kirigami.Theme.highlightColor | ||
99 | } | 99 | } | ||
100 | } | 100 | } | ||
101 | } | 101 | } |