Changeset View
Changeset View
Standalone View
Standalone View
org.kde.desktop/ScrollBar.qml
Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | 48 | onPressed: { | |||
---|---|---|---|---|---|
69 | } else { | 69 | } else { | ||
70 | mouse.accepted = false | 70 | mouse.accepted = false | ||
71 | } | 71 | } | ||
72 | } | 72 | } | ||
73 | onPositionChanged: { | 73 | onPositionChanged: { | ||
74 | style.activeControl = style.hitTest(mouse.x, mouse.y) | 74 | style.activeControl = style.hitTest(mouse.x, mouse.y) | ||
75 | if (mouse.buttons & Qt.MiddleButton) { | 75 | if (mouse.buttons & Qt.MiddleButton) { | ||
76 | style.activeControl = "handle"; | 76 | style.activeControl = "handle"; | ||
77 | controlRoot.position = Math.min(1 - controlRoot.size, Math.max(0, mouse.y/(controlRoot.orientation == Qt.Vertical ? height: width) - controlRoot.size/2)); | 77 | controlRoot.position = Math.min(1 - controlRoot.size, Math.max(0, mouse.y/style.length - controlRoot.size/2)); | ||
78 | mouse.accepted = true; | 78 | mouse.accepted = true; | ||
79 | } | 79 | } | ||
80 | } | 80 | } | ||
81 | onReleased: { | 81 | onReleased: { | ||
82 | buttonTimer.running = false; | 82 | buttonTimer.running = false; | ||
83 | mouse.accepted = false | 83 | mouse.accepted = false | ||
84 | } | 84 | } | ||
85 | onCanceled: buttonTimer.running = false; | 85 | onCanceled: buttonTimer.running = false; | ||
86 | 86 | | |||
87 | implicitWidth: style.horizontal ? 200 : style.pixelMetric("scrollbarExtent") | 87 | implicitWidth: style.horizontal ? 200 : style.pixelMetric("scrollbarExtent") | ||
88 | implicitHeight: style.horizontal ? style.pixelMetric("scrollbarExtent") : 200 | 88 | implicitHeight: style.horizontal ? style.pixelMetric("scrollbarExtent") : 200 | ||
89 | 89 | | |||
90 | StylePrivate.StyleItem { | 90 | StylePrivate.StyleItem { | ||
91 | id: style | 91 | id: style | ||
92 | | ||||
93 | readonly property real length: (controlRoot.orientation == Qt.Vertical ? height : width) | ||||
94 | | ||||
92 | control: controlRoot | 95 | control: controlRoot | ||
93 | anchors.fill: parent | 96 | anchors.fill: parent | ||
94 | elementType: "scrollbar" | 97 | elementType: "scrollbar" | ||
95 | hover: activeControl != "none" | 98 | hover: activeControl != "none" | ||
96 | activeControl: "none" | 99 | activeControl: "none" | ||
97 | sunken: controlRoot.pressed | 100 | sunken: controlRoot.pressed | ||
98 | minimum: 0 | 101 | minimum: 0 | ||
99 | maximum: (controlRoot.height/controlRoot.size - controlRoot.height) | 102 | maximum: style.length/controlRoot.size - style.length | ||
100 | value: controlRoot.position * (controlRoot.height/controlRoot.size) | 103 | value: controlRoot.position * (style.length/controlRoot.size) | ||
101 | horizontal: controlRoot.orientation == Qt.Horizontal | 104 | horizontal: controlRoot.orientation == Qt.Horizontal | ||
102 | enabled: controlRoot.enabled | 105 | enabled: controlRoot.enabled | ||
103 | 106 | | |||
104 | visible: controlRoot.size < 1.0 | 107 | visible: controlRoot.size < 1.0 | ||
105 | opacity: 1 | 108 | opacity: 1 | ||
106 | 109 | | |||
107 | Timer { | 110 | Timer { | ||
108 | id: buttonTimer | 111 | id: buttonTimer | ||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |