on xenial help sign in
Implement search click

The fake scope still doesn't provide valid scopes results in search, been tested manually commenting the code Will make tryDash able to test it next

commitb8f3f489abdd8f5821c3a8b1b9127608a5763466 authorAlbert Astals <albert.astals@canonical.com> dateThu 17 Jul 2014, 11:52 (12 years ago) parentc0e1f1c
3 files changed+85−31
qml/Dash/Dash.qml+45−25 qml/Dash/GenericScopeView.qml+12 qml/Dash/ScopesOverview.qml+28−6
qml/Dash/Dash.qml+45−25
@@ -80,8 +80,9 @@ Showable {
8080 property alias enableAnimation: progressAnimation.enabled
8181 property real progress: 0
8282 property bool showingNonFavoriteScope: false
83− property bool growingDashFromAll: false
84− property var allScopePosition: undefined
83+ property bool growingDashFromPos: false
84+ property var allScopePosition
85+ property var allScopeSize
8586 Behavior on progress {
8687 id: progressAnimation
8788 UbuntuNumberAnimation { }
@@ -114,17 +115,19 @@ Showable {
114115 hide();
115116 }
116117 onAllSelected: {
117− scopeItem.scope = scopes.getScope(scopeId);
118− scopeItem.parent = scopesOverviewXYScaler;
119− scopesOverviewXYScaler.scale = scopesOverview.allCardSize.width / scopesOverviewXYScaler.width;
120− scopesOverviewXYScaler.x = pos.x -(scopesOverviewXYScaler.width - scopesOverviewXYScaler.width * scopesOverviewXYScaler.scale) / 2;
121− scopesOverviewXYScaler.y = pos.y -(scopesOverviewXYScaler.height - scopesOverviewXYScaler.height * scopesOverviewXYScaler.scale) / 2;
122− overviewController.showingNonFavoriteScope = true;
123− overviewController.allScopePosition = pos;
124− scopesOverview.overrideOpacity = 0;
125− scopesOverviewXYScaler.scale = 1;
126− scopesOverviewXYScaler.x = 0;
127− scopesOverviewXYScaler.y = 0;
118+ showTemporaryScope(scopeId, pos, scopesOverview.allCardSize);
119+ }
120+ onSearchSelected: {
121+ var scopeIndex = filteredScopes.findFirst(Scopes.RoleId, scopeId);
122+ if (scopeIndex >= 0) {
123+ // Is a favorite one
124+ setCurrentScope(scopeId, false, false);
125+ showDashFromPos(pos, size);
126+ hide();
127+ } else {
128+ // Is not a favorite one
129+ showTemporaryScope(scopeId, pos, size)
130+ }
128131 }
129132 function hide() {
130133 overviewController.enableAnimation = true;
@@ -133,17 +136,34 @@ Showable {
133136 function animateDashFromAll() {
134137 var currentScopePos = scopesOverview.allScopeCardPosition(dashContent.currentScopeId);
135138 if (currentScopePos) {
136− scopesOverviewXYScaler.scale = scopesOverview.allCardSize.width / scopesOverviewXYScaler.width;
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;
139+ showDashFromPos(currentScopePos, scopesOverview.allCardSize);
143140 } else {
144141 console.log("Warning: Could not find Dash OverView All card position for scope", dashContent.currentScopeId);
145142 }
146143 }
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+ }
147167 }
148168
149169 DashContent {
@@ -190,7 +210,7 @@ Showable {
190210 }
191211
192212 enabled: opacity == 1
193− opacity: overviewController.growingDashFromAll ? 1 : 1 - overviewController.progress
213+ opacity: overviewController.growingDashFromPos ? 1 : 1 - overviewController.progress
194214 }
195215
196216 DashBackground
@@ -214,7 +234,7 @@ Showable {
214234 isCurrent: visible
215235 onBackClicked: {
216236 if (overviewController.showingNonFavoriteScope) {
217− var v = scopesOverview.allCardSize.width / scopeItem.width;
237+ var v = overviewController.allScopeSize.width / scopeItem.width;
218238 scopesOverviewXYScaler.scale = v;
219239 scopesOverviewXYScaler.x = overviewController.allScopePosition.x -(scopeItem.width - scopeItem.width * v) / 2;
220240 scopesOverviewXYScaler.y = overviewController.allScopePosition.y -(scopeItem.height - scopeItem.height * v) / 2;
@@ -245,7 +265,7 @@ Showable {
245265 enabled: scale == 1
246266 opacity: scale
247267
248− property bool animationsEnabled: overviewController.showingNonFavoriteScope || overviewController.growingDashFromAll
268+ property bool animationsEnabled: overviewController.showingNonFavoriteScope || overviewController.growingDashFromPos
249269
250270 Behavior on x {
251271 enabled: scopesOverviewXYScaler.animationsEnabled
@@ -265,8 +285,8 @@ Showable {
265285 overviewController.showingNonFavoriteScope = false;
266286 scopeItem.scope = null;
267287 scopeItem.parent = dash;
268− } else if (overviewController.growingDashFromAll) {
269− overviewController.growingDashFromAll = false;
288+ } else if (overviewController.growingDashFromPos) {
289+ overviewController.growingDashFromPos = false;
270290 }
271291 }
272292 }
qml/Dash/GenericScopeView.qml+12
@@ -34,6 +34,8 @@ FocusScope {
3434 property bool enableHeightBehaviorOnNextCreation: false
3535 property var categoryView: categoryView
3636 property bool showPageHeader: true
37+ property var clickOverride: null
38+ property var pressAndHoldOverride: null
3739 readonly property alias previewShown: previewListView.open
3840
3941 property var scopeStyle: ScopeStyle {
@@ -197,6 +199,11 @@ FocusScope {
197199 Connections {
198200 target: rendererLoader.item
199201 onClicked: {
202+ if (scopeView.clickOverride) {
203+ scopeView.clickOverride(index, result, item, itemModel);
204+ return;
205+ }
206+
200207 if (scopeView.scope.id === "scopes" || scopeView.scope.id == "clickscope") {
201208 // TODO Technically it is possible that calling activate() will make the scope emit
202209 // previewRequested so that we show a preview but there's no scope that does that yet
@@ -210,6 +217,11 @@ FocusScope {
210217 }
211218 }
212219 onPressAndHold: {
220+ if (scopeView.pressAndHoldOverride) {
221+ scopeView.pressAndHoldOverride(index);
222+ return;
223+ }
224+
213225 previewListView.model = target.model;
214226 previewListView.currentIndex = -1
215227 previewListView.currentIndex = index;
qml/Dash/ScopesOverview.qml+28−6
@@ -23,8 +23,9 @@ Item {
2323
2424 property real progress: 0
2525 property var scope: null
26+ property bool forceDisableDashEater: false
2627 property var dashItemEater: {
27− if (tabBar.currentTab == 0 && middleItems.count > 0) {
28+ if (!forceDisableDashEater && tabBar.currentTab == 0 && middleItems.count > 0) {
2829 var loaderItem = middleItems.itemAt(0).item;
2930 return loaderItem && loaderItem.currentItem ? loaderItem.currentItem : null;
3031 }
@@ -53,6 +54,7 @@ Item {
5354 signal favoriteSelected(int index)
5455 signal allFavoriteSelected(var scopeId)
5556 signal allSelected(var scopeId, var pos)
57+ signal searchSelected(var scopeId, var pos, var size)
5658
5759 function allScopeCardPosition(scopeId) {
5860 if (middleItems.count > 1) {
@@ -67,6 +69,7 @@ Item {
6769 onProgressChanged: {
6870 if (progress == 0) {
6971 tabBar.currentTab = 0;
72+ pageHeader.searchQuery = "";
7073 }
7174 }
7275
@@ -79,10 +82,18 @@ Item {
7982 }
8083 }
8184
82− Binding {
83− target: root.scope
84− property: "searchQuery"
85− value: pageHeader.searchQuery
85+ Connections {
86+ target: pageHeader
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;
94+ root.scope.searchQuery = pageHeader.searchQuery;
95+ root.forceDisableDashEater = false;
96+ }
8697 }
8798
8899 Item {
@@ -245,7 +256,18 @@ Item {
245256 opacity: searchResultsViewer.scope ? 1 : 0
246257 Behavior on opacity { UbuntuNumberAnimation {} }
247258
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+ }
249271 }
250272
251273 Rectangle {