on xenial help sign in
Reorganize code + todo so i don't forget
94d598fAlbert Astals
qml/Dash/Dash.qml+11−102
@@ -79,10 +79,6 @@ Showable {
79
79
80 property alias enableAnimation: progressAnimation.enabled
80 property alias enableAnimation: progressAnimation.enabled
81 property real progress: 0
81 property real progress: 0
82− property bool showingNonFavoriteScope: false
83− property bool growingDashFromPos: false
84− property var allScopePosition
85− property var allScopeSize
86 Behavior on progress {
82 Behavior on progress {
87 id: progressAnimation
83 id: progressAnimation
88 UbuntuNumberAnimation { }
84 UbuntuNumberAnimation { }
@@ -94,14 +90,13 @@ Showable {
94 id: scopesOverview
90 id: scopesOverview
95 anchors.fill: parent
91 anchors.fill: parent
96 scope: scopes ? scopes.getScope("scopesOverview") : null
92 scope: scopes ? scopes.getScope("scopesOverview") : null
97− enabled: !overviewController.showingNonFavoriteScope
98 progress: overviewController.progress
93 progress: overviewController.progress
99 scopeScale: 1 - overviewController.progress * 0.6
94 scopeScale: 1 - overviewController.progress * 0.6
100 visible: scopeScale != 1
95 visible: scopeScale != 1
101 currentIndex: dashContent.currentIndex
96 currentIndex: dashContent.currentIndex
102 onDone: {
97 onDone: {
103− if (dashContent.parent == scopesOverviewXYScaler) {
98+ if (currentTab == 1) {
104− animateDashFromAll();
99+ animateDashFromAll(dashContent.currentScopeId);
105 }
100 }
106 hide();
101 hide();
107 }
102 }
@@ -111,11 +106,11 @@ Showable {
111 }
106 }
112 onAllFavoriteSelected: {
107 onAllFavoriteSelected: {
113 setCurrentScope(scopeId, false, false);
108 setCurrentScope(scopeId, false, false);
114− animateDashFromAll();
109+ animateDashFromAll(dashContent.currentScopeId);
115 hide();
110 hide();
116 }
111 }
117 onAllSelected: {
112 onAllSelected: {
118− showTemporaryScope(scopeId, pos, scopesOverview.allCardSize);
113+ showTemporaryScope(scopes.getScope(scopeId), pos, allCardSize);
119 }
114 }
120 onSearchSelected: {
115 onSearchSelected: {
121 var scopeIndex = filteredScopes.findFirst(Scopes.RoleId, scopeId);
116 var scopeIndex = filteredScopes.findFirst(Scopes.RoleId, scopeId);
@@ -126,63 +121,24 @@ Showable {
126 hide();
121 hide();
127 } else {
122 } else {
128 // Is not a favorite one
123 // Is not a favorite one
129− showTemporaryScope(scopeId, pos, size)
124+ showTemporaryScope(scopes.getScope(scopeId), pos, size)
130 }
125 }
131 }
126 }
132 function hide() {
127 function hide() {
133 overviewController.enableAnimation = true;
128 overviewController.enableAnimation = true;
134 overviewController.progress = 0;
129 overviewController.progress = 0;
135 }
130 }
136− function animateDashFromAll() {
137− var currentScopePos = scopesOverview.allScopeCardPosition(dashContent.currentScopeId);
138− if (currentScopePos) {
139− showDashFromPos(currentScopePos, scopesOverview.allCardSize);
140− } else {
141− console.log("Warning: Could not find Dash OverView All card position for scope", dashContent.currentScopeId);
142− }
143− }
144− function showDashFromPos(itemPos, itemSize) {
145− scopesOverviewXYScaler.scale = itemSize.width / scopesOverviewXYScaler.width;
146− scopesOverviewXYScaler.x = itemPos.x -(scopesOverviewXYScaler.width - scopesOverviewXYScaler.width * scopesOverviewXYScaler.scale) / 2;
147− scopesOverviewXYScaler.y = itemPos.y -(scopesOverviewXYScaler.height - scopesOverviewXYScaler.height * scopesOverviewXYScaler.scale) / 2;
148− overviewController.growingDashFromPos = true;
149− scopesOverviewXYScaler.scale = 1;
150− scopesOverviewXYScaler.x = 0;
151− scopesOverviewXYScaler.y = 0;
152− }
153− function showTemporaryScope(scopeId, itemPos, itemSize) {
154− scopeItem.scope = scopes.getScope(scopeId);
155− scopeItem.parent = scopesOverviewXYScaler;
156− scopesOverviewXYScaler.scale = itemSize.width / scopesOverviewXYScaler.width;
157− scopesOverviewXYScaler.x = itemPos.x -(scopesOverviewXYScaler.width - scopesOverviewXYScaler.width * scopesOverviewXYScaler.scale) / 2;
158− scopesOverviewXYScaler.y = itemPos.y -(scopesOverviewXYScaler.height - scopesOverviewXYScaler.height * scopesOverviewXYScaler.scale) / 2;
159− overviewController.showingNonFavoriteScope = true;
160− overviewController.allScopePosition = itemPos;
161− overviewController.allScopeSize = itemSize;
162− scopesOverview.overrideOpacity = 0;
163− scopesOverviewXYScaler.scale = 1;
164− scopesOverviewXYScaler.x = 0;
165− scopesOverviewXYScaler.y = 0;
166− }
167 }
131 }
168
132
169 DashContent {
133 DashContent {
170 id: dashContent
134 id: dashContent
171− parent: {
172− if (overviewController.progress == 0) {
135+ parent: overviewController.progress == 0 ? dash : scopesOverview.dashItemEater
173− return dash;
174− } else if (scopesOverview.dashItemEater) {
175− return scopesOverview.dashItemEater;
176− } else {
177− return scopesOverviewXYScaler;
178− }
179− }
180 objectName: "dashContent"
136 objectName: "dashContent"
181 width: dash.width
137 width: dash.width
182 height: dash.height
138 height: dash.height
183 model: filteredScopes
139 model: filteredScopes
184 scopes: scopes
140 scopes: scopes
185− visible: !overviewController.showingNonFavoriteScope && x != -width
141+ visible: !scopesOverview.showingNonFavoriteScope && x != -width
186 onGotoScope: {
142 onGotoScope: {
187 dash.setCurrentScope(scopeId, true, false);
143 dash.setCurrentScope(scopeId, true, false);
188 }
144 }
@@ -210,7 +166,7 @@ Showable {
210 }
166 }
211
167
212 enabled: opacity == 1
168 enabled: opacity == 1
213− opacity: overviewController.growingDashFromPos ? 1 : 1 - overviewController.progress
169+ opacity: scopesOverview.growingDashFromPos ? 1 : 1 - overviewController.progress
214 }
170 }
215
171
216 DashBackground
172 DashBackground
@@ -223,8 +179,7 @@ Showable {
223 GenericScopeView {
179 GenericScopeView {
224 id: scopeItem
180 id: scopeItem
225
181
226− x: overviewController.showingNonFavoriteScope ? 0 : width + dashContent.x
182+ anchors.left: dashContent.right
227− z: 1
228 width: parent.width
183 width: parent.width
229 height: parent.height
184 height: parent.height
230 scale: dash.contentScale
185 scale: dash.contentScale
@@ -233,16 +188,8 @@ Showable {
233 hasBackAction: true
188 hasBackAction: true
234 isCurrent: visible
189 isCurrent: visible
235 onBackClicked: {
190 onBackClicked: {
236− if (overviewController.showingNonFavoriteScope) {
237− var v = overviewController.allScopeSize.width / scopeItem.width;
238− scopesOverviewXYScaler.scale = v;
239− scopesOverviewXYScaler.x = overviewController.allScopePosition.x -(scopeItem.width - scopeItem.width * v) / 2;
240− scopesOverviewXYScaler.y = overviewController.allScopePosition.y -(scopeItem.height - scopeItem.height * v) / 2;
241− scopesOverview.overrideOpacity = -1;
242− } else {
243− closeOverlayScope();
191+ closeOverlayScope();
244− closePreview();
192+ closePreview();
245− }
246 }
193 }
247
194
248 Connections {
195 Connections {
@@ -256,44 +203,6 @@ Showable {
256 }
203 }
257 }
204 }
258
205
259− Item {
260− id: scopesOverviewXYScaler
261− width: parent.width
262− height: parent.height
263−
264− clip: scale != 1.0
265− enabled: scale == 1
266− opacity: scale
267−
268− property bool animationsEnabled: overviewController.showingNonFavoriteScope || overviewController.growingDashFromPos
269−
270− Behavior on x {
271− enabled: scopesOverviewXYScaler.animationsEnabled
272− UbuntuNumberAnimation { }
273− }
274− Behavior on y {
275− enabled: scopesOverviewXYScaler.animationsEnabled
276− UbuntuNumberAnimation { }
277− }
278−
279− Behavior on scale {
280− enabled: scopesOverviewXYScaler.animationsEnabled
281− UbuntuNumberAnimation {
282− onRunningChanged: {
283− if (!running) {
284− if (overviewController.showingNonFavoriteScope && scopesOverviewXYScaler.scale != 1) {
285− overviewController.showingNonFavoriteScope = false;
286− scopeItem.scope = null;
287− scopeItem.parent = dash;
288− } else if (overviewController.growingDashFromPos) {
289− overviewController.growingDashFromPos = false;
290− }
291− }
292− }
293− }
294− }
295− }
296−
297 EdgeDragArea {
206 EdgeDragArea {
298 id: overviewDragHandle
207 id: overviewDragHandle
299 z: 1
208 z: 1
qml/Dash/ScopesOverview.qml+142−24
@@ -21,25 +21,24 @@ import "../Components"
21Item {
21Item {
22 id: root
22 id: root
23
23
24+ // Properties passed by parent
24 property real progress: 0
25 property real progress: 0
25 property var scope: null
26 property var scope: null
26− property bool forceDisableDashEater: false
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
27− property var dashItemEater: {
34+ readonly property var dashItemEater: {
28− if (!forceDisableDashEater && tabBar.currentTab == 0 && middleItems.count > 0) {
35+ if (!forceXYScalerEater && tabBar.currentTab == 0 && middleItems.count > 0) {
29 var loaderItem = middleItems.itemAt(0).item;
36 var loaderItem = middleItems.itemAt(0).item;
30 return loaderItem && loaderItem.currentItem ? loaderItem.currentItem : null;
37 return loaderItem && loaderItem.currentItem ? loaderItem.currentItem : null;
31 }
38 }
32− return null;
39+ return scopesOverviewXYScaler;
33 }
40 }
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: {
43 if (middleItems.count > 1) {
42 if (middleItems.count > 1) {
44 var loaderItem = middleItems.itemAt(1).item;
43 var loaderItem = middleItems.itemAt(1).item;
45 if (loaderItem) {
44 if (loaderItem) {
@@ -50,12 +49,57 @@ Item {
50 return Qt.size(0, 0);
49 return Qt.size(0, 0);
51 }
50 }
52
51
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+
53 signal done()
61 signal done()
54 signal favoriteSelected(int index)
62 signal favoriteSelected(int index)
55 signal allFavoriteSelected(var scopeId)
63 signal allFavoriteSelected(var scopeId)
56 signal allSelected(var scopeId, var pos)
64 signal allSelected(var scopeId, var pos)
57 signal searchSelected(var scopeId, var pos, var size)
65 signal searchSelected(var scopeId, var pos, var size)
58
66
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+
59 function allScopeCardPosition(scopeId) {
103 function allScopeCardPosition(scopeId) {
60 if (middleItems.count > 1) {
104 if (middleItems.count > 1) {
61 var loaderItem = middleItems.itemAt(1).item;
105 var loaderItem = middleItems.itemAt(1).item;
@@ -89,11 +133,11 @@ Item {
89 // Need this in order, otherwise something gets unhappy in rendering
133 // Need this in order, otherwise something gets unhappy in rendering
90 // of the overlay in carousels because the parent of the dash dies for
134 // of the overlay in carousels because the parent of the dash dies for
91 // a moment, this way we make sure it's reparented first
135 // a moment, this way we make sure it's reparented first
92− // by forceDisableDashEater making dashItemEater return null and
136+ // by forceXYScalerEater making dashItemEater return scopesOverviewXYScaler
93− // then really kill the parent by updating scope.searchQuery
137+ // before we kill the previous parent by scope.searchQuery
94− root.forceDisableDashEater = true;
138+ root.forceXYScalerEater = true;
95 root.scope.searchQuery = pageHeader.searchQuery;
139 root.scope.searchQuery = pageHeader.searchQuery;
96− root.forceDisableDashEater = false;
140+ root.forceXYScalerEater = false;
97 }
141 }
98 }
142 }
99
143
@@ -107,11 +151,13 @@ Item {
107 PageHeader {
151 PageHeader {
108 id: pageHeader
152 id: pageHeader
109
153
154+ readonly property real yDisplacement: pageHeader.height + tabBar.height + tabBar.anchors.margins
155+
110 y: {
156 y: {
111 if (root.progress < 0.5) {
157 if (root.progress < 0.5) {
112− return -height;
158+ return -yDisplacement;
113 } else {
159 } else {
114− return -height + (root.progress - 0.5) * height * 2;
160+ return -yDisplacement + (root.progress - 0.5) * yDisplacement * 2;
115 }
161 }
116 }
162 }
117 width: parent.width
163 width: parent.width
@@ -135,11 +181,12 @@ Item {
135
181
136 enabled: opacity == 1
182 enabled: opacity == 1
137 opacity: !scope || scope.searchQuery == "" ? 1 : 0
183 opacity: !scope || scope.searchQuery == "" ? 1 : 0
138− Behavior on opacity { UbuntuNumberAnimation {} }
184+ Behavior on opacity { UbuntuNumberAnimation { } }
139 }
185 }
140
186
141 Repeater {
187 Repeater {
142 id: middleItems
188 id: middleItems
189+ property real overrideOpacity: -1
143 model: scope && scope.searchQuery == "" ? scope.categories : null
190 model: scope && scope.searchQuery == "" ? scope.categories : null
144 delegate: Loader {
191 delegate: Loader {
145 id: loader
192 id: loader
@@ -172,8 +219,8 @@ Item {
172 scale: index == 0 ? scopeScale : 1
219 scale: index == 0 ? scopeScale : 1
173
220
174 opacity: {
221 opacity: {
175− if (root.overrideOpacity >= 0)
222+ if (middleItems.overrideOpacity >= 0)
176− return root.overrideOpacity;
223+ return middleItems.overrideOpacity;
177
224
178 if (tabBar.currentTab != index)
225 if (tabBar.currentTab != index)
179 return 0;
226 return 0;
@@ -255,9 +302,10 @@ Item {
255 showPageHeader: false
302 showPageHeader: false
256 clip: true
303 clip: true
257 opacity: searchResultsViewer.scope ? 1 : 0
304 opacity: searchResultsViewer.scope ? 1 : 0
258− Behavior on opacity { UbuntuNumberAnimation {} }
305+ Behavior on opacity { UbuntuNumberAnimation { } }
259
306
260 clickOverride: function (index, result, item, itemModel) {
307 clickOverride: function (index, result, item, itemModel) {
308+ // TODO Make sure pageheader suggestions popup is hidden
261 if (itemModel.scopeId) {
309 if (itemModel.scopeId) {
262 root.searchSelected(itemModel.scopeId, item.mapToItem(null, 0, 0), Qt.size(item.width, item.height));
310 root.searchSelected(itemModel.scopeId, item.mapToItem(null, 0, 0), Qt.size(item.width, item.height));
263 } else {
311 } else {
@@ -278,7 +326,7 @@ Item {
278 width: parent.width
326 width: parent.width
279 enabled: opacity == 0.4
327 enabled: opacity == 0.4
280 opacity: scope && scope.searchQuery == "" ? 0.4 : 0
328 opacity: scope && scope.searchQuery == "" ? 0.4 : 0
281− Behavior on opacity { UbuntuNumberAnimation {} }
329+ Behavior on opacity { UbuntuNumberAnimation { } }
282 y: {
330 y: {
283 if (root.progress < 0.5) {
331 if (root.progress < 0.5) {
284 return parent.height;
332 return parent.height;
@@ -323,4 +371,74 @@ Item {
323 height: parent.height
371 height: parent.height
324 anchors.left: scopesOverviewContent.right
372 anchors.left: scopesOverviewContent.right
325 }
373 }
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+ }
326}
444}