@@ -21,25 +21,24 @@ import "../Components"
2121Item {
2222 id: root
2323
24+ // Properties passed by parent
2425 property real progress: 0
2526 property var scope: null
26− property bool forceDisableDashEater: false
27− property var dashItemEater: {
28− if (!forceDisableDashEater && tabBar.currentTab == 0 && middleItems.count > 0) {
27+ property int currentIndex: 0
28+ property real scopeScale: 1
29+
30+ // Properties used by parent
31+ property bool growingDashFromPos: false
32+ readonly property bool showingNonFavoriteScope: tempScopeItem.scope != null
33+ readonly property alias currentTab: tabBar.currentTab
34+ readonly property var dashItemEater: {
35+ if (!forceXYScalerEater && tabBar.currentTab == 0 && middleItems.count > 0) {
2936 var loaderItem = middleItems.itemAt(0).item;
3037 return loaderItem && loaderItem.currentItem ? loaderItem.currentItem : null;
3138 }
32− return null;
39+ return scopesOverviewXYScaler;
3340 }
34− property int currentIndex: 0
35− property real scopeScale: 1
36− property real overrideOpacity: -1
37− property QtObject scopeStyle: QtObject {
38− property string headerLogo: ""
39− property color foreground: "white"
40− property color background: "transparent"
41− }
42− property size allCardSize: {
41+ readonly property size allCardSize: {
4342 if (middleItems.count > 1) {
4443 var loaderItem = middleItems.itemAt(1).item;
4544 if (loaderItem) {
@@ -50,12 +49,57 @@ Item {
5049 return Qt.size(0, 0);
5150 }
5251
52+ // Internal properties
53+ property bool forceXYScalerEater: false
54+ property QtObject scopeStyle: QtObject {
55+ property string headerLogo: ""
56+ property color foreground: "white"
57+ property color background: "transparent"
58+ }
59+
60+
5361 signal done()
5462 signal favoriteSelected(int index)
5563 signal allFavoriteSelected(var scopeId)
5664 signal allSelected(var scopeId, var pos)
5765 signal searchSelected(var scopeId, var pos, var size)
5866
67+ function showTemporaryScope(scope, itemPos, itemSize) {
68+ scopesOverviewXYScaler.restorePosition = itemPos;
69+ scopesOverviewXYScaler.restoreSize = itemSize;
70+ scopesOverviewXYScaler.scale = itemSize.width / scopesOverviewXYScaler.width;
71+ scopesOverviewXYScaler.x = itemPos.x -(scopesOverviewXYScaler.width - scopesOverviewXYScaler.width * scopesOverviewXYScaler.scale) / 2;
72+ scopesOverviewXYScaler.y = itemPos.y -(scopesOverviewXYScaler.height - scopesOverviewXYScaler.height * scopesOverviewXYScaler.scale) / 2;
73+ scopesOverviewXYScaler.opacity = 0;
74+ tempScopeItem.scope = scope;
75+ middleItems.overrideOpacity = 0;
76+ scopesOverviewXYScaler.scale = 1;
77+ scopesOverviewXYScaler.x = 0;
78+ scopesOverviewXYScaler.y = 0;
79+ scopesOverviewXYScaler.opacity = 1;
80+ }
81+
82+ function animateDashFromAll(scopeId) {
83+ var currentScopePos = allScopeCardPosition(scopeId);
84+ if (currentScopePos) {
85+ showDashFromPos(currentScopePos, allCardSize);
86+ } else {
87+ console.log("Warning: Could not find Dash OverView All card position for scope", dashContent.currentScopeId);
88+ }
89+ }
90+
91+ function showDashFromPos(itemPos, itemSize) {
92+ scopesOverviewXYScaler.scale = itemSize.width / scopesOverviewXYScaler.width;
93+ scopesOverviewXYScaler.x = itemPos.x -(scopesOverviewXYScaler.width - scopesOverviewXYScaler.width * scopesOverviewXYScaler.scale) / 2;
94+ scopesOverviewXYScaler.y = itemPos.y -(scopesOverviewXYScaler.height - scopesOverviewXYScaler.height * scopesOverviewXYScaler.scale) / 2;
95+ scopesOverviewXYScaler.opacity = 0;
96+ root.growingDashFromPos = true;
97+ scopesOverviewXYScaler.scale = 1;
98+ scopesOverviewXYScaler.x = 0;
99+ scopesOverviewXYScaler.y = 0;
100+ scopesOverviewXYScaler.opacity = 1;
101+ }
102+
59103 function allScopeCardPosition(scopeId) {
60104 if (middleItems.count > 1) {
61105 var loaderItem = middleItems.itemAt(1).item;
@@ -89,11 +133,11 @@ Item {
89133 // Need this in order, otherwise something gets unhappy in rendering
90134 // of the overlay in carousels because the parent of the dash dies for
91135 // a moment, this way we make sure it's reparented first
92− // by forceDisableDashEater making dashItemEater return null and
93− // then really kill the parent by updating scope.searchQuery
94− root.forceDisableDashEater = true;
136+ // by forceXYScalerEater making dashItemEater return scopesOverviewXYScaler
137+ // before we kill the previous parent by scope.searchQuery
138+ root.forceXYScalerEater = true;
95139 root.scope.searchQuery = pageHeader.searchQuery;
96− root.forceDisableDashEater = false;
140+ root.forceXYScalerEater = false;
97141 }
98142 }
99143
@@ -107,11 +151,13 @@ Item {
107151 PageHeader {
108152 id: pageHeader
109153
154+ readonly property real yDisplacement: pageHeader.height + tabBar.height + tabBar.anchors.margins
155+
110156 y: {
111157 if (root.progress < 0.5) {
112− return -height;
158+ return -yDisplacement;
113159 } else {
114− return -height + (root.progress - 0.5) * height * 2;
160+ return -yDisplacement + (root.progress - 0.5) * yDisplacement * 2;
115161 }
116162 }
117163 width: parent.width
@@ -135,11 +181,12 @@ Item {
135181
136182 enabled: opacity == 1
137183 opacity: !scope || scope.searchQuery == "" ? 1 : 0
138− Behavior on opacity { UbuntuNumberAnimation {} }
184+ Behavior on opacity { UbuntuNumberAnimation { } }
139185 }
140186
141187 Repeater {
142188 id: middleItems
189+ property real overrideOpacity: -1
143190 model: scope && scope.searchQuery == "" ? scope.categories : null
144191 delegate: Loader {
145192 id: loader
@@ -172,8 +219,8 @@ Item {
172219 scale: index == 0 ? scopeScale : 1
173220
174221 opacity: {
175− if (root.overrideOpacity >= 0)
176− return root.overrideOpacity;
222+ if (middleItems.overrideOpacity >= 0)
223+ return middleItems.overrideOpacity;
177224
178225 if (tabBar.currentTab != index)
179226 return 0;
@@ -255,9 +302,10 @@ Item {
255302 showPageHeader: false
256303 clip: true
257304 opacity: searchResultsViewer.scope ? 1 : 0
258− Behavior on opacity { UbuntuNumberAnimation {} }
305+ Behavior on opacity { UbuntuNumberAnimation { } }
259306
260307 clickOverride: function (index, result, item, itemModel) {
308+ // TODO Make sure pageheader suggestions popup is hidden
261309 if (itemModel.scopeId) {
262310 root.searchSelected(itemModel.scopeId, item.mapToItem(null, 0, 0), Qt.size(item.width, item.height));
263311 } else {
@@ -278,7 +326,7 @@ Item {
278326 width: parent.width
279327 enabled: opacity == 0.4
280328 opacity: scope && scope.searchQuery == "" ? 0.4 : 0
281− Behavior on opacity { UbuntuNumberAnimation {} }
329+ Behavior on opacity { UbuntuNumberAnimation { } }
282330 y: {
283331 if (root.progress < 0.5) {
284332 return parent.height;
@@ -323,4 +371,74 @@ Item {
323371 height: parent.height
324372 anchors.left: scopesOverviewContent.right
325373 }
374+
375+
376+
377+ Item {
378+ id: scopesOverviewXYScaler
379+ width: parent.width
380+ height: parent.height
381+
382+ clip: scale != 1.0
383+ enabled: scale == 1
384+
385+ property bool animationsEnabled: root.showingNonFavoriteScope || root.growingDashFromPos
386+
387+ property var restorePosition
388+ property var restoreSize
389+
390+ Behavior on x {
391+ enabled: scopesOverviewXYScaler.animationsEnabled
392+ UbuntuNumberAnimation { }
393+ }
394+ Behavior on y {
395+ enabled: scopesOverviewXYScaler.animationsEnabled
396+ UbuntuNumberAnimation { }
397+ }
398+ Behavior on opacity {
399+ enabled: scopesOverviewXYScaler.animationsEnabled
400+ UbuntuNumberAnimation { }
401+ }
402+ Behavior on scale {
403+ enabled: scopesOverviewXYScaler.animationsEnabled
404+ UbuntuNumberAnimation {
405+ onRunningChanged: {
406+ if (!running) {
407+ if (root.showingNonFavoriteScope && scopesOverviewXYScaler.scale != 1) {
408+ tempScopeItem.scope = null;
409+ } else if (root.growingDashFromPos) {
410+ root.growingDashFromPos = false;
411+ }
412+ }
413+ }
414+ }
415+ }
416+
417+ DashBackground
418+ {
419+ anchors.fill: tempScopeItem
420+ visible: tempScopeItem.visible
421+ parent: tempScopeItem.parent
422+ }
423+
424+ GenericScopeView {
425+ id: tempScopeItem
426+
427+ width: parent.width
428+ height: parent.height
429+ scale: dash.contentScale
430+ clip: scale != 1.0
431+ visible: scope != null
432+ hasBackAction: true
433+ isCurrent: visible
434+ onBackClicked: {
435+ var v = scopesOverviewXYScaler.restoreSize.width / tempScopeItem.width;
436+ scopesOverviewXYScaler.scale = v;
437+ scopesOverviewXYScaler.x = scopesOverviewXYScaler.restorePosition.x -(tempScopeItem.width - tempScopeItem.width * v) / 2;
438+ scopesOverviewXYScaler.y = scopesOverviewXYScaler.restorePosition.y -(tempScopeItem.height - tempScopeItem.height * v) / 2;
439+ scopesOverviewXYScaler.opacity = 0;
440+ scopesOverview.middleItems = -1;
441+ }
442+ }
443+ }
326444}