21 import QtQuick.Controls 1.3 as Controls
22 import org.kde.kirigami 1.0
23 import QtGraphicalEffects 1.0
49 default property Item contentItem
91 property Item background
96 openAnimation.from = -root.height;
97 openAnimation.to = openAnimation.topOpenPosition;
98 openAnimation.running =
true;
103 if (scrollView.flickableItem.contentY < 0) {
104 closeAnimation.to = -height;
106 closeAnimation.to = scrollView.flickableItem.contentHeight;
108 closeAnimation.running =
true;
113 color:
Theme.textColor
114 opacity: 0.6 * Math.min(
115 (Math.min(scrollView.flickableItem.contentY + scrollView.flickableItem.height, scrollView.flickableItem.height) / scrollView.flickableItem.height),
116 (2 + (scrollView.flickableItem.contentHeight - scrollView.flickableItem.contentY - scrollView.flickableItem.topMargin - scrollView.flickableItem.bottomMargin)/scrollView.flickableItem.height))
120 Component.onCompleted: {
121 scrollView.flickableItem.interactive =
true;
123 onBackgroundChanged: {
124 background.parent = flickableContents;
127 onContentItemChanged: {
128 if (contentItem.hasOwnProperty(
"contentY") &&
129 contentItem.hasOwnProperty(
"contentHeight")) {
130 contentItem.parent = scrollView;
131 scrollView.contentItem = contentItem;
133 contentItem.parent = contentItemParent;
134 scrollView.contentItem = flickableContents;
135 contentItem.anchors.left = contentItemParent.left;
136 contentItem.anchors.right = contentItemParent.right;
138 scrollView.flickableItem.flickableDirection = Flickable.VerticalFlick;
145 Qt.inputMethod.hide();
149 if (!contentItem.contentItem)
152 var width = Math.max(root.width/2, Math.min(root.width, root.contentItem.implicitWidth));
153 contentItem.contentItem.x = (root.width - width)/2
154 contentItem.contentItem.width = width;
159 if (typeof applicationWindow !==
"undefined") {
160 focusItem = applicationWindow().activeFocusItem;
163 focusItem = activeFocusItem;
166 if (!activeFocusItem) {
172 var isDescendent =
false;
173 var candidate = focusItem.parent;
175 if (candidate == root) {
179 candidate = candidate.parent;
186 if (focusItem.cursorPosition !== undefined) {
187 cursorY = focusItem.positionToRectangle(focusItem.cursorPosition).y;
191 var pos = focusItem.mapToItem(flickableContents, 0, cursorY -
Units.
gridUnit*3);
193 if (pos.y >= scrollView.flickableItem.contentY && pos.y <= scrollView.flickableItem.contentY + scrollView.flickableItem.height -
Units.
gridUnit * 8) {
196 scrollView.flickableItem.contentY = pos.y;
202 property int topOpenPosition: Math.min(-root.height*0.15, scrollView.flickableItem.contentHeight - root.height +
Units.
gridUnit * 5)
203 property int bottomOpenPosition: (scrollView.flickableItem.contentHeight - root.height) + (
Units.
gridUnit * 5)
204 target: scrollView.flickableItem
205 properties:
"contentY"
209 easing.type: Easing.OutQuad
211 if (!running && contentItem.contentItem) {
212 var width = Math.max(root.width/2, Math.min(root.width, root.contentItem.implicitWidth));
213 contentItem.contentItem.x = (root.width - width)/2
214 contentItem.contentItem.width = width;
219 SequentialAnimation {
221 property int to: -root.height
223 target: scrollView.flickableItem
224 properties:
"contentY"
225 to: closeAnimation.to
227 easing.type: Easing.InQuad
231 scrollView.flickableItem.contentY = -root.height;
232 root.visible = root.opened =
false;
240 drag.filterChildren:
true
244 var pos = mapToItem(flickableContents, mouse.x, mouse.y);
245 if (!flickableContents.contains(pos)) {
251 id: flickableContents
253 x: (root.width - width) / 2
254 y: scrollView.flickableItem && root.contentItem.hasOwnProperty(
"contentY") ? -scrollView.flickableItem.contentY : 0
255 width: root.contentItem.implicitWidth <= 0 ? root.width : Math.max(root.width/2, Math.min(root.width, root.contentItem.implicitWidth))
256 height: scrollView.flickableItem && root.contentItem.hasOwnProperty(
"contentY") ? scrollView.flickableItem.contentHeight : (root.contentItem.height + topPadding + bottomPadding +
Units.
iconSizes.medium +
Units.
gridUnit)
258 id: contentItemParent
261 leftMargin: leftPadding
262 topMargin: topPadding
263 rightMargin: rightPadding
264 bottomMargin: bottomPadding
269 when: scrollView.flickableItem != null
270 target: scrollView.flickableItem
271 property:
"topMargin"
272 value: scrollView.height
275 when: scrollView.flickableItem != null
276 target: scrollView.flickableItem
277 property:
"bottomMargin"
278 value: scrollView.height
282 target: scrollView.flickableItem
283 function movementEnded() {
285 if ((root.height + scrollView.flickableItem.contentY) < root.height/2) {
286 closeAnimation.to = -root.height;
287 closeAnimation.running =
true;
288 }
else if ((root.height*0.6 + scrollView.flickableItem.contentY) > scrollView.flickableItem.contentHeight) {
289 closeAnimation.to = scrollView.flickableItem.contentHeight
290 closeAnimation.running =
true;
293 }
else if (scrollView.flickableItem.contentY < openAnimation.topOpenPosition) {
294 openAnimation.from = scrollView.flickableItem.contentY;
295 openAnimation.to = openAnimation.topOpenPosition;
296 openAnimation.running =
true;
298 }
else if (scrollView.flickableItem.contentY > openAnimation.bottomOpenPosition) {
299 openAnimation.from = scrollView.flickableItem.contentY;
300 openAnimation.to = openAnimation.bottomOpenPosition;
301 openAnimation.running =
true;
304 onMovementEnded: movementEnded();
305 onFlickEnded: movementEnded();
306 onContentHeightChanged: {
307 if (openAnimation.running) {
308 openAnimation.running =
false;
313 Controls.ScrollView {
316 horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
int longDuration
units.longDuration should be used for longer, screen-covering animations, for opening and closing of ...
int gridUnit
The fundamental unit of space that should be used for sizes, expressed in pixels. ...
QtObject iconSizes
units.iconSizes provides access to platform-dependent icon sizing