Changeset View
Changeset View
Standalone View
Standalone View
org.kde.desktop/ScrollBar.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 org.kde.qqc2desktopstyle.private 1.0 as StylePrivate | 24 | import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate | ||
25 | import QtQuick.Templates @QQC2_VERSION@ as T | 25 | import QtQuick.Templates @QQC2_VERSION@ as T | ||
26 | import org.kde.kirigami 2.4 as Kirigami | 26 | import org.kde.kirigami 2.11 as Kirigami | ||
27 | 27 | | |||
28 | T.ScrollBar { | 28 | T.ScrollBar { | ||
29 | id: controlRoot | 29 | id: controlRoot | ||
30 | 30 | | |||
31 | @DISABLE_UNDER_QQC2_2_4@ palette: Kirigami.Theme.palette | 31 | @DISABLE_UNDER_QQC2_2_4@ palette: Kirigami.Theme.palette | ||
32 | implicitWidth: background.implicitWidth | 32 | implicitWidth: background.implicitWidth | ||
33 | implicitHeight: background.implicitHeight | 33 | implicitHeight: background.implicitHeight | ||
34 | 34 | | |||
35 | hoverEnabled: true | 35 | hoverEnabled: true | ||
36 | 36 | | |||
37 | visible: controlRoot.size < 1.0 && controlRoot.policy !== T.ScrollBar.AlwaysOff | 37 | visible: controlRoot.size < 1.0 && controlRoot.policy !== T.ScrollBar.AlwaysOff | ||
38 | stepSize: 0.02 | 38 | stepSize: 0.02 | ||
39 | interactive: !Kirigami.Settings.tabletMode | ||||
40 | | ||||
41 | onPositionChanged: { | ||||
42 | disappearTimer.restart(); | ||||
43 | handleGraphics.handleState = Math.min(1, handleGraphics.handleState + 0.1) | ||||
44 | } | ||||
45 | | ||||
46 | contentItem: Item { | ||||
47 | visible: !controlRoot.interactive | ||||
48 | | ||||
49 | Rectangle { | ||||
50 | id: handleGraphics | ||||
broulik: `Math.round` | |||||
51 | property real handleState: 0 | ||||
52 | | ||||
53 | x: controlRoot.orientation == Qt.Vertical | ||||
54 | ? (parent.width - width) - (parent.width/2 - width/2) * handleState | ||||
55 | : 0 | ||||
56 | | ||||
57 | y: controlRoot.orientation == Qt.Horizontal | ||||
58 | ? (parent.height - height) - (parent.height/2 - height/2) * handleState | ||||
59 | : 0 | ||||
60 | | ||||
61 | | ||||
62 | NumberAnimation { | ||||
63 | id: resetAnim | ||||
64 | target: handleGraphics | ||||
65 | property: "handleState" | ||||
66 | from: handleGraphics.handleState | ||||
67 | to: 0 | ||||
68 | duration: Kirigami.Units.longDuration | ||||
69 | easing.type: Easing.InOutQuad | ||||
70 | } | ||||
71 | | ||||
72 | width: Math.round(controlRoot.orientation == Qt.Vertical | ||||
73 | ? Math.max(2, Kirigami.Units.smallSpacing * handleState) | ||||
74 | : parent.width) | ||||
75 | height: Math.round(controlRoot.orientation == Qt.Horizontal | ||||
76 | ? Math.max(2, Kirigami.Units.smallSpacing * handleState) | ||||
77 | : parent.height) | ||||
78 | radius: Math.min(width, height) | ||||
79 | color: Kirigami.Theme.textColor | ||||
80 | opacity: 0.3 | ||||
81 | Timer { | ||||
82 | id: disappearTimer | ||||
83 | interval: 1000 | ||||
84 | onTriggered: { | ||||
85 | resetAnim.restart(); | ||||
86 | handleGraphics.handleState = 0; | ||||
87 | } | ||||
88 | } | ||||
89 | } | ||||
90 | } | ||||
39 | 91 | | |||
40 | background: MouseArea { | 92 | background: MouseArea { | ||
41 | id: mouseArea | 93 | id: mouseArea | ||
42 | anchors.fill: parent | 94 | anchors.fill: parent | ||
43 | visible: controlRoot.size < 1.0 | 95 | visible: controlRoot.size < 1.0 && interactive | ||
44 | hoverEnabled: true | 96 | hoverEnabled: true | ||
45 | state: "inactive" | 97 | state: "inactive" | ||
46 | acceptedButtons: Qt.LeftButton | Qt.MiddleButton | 98 | acceptedButtons: Qt.LeftButton | Qt.MiddleButton | ||
47 | onExited: style.activeControl = "groove"; | 99 | onExited: style.activeControl = "groove"; | ||
48 | onPressed: { | 100 | onPressed: { | ||
49 | if (mouse.buttons & Qt.MiddleButton) { | 101 | if (mouse.buttons & Qt.MiddleButton) { | ||
50 | style.activeControl = "handle"; | 102 | style.activeControl = "handle"; | ||
51 | controlRoot.position = Math.min(1 - controlRoot.size, Math.max(0, mouse.y/(controlRoot.orientation == Qt.Vertical ? height: width) - controlRoot.size/2)); | 103 | controlRoot.position = Math.min(1 - controlRoot.size, Math.max(0, mouse.y/(controlRoot.orientation == Qt.Vertical ? height: width) - controlRoot.size/2)); | ||
▲ Show 20 Lines • Show All 128 Lines • ▼ Show 20 Line(s) | 230 | NumberAnimation { | |||
180 | property: "opacity" | 232 | property: "opacity" | ||
181 | duration: Kirigami.Units.shortDuration | 233 | duration: Kirigami.Units.shortDuration | ||
182 | easing.type: Easing.InOutQuad | 234 | easing.type: Easing.InOutQuad | ||
183 | } | 235 | } | ||
184 | } | 236 | } | ||
185 | } | 237 | } | ||
186 | ] | 238 | ] | ||
187 | } | 239 | } | ||
188 | | ||||
189 | contentItem: Item {} | | |||
190 | } | 240 | } |
Math.round