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 1.3
19 import Ubuntu.Gestures 0.1
22 import Unity.DashCommunicator 0.1
23 import "../Components"
35 dashContent.currentScope.performQuery(uris[0])
39 property bool windowActive: window.active
40 property bool showOverlayScope: false
42 DashCommunicatorService {
43 objectName: "dashCommunicatorService"
44 onSetCurrentScopeRequested: {
45 if (!isSwipe || !windowActive || bottomEdgeController.progress != 0 || scopeItem.scope || dashContent.subPageShown) {
46 if (bottomEdgeController.progress != 0 && window.active) animate = false;
47 dashContent.setCurrentScopeAtIndex(index, animate, true)
53 function backToDashContent()
55 // Close dash overview and nested temp scopes in it
56 if (bottomEdgeController.progress != 0) {
57 bottomEdgeController.enableAnimation = window.active;
58 bottomEdgeController.progress = 0;
60 // Close normal temp scopes (e.g. App Store)
61 if (scopeItem.scope) {
62 scopeItem.backClicked();
65 if (dashContent.subPageShown) {
66 dashContent.closePreview();
70 function setCurrentScope(scopeId, animate, reset) {
72 for (var i = 0; i < scopes.count; ++i) {
73 if (scopes.getScope(i).id == scopeId) {
79 if (scopeIndex == -1) {
80 console.warn("No match for scope with id: %1".arg(scopeId))
84 dash.showOverlayScope = false;
86 dashContent.closePreview();
88 if (scopeIndex == dashContent.currentIndex && !reset) {
89 // the scope is already the current one
93 dashContent.workaroundRestoreIndex = -1;
94 dashContent.setCurrentScopeAtIndex(scopeIndex, animate, reset)
102 id: bottomEdgeController
103 objectName: "bottomEdgeController"
105 property alias enableAnimation: progressAnimation.enabled
106 property real progress: 0
107 Behavior on progress {
108 id: progressAnimation
109 UbuntuNumberAnimation { }
113 // FIXME This is to workaround a Qt bug with the model moving the current item
114 // when the list is ListView.SnapOneItem and ListView.StrictlyEnforceRange
115 // together with the code in DashContent.qml
116 if (dashContent.workaroundRestoreIndex != -1) {
117 dashContent.currentIndex = dashContent.workaroundRestoreIndex;
118 dashContent.workaroundRestoreIndex = -1;
126 objectName: "dashContent"
131 x: dash.showOverlayScope ? -width : 0
133 dash.setCurrentScope(scopeId, true, false);
136 scopeItem.scope = scope;
137 dash.showOverlayScope = true;
140 UbuntuNumberAnimation {
142 if (!running && dashContent.x == 0) {
143 scopes.closeScope(scopeItem.scope);
144 scopeItem.scope = null;
150 // This is to avoid the situation where a bottom-edge swipe would bring up the dash overview
151 // (as expected) but would also cause the dash content flickable to move a bit, because
152 // that flickable was getting the touch events while overviewDragHandle was still undecided
153 // about whether that touch was indeed performing a directional drag gesture.
154 forceNonInteractive: overviewDragHandle.dragging
156 enabled: bottomEdgeController.progress == 0
161 opacity: bottomEdgeController.progress
162 anchors.fill: dashContent
167 objectName: "scopesList"
170 scope: scopes.overviewScope
171 y: dash.height * (1 - bottomEdgeController.progress)
172 visible: bottomEdgeController.progress != 0
174 bottomEdgeController.enableAnimation = true;
175 bottomEdgeController.progress = 0;
178 bottomEdgeController.enableAnimation = true;
179 bottomEdgeController.progress = 0;
180 scopesList.scope.performQuery("scope://com.canonical.scopes.clickstore");
183 scopes.setFavorite(scopeId, favorite);
185 onRequestFavoriteMoveTo: {
186 scopes.moveFavoriteTo(scopeId, index);
189 bottomEdgeController.enableAnimation = true;
190 bottomEdgeController.progress = 0;
191 dash.setCurrentScope(scopeId, false, false);
195 target: scopesList.scope
197 value: bottomEdgeController.progress === 1 && (Qt.application.state == Qt.ApplicationActive)
201 target: scopesList.scope
203 bottomEdgeController.enableAnimation = true;
204 bottomEdgeController.progress = 0;
205 scopeItem.scope = scope;
206 dash.showOverlayScope = true;
209 bottomEdgeController.enableAnimation = true;
210 bottomEdgeController.progress = 0;
211 dashContent.gotoScope(scopeId);
217 anchors.fill: scopeItem
218 visible: scopeItem.visible
223 objectName: "dashTempScopeItem"
225 x: dash.showOverlayScope ? 0 : width
228 height: parent.height
229 visible: scope != null
233 dash.showOverlayScope = false;
238 target: scopeItem.scope
240 dashContent.gotoScope(scopeId);
243 scopeItem.closePreview();
244 var oldScope = scopeItem.scope;
245 scopeItem.scope = scope;
246 scopes.closeScope(oldScope);
251 UbuntuNumberAnimation { }
257 objectName: "processingIndicator"
261 bottom: parent.bottom
262 bottomMargin: Qt.inputMethod.keyboardRectangle.height
265 color: scopeStyle.backgroundLuminance > 0.7 ? "#50000000" : "#50ffffff"
269 readonly property bool processing: dashContent.processing || scopeItem.processing || scopesList.processing
271 Behavior on opacity {
272 UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
275 onProcessingChanged: {
276 if (processing) delay.start();
277 else if (!persist.running) indicator.opacity = 0;
283 onTriggered: if (indicator.processing) {
285 indicator.opacity = 1;
291 interval: 2 * UbuntuAnimation.SleepyDuration - UbuntuAnimation.FastDuration
292 onTriggered: if (!indicator.processing) indicator.opacity = 0
297 anchors { top: parent.top; bottom: parent.bottom }
298 width: parent.width / 4
299 color: theme.palette.normal.activity
301 SequentialAnimation {
302 running: indicator.visible
303 loops: Animation.Infinite
305 from: -activityPulse.width / 2
306 to: indicator.width - activityPulse.width / 2
307 duration: UbuntuAnimation.SleepyDuration
308 easing.type: Easing.InOutSine
309 target: activityPulse
312 from: indicator.width - activityPulse.width / 2
313 to: -activityPulse.width / 2
314 duration: UbuntuAnimation.SleepyDuration
315 easing.type: Easing.InOutSine
316 target: activityPulse
323 objectName: "overviewHint"
324 source: "graphics/overview_hint.png"
325 anchors.horizontalCenter: parent.horizontalCenter
326 opacity: !scopeItem.scope && (scopes.count == 0 || dashContent.pageHeaderTotallyVisible) &&
327 (overviewDragHandle.enabled || bottomEdgeController.progress != 0) ? 1 : 0
328 Behavior on opacity {
329 enabled: bottomEdgeController.progress == 0
330 UbuntuNumberAnimation {}
332 y: parent.height - height * (1 - bottomEdgeController.progress * 4) - units.gu(1)
334 // Eat direct presses on the overview hint so that they do not end up in the card below
336 enabled: parent.opacity != 0
338 // TODO: This is a temporary workaround to allow people opening the
339 // dash overview when there's no touch input around. Will be replaced with
340 // a SDK component once that's available
341 onClicked: bottomEdgeController.progress = 1;
343 // We need to eat touch events here in order to not allow opening the bottom edge with a touch press
344 MultiPointTouchArea {
347 enabled: parent.enabled
353 id: overviewDragHandle
354 objectName: "overviewDragHandle"
356 direction: Direction.Upwards
357 enabled: !dashContent.subPageShown &&
358 (scopes.count == 0 || (dashContent.currentScope && dashContent.currentScope.searchQuery == "")) &&
360 (bottomEdgeController.progress == 0 || dragging)
362 readonly property real fullMovement: dash.height
364 anchors { left: parent.left; right: parent.right; bottom: parent.bottom }
369 bottomEdgeController.enableAnimation = false;
370 bottomEdgeController.progress = Math.max(0, Math.min(1, distance / fullMovement));
376 bottomEdgeController.enableAnimation = true;
377 bottomEdgeController.progress = (bottomEdgeController.progress > 0.2) ? 1 : 0;