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 property string showScopeOnLoaded: "clickscope"
32 property real contentScale: 1.0
34 DashCommunicatorService {
35 objectName: "dashCommunicatorService"
36 onSetCurrentScopeRequested: {
37 if (!isSwipe || !window.active || overviewController.progress != 0) {
38 if (overviewController.progress != 0 && window.active) animate = false;
39 dash.setCurrentScope(scopeId, animate, isSwipe)
40 if (overviewController.progress != 0) {
42 dashContentCache.scheduleUpdate();
44 overviewController.enableAnimation = window.active;
45 overviewController.progress = 0;
51 function setCurrentScope(scopeId, animate, reset) {
53 for (var i = 0; i < scopes.count; ++i) {
54 if (scopes.getScope(i).id == scopeId) {
60 if (scopeIndex == -1) {
61 console.warn("No match for scope with id: %1".arg(scopeId))
67 dashContent.closePreview();
69 if (scopeIndex == dashContent.currentIndex && !reset) {
70 // the scope is already the current one
74 dashContent.setCurrentScopeAtIndex(scopeIndex, animate, reset)
77 function closeOverlayScope() {
78 if (dashContent.x != 0) {
88 id: overviewController
89 objectName: "overviewController"
91 property alias enableAnimation: progressAnimation.enabled
92 property real progress: 0
93 Behavior on progress {
95 UbuntuNumberAnimation { }
101 objectName: "scopesOverview"
103 scope: scopes.overviewScope
104 progress: overviewController.progress
105 scopeScale: scopeItem.scope ? 0.4 : (1 - overviewController.progress * 0.6)
106 visible: scopeScale != 1
107 currentIndex: dashContent.currentIndex
109 if (currentTab == 1) {
110 animateDashFromAll(dashContent.currentScopeId);
114 onFavoriteSelected: {
115 setCurrentScope(scopeId, false, false);
116 dashContentCache.scheduleUpdate();
119 onAllFavoriteSelected: {
120 setCurrentScope(scopeId, false, false);
121 dashContentCache.scheduleUpdate();
122 animateDashFromAll(dashContent.currentScopeId);
127 for (var i = 0; i < scopes.count; ++i) {
128 if (scopes.getScope(i).id == scopeId) {
133 if (scopeIndex >= 0) {
135 setCurrentScope(scopeId, false, false);
136 dashContentCache.scheduleUpdate();
137 showDashFromPos(pos, size);
140 // Is not a favorite one, activate and get openScope
141 scope.activate(result);
145 overviewController.enableAnimation = true;
146 overviewController.progress = 0;
150 currentTab = scopeItem.scope ? 1 : 0;
157 parent: scopesOverview.dashItemEater
159 sourceItem: dashContent
160 height: sourceItem.height
161 width: sourceItem.width
162 opacity: 1 - overviewController.progress
163 visible: overviewController.progress != 0 && scopeItem.scope === null
170 property var scopeThatOpenedScope: null
172 objectName: "dashContent"
176 visible: !scopesOverview.showingNonFavoriteScope && x != -width
178 dash.setCurrentScope(scopeId, true, false);
181 scopeThatOpenedScope = currentScope;
182 scopeItem.scope = scope;
183 scopesOverview.currentTab = 1;
184 scopesOverview.ensureAllScopeVisible(scope.id);
188 if (scopeId == dash.showScopeOnLoaded) {
189 dash.setCurrentScope(scopeId, false, false)
190 dash.showScopeOnLoaded = ""
193 scale: dash.contentScale
194 clip: scale != 1.0 || scopeItem.visible || overviewController.progress != 0
196 UbuntuNumberAnimation {
197 duration: overviewController.progress != 0 ? 0 : UbuntuAnimation.FastDuration
199 if (!running && dashContent.x == 0) {
200 dashContent.scopeThatOpenedScope.closeScope(scopeItem.scope);
201 scopeItem.scope = null;
202 if (overviewController.progress == 0) {
203 // Set tab to Favorites only if we are not showing the overview
204 scopesOverview.currentTab = 0;
211 enabled: overviewController.progress == 0
212 opacity: enabled ? 1 : 0
217 anchors.fill: scopeItem
218 visible: scopeItem.visible
219 parent: scopeItem.parent
220 scale: scopeItem.scale
221 opacity: scopeItem.opacity
226 objectName: "dashTempScopeItem"
228 readonly property real targetOverviewScale: {
229 if (scopesOverview.currentTab == 0) {
232 return scopesOverview.allCardSize.width / scopeItem.width;
235 readonly property real overviewProgressScale: (1 - overviewController.progress * (1 - targetOverviewScale))
236 readonly property var targetOverviewPosition: scope ? scopesOverview.allScopeCardPosition(scope.id) : null
237 readonly property real overviewProgressX: scope && scopesOverview.currentTab == 1 && targetOverviewPosition ?
238 overviewController.progress * (targetOverviewPosition.x - (width - scopesOverview.allCardSize.width) / 2)
240 readonly property real overviewProgressY: scope && scopesOverview.currentTab == 1 && targetOverviewPosition ?
241 overviewController.progress * (targetOverviewPosition.y - (height - scopesOverview.allCardSize.height) / 2)
244 x: overviewController.progress == 0 ? dashContent.x + width : overviewProgressX
245 y: overviewController.progress == 0 ? dashContent.y : overviewProgressY
247 height: parent.height
248 scale: dash.contentScale * overviewProgressScale
249 enabled: opacity == 1
250 opacity: 1 - overviewController.progress
252 visible: scope != null
261 target: scopeItem.scope
263 dashContent.gotoScope(scopeId);
266 dashContent.openScope(scope);
273 objectName: "processingIndicator"
277 bottom: parent.bottom
278 bottomMargin: Qt.inputMethod.keyboardRectangle.height
281 color: scopeStyle.backgroundLuminance > 0.7 ? "#50000000" : "#50ffffff"
285 readonly property bool processing: dashContent.processing || scopeItem.processing || scopesOverview.processing
287 Behavior on opacity {
288 UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
291 onProcessingChanged: {
292 if (processing) delay.start();
293 else if (!persist.running) indicator.opacity = 0;
299 onTriggered: if (indicator.processing) {
301 indicator.opacity = 1;
307 interval: 2 * UbuntuAnimation.SleepyDuration - UbuntuAnimation.FastDuration
308 onTriggered: if (!indicator.processing) indicator.opacity = 0
313 anchors { top: parent.top; bottom: parent.bottom }
314 width: parent.width / 4
315 color: Theme.palette.selected.foreground
317 SequentialAnimation {
318 running: indicator.visible
319 loops: Animation.Infinite
321 from: -orange.width / 2
322 to: indicator.width - orange.width / 2
323 duration: UbuntuAnimation.SleepyDuration
324 easing.type: Easing.InOutSine
328 from: indicator.width - orange.width / 2
329 to: -orange.width / 2
330 duration: UbuntuAnimation.SleepyDuration
331 easing.type: Easing.InOutSine
339 source: "graphics/overview_hint.png"
340 anchors.horizontalCenter: parent.horizontalCenter
341 opacity: (scopeItem.scope ? scopeItem.pageHeaderTotallyVisible : dashContent.pageHeaderTotallyVisible) &&
342 (overviewDragHandle.enabled || overviewController.progress != 0) ? 1 : 0
343 Behavior on opacity {
344 enabled: overviewController.progress == 0
345 UbuntuNumberAnimation {}
347 y: parent.height - height * (1 - overviewController.progress * 4)
351 id: overviewDragHandle
352 objectName: "overviewDragHandle"
354 direction: Direction.Upwards
355 enabled: !dashContent.subPageShown &&
356 dashContent.currentScope &&
357 dashContent.currentScope.searchQuery == "" &&
358 !scopeItem.subPageShown &&
359 (overviewController.progress == 0 || dragging)
361 readonly property real fullMovement: units.gu(20)
363 anchors { left: parent.left; right: parent.right; bottom: parent.bottom }
366 onSceneDistanceChanged: {
367 if (overviewController.enableAnimation) {
368 dashContentCache.scheduleUpdate();
370 overviewController.enableAnimation = false;
371 overviewController.progress = Math.max(0, Math.min(1, sceneDistance / fullMovement));
375 overviewController.enableAnimation = true;
376 overviewController.progress = (overviewController.progress > 0.7) ? 1 : 0;