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"
31 DashCommunicatorService {
32 objectName: "dashCommunicatorService"
33 onSetCurrentScopeRequested: {
34 if (!isSwipe || !window.active || bottomEdgeController.progress != 0 || scopeItem.scope || dashContent.subPageShown) {
35 if (bottomEdgeController.progress != 0 && window.active) animate = false;
36 dashContent.setCurrentScopeAtIndex(index, animate, isSwipe)
37 // Close dash overview and nested temp scopes in it
38 if (bottomEdgeController.progress != 0) {
39 bottomEdgeController.enableAnimation = window.active;
40 bottomEdgeController.progress = 0;
42 // Close normal temp scopes (e.g. App Store)
43 if (scopeItem.scope) {
44 scopeItem.backClicked();
47 if (dashContent.subPageShown) {
48 dashContent.closePreview();
54 function setCurrentScope(scopeId, animate, reset) {
56 for (var i = 0; i < scopes.count; ++i) {
57 if (scopes.getScope(i).id == scopeId) {
63 if (scopeIndex == -1) {
64 console.warn("No match for scope with id: %1".arg(scopeId))
70 dashContent.closePreview();
72 if (scopeIndex == dashContent.currentIndex && !reset) {
73 // the scope is already the current one
77 dashContent.workaroundRestoreIndex = -1;
78 dashContent.setCurrentScopeAtIndex(scopeIndex, animate, reset)
81 function closeOverlayScope() {
82 if (dashContent.x != 0) {
92 id: bottomEdgeController
93 objectName: "bottomEdgeController"
95 property alias enableAnimation: progressAnimation.enabled
96 property real progress: 0
97 Behavior on progress {
99 UbuntuNumberAnimation { }
103 // FIXME This is to workaround a Qt bug with the model moving the current item
104 // when the list is ListView.SnapOneItem and ListView.StrictlyEnforceRange
105 // together with the code in DashContent.qml
106 if (dashContent.workaroundRestoreIndex != -1) {
107 dashContent.currentIndex = dashContent.workaroundRestoreIndex;
108 dashContent.workaroundRestoreIndex = -1;
116 objectName: "dashContent"
122 dash.setCurrentScope(scopeId, true, false);
125 scopeItem.scopeThatOpenedScope = currentScope;
126 scopeItem.scope = scope;
130 UbuntuNumberAnimation {
132 if (!running && dashContent.x == 0) {
133 scopeItem.scopeThatOpenedScope.closeScope(scopeItem.scope);
134 scopeItem.scope = null;
140 // This is to avoid the situation where a bottom-edge swipe would bring up the dash overview
141 // (as expected) but would also cause the dash content flickable to move a bit, because
142 // that flickable was getting the touch events while overviewDragHandle was still undecided
143 // about whether that touch was indeed performing a directional drag gesture.
144 forceNonInteractive: overviewDragHandle.status != DirectionalDragArea.WaitingForTouch
146 enabled: bottomEdgeController.progress == 0
151 opacity: bottomEdgeController.progress
152 anchors.fill: dashContent
157 objectName: "scopesList"
160 scope: scopes.overviewScope
161 y: dash.height * (1 - bottomEdgeController.progress)
162 visible: bottomEdgeController.progress != 0
164 bottomEdgeController.enableAnimation = true;
165 bottomEdgeController.progress = 0;
168 bottomEdgeController.enableAnimation = true;
169 bottomEdgeController.progress = 0;
170 scopesList.scope.performQuery("scope://com.canonical.scopes.clickstore");
173 scopes.setFavorite(scopeId, favorite);
175 onRequestFavoriteMoveTo: {
176 scopes.moveFavoriteTo(scopeId, index);
180 target: scopesList.scope
182 value: bottomEdgeController.progress === 1
186 target: scopesList.scope
188 bottomEdgeController.enableAnimation = true;
189 bottomEdgeController.progress = 0;
190 scopeItem.scopeThatOpenedScope = scopesList.scope;
191 scopeItem.scope = scope;
192 dashContent.x = -dashContent.width;
195 bottomEdgeController.enableAnimation = true;
196 bottomEdgeController.progress = 0;
197 dashContent.gotoScope(scopeId);
204 anchors.fill: scopeItem
205 visible: scopeItem.visible
210 objectName: "dashTempScopeItem"
212 property var scopeThatOpenedScope: null
214 x: dashContent.x + width
217 height: parent.height
218 visible: scope != null
227 target: scopeItem.scope
229 dashContent.gotoScope(scopeId);
232 dashContent.openScope(scope);
239 objectName: "processingIndicator"
243 bottom: parent.bottom
244 bottomMargin: Qt.inputMethod.keyboardRectangle.height
247 color: scopeStyle.backgroundLuminance > 0.7 ? "#50000000" : "#50ffffff"
251 readonly property bool processing: dashContent.processing || scopeItem.processing || scopesList.processing
253 Behavior on opacity {
254 UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
257 onProcessingChanged: {
258 if (processing) delay.start();
259 else if (!persist.running) indicator.opacity = 0;
265 onTriggered: if (indicator.processing) {
267 indicator.opacity = 1;
273 interval: 2 * UbuntuAnimation.SleepyDuration - UbuntuAnimation.FastDuration
274 onTriggered: if (!indicator.processing) indicator.opacity = 0
279 anchors { top: parent.top; bottom: parent.bottom }
280 width: parent.width / 4
281 color: UbuntuColors.orange
283 SequentialAnimation {
284 running: indicator.visible
285 loops: Animation.Infinite
287 from: -orange.width / 2
288 to: indicator.width - orange.width / 2
289 duration: UbuntuAnimation.SleepyDuration
290 easing.type: Easing.InOutSine
294 from: indicator.width - orange.width / 2
295 to: -orange.width / 2
296 duration: UbuntuAnimation.SleepyDuration
297 easing.type: Easing.InOutSine
305 source: "graphics/overview_hint.png"
306 anchors.horizontalCenter: parent.horizontalCenter
307 opacity: !scopeItem.scope && (scopes.count == 0 || dashContent.pageHeaderTotallyVisible) &&
308 (overviewDragHandle.enabled || overviewDragHandle.status.progress != 0) ? 1 : 0
309 Behavior on opacity {
310 enabled: bottomEdgeController.progress == 0
311 UbuntuNumberAnimation {}
313 y: parent.height - height * (1 - bottomEdgeController.progress * 4)
315 // Eat direct presses on the overview hint so that they do not end up in the card below
317 enabled: parent.opacity != 0
322 id: overviewDragHandle
323 objectName: "overviewDragHandle"
325 direction: Direction.Upwards
326 enabled: !dashContent.subPageShown &&
327 (scopes.count == 0 || (dashContent.currentScope && dashContent.currentScope.searchQuery == "")) &&
329 (bottomEdgeController.progress == 0 || dragging)
331 readonly property real fullMovement: dash.height
333 anchors { left: parent.left; right: parent.right; bottom: parent.bottom }
336 onSceneDistanceChanged: {
337 if (status == DirectionalDragArea.Recognized) {
338 bottomEdgeController.enableAnimation = false;
339 bottomEdgeController.progress = Math.max(0, Math.min(1, sceneDistance / fullMovement));
343 property int previousStatus: -1
344 property int currentStatus: DirectionalDragArea.WaitingForTouch
347 previousStatus = currentStatus;
348 currentStatus = status;
350 if (status == DirectionalDragArea.WaitingForTouch &&
351 previousStatus == DirectionalDragArea.Recognized) {
352 bottomEdgeController.enableAnimation = true;
353 bottomEdgeController.progress = (bottomEdgeController.progress > 0.2) ? 1 : 0;