2 * Copyright (C) 2013, 2014 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/>.
18 import Ubuntu.Components 0.1
19 import Ubuntu.Gestures 0.1
22 import Unity.DashCommunicator 0.1
23 import "../Components"
35 dashContent.currentScope.performQuery(uris[0])
39 DashCommunicatorService {
40 objectName: "dashCommunicatorService"
41 onSetCurrentScopeRequested: {
42 if (!isSwipe || !window.active || bottomEdgeController.progress != 0 || scopeItem.scope || dashContent.subPageShown) {
43 if (bottomEdgeController.progress != 0 && window.active) animate = false;
44 dashContent.setCurrentScopeAtIndex(index, animate, isSwipe)
50 function backToDashContent()
52 // Close dash overview and nested temp scopes in it
53 if (bottomEdgeController.progress != 0) {
54 bottomEdgeController.enableAnimation = window.active;
55 bottomEdgeController.progress = 0;
57 // Close normal temp scopes (e.g. App Store)
58 if (scopeItem.scope) {
59 scopeItem.backClicked();
62 if (dashContent.subPageShown) {
63 dashContent.closePreview();
67 function setCurrentScope(scopeId, animate, reset) {
69 for (var i = 0; i < scopes.count; ++i) {
70 if (scopes.getScope(i).id == scopeId) {
76 if (scopeIndex == -1) {
77 console.warn("No match for scope with id: %1".arg(scopeId))
83 dashContent.closePreview();
85 if (scopeIndex == dashContent.currentIndex && !reset) {
86 // the scope is already the current one
90 dashContent.workaroundRestoreIndex = -1;
91 dashContent.setCurrentScopeAtIndex(scopeIndex, animate, reset)
94 function closeOverlayScope() {
95 if (dashContent.x != 0) {
105 id: bottomEdgeController
106 objectName: "bottomEdgeController"
108 property alias enableAnimation: progressAnimation.enabled
109 property real progress: 0
110 Behavior on progress {
111 id: progressAnimation
112 UbuntuNumberAnimation { }
116 // FIXME This is to workaround a Qt bug with the model moving the current item
117 // when the list is ListView.SnapOneItem and ListView.StrictlyEnforceRange
118 // together with the code in DashContent.qml
119 if (dashContent.workaroundRestoreIndex != -1) {
120 dashContent.currentIndex = dashContent.workaroundRestoreIndex;
121 dashContent.workaroundRestoreIndex = -1;
129 objectName: "dashContent"
135 dash.setCurrentScope(scopeId, true, false);
138 scopeItem.scope = scope;
142 UbuntuNumberAnimation {
144 if (!running && dashContent.x == 0) {
145 scopes.closeScope(scopeItem.scope);
146 scopeItem.scope = null;
152 // This is to avoid the situation where a bottom-edge swipe would bring up the dash overview
153 // (as expected) but would also cause the dash content flickable to move a bit, because
154 // that flickable was getting the touch events while overviewDragHandle was still undecided
155 // about whether that touch was indeed performing a directional drag gesture.
156 forceNonInteractive: overviewDragHandle.status != DirectionalDragArea.WaitingForTouch
158 enabled: bottomEdgeController.progress == 0
163 opacity: bottomEdgeController.progress
164 anchors.fill: dashContent
169 objectName: "scopesList"
172 scope: scopes.overviewScope
173 y: dash.height * (1 - bottomEdgeController.progress)
174 visible: bottomEdgeController.progress != 0
176 bottomEdgeController.enableAnimation = true;
177 bottomEdgeController.progress = 0;
180 bottomEdgeController.enableAnimation = true;
181 bottomEdgeController.progress = 0;
182 scopesList.scope.performQuery("scope://com.canonical.scopes.clickstore");
185 scopes.setFavorite(scopeId, favorite);
187 onRequestFavoriteMoveTo: {
188 scopes.moveFavoriteTo(scopeId, index);
192 target: scopesList.scope
194 value: bottomEdgeController.progress === 1 && (Qt.application.state == Qt.ApplicationActive)
198 target: scopesList.scope
200 bottomEdgeController.enableAnimation = true;
201 bottomEdgeController.progress = 0;
202 scopeItem.scope = scope;
203 dashContent.x = -dashContent.width;
206 bottomEdgeController.enableAnimation = true;
207 bottomEdgeController.progress = 0;
208 dashContent.gotoScope(scopeId);
214 anchors.fill: scopeItem
215 visible: scopeItem.visible
220 objectName: "dashTempScopeItem"
222 x: dashContent.x + width
225 height: parent.height
226 visible: scope != null
235 target: scopeItem.scope
237 dashContent.gotoScope(scopeId);
240 scopeItem.closePreview();
241 var oldScope = scopeItem.scope;
242 scopeItem.scope = scope;
243 scopes.closeScope(oldScope);
250 objectName: "processingIndicator"
254 bottom: parent.bottom
255 bottomMargin: Qt.inputMethod.keyboardRectangle.height
258 color: scopeStyle.backgroundLuminance > 0.7 ? "#50000000" : "#50ffffff"
262 readonly property bool processing: dashContent.processing || scopeItem.processing || scopesList.processing
264 Behavior on opacity {
265 UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
268 onProcessingChanged: {
269 if (processing) delay.start();
270 else if (!persist.running) indicator.opacity = 0;
276 onTriggered: if (indicator.processing) {
278 indicator.opacity = 1;
284 interval: 2 * UbuntuAnimation.SleepyDuration - UbuntuAnimation.FastDuration
285 onTriggered: if (!indicator.processing) indicator.opacity = 0
290 anchors { top: parent.top; bottom: parent.bottom }
291 width: parent.width / 4
292 color: UbuntuColors.orange
294 SequentialAnimation {
295 running: indicator.visible
296 loops: Animation.Infinite
298 from: -orange.width / 2
299 to: indicator.width - orange.width / 2
300 duration: UbuntuAnimation.SleepyDuration
301 easing.type: Easing.InOutSine
305 from: indicator.width - orange.width / 2
306 to: -orange.width / 2
307 duration: UbuntuAnimation.SleepyDuration
308 easing.type: Easing.InOutSine
316 objectName: "overviewHint"
317 source: "graphics/overview_hint.png"
318 anchors.horizontalCenter: parent.horizontalCenter
319 opacity: !scopeItem.scope && (scopes.count == 0 || dashContent.pageHeaderTotallyVisible) &&
320 (overviewDragHandle.enabled || bottomEdgeController.progress != 0) ? 1 : 0
321 Behavior on opacity {
322 enabled: bottomEdgeController.progress == 0
323 UbuntuNumberAnimation {}
325 y: parent.height - height * (1 - bottomEdgeController.progress * 4)
327 // Eat direct presses on the overview hint so that they do not end up in the card below
329 enabled: parent.opacity != 0
334 id: overviewDragHandle
335 objectName: "overviewDragHandle"
337 direction: Direction.Upwards
338 enabled: !dashContent.subPageShown &&
339 (scopes.count == 0 || (dashContent.currentScope && dashContent.currentScope.searchQuery == "")) &&
341 (bottomEdgeController.progress == 0 || dragging)
343 readonly property real fullMovement: dash.height
345 anchors { left: parent.left; right: parent.right; bottom: parent.bottom }
348 onSceneDistanceChanged: {
349 if (status == DirectionalDragArea.Recognized) {
350 bottomEdgeController.enableAnimation = false;
351 bottomEdgeController.progress = Math.max(0, Math.min(1, sceneDistance / fullMovement));
355 property int previousStatus: -1
356 property int currentStatus: DirectionalDragArea.WaitingForTouch
359 previousStatus = currentStatus;
360 currentStatus = status;
362 if (status == DirectionalDragArea.WaitingForTouch &&
363 previousStatus == DirectionalDragArea.Recognized) {
364 bottomEdgeController.enableAnimation = true;
365 bottomEdgeController.progress = (bottomEdgeController.progress > 0.2) ? 1 : 0;