2 * Copyright (C) 2013 Canonical, Ltd.
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.
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.
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/>.
18import Ubuntu.Components 0.1
20import Unity.Launcher 0.1
21import "../Components/ListItems"
26 rotation: inverted ? 180 : 0
29 property bool inverted: true
30 property bool dragging: false
31 property bool moving: launcherListView.moving || launcherListView.flicking
32 property int dragPosition: 0
33 property int highlightIndex: -1
35 signal applicationSelected(string desktopFile)
36 signal dashItemSelected(int index)
38 onDragPositionChanged: {
39 var effectiveDragPosition = root.inverted ? launcherListView.height - dragPosition : dragPosition - mainColumn.anchors.margins
41 var hiddenContentHeight = launcherListView.contentHeight - launcherListView.height
42 // Shortening scrollable height because the first/last item needs to be fully expanded before reaching the top/bottom
43 var scrollableHeight = launcherListView.height - (launcherListView.itemSize + launcherColumn.spacing) *2
44 // As we shortened the scrollableHeight, lets move everything down by the itemSize
45 var shortenedEffectiveDragPosition = effectiveDragPosition - launcherListView.itemSize - launcherColumn.spacing
46 var newContentY = shortenedEffectiveDragPosition * hiddenContentHeight / scrollableHeight
48 // limit top/bottom to prevent overshooting
49 launcherListView.contentY = Math.min(hiddenContentHeight, Math.max(0, newContentY));
51 // Now calculate the current index:
52 // > the current mouse position + the hidden/scolled content on top is the mouse position in the averall view
53 // > adjust that removing all the margins
54 // > divide by itemSize to get index
55 highlightIndex = (effectiveDragPosition + launcherListView.contentY - mainColumn.anchors.margins*3 - launcherColumn.spacing/2) / (launcherListView.itemSize + launcherColumn.spacing)
60 source: "graphics/launcher_bg.sci"
68 topMargin: units.gu(0.5)
69 bottomMargin: units.gu(1)
70 leftMargin: units.gu(0.5)
71 rightMargin: units.gu(0.5)
73 spacing: units.gu(0.5)
79 onClicked: root.dashItemSelected(0)
82 objectName: "dashItem"
85 anchors.centerIn: parent
86 source: "graphics/home.png"
93 margins: -mainColumn.anchors.leftMargin
95 rotation: root.rotation
99 anchors.left: parent.left
100 anchors.right: parent.right
101 height: parent.height - dashItem.height - parent.spacing*2
105 anchors.topMargin: -itemSize
106 anchors.bottomMargin: -itemSize
108 bottomMargin: itemSize
109 height: parent.height - dashItem.height - parent.spacing*2
111 cacheBuffer: itemSize * 3
112 snapMode: ListView.SnapToItem
113 highlightRangeMode: ListView.ApplyRange
114 preferredHighlightBegin: (height - itemSize) / 2
115 preferredHighlightEnd: (height + itemSize) / 2
117 // The height of the area where icons start getting folded
118 property int foldingAreaHeight: itemSize * 0.75
119 property int itemSize: width
121 Component.onCompleted: {
122 // This is needed because snapping would partially fold
123 // the first item on initialisation. This can only be
124 // overridden by mouse interactions - which is what flick()
125 // simulates. Setting contentY to 0 would not work because
127 flick(0, units.gu(20))
130 delegate: LauncherDelegate {
132 objectName: "launcherDelegate" + index
133 width: launcherListView.itemSize
134 height: launcherListView.itemSize
136 inverted: root.inverted
137 highlighted: root.dragging && index === root.highlightIndex
143 root.applicationSelected("/usr/share/applications/" + LauncherModel.get(index).desktopFile);
153 topMargin: launcherListView.topMargin
155 height: launcherListView.itemSize
156 enabled: launcherListView.contentY > -launcherListView.topMargin
157 onClicked: launcherListView.flick(0, units.gu(40))
161 id: bottomFoldingArea
165 bottom: parent.bottom
166 bottomMargin: launcherListView.bottomMargin
168 height: launcherListView.itemSize
169 enabled: launcherListView.contentHeight - launcherListView.height - launcherListView.contentY > -launcherListView.bottomMargin
170 onClicked: launcherListView.flick(0, -units.gu(40))
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list