22 import org.kde.plasma.core 0.1 as PlasmaCore
25 PlasmaCore.FrameSvgItem {
28 imagePath:
"widgets/scrollbar"
29 prefix: internalLoader.isVertical ?
"background-vertical" :
"background-horizontal"
31 property int implicitWidth: scrollbarSvg.hasElement(
"hint-scrollbar-size") ? scrollbarSvg.elementSize(
"hint-scrollbar-size").width : scrollbarSvg.elementSize(
"arrow-up").width
32 property int implicitHeight: scrollbarSvg.hasElement(
"hint-scrollbar-size") ? scrollbarSvg.elementSize(
"hint-scrollbar-size").height : scrollbarSvg.elementSize(
"arrow-left").height
35 if (!enabled || !internalLoader.isVertical)
39 internalLoader.incrementValue(stepSize);
41 internalLoader.incrementValue(-stepSize);
45 if (!enabled || !internalLoader.isVertical)
49 internalLoader.incrementValue(-stepSize);
51 internalLoader.incrementValue(stepSize);
55 if (!enabled || internalLoader.isVertical)
59 internalLoader.incrementValue(stepSize);
61 internalLoader.incrementValue(-stepSize);
64 Keys.onRightPressed: {
65 if (!enabled || internalLoader.isVertical)
69 internalLoader.incrementValue(-stepSize);
71 internalLoader.incrementValue(stepSize);
74 property Item handle: handle
76 property Item contents: contents
81 leftMargin: (!internalLoader.isVertical && leftButton.visible) ? leftButton.width : 0
82 rightMargin: (!internalLoader.isVertical && rightButton.visible) ? rightButton.width : 0
83 topMargin: (internalLoader.isVertical && leftButton.visible) ? leftButton.height : 0
84 bottomMargin: (internalLoader.isVertical && rightButton.visible) ? rightButton.height : 0
87 PlasmaCore.FrameSvgItem {
89 imagePath:
"widgets/scrollbar"
91 if (mouseArea.pressed) {
92 return "sunken-slider"
95 if (scrollbar.activeFocus || mouseArea.containsMouse) {
96 return "mouseover-slider"
102 property int length: internalLoader.isVertical? flickableItem.visibleArea.heightRatio * parent.height : flickableItem.visibleArea.widthRatio * parent.width
104 width: internalLoader.isVertical ? parent.width : length
105 height: internalLoader.isVertical ? length : parent.height
111 imagePath:
"widgets/scrollbar"
112 property bool arrowPresent: scrollbarSvg.hasElement(
"arrow-up")
114 onRepaintNeeded: arrowPresent = scrollbarSvg.hasElement(
"arrow-up")
119 visible: stepSize > 0 && scrollbarSvg.arrowPresent
122 left: internalLoader.isVertical ? undefined : parent.left
123 verticalCenter: internalLoader.isVertical ? undefined : parent.verticalCenter
124 top: internalLoader.isVertical ? parent.top : undefined
125 horizontalCenter: internalLoader.isVertical ? parent.horizontalCenter : undefined
131 if (leftMouseArea.pressed) {
132 return internalLoader.isVertical ?
"sunken-arrow-up" :
"sunken-arrow-left"
135 if (scrollbar.activeFocus || leftMouseArea.containsMouse) {
136 return internalLoader.isVertical ?
"mouseover-arrow-up" :
"mouseover-arrow-left"
138 return internalLoader.isVertical ?
"arrow-up" :
"arrow-left"
146 enabled: scrollbar.enabled
151 interval: scrollbar.scrollButtonInterval;
152 running: parent.pressed
154 triggeredOnStart:
true
156 background.forceActiveFocus()
158 internalLoader.incrementValue(stepSize);
160 internalLoader.incrementValue(-stepSize);
169 visible: leftButton.visible
172 right: internalLoader.isVertical ? undefined : parent.right
173 verticalCenter: internalLoader.isVertical ? undefined : parent.verticalCenter
174 bottom: internalLoader.isVertical ? parent.bottom : undefined
175 horizontalCenter: internalLoader.isVertical ? parent.horizontalCenter : undefined
181 if (rightMouseArea.pressed) {
182 return internalLoader.isVertical ?
"sunken-arrow-down" :
"sunken-arrow-right"
185 if (scrollbar.activeFocus || rightMouseArea.containsMouse) {
186 return internalLoader.isVertical ?
"mouseover-arrow-down" :
"mouseover-arrow-right"
188 return internalLoader.isVertical ?
"arrow-down" :
"arrow-right"
196 enabled: scrollbar.enabled
201 interval: scrollbar.scrollButtonInterval;
202 running: parent.pressed;
204 triggeredOnStart:
true
206 background.forceActiveFocus();
208 internalLoader.incrementValue(-stepSize);
210 internalLoader.incrementValue(stepSize);
216 property MouseArea mouseArea: mouseArea
220 anchors.fill: contents
221 enabled: scrollbar.enabled
225 axis: internalLoader.isVertical ? Drag.YAxis : Drag.XAxis
226 minimumX: range.positionAtMinimum
227 maximumX: range.positionAtMaximum
228 minimumY: range.positionAtMinimum
229 maximumY: range.positionAtMaximum
233 if (internalLoader.isVertical) {
235 var newY = Math.max(mouse.y, drag.minimumY);
236 newY = Math.min(newY, drag.maximumY);
240 if (newY > handle.y + handle.height) {
241 handle.y = mouse.y - handle.height
242 }
else if (newY < handle.y) {
247 var newX = Math.max(mouse.x, drag.minimumX);
248 newX = Math.min(newX, drag.maximumX);
252 if (newX > handle.x + handle.width) {
253 handle.x = mouse.x - handle.width
254 }
else if (newX < handle.x) {
259 background.forceActiveFocus();
262 Component.onCompleted: {
263 acceptedButtons |= Qt.MiddleButton