on xenial help sign in
Implement search click
b8f3f48Albert Astals
qml/Dash/Dash.qml+45−25
@@ -80,8 +80,9 @@ Showable {
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
82 property bool showingNonFavoriteScope: false
83− property bool growingDashFromAll: false
83+ property bool growingDashFromPos: false
84− property var allScopePosition: undefined
84+ property var allScopePosition
85+ property var allScopeSize
85 Behavior on progress {
86 Behavior on progress {
86 id: progressAnimation
87 id: progressAnimation
87 UbuntuNumberAnimation { }
88 UbuntuNumberAnimation { }
@@ -114,17 +115,19 @@ Showable {
114 hide();
115 hide();
115 }
116 }
116 onAllSelected: {
117 onAllSelected: {
117− scopeItem.scope = scopes.getScope(scopeId);
118+ showTemporaryScope(scopeId, pos, scopesOverview.allCardSize);
118− scopeItem.parent = scopesOverviewXYScaler;
119+ }
119− scopesOverviewXYScaler.scale = scopesOverview.allCardSize.width / scopesOverviewXYScaler.width;
120+ onSearchSelected: {
120− scopesOverviewXYScaler.x = pos.x -(scopesOverviewXYScaler.width - scopesOverviewXYScaler.width * scopesOverviewXYScaler.scale) / 2;
121+ var scopeIndex = filteredScopes.findFirst(Scopes.RoleId, scopeId);
121− scopesOverviewXYScaler.y = pos.y -(scopesOverviewXYScaler.height - scopesOverviewXYScaler.height * scopesOverviewXYScaler.scale) / 2;
122+ if (scopeIndex >= 0) {
122− overviewController.showingNonFavoriteScope = true;
123+ // Is a favorite one
123− overviewController.allScopePosition = pos;
124+ setCurrentScope(scopeId, false, false);
124− scopesOverview.overrideOpacity = 0;
125+ showDashFromPos(pos, size);
125− scopesOverviewXYScaler.scale = 1;
126+ hide();
126− scopesOverviewXYScaler.x = 0;
127+ } else {
127− scopesOverviewXYScaler.y = 0;
128+ // Is not a favorite one
129+ showTemporaryScope(scopeId, pos, size)
130+ }
128 }
131 }
129 function hide() {
132 function hide() {
130 overviewController.enableAnimation = true;
133 overviewController.enableAnimation = true;
@@ -133,17 +136,34 @@ Showable {
133 function animateDashFromAll() {
136 function animateDashFromAll() {
134 var currentScopePos = scopesOverview.allScopeCardPosition(dashContent.currentScopeId);
137 var currentScopePos = scopesOverview.allScopeCardPosition(dashContent.currentScopeId);
135 if (currentScopePos) {
138 if (currentScopePos) {
136− scopesOverviewXYScaler.scale = scopesOverview.allCardSize.width / scopesOverviewXYScaler.width;
139+ showDashFromPos(currentScopePos, scopesOverview.allCardSize);
137− scopesOverviewXYScaler.x = currentScopePos.x -(scopesOverviewXYScaler.width - scopesOverviewXYScaler.width * scopesOverviewXYScaler.scale) / 2;
138− scopesOverviewXYScaler.y = currentScopePos.y -(scopesOverviewXYScaler.height - scopesOverviewXYScaler.height * scopesOverviewXYScaler.scale) / 2;
139− overviewController.growingDashFromAll = true;
140− scopesOverviewXYScaler.scale = 1;
141− scopesOverviewXYScaler.x = 0;
142− scopesOverviewXYScaler.y = 0;
143 } else {
140 } else {
144 console.log("Warning: Could not find Dash OverView All card position for scope", dashContent.currentScopeId);
141 console.log("Warning: Could not find Dash OverView All card position for scope", dashContent.currentScopeId);
145 }
142 }
146 }
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+ }
147 }
167 }
148
168
149 DashContent {
169 DashContent {
@@ -190,7 +210,7 @@ Showable {
190 }
210 }
191
211
192 enabled: opacity == 1
212 enabled: opacity == 1
193− opacity: overviewController.growingDashFromAll ? 1 : 1 - overviewController.progress
213+ opacity: overviewController.growingDashFromPos ? 1 : 1 - overviewController.progress
194 }
214 }
195
215
196 DashBackground
216 DashBackground
@@ -214,7 +234,7 @@ Showable {
214 isCurrent: visible
234 isCurrent: visible
215 onBackClicked: {
235 onBackClicked: {
216 if (overviewController.showingNonFavoriteScope) {
236 if (overviewController.showingNonFavoriteScope) {
217− var v = scopesOverview.allCardSize.width / scopeItem.width;
237+ var v = overviewController.allScopeSize.width / scopeItem.width;
218 scopesOverviewXYScaler.scale = v;
238 scopesOverviewXYScaler.scale = v;
219 scopesOverviewXYScaler.x = overviewController.allScopePosition.x -(scopeItem.width - scopeItem.width * v) / 2;
239 scopesOverviewXYScaler.x = overviewController.allScopePosition.x -(scopeItem.width - scopeItem.width * v) / 2;
220 scopesOverviewXYScaler.y = overviewController.allScopePosition.y -(scopeItem.height - scopeItem.height * v) / 2;
240 scopesOverviewXYScaler.y = overviewController.allScopePosition.y -(scopeItem.height - scopeItem.height * v) / 2;
@@ -245,7 +265,7 @@ Showable {
245 enabled: scale == 1
265 enabled: scale == 1
246 opacity: scale
266 opacity: scale
247
267
248− property bool animationsEnabled: overviewController.showingNonFavoriteScope || overviewController.growingDashFromAll
268+ property bool animationsEnabled: overviewController.showingNonFavoriteScope || overviewController.growingDashFromPos
249
269
250 Behavior on x {
270 Behavior on x {
251 enabled: scopesOverviewXYScaler.animationsEnabled
271 enabled: scopesOverviewXYScaler.animationsEnabled
@@ -265,8 +285,8 @@ Showable {
265 overviewController.showingNonFavoriteScope = false;
285 overviewController.showingNonFavoriteScope = false;
266 scopeItem.scope = null;
286 scopeItem.scope = null;
267 scopeItem.parent = dash;
287 scopeItem.parent = dash;
268− } else if (overviewController.growingDashFromAll) {
288+ } else if (overviewController.growingDashFromPos) {
269− overviewController.growingDashFromAll = false;
289+ overviewController.growingDashFromPos = false;
270 }
290 }
271 }
291 }
272 }
292 }
qml/Dash/GenericScopeView.qml+12
@@ -34,6 +34,8 @@ FocusScope {
34 property bool enableHeightBehaviorOnNextCreation: false
34 property bool enableHeightBehaviorOnNextCreation: false
35 property var categoryView: categoryView
35 property var categoryView: categoryView
36 property bool showPageHeader: true
36 property bool showPageHeader: true
37+ property var clickOverride: null
38+ property var pressAndHoldOverride: null
37 readonly property alias previewShown: previewListView.open
39 readonly property alias previewShown: previewListView.open
38
40
39 property var scopeStyle: ScopeStyle {
41 property var scopeStyle: ScopeStyle {
@@ -197,6 +199,11 @@ FocusScope {
197 Connections {
199 Connections {
198 target: rendererLoader.item
200 target: rendererLoader.item
199 onClicked: {
201 onClicked: {
202+ if (scopeView.clickOverride) {
203+ scopeView.clickOverride(index, result, item, itemModel);
204+ return;
205+ }
206+
200 if (scopeView.scope.id === "scopes" || scopeView.scope.id == "clickscope") {
207 if (scopeView.scope.id === "scopes" || scopeView.scope.id == "clickscope") {
201 // TODO Technically it is possible that calling activate() will make the scope emit
208 // TODO Technically it is possible that calling activate() will make the scope emit
202 // previewRequested so that we show a preview but there's no scope that does that yet
209 // previewRequested so that we show a preview but there's no scope that does that yet
@@ -210,6 +217,11 @@ FocusScope {
210 }
217 }
211 }
218 }
212 onPressAndHold: {
219 onPressAndHold: {
220+ if (scopeView.pressAndHoldOverride) {
221+ scopeView.pressAndHoldOverride(index);
222+ return;
223+ }
224+
213 previewListView.model = target.model;
225 previewListView.model = target.model;
214 previewListView.currentIndex = -1
226 previewListView.currentIndex = -1
215 previewListView.currentIndex = index;
227 previewListView.currentIndex = index;
qml/Dash/ScopesOverview.qml+28−6
@@ -23,8 +23,9 @@ Item {
23
23
24 property real progress: 0
24 property real progress: 0
25 property var scope: null
25 property var scope: null
26+ property bool forceDisableDashEater: false
26 property var dashItemEater: {
27 property var dashItemEater: {
27− if (tabBar.currentTab == 0 && middleItems.count > 0) {
28+ if (!forceDisableDashEater && tabBar.currentTab == 0 && middleItems.count > 0) {
28 var loaderItem = middleItems.itemAt(0).item;
29 var loaderItem = middleItems.itemAt(0).item;
29 return loaderItem && loaderItem.currentItem ? loaderItem.currentItem : null;
30 return loaderItem && loaderItem.currentItem ? loaderItem.currentItem : null;
30 }
31 }
@@ -53,6 +54,7 @@ Item {
53 signal favoriteSelected(int index)
54 signal favoriteSelected(int index)
54 signal allFavoriteSelected(var scopeId)
55 signal allFavoriteSelected(var scopeId)
55 signal allSelected(var scopeId, var pos)
56 signal allSelected(var scopeId, var pos)
57+ signal searchSelected(var scopeId, var pos, var size)
56
58
57 function allScopeCardPosition(scopeId) {
59 function allScopeCardPosition(scopeId) {
58 if (middleItems.count > 1) {
60 if (middleItems.count > 1) {
@@ -67,6 +69,7 @@ Item {
67 onProgressChanged: {
69 onProgressChanged: {
68 if (progress == 0) {
70 if (progress == 0) {
69 tabBar.currentTab = 0;
71 tabBar.currentTab = 0;
72+ pageHeader.searchQuery = "";
70 }
73 }
71 }
74 }
72
75
@@ -79,10 +82,18 @@ Item {
79 }
82 }
80 }
83 }
81
84
82− Binding {
85+ Connections {
83− target: root.scope
86+ target: pageHeader
84− property: "searchQuery"
87+ onSearchQueryChanged: {
88+ // Need this in order, otherwise something gets unhappy in rendering
89+ // of the overlay in carousels because the parent of the dash dies for
90+ // a moment, this way we make sure it's reparented first
91+ // by forceDisableDashEater making dashItemEater return null and
92+ // then really kill the parent by updating scope.searchQuery
93+ root.forceDisableDashEater = true;
85− value: pageHeader.searchQuery
94+ root.scope.searchQuery = pageHeader.searchQuery;
95+ root.forceDisableDashEater = false;
96+ }
86 }
97 }
87
98
88 Item {
99 Item {
@@ -245,7 +256,18 @@ Item {
245 opacity: searchResultsViewer.scope ? 1 : 0
256 opacity: searchResultsViewer.scope ? 1 : 0
246 Behavior on opacity { UbuntuNumberAnimation {} }
257 Behavior on opacity { UbuntuNumberAnimation {} }
247
258
248− // TODO Do something when people click on search results
259+ clickOverride: function (index, result, item, itemModel) {
260+ if (itemModel.scopeId) {
261+ root.searchSelected(itemModel.scopeId, item.mapToItem(null, 0, 0), Qt.size(item.width, item.height));
262+ } else {
263+ // Not a scope, just activate it
264+ searchResultsViewer.scope.activate(result);
265+ }
266+ }
267+
268+ pressAndHoldOverride: function (index) {
269+ // Do nothing
270+ }
249 }
271 }
250
272
251 Rectangle {
273 Rectangle {