2 * Copyright (C) 2013-2015 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/>.
19import Ubuntu.Components 1.3
20import Ubuntu.Gestures 0.1
21import Unity.Launcher 0.1
26 property bool autohideEnabled: false
27 property bool lockedVisible: false
28 property bool available: true // can be used to disable all interactions
29 property alias inverted: panel.inverted
31 property int panelWidth: units.gu(10)
32 property int dragAreaWidth: units.gu(1)
33 property int minimizeDistance: units.gu(26)
34 property real progress: dragArea.dragging && dragArea.touchPosition.x > panelWidth ?
35 (width * (dragArea.touchPosition.x-panelWidth) / (width - panelWidth)) : 0
37 property bool superPressed: false
38 property bool superTabPressed: false
40 readonly property bool dragging: dragArea.dragging
41 readonly property real dragDistance: dragArea.dragging ? dragArea.touchPosition.x : 0
42 readonly property real visibleWidth: panel.width + panel.x
43 readonly property alias shortcutHintsShown: panel.shortcutHintsShown
45 readonly property bool shown: panel.x > -panel.width
47 // emitted when an application is selected
48 signal launcherApplicationSelected(string appId)
50 // emitted when the apps dash should be shown because of a swipe gesture
53 // emitted when the dash icon in the launcher has been tapped
58 panel.dismissTimer.stop()
60 panel.dismissTimer.restart()
64 onSuperPressedChanged: {
66 superPressTimer.start();
67 superLongPressTimer.start();
69 superPressTimer.stop();
70 superLongPressTimer.stop();
71 launcher.switchToNextState("");
72 panel.shortcutHintsShown = false;
76 onSuperTabPressedChanged: {
77 if (superTabPressed) {
78 switchToNextState("visible")
79 panel.highlightIndex = -1;
81 superPressTimer.stop();
82 superLongPressTimer.stop();
84 if (panel.highlightIndex == -1) {
86 } else if (panel.highlightIndex >= 0){
87 launcherApplicationSelected(LauncherModel.get(panel.highlightIndex).appId);
89 panel.highlightIndex = -2;
90 switchToNextState("");
95 onLockedVisibleChanged: {
96 print("lockedVisible changed:", lockedVisible, "state:", state)
97 if (lockedVisible && state == "") {
98 panel.dismissTimer.stop();
99 fadeOutAnimation.stop();
100 switchToNextState("visible")
101 } else if (!lockedVisible && state == "visible") {
107 switchToNextState("")
111 if (!root.lockedVisible) {
112 fadeOutAnimation.start();
116 function switchToNextState(state) {
117 animateTimer.nextState = state
118 animateTimer.start();
122 if (available && !dragArea.dragging) {
123 teaseTimer.mode = "teasing"
129 if (available && root.state == "") {
130 teaseTimer.mode = "hinting"
135 function pushEdge(amount) {
136 if (root.state === "") {
137 edgeBarrier.push(amount);
141 function openForKeyboardNavigation() {
142 panel.highlightIndex = -1; // The BFB
144 switchToNextState("visible")
150 panel.highlightPrevious();
151 event.accepted = true;
155 panel.highlightNext()
157 panel.highlightPrevious();
159 event.accepted = true;
162 panel.highlightNext();
163 event.accepted = true;
167 panel.highlightPrevious();
169 panel.highlightNext();
171 event.accepted = true;
175 panel.openQuicklist(panel.highlightIndex)
176 event.accepted = true;
179 panel.highlightIndex = -2;
180 // Falling through intentionally
184 if (panel.highlightIndex == -1) {
186 } else if (panel.highlightIndex >= 0) {
187 launcherApplicationSelected(LauncherModel.get(panel.highlightIndex).appId);
190 panel.highlightIndex = -2
191 event.accepted = true;
200 switchToNextState("visible")
205 id: superLongPressTimer
208 switchToNextState("visible")
209 panel.shortcutHintsShown = true;
215 interval: mode == "teasing" ? 200 : 300
216 property string mode: "teasing"
219 // Because the animation on x is disabled while dragging
220 // switching state directly in the drag handlers would not animate
221 // the completion of the hide/reveal gesture. Lets update the state
222 // machine and switch to the final state in the next event loop run
225 objectName: "animateTimer"
227 property string nextState: ""
229 if (root.lockedVisible && nextState == "") {
230 // Due to binding updates when switching between modes
231 // it could happen that our request to show will be overwritten
232 // with a hide request. Rewrite it when we know hiding is not allowed.
233 nextState = "visible"
236 // switching to an intermediate state here to make sure all the
237 // values are restored, even if we were already in the target state
239 root.state = nextState
244 target: LauncherModel
250 onLanguageChanged: LauncherModel.refresh()
253 SequentialAnimation {
257 animateTimer.stop(); // Don't change the state behind our back
258 panel.layer.enabled = true
261 UbuntuNumberAnimation {
264 easing.type: Easing.InQuad
269 panel.layer.enabled = false
270 panel.animate = false;
272 panel.x = -panel.width
274 panel.animate = true;
282 enabled: root.state == "visible" && (!root.lockedVisible || panel.highlightIndex >= -1)
285 mouse.accepted = false;
286 panel.highlightIndex = -2;
293 enabled: root.available && (root.state == "visible" || root.state == "visibleTemporary") && !root.lockedVisible
295 anchors.rightMargin: -units.gu(2)
303 if (panel.x < -panel.width/3) {
304 root.switchToNextState("")
306 root.switchToNextState("visible")
315 enabled: root.available
316 onPassed: { root.switchToNextState("visibleTemporary"); }
317 material: Component {
323 anchors.centerIn: parent
325 GradientStop { position: 0.0; color: Qt.rgba(panel.color.r, panel.color.g, panel.color.b, .5)}
326 GradientStop { position: 1.0; color: Qt.rgba(panel.color.r,panel.color.g,panel.color.b,0)}
335 objectName: "launcherPanel"
336 enabled: root.available && root.state == "visible" || root.state == "visibleTemporary"
337 width: root.panelWidth
340 bottom: parent.bottom
343 visible: root.x > 0 || x > -width || dragArea.pressed
346 property var dismissTimer: Timer { interval: 500 }
348 target: panel.dismissTimer
350 if (root.autohideEnabled && !root.lockedVisible) {
351 if (!panel.preventHiding) {
354 panel.dismissTimer.restart()
360 property bool animate: true
362 onApplicationSelected: {
364 launcherApplicationSelected(appId)
371 onPreventHidingChanged: {
372 if (panel.dismissTimer.running) {
373 panel.dismissTimer.restart();
377 onKbdNavigationCancelled: {
378 panel.highlightIndex = -2;
384 enabled: !dragArea.dragging && !launcherDragArea.drag.active && panel.animate;
387 easing.type: Easing.OutCubic
391 Behavior on opacity {
393 duration: UbuntuAnimation.FastDuration; easing.type: Easing.OutCubic
400 objectName: "launcherDragArea"
402 direction: Direction.Rightwards
404 enabled: root.available
405 x: -root.x // so if launcher is adjusted relative to screen, we stay put (like tutorial does when teasing)
406 width: root.dragAreaWidth
410 if (!dragging || launcher.state == "visible")
413 panel.x = -panel.width + Math.min(Math.max(0, distance), panel.width);
418 if (distance > panel.width / 2) {
419 root.switchToNextState("visible")
420 if (distance > minimizeDistance) {
423 } else if (root.state === "") {
424 // didn't drag far enough. rollback
425 root.switchToNextState("")
433 name: "" // hidden state. Must be the default state ("") because "when:" falls back to this.
443 x: -root.x // so we never go past panelWidth, even when teased by tutorial
447 name: "visibleTemporary"
451 autohideEnabled: true
456 when: teaseTimer.running && teaseTimer.mode == "teasing"
459 x: -root.panelWidth + units.gu(2)
464 when: teaseTimer.running && teaseTimer.mode == "hinting"
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