on 239fdcc help sign in
unity8/qml/Launcher/LauncherPanel.qml
824 lines 38 kB history raw
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17import QtQuick 2.4
18import Ubuntu.Components 1.3
19import Unity.Launcher 0.1
20import Ubuntu.Components.Popups 1.3
21import "../Components/ListItems"
22import "../Components/"
24Rectangle {
25 id: root
26 color: "#F2111111"
28 rotation: inverted ? 180 : 0
30 property var model
31 property bool inverted: false
32 property bool dragging: false
33 property bool moving: launcherListView.moving || launcherListView.flicking
34 property bool preventHiding: moving || dndArea.draggedIndex >= 0 || quickList.state === "open" || dndArea.pressed
35 || mouseEventEater.containsMouse || dashItem.hovered
36 property int highlightIndex: -2
37 property bool shortcutHintsShown: false
39 signal applicationSelected(string appId)
40 signal showDashHome()
41 signal kbdNavigationCancelled()
43 onXChanged: {
44 if (quickList.state == "open") {
45 quickList.state = ""
46 }
47 }
49 function highlightNext() {
50 highlightIndex++;
51 if (highlightIndex >= launcherListView.count) {
52 highlightIndex = -1;
53 }
54 launcherListView.moveToIndex(Math.max(highlightIndex, 0));
55 }
56 function highlightPrevious() {
57 highlightIndex--;
58 if (highlightIndex <= -2) {
59 highlightIndex = launcherListView.count - 1;
60 }
61 launcherListView.moveToIndex(Math.max(highlightIndex, 0));
62 }
63 function openQuicklist(index) {
64 quickList.open(index);
65 quickList.selectedIndex = 0;
66 quickList.focus = true;
67 }
69 MouseArea {
70 id: mouseEventEater
71 anchors.fill: parent
72 hoverEnabled: true
73 }
75 Column {
76 id: mainColumn
77 anchors {
78 fill: parent
79 }
81 Rectangle {
82 objectName: "buttonShowDashHome"
83 width: parent.width
84 height: width * .9
85 color: UbuntuColors.orange
86 readonly property bool highlighted: root.highlightIndex == -1;
88 Image {
89 objectName: "dashItem"
90 width: parent.width * .6
91 height: width
92 anchors.centerIn: parent
93 source: "graphics/home.png"
94 rotation: root.rotation
95 }
96 AbstractButton {
97 id: dashItem
98 anchors.fill: parent
99 activeFocusOnPress: false
100 onClicked: root.showDashHome()
101 }
102 Rectangle {
103 objectName: "bfbFocusHighlight"
104 anchors.fill: parent
105 border.color: "white"
106 border.width: units.dp(1)
107 color: "transparent"
108 visible: parent.highlighted
109 }
110 }
112 Item {
113 anchors.left: parent.left
114 anchors.right: parent.right
115 height: parent.height - dashItem.height - parent.spacing*2
117 Item {
118 id: launcherListViewItem
119 anchors.fill: parent
120 clip: true
122 ListView {
123 id: launcherListView
124 objectName: "launcherListView"
125 anchors {
126 fill: parent
127 topMargin: -extensionSize + width * .15
128 bottomMargin: -extensionSize + width * .15
129 }
130 topMargin: extensionSize
131 bottomMargin: extensionSize
132 height: parent.height - dashItem.height - parent.spacing*2
133 model: root.model
134 cacheBuffer: itemHeight * 3
135 snapMode: interactive ? ListView.SnapToItem : ListView.NoSnap
136 highlightRangeMode: ListView.ApplyRange
137 preferredHighlightBegin: (height - itemHeight) / 2
138 preferredHighlightEnd: (height + itemHeight) / 2
140 // for the single peeking icon, when alert-state is set on delegate
141 property int peekingIndex: -1
143 // The size of the area the ListView is extended to make sure items are not
144 // destroyed when dragging them outside the list. This needs to be at least
145 // itemHeight to prevent folded items from disappearing and DragArea limits
146 // need to be smaller than this size to avoid breakage.
147 property int extensionSize: 0
149 // Setting extensionSize after the list has been populated because it has
150 // the potential to mess up with the intial positioning in combination
151 // with snapping to the center of the list. This catches all the cases
152 // where the item would be outside the list for more than itemHeight / 2.
153 // For the rest, give it a flick to scroll to the beginning. Note that
154 // the flicking alone isn't enough because in some cases it's not strong
155 // enough to overcome the snapping.
156 // https://bugreports.qt-project.org/browse/QTBUG-32251
157 Component.onCompleted: {
158 extensionSize = itemHeight * 3
159 flick(0, clickFlickSpeed)
160 }
162 // The height of the area where icons start getting folded
163 property int foldingStartHeight: itemHeight
164 // The height of the area where the items reach the final folding angle
165 property int foldingStopHeight: foldingStartHeight - itemHeight - spacing
166 property int itemWidth: width * .75
167 property int itemHeight: itemWidth * 15 / 16 + units.gu(1)
168 property int clickFlickSpeed: units.gu(60)
169 property int draggedIndex: dndArea.draggedIndex
170 property real realContentY: contentY - originY + topMargin
171 property int realItemHeight: itemHeight + spacing
173 // In case the start dragging transition is running, we need to delay the
174 // move because the displaced transition would clash with it and cause items
175 // to be moved to wrong places
176 property bool draggingTransitionRunning: false
177 property int scheduledMoveTo: -1
179 UbuntuNumberAnimation {
180 id: snapToBottomAnimation
181 target: launcherListView
182 property: "contentY"
183 to: launcherListView.originY + launcherListView.topMargin
184 }
186 UbuntuNumberAnimation {
187 id: snapToTopAnimation
188 target: launcherListView
189 property: "contentY"
190 to: launcherListView.contentHeight - launcherListView.height + launcherListView.originY - launcherListView.topMargin
191 }
193 UbuntuNumberAnimation {
194 id: moveAnimation
195 objectName: "moveAnimation"
196 target: launcherListView
197 property: "contentY"
198 function moveTo(contentY) {
199 from = launcherListView.contentY;
200 to = contentY;
201 restart();
202 }
203 }
204 function moveToIndex(index) {
205 var totalItemHeight = launcherListView.itemHeight + launcherListView.spacing
206 var itemPosition = index * totalItemHeight;
207 var height = launcherListView.height - launcherListView.topMargin - launcherListView.bottomMargin
208 var distanceToEnd = index == 0 || index == launcherListView.count - 1 ? 0 : totalItemHeight
209 if (itemPosition + totalItemHeight + distanceToEnd > launcherListView.contentY + launcherListView.originY + launcherListView.topMargin + height) {
210 moveAnimation.moveTo(itemPosition + launcherListView.itemHeight - launcherListView.topMargin - height + distanceToEnd - launcherListView.originY);
211 } else if (itemPosition - distanceToEnd < launcherListView.contentY - launcherListView.originY + launcherListView.topMargin) {
212 moveAnimation.moveTo(itemPosition - distanceToEnd - launcherListView.topMargin + launcherListView.originY);
213 }
214 }
216 displaced: Transition {
217 NumberAnimation { properties: "x,y"; duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
218 }
220 delegate: FoldingLauncherDelegate {
221 id: launcherDelegate
222 objectName: "launcherDelegate" + index
223 // We need the appId in the delegate in order to find
224 // the right app when running autopilot tests for
225 // multiple apps.
226 readonly property string appId: model.appId
227 itemIndex: index
228 itemHeight: launcherListView.itemHeight
229 itemWidth: launcherListView.itemWidth
230 width: parent.width
231 height: itemHeight
232 iconName: model.icon
233 count: model.count
234 countVisible: model.countVisible
235 progress: model.progress
236 itemRunning: model.running
237 itemFocused: model.focused
238 inverted: root.inverted
239 alerting: model.alerting
240 highlighted: root.highlightIndex == index
241 shortcutHintShown: root.shortcutHintsShown && index <= 9
242 z: -Math.abs(offset)
243 maxAngle: 55
244 property bool dragging: false
246 SequentialAnimation {
247 id: peekingAnimation
249 // revealing
250 PropertyAction { target: root; property: "visible"; value: (launcher.visibleWidth === 0) ? 1 : 0 }
251 PropertyAction { target: launcherListViewItem; property: "clip"; value: 0 }
253 UbuntuNumberAnimation {
254 target: launcherDelegate
255 alwaysRunToEnd: true
256 loops: 1
257 properties: "x"
258 to: (units.gu(.5) + launcherListView.width * .5) * (root.inverted ? -1 : 1)
259 duration: UbuntuAnimation.BriskDuration
260 }
262 // hiding
263 UbuntuNumberAnimation {
264 target: launcherDelegate
265 alwaysRunToEnd: true
266 loops: 1
267 properties: "x"
268 to: 0
269 duration: UbuntuAnimation.BriskDuration
270 }
272 PropertyAction { target: launcherListViewItem; property: "clip"; value: 1 }
273 PropertyAction { target: root; property: "visible"; value: (launcher.visibleWidth === 0) ? 0 : 1 }
274 }
276 onAlertingChanged: {
277 if(alerting) {
278 if (!dragging && (launcherListView.peekingIndex === -1 || launcher.visibleWidth > 0)) {
279 launcherListView.moveToIndex(index)
280 if (!dragging && launcher.state !== "visible") {
281 peekingAnimation.start()
282 }
283 }
285 if (launcherListView.peekingIndex === -1) {
286 launcherListView.peekingIndex = index
287 }
288 } else {
289 if (launcherListView.peekingIndex === index) {
290 launcherListView.peekingIndex = -1
291 }
292 }
293 }
295 ThinDivider {
296 id: dropIndicator
297 objectName: "dropIndicator"
298 anchors.centerIn: parent
299 width: parent.width + mainColumn.anchors.leftMargin + mainColumn.anchors.rightMargin
300 opacity: 0
301 source: "graphics/divider-line.png"
302 }
304 states: [
305 State {
306 name: "selected"
307 when: dndArea.selectedItem === launcherDelegate && fakeDragItem.visible && !dragging
308 PropertyChanges {
309 target: launcherDelegate
310 itemOpacity: 0
311 }
312 },
313 State {
314 name: "dragging"
315 when: dragging
316 PropertyChanges {
317 target: launcherDelegate
318 height: units.gu(1)
319 itemOpacity: 0
320 }
321 PropertyChanges {
322 target: dropIndicator
323 opacity: 1
324 }
325 },
326 State {
327 name: "expanded"
328 when: dndArea.draggedIndex >= 0 && (dndArea.preDragging || dndArea.dragging || dndArea.postDragging) && dndArea.draggedIndex != index
329 PropertyChanges {
330 target: launcherDelegate
331 angle: 0
332 offset: 0
333 itemOpacity: 0.6
334 }
335 }
336 ]
338 transitions: [
339 Transition {
340 from: ""
341 to: "selected"
342 NumberAnimation { properties: "itemOpacity"; duration: UbuntuAnimation.FastDuration }
343 },
344 Transition {
345 from: "*"
346 to: "expanded"
347 NumberAnimation { properties: "itemOpacity"; duration: UbuntuAnimation.FastDuration }
348 UbuntuNumberAnimation { properties: "angle,offset" }
349 },
350 Transition {
351 from: "expanded"
352 to: ""
353 NumberAnimation { properties: "itemOpacity"; duration: UbuntuAnimation.BriskDuration }
354 UbuntuNumberAnimation { properties: "angle,offset" }
355 },
356 Transition {
357 id: draggingTransition
358 from: "selected"
359 to: "dragging"
360 SequentialAnimation {
361 PropertyAction { target: launcherListView; property: "draggingTransitionRunning"; value: true }
362 ParallelAnimation {
363 UbuntuNumberAnimation { properties: "height" }
364 NumberAnimation { target: dropIndicator; properties: "opacity"; duration: UbuntuAnimation.FastDuration }
365 }
366 ScriptAction {
367 script: {
368 if (launcherListView.scheduledMoveTo > -1) {
369 launcherListView.model.move(dndArea.draggedIndex, launcherListView.scheduledMoveTo)
370 dndArea.draggedIndex = launcherListView.scheduledMoveTo
371 launcherListView.scheduledMoveTo = -1
372 }
373 }
374 }
375 PropertyAction { target: launcherListView; property: "draggingTransitionRunning"; value: false }
376 }
377 },
378 Transition {
379 from: "dragging"
380 to: "*"
381 NumberAnimation { target: dropIndicator; properties: "opacity"; duration: UbuntuAnimation.SnapDuration }
382 NumberAnimation { properties: "itemOpacity"; duration: UbuntuAnimation.BriskDuration }
383 SequentialAnimation {
384 ScriptAction { script: if (index == launcherListView.count-1) launcherListView.flick(0, -launcherListView.clickFlickSpeed); }
385 UbuntuNumberAnimation { properties: "height" }
386 ScriptAction { script: if (index == launcherListView.count-1) launcherListView.flick(0, -launcherListView.clickFlickSpeed); }
387 PropertyAction { target: dndArea; property: "postDragging"; value: false }
388 PropertyAction { target: dndArea; property: "draggedIndex"; value: -1 }
389 }
390 }
391 ]
392 }
394 MouseArea {
395 id: dndArea
396 objectName: "dndArea"
397 acceptedButtons: Qt.LeftButton | Qt.RightButton
398 anchors {
399 fill: parent
400 topMargin: launcherListView.topMargin
401 bottomMargin: launcherListView.bottomMargin
402 }
403 drag.minimumY: -launcherListView.topMargin
404 drag.maximumY: height + launcherListView.bottomMargin
406 property int draggedIndex: -1
407 property var selectedItem
408 property bool preDragging: false
409 property bool dragging: !!selectedItem && selectedItem.dragging
410 property bool postDragging: false
411 property int startX
412 property int startY
414 onPressed: {
415 processPress(mouse);
416 }
418 function processPress(mouse) {
419 selectedItem = launcherListView.itemAt(mouse.x, mouse.y + launcherListView.realContentY)
420 }
422 onClicked: {
423 var index = Math.floor((mouseY + launcherListView.realContentY) / launcherListView.realItemHeight);
424 var clickedItem = launcherListView.itemAt(mouseX, mouseY + launcherListView.realContentY)
426 // Check if we actually clicked an item or only at the spacing in between
427 if (clickedItem === null) {
428 return;
429 }
431 if (mouse.button & Qt.RightButton) { // context menu
432 // Opening QuickList
433 quickList.open(index);
434 return;
435 }
437 Haptics.play();
439 // First/last item do the scrolling at more than 12 degrees
440 if (index == 0 || index == launcherListView.count - 1) {
441 if (clickedItem.angle > 12 || clickedItem.angle < -12) {
442 launcherListView.moveToIndex(index);
443 } else {
444 root.applicationSelected(LauncherModel.get(index).appId);
445 }
446 return;
447 }
449 // the rest launches apps up to an angle of 30 degrees
450 if (clickedItem.angle > 30 || clickedItem.angle < -30) {
451 launcherListView.moveToIndex(index);
452 } else {
453 root.applicationSelected(LauncherModel.get(index).appId);
454 }
455 }
457 onCanceled: {
458 endDrag(drag);
459 }
461 onReleased: {
462 endDrag(drag);
463 }
465 function endDrag(dragItem) {
466 var droppedIndex = draggedIndex;
467 if (dragging) {
468 postDragging = true;
469 } else {
470 draggedIndex = -1;
471 }
473 if (!selectedItem) {
474 return;
475 }
477 selectedItem.dragging = false;
478 selectedItem = undefined;
479 preDragging = false;
481 dragItem.target = undefined
483 progressiveScrollingTimer.stop();
484 launcherListView.interactive = true;
485 if (droppedIndex >= launcherListView.count - 2 && postDragging) {
486 snapToBottomAnimation.start();
487 } else if (droppedIndex < 2 && postDragging) {
488 snapToTopAnimation.start();
489 }
490 }
492 onPressAndHold: {
493 processPressAndHold(mouse, drag);
494 }
496 function processPressAndHold(mouse, dragItem) {
497 if (Math.abs(selectedItem.angle) > 30) {
498 return;
499 }
501 Haptics.play();
503 draggedIndex = Math.floor((mouse.y + launcherListView.realContentY) / launcherListView.realItemHeight);
505 quickList.open(draggedIndex)
507 launcherListView.interactive = false
509 var yOffset = draggedIndex > 0 ? (mouse.y + launcherListView.realContentY) % (draggedIndex * launcherListView.realItemHeight) : mouse.y + launcherListView.realContentY
511 fakeDragItem.iconName = launcherListView.model.get(draggedIndex).icon
512 fakeDragItem.x = units.gu(0.5)
513 fakeDragItem.y = mouse.y - yOffset + launcherListView.anchors.topMargin + launcherListView.topMargin
514 fakeDragItem.angle = selectedItem.angle * (root.inverted ? -1 : 1)
515 fakeDragItem.offset = selectedItem.offset * (root.inverted ? -1 : 1)
516 fakeDragItem.count = LauncherModel.get(draggedIndex).count
517 fakeDragItem.progress = LauncherModel.get(draggedIndex).progress
518 fakeDragItem.flatten()
519 dragItem.target = fakeDragItem
521 startX = mouse.x
522 startY = mouse.y
523 }
525 onPositionChanged: {
526 processPositionChanged(mouse)
527 }
529 function processPositionChanged(mouse) {
530 if (draggedIndex >= 0) {
531 if (!selectedItem.dragging) {
532 var distance = Math.max(Math.abs(mouse.x - startX), Math.abs(mouse.y - startY))
533 if (!preDragging && distance > units.gu(1.5)) {
534 preDragging = true;
535 quickList.state = "";
536 }
537 if (distance > launcherListView.itemHeight) {
538 selectedItem.dragging = true
539 preDragging = false;
540 }
541 }
542 if (!selectedItem.dragging) {
543 return
544 }
546 var itemCenterY = fakeDragItem.y + fakeDragItem.height / 2
548 // Move it down by the the missing size to compensate index calculation with only expanded items
549 itemCenterY += (launcherListView.itemHeight - selectedItem.height) / 2
551 if (mouseY > launcherListView.height - launcherListView.topMargin - launcherListView.bottomMargin - launcherListView.realItemHeight) {
552 progressiveScrollingTimer.downwards = false
553 progressiveScrollingTimer.start()
554 } else if (mouseY < launcherListView.realItemHeight) {
555 progressiveScrollingTimer.downwards = true
556 progressiveScrollingTimer.start()
557 } else {
558 progressiveScrollingTimer.stop()
559 }
561 var newIndex = (itemCenterY + launcherListView.realContentY) / launcherListView.realItemHeight
563 if (newIndex > draggedIndex + 1) {
564 newIndex = draggedIndex + 1
565 } else if (newIndex < draggedIndex) {
566 newIndex = draggedIndex -1
567 } else {
568 return
569 }
571 if (newIndex >= 0 && newIndex < launcherListView.count) {
572 if (launcherListView.draggingTransitionRunning) {
573 launcherListView.scheduledMoveTo = newIndex
574 } else {
575 launcherListView.model.move(draggedIndex, newIndex)
576 draggedIndex = newIndex
577 }
578 }
579 }
580 }
581 }
582 Timer {
583 id: progressiveScrollingTimer
584 interval: 2
585 repeat: true
586 running: false
587 property bool downwards: true
588 onTriggered: {
589 if (downwards) {
590 var minY = -launcherListView.topMargin
591 if (launcherListView.contentY > minY) {
592 launcherListView.contentY = Math.max(launcherListView.contentY - units.dp(2), minY)
593 }
594 } else {
595 var maxY = launcherListView.contentHeight - launcherListView.height + launcherListView.topMargin + launcherListView.originY
596 if (launcherListView.contentY < maxY) {
597 launcherListView.contentY = Math.min(launcherListView.contentY + units.dp(2), maxY)
598 }
599 }
600 }
601 }
602 }
603 }
605 LauncherDelegate {
606 id: fakeDragItem
607 objectName: "fakeDragItem"
608 visible: dndArea.draggedIndex >= 0 && !dndArea.postDragging
609 itemWidth: launcherListView.itemWidth
610 itemHeight: launcherListView.itemHeight
611 height: itemHeight
612 width: itemWidth
613 rotation: root.rotation
614 itemOpacity: 0.9
615 onVisibleChanged: if (!visible) iconName = "";
617 function flatten() {
618 fakeDragItemAnimation.start();
619 }
621 UbuntuNumberAnimation {
622 id: fakeDragItemAnimation
623 target: fakeDragItem;
624 properties: "angle,offset";
625 to: 0
626 }
627 }
628 }
629 }
631 UbuntuShapeForItem {
632 id: quickListShape
633 objectName: "quickListShape"
634 anchors.fill: quickList
635 opacity: quickList.state === "open" ? 0.95 : 0
636 visible: opacity > 0
637 rotation: root.rotation
638 aspect: UbuntuShape.Flat
640 Behavior on opacity {
641 UbuntuNumberAnimation {}
642 }
644 image: quickList
646 Image {
647 anchors {
648 right: parent.left
649 rightMargin: -units.dp(4)
650 verticalCenter: parent.verticalCenter
651 verticalCenterOffset: -quickList.offset * (root.inverted ? -1 : 1)
652 }
653 height: units.gu(1)
654 width: units.gu(2)
655 source: "graphics/quicklist_tooltip.png"
656 rotation: 90
657 }
658 }
660 InverseMouseArea {
661 anchors.fill: quickListShape
662 enabled: quickList.state == "open" || pressed
664 onClicked: {
665 quickList.state = "";
666 quickList.focus = false;
667 root.kbdNavigationCancelled();
668 }
670 // Forward for dragging to work when quickList is open
672 onPressed: {
673 var m = mapToItem(dndArea, mouseX, mouseY)
674 dndArea.processPress(m)
675 }
677 onPressAndHold: {
678 var m = mapToItem(dndArea, mouseX, mouseY)
679 dndArea.processPressAndHold(m, drag)
680 }
682 onPositionChanged: {
683 var m = mapToItem(dndArea, mouseX, mouseY)
684 dndArea.processPositionChanged(m)
685 }
687 onCanceled: {
688 dndArea.endDrag(drag);
689 }
691 onReleased: {
692 dndArea.endDrag(drag);
693 }
694 }
696 Rectangle {
697 id: quickList
698 objectName: "quickList"
699 color: theme.palette.normal.background
700 // Because we're setting left/right anchors depending on orientation, it will break the
701 // width setting after rotating twice. This makes sure we also re-apply width on rotation
702 width: root.inverted ? units.gu(30) : units.gu(30)
703 height: quickListColumn.height
704 visible: quickListShape.visible
705 anchors {
706 left: root.inverted ? undefined : parent.right
707 right: root.inverted ? parent.left : undefined
708 margins: units.gu(1)
709 }
710 y: itemCenter - (height / 2) + offset
711 rotation: root.rotation
713 property var model
714 property string appId
715 property var item
716 property int selectedIndex: -1
718 Keys.onPressed: {
719 switch (event.key) {
720 case Qt.Key_Down:
721 selectedIndex++;
722 if (selectedIndex >= popoverRepeater.count) {
723 selectedIndex = 0;
724 }
725 event.accepted = true;
726 break;
727 case Qt.Key_Up:
728 selectedIndex--;
729 if (selectedIndex < 0) {
730 selectedIndex = popoverRepeater.count - 1;
731 }
732 event.accepted = true;
733 break;
734 case Qt.Key_Left:
735 case Qt.Key_Escape:
736 quickList.selectedIndex = -1;
737 quickList.focus = false;
738 quickList.state = ""
739 event.accepted = true;
740 break;
741 case Qt.Key_Enter:
742 case Qt.Key_Return:
743 case Qt.Key_Space:
744 if (quickList.selectedIndex >= 0) {
745 LauncherModel.quickListActionInvoked(quickList.appId, quickList.selectedIndex)
746 }
747 quickList.selectedIndex = -1;
748 quickList.focus = false;
749 quickList.state = ""
750 root.kbdNavigationCancelled();
751 event.accepted = true;
752 break;
753 }
754 }
756 // internal
757 property int itemCenter: item ? root.mapFromItem(quickList.item).y + (item.height / 2) + quickList.item.offset : units.gu(1)
758 property int offset: itemCenter + (height/2) + units.gu(1) > parent.height ? -itemCenter - (height/2) - units.gu(1) + parent.height :
759 itemCenter - (height/2) < units.gu(1) ? (height/2) - itemCenter + units.gu(1) : 0
761 function open(index) {
762 var itemPosition = index * launcherListView.itemHeight;
763 var height = launcherListView.height - launcherListView.topMargin - launcherListView.bottomMargin
764 item = launcherListView.itemAt(launcherListView.width / 2, itemPosition + launcherListView.itemHeight / 2);
765 quickList.model = launcherListView.model.get(index).quickList;
766 quickList.appId = launcherListView.model.get(index).appId;
767 quickList.state = "open";
768 }
770 Item {
771 width: parent.width
772 height: quickListColumn.height
774 Column {
775 id: quickListColumn
776 width: parent.width
777 height: childrenRect.height
779 Repeater {
780 id: popoverRepeater
781 model: quickList.model
783 ListItem {
784 objectName: "quickListEntry" + index
785 selected: index === quickList.selectedIndex
786 height: label.implicitHeight + label.anchors.topMargin + label.anchors.bottomMargin
787 color: model.clickable ? (selected ? theme.palette.highlighted.background : "transparent") : theme.palette.disabled.background
788 highlightColor: !model.clickable ? quickList.color : undefined // make disabled items visually unclickable
789 divider.colorFrom: UbuntuColors.inkstone
790 divider.colorTo: UbuntuColors.inkstone
792 Label {
793 id: label
794 anchors.fill: parent
795 anchors.leftMargin: units.gu(3) // 2 GU for checkmark, 3 GU total
796 anchors.rightMargin: units.gu(2)
797 anchors.topMargin: units.gu(2)
798 anchors.bottomMargin: units.gu(2)
799 verticalAlignment: Label.AlignVCenter
800 text: model.label
801 fontSize: index == 0 ? "medium" : "small"
802 font.weight: index == 0 ? Font.Medium : Font.Light
803 color: model.clickable ? theme.palette.normal.backgroundText : theme.palette.disabled.backgroundText
804 }
806 onClicked: {
807 if (!model.clickable) {
808 return;
809 }
810 Haptics.play();
811 quickList.state = "";
812 // Unsetting model to prevent showing changing entries during fading out
813 // that may happen because of triggering an action.
814 LauncherModel.quickListActionInvoked(quickList.appId, index);
815 quickList.focus = false;
816 root.kbdNavigationCancelled();
817 quickList.model = undefined;
818 }
819 }
820 }
821 }
822 }
823 }