2
import UnityApplications 1.0
3
import Unity2d 1.0 /* required for drag’n’drop handling */
5
AutoScrollingListView {
8
/* The spacing is explicitly set to 0 and compensated for
9
by adding some padding to the tiles because of
10
http://bugreports.qt.nokia.com/browse/QTBUG-17622. */
13
property int tileSize: 54
15
/* Keep a reference to the currently visible contextual menu */
16
property variant visibleMenu
18
/* A hint for items to determine the value of their 'z' property */
19
property real itemZ: 0
21
delegate: LauncherItem {
25
tileSize: list.tileSize
27
desktopFile: item.desktop_file ? item.desktop_file : ""
28
icon: "image://icons/" + item.icon
32
launching: item.launching
33
pips: Math.min(item.windowCount, 3)
35
property bool noOverlays: item.counter == undefined
36
counter: (noOverlays) ? 0 : item.counter
37
counterVisible: (noOverlays) ? false : item.counterVisible
38
progress: (noOverlays) ? 0.0 : item.progress
39
progressBarVisible: (noOverlays) ? false : item.progressBarVisible
40
emblem: (noOverlays && item.emblem) ? "image://icons/" + item.emblem : ""
41
emblemVisible: (noOverlays) ? false : item.emblemVisible
43
shortcutVisible: item.toString().indexOf("LauncherApplication") == 0 &&
44
index <= 9 && launcherView.superKeyPressed
45
shortcutText: index + 1
47
/* Best way I could find to check if the item is an application or the
48
workspaces switcher. There may be something cleaner and better. */
49
backgroundFromIcon: item.toString().indexOf("LauncherApplication") == 0 ||
50
item.toString().indexOf("Workspaces") == 0
52
Binding { target: item.menu; property: "title"; value: item.name }
54
/* Drag’n’drop handling */
55
function dragEnterEvent(event) { item.onDragEnter(event) }
56
function dropEvent(event) { item.onDrop(event) }
59
/* Prevent the simultaneous display of multiple menus */
60
if (list.visibleMenu != item.menu && list.visibleMenu != undefined) {
61
list.visibleMenu.hide()
63
list.visibleMenu = item.menu
64
// The extra 4 pixels are needed to center exactly with the arrow
65
// indicating the active tile.
66
item.menu.show(width, panel.y + list.y +
67
y + height / 2 - list.contentY
68
- list.paddingTop + 4)
73
if (mouse.button == Qt.LeftButton) {
77
else if (mouse.button == Qt.RightButton) {
78
item.menu.folded = false
83
/* Display the tooltip when hovering the item only when the list
85
onEntered: if (!list.moving && !list.autoScrolling) showMenu()
87
/* When unfolded, leave enough time for the user to reach the
88
menu. Necessary because there is some void between the item
89
and the menu. Also it fixes the case when the user
91
if (!item.menu.folded)
92
item.menu.hideWithDelay(400)
99
onMovementStarted: item.menu.hide()
100
onAutoScrollingChanged: if (list.autoScrolling) item.menu.hide()
105
/* Hide the tooltip/menu when dragging an application. */
106
onCurrentIdChanged: if (dnd.currentId != "") item.menu.hide()
109
function setIconGeometry() {
111
item.setIconGeometry(x + panel.x, y + panel.y, width, height)
115
ListView.onAdd: SequentialAnimation {
116
PropertyAction { target: launcherItem; property: "scale"; value: 0 }
117
NumberAnimation { target: launcherItem; property: "height";
118
from: 0; to: launcherItem.tileSize; duration: 250; easing.type: Easing.InOutQuad }
119
NumberAnimation { target: launcherItem; property: "scale"; to: 1; duration: 250; easing.type: Easing.InOutQuad }
122
ListView.onRemove: SequentialAnimation {
123
PropertyAction { target: launcherItem; property: "ListView.delayRemove"; value: true }
124
NumberAnimation { target: launcherItem; property: "scale"; to: 0; duration: 250; easing.type: Easing.InOutQuad }
125
NumberAnimation { target: launcherItem; property: "height"; to: 0; duration: 250; easing.type: Easing.InOutQuad }
126
PropertyAction { target: launcherItem; property: "ListView.delayRemove"; value: false }
129
onRunningChanged: setIconGeometry()
130
/* Note: this doesn’t work as expected for the first favorite
131
application in the list if it is already running when the
132
launcher is started, because its y property doesn’t change.
133
This isn’t too bad though, as the launcher is supposed to be
134
started before any other regular application. */
135
onYChanged: setIconGeometry()
139
onWindowAdded: item.setIconGeometry(x + panel.x, y + panel.y, width, height, xid)
140
/* Not all items are applications. */
141
ignoreUnknownSignals: true
146
onKeyboardShortcutPressed: {
147
/* Only applications can be launched by keyboard shortcuts */
148
if (item.toString().indexOf("LauncherApplication") == 0 && index == itemIndex) {