on xenial help sign in
Implement search
3a12793Albert Astals
qml/Components/PageHeader.qml+1−1
@@ -24,7 +24,7 @@ import "SearchHistoryModel"
24Item {
24Item {
25 id: root
25 id: root
26 objectName: "pageHeader"
26 objectName: "pageHeader"
27− implicitHeight: headerContainer.height + units.gu(2) + bottomContainer.height
27+ implicitHeight: headerContainer.height + bottomContainer.height + (showSignatureLine ? units.gu(2) : 0)
28
28
29 property bool showBackButton: false
29 property bool showBackButton: false
30 property string title
30 property string title
qml/Dash/Dash.qml+1−1
@@ -278,7 +278,7 @@ Showable {
278 z: 1
278 z: 1
279 direction: Direction.Upwards
279 direction: Direction.Upwards
280 // TODO this needs to be disabled in a few more cases
280 // TODO this needs to be disabled in a few more cases
281− enabled: !dashContent.previewShown && dashContent.currentScope.searchQuery == "" && (overviewController.progress == 0 || dragging)
281+ enabled: !dashContent.previewShown && dashContent.currentScope && dashContent.currentScope.searchQuery == "" && (overviewController.progress == 0 || dragging)
282
282
283 readonly property real fullMovement: units.gu(20)
283 readonly property real fullMovement: units.gu(20)
284
284
qml/Dash/GenericScopeView.qml+34−23
@@ -33,6 +33,7 @@ FocusScope {
33 property bool hasBackAction: false
33 property bool hasBackAction: false
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 readonly property alias previewShown: previewListView.open
37 readonly property alias previewShown: previewListView.open
37
38
38 property var scopeStyle: ScopeStyle {
39 property var scopeStyle: ScopeStyle {
@@ -79,22 +80,24 @@ FocusScope {
79 }
80 }
80
81
81 onIsCurrentChanged: {
82 onIsCurrentChanged: {
83+ if (showPageHeader) {
82− pageHeader.resetSearch();
84+ pageHeaderLoader.item.resetSearch();
85+ }
83 previewListView.open = false;
86 previewListView.open = false;
84 }
87 }
85
88
86 Binding {
89 Binding {
87 target: scopeView.scope
90 target: scopeView.scope
88 property: "searchQuery"
91 property: "searchQuery"
89− value: pageHeader.searchQuery
92+ value: pageHeaderLoader.item.searchQuery
90− when: isCurrent
93+ when: isCurrent && showPageHeader
91 }
94 }
92
95
93 Binding {
96 Binding {
94− target: pageHeader
97+ target: pageHeaderLoader.item
95 property: "searchQuery"
98 property: "searchQuery"
96 value: scopeView.scope ? scopeView.scope.searchQuery : ""
99 value: scopeView.scope ? scopeView.scope.searchQuery : ""
97− when: isCurrent
100+ when: isCurrent && showPageHeader
98 }
101 }
99
102
100 Connections {
103 Connections {
@@ -330,26 +333,34 @@ FocusScope {
330 }
333 }
331 }
334 }
332
335
333− pageHeader: PageHeader {
336+ pageHeader: scopeView.showPageHeader ? pageHeaderLoader : null
334− id: pageHeader
337+ Loader {
335− objectName: "scopePageHeader"
338+ id: pageHeaderLoader
336 width: parent.width
339 width: parent.width
340+ sourceComponent: scopeView.showPageHeader ? pageHeaderComponent : undefined
341+ Component {
342+ id: pageHeaderComponent
343+ PageHeader {
344+ objectName: "scopePageHeader"
345+ width: parent.width
337− title: scopeView.scope ? scopeView.scope.name : ""
346+ title: scopeView.scope ? scopeView.scope.name : ""
338− showBackButton: scopeView.hasBackAction
347+ showBackButton: scopeView.hasBackAction
339− searchEntryEnabled: true
348+ searchEntryEnabled: true
340− searchInProgress: scopeView.scope ? scopeView.scope.searchInProgress : false
349+ searchInProgress: scopeView.scope ? scopeView.scope.searchInProgress : false
341− scopeStyle: scopeView.scopeStyle
350+ scopeStyle: scopeView.scopeStyle
342−
351+
343− bottomItem: DashDepartments {
352+ bottomItem: DashDepartments {
344− scope: scopeView.scope
353+ scope: scopeView.scope
345− width: parent.width <= units.gu(60) ? parent.width : units.gu(40)
354+ width: parent.width <= units.gu(60) ? parent.width : units.gu(40)
346− anchors.right: parent.right
355+ anchors.right: parent.right
347− windowHeight: scopeView.height
356+ windowHeight: scopeView.height
348− windowWidth: scopeView.width
357+ windowWidth: scopeView.width
349− scopeStyle: scopeView.scopeStyle
358+ scopeStyle: scopeView.scopeStyle
350− }
359+ }
351
360
352− onBackClicked: scopeView.backClicked()
361+ onBackClicked: scopeView.backClicked()
362+ }
363+ }
353 }
364 }
354 }
365 }
355
366
qml/Dash/ScopesOverview.qml+40−19
@@ -26,7 +26,7 @@ Item {
26 property real progress: 0
26 property real progress: 0
27 property var scope: null
27 property var scope: null
28 property var dashItemEater: {
28 property var dashItemEater: {
29− if (tabBarHolder.currentTab == 0 && middleItems.count > 0) {
29+ if (tabBar.currentTab == 0 && middleItems.count > 0) {
30 var loaderItem = middleItems.itemAt(0).item;
30 var loaderItem = middleItems.itemAt(0).item;
31 return loaderItem && loaderItem.currentItem ? loaderItem.currentItem : null;
31 return loaderItem && loaderItem.currentItem ? loaderItem.currentItem : null;
32 }
32 }
@@ -38,6 +38,7 @@ Item {
38 property QtObject scopeStyle: QtObject {
38 property QtObject scopeStyle: QtObject {
39 property string headerLogo: ""
39 property string headerLogo: ""
40 property color foreground: "white"
40 property color foreground: "white"
41+ property color background: "transparent"
41 }
42 }
42 property size allCardSize: {
43 property size allCardSize: {
43 if (middleItems.count > 1) {
44 if (middleItems.count > 1) {
@@ -67,7 +68,7 @@ Item {
67
68
68 onProgressChanged: {
69 onProgressChanged: {
69 if (progress == 0) {
70 if (progress == 0) {
70− tabBarHolder.currentTab = 0;
71+ tabBar.currentTab = 0;
71 }
72 }
72 }
73 }
73
74
@@ -96,7 +97,7 @@ Item {
96 Item {
97 Item {
97 id: topBar
98 id: topBar
98 width: parent.width
99 width: parent.width
99− height: childrenRect.height
100+ height: pageHeader.height + (tabBar.opacity == 1 ? tabBar.height + tabBar.anchors.margins : 0)
100
101
101 y: {
102 y: {
102 if (root.progress < 0.5) {
103 if (root.progress < 0.5) {
@@ -118,7 +119,7 @@ Item {
118 }
119 }
119
120
120 ScopesOverviewTab {
121 ScopesOverviewTab {
121− id: tabBarHolder
122+ id: tabBar
122 anchors {
123 anchors {
123 left: parent.left
124 left: parent.left
124 right: parent.right
125 right: parent.right
@@ -126,27 +127,31 @@ Item {
126 margins: units.gu(2)
127 margins: units.gu(2)
127 }
128 }
128 height: units.gu(4)
129 height: units.gu(4)
130+
131+ enabled: opacity == 1
132+ opacity: !scope || scope.searchQuery == "" ? 1 : 0
133+ Behavior on opacity { }
129 }
134 }
130 }
135 }
131
136
132 Repeater {
137 Repeater {
133 id: middleItems
138 id: middleItems
134− model: scope ? scope.categories : null
139+ model: scope && scope.searchQuery == "" ? scope.categories : null
135 delegate: Loader {
140 delegate: Loader {
136 id: loader
141 id: loader
137
142
138 height: {
143 height: {
139 if (index == 0) {
144 if (index == 0) {
140− return parent.height;
145+ return root.height;
141 } else {
146 } else {
142− return parent.height - topBar.height - units.gu(2)
147+ return root.height - topBar.height - units.gu(2)
143 }
148 }
144 }
149 }
145 width: {
150 width: {
146 if (index == 0) {
151 if (index == 0) {
147− return parent.width / scopeScale
152+ return root.width / scopeScale
148 } else {
153 } else {
149− return parent.width
154+ return root.width
150 }
155 }
151 }
156 }
152 x: {
157 x: {
@@ -157,7 +162,7 @@ Item {
157 }
162 }
158 }
163 }
159 anchors {
164 anchors {
160− bottom: parent.bottom
165+ bottom: scopesOverviewContent.bottom
161 }
166 }
162
167
163 scale: index == 0 ? scopeScale : 1
168 scale: index == 0 ? scopeScale : 1
@@ -166,7 +171,7 @@ Item {
166 if (root.overrideOpacity >= 0)
171 if (root.overrideOpacity >= 0)
167 return root.overrideOpacity;
172 return root.overrideOpacity;
168
173
169− if (tabBarHolder.currentTab != index)
174+ if (tabBar.currentTab != index)
170 return 0;
175 return 0;
171
176
172 return index == 0 ? 1 : root.progress;
177 return index == 0 ? 1 : root.progress;
@@ -189,12 +194,9 @@ Item {
189 }
194 }
190
195
191 source: {
196 source: {
192− if (index == 0) return "ScopesOverviewFavourites.qml";
197+ if (index == 0 && categoryId == "favorites") return "ScopesOverviewFavorites.qml";
193− else if (index == 1) return "ScopesOverviewAll.qml";
198+ else if (index == 1 && categoryId == "all") return "ScopesOverviewAll.qml";
194− else {
195− console.log("WARNING: ScopesOverview scope is not supposed to have more than 2 categories");
196− return "";
199+ else return "";
197− }
198 }
200 }
199
201
200 onLoaded: {
202 onLoaded: {
@@ -213,7 +215,7 @@ Item {
213 Connections {
215 Connections {
214 target: loader.item
216 target: loader.item
215 onClicked: {
217 onClicked: {
216− if (tabBarHolder.currentTab == 0) {
218+ if (tabBar.currentTab == 0) {
217 root.favoriteSelected(index)
219 root.favoriteSelected(index)
218 } else {
220 } else {
219 var favoriteScopesItem = middleItems.itemAt(0).item;
221 var favoriteScopesItem = middleItems.itemAt(0).item;
@@ -235,12 +237,31 @@ Item {
235 }
237 }
236 }
238 }
237
239
240+ GenericScopeView {
241+ id: searchResultsViewer
242+ anchors {
243+ top: topBar.bottom
244+ right: parent.right
245+ left: parent.left
246+ bottom: parent.bottom
247+ }
248+ scope: root.scope && root.scope.searchQuery != "" ? root.scope : null
249+ scopeStyle: root.scopeStyle
250+ enabled: opacity == 1
251+ showPageHeader: false
252+ clip: true
253+ opacity: searchResultsViewer.scope ? 1 : 0
254+ Behavior on opacity { UbuntuNumberAnimation {} }
255+ }
256+
238 Rectangle {
257 Rectangle {
239 id: bottomBar
258 id: bottomBar
240 color: "black"
259 color: "black"
241 height: units.gu(6)
260 height: units.gu(6)
242 width: parent.width
261 width: parent.width
262+ enabled: opacity == 0.4
243− opacity: 0.4
263+ opacity: scope && scope.searchQuery == "" ? 0.4 : 0
264+ Behavior on opacity { UbuntuNumberAnimation {} }
244 y: {
265 y: {
245 if (root.progress < 0.5) {
266 if (root.progress < 0.5) {
246 return parent.height;
267 return parent.height;
qml/Dash/ScopesOverviewFavourites.qml → qml/Dash/ScopesOverviewFavorites.qmlrenamed

The content is the same.

qml/Dash/ScopesOverviewTab.qml+6−6
@@ -28,13 +28,13 @@ Item {
28 width: parent.width / 2
28 width: parent.width / 2
29 Rectangle {
29 Rectangle {
30 anchors.fill: parent
30 anchors.fill: parent
31− color: root.currentTab == 0 ? "white" : "transparent"
31+ color: root.currentTab == 0 && root.enabled ? "white" : "transparent"
32 radius: units.dp(10)
32 radius: units.dp(10)
33 }
33 }
34 Label {
34 Label {
35 anchors.centerIn: parent
35 anchors.centerIn: parent
36− text: i18n.tr("Favourites")
36+ text: i18n.tr("Favorites")
37− color: root.currentTab == 0 ? "black" : "white"
37+ color: root.currentTab == 0 && root.enabled ? "black" : "white"
38 }
38 }
39 onClicked: root.currentTab = 0
39 onClicked: root.currentTab = 0
40 }
40 }
@@ -45,19 +45,19 @@ Item {
45 width: parent.width / 2
45 width: parent.width / 2
46 Rectangle {
46 Rectangle {
47 anchors.fill: parent
47 anchors.fill: parent
48− color: root.currentTab == 1 ? "white" : "transparent"
48+ color: root.currentTab == 1 && root.enabled ? "white" : "transparent"
49 radius: units.dp(10)
49 radius: units.dp(10)
50 }
50 }
51 Label {
51 Label {
52 anchors.centerIn: parent
52 anchors.centerIn: parent
53 text: i18n.tr("All")
53 text: i18n.tr("All")
54− color: root.currentTab == 1 ? "black" : "white"
54+ color: root.currentTab == 1 && root.enabled ? "black" : "white"
55 }
55 }
56 onClicked: root.currentTab = 1
56 onClicked: root.currentTab = 1
57 }
57 }
58 Rectangle {
58 Rectangle {
59 id: centerPiece
59 id: centerPiece
60− width: units.dp(10)
60+ width: root.enabled ? units.dp(10) : units.dp(1)
61 height: parent.height
61 height: parent.height
62 color: "white"
62 color: "white"
63 x: root.currentTab == 1 ? tab2.x : tab2.x - width
63 x: root.currentTab == 1 ? tab2.x : tab2.x - width
tests/mocks/Unity/fake_scope.cpp+1
@@ -167,6 +167,7 @@ void Scope::cancelActivation()
167
167
168void Scope::closeScope(unity::shell::scopes::ScopeInterface* /*scope*/)
168void Scope::closeScope(unity::shell::scopes::ScopeInterface* /*scope*/)
169{
169{
170+ qFatal("Scope::closeScope is not implemented");
170}
171}
171
172
172QString Scope::currentDepartmentId() const
173QString Scope::currentDepartmentId() const
tests/mocks/Unity/fake_scopesoverview.cpp+15−9
@@ -23,16 +23,22 @@
23ScopesOverview::ScopesOverview(Scopes* parent)
23ScopesOverview::ScopesOverview(Scopes* parent)
24 : Scope("scopesOverview", "Scopes Overview", false, parent)
24 : Scope("scopesOverview", "Scopes Overview", false, parent)
25{
25{
26− delete m_categories;
26+ m_searchCategories = m_categories; // save the usual categories as search result
27− m_categories = new ScopesOverviewCategories(parent, this);
27+ m_scopesOverviewCategories = new ScopesOverviewCategories(parent, this);
28+ m_categories = m_scopesOverviewCategories;
28}
29}
29
30
30−void ScopesOverview::activate(QVariant const& result)
31+void ScopesOverview::setSearchQuery(const QString& search_query)
31{
32{
32− Scopes *scopes = dynamic_cast<Scopes*>(parent());
33+ Scope::setSearchQuery(search_query);
33− Q_EMIT openScope(scopes->getScope(result.toString()));
34+
34−}
35+ auto origCategories = m_categories;
36+ if (search_query.isEmpty()) m_categories = m_scopesOverviewCategories;
37+ else m_categories = m_searchCategories;
35
38
39+ if (m_categories != origCategories)
40+ Q_EMIT categoriesChanged();
41+}
36
42
37
43
38ScopesOverviewCategories::ScopesOverviewCategories(Scopes *scopes, QObject* parent)
44ScopesOverviewCategories::ScopesOverviewCategories(Scopes *scopes, QObject* parent)
@@ -71,9 +77,9 @@ ScopesOverviewCategories::data(const QModelIndex& index, int role) const
71 }
77 }
72 switch (role) {
78 switch (role) {
73 case RoleCategoryId:
79 case RoleCategoryId:
74− return index.row() == 0 ? "favourites" : "all";
80+ return index.row() == 0 ? "favorites" : "all";
75 case RoleName:
81 case RoleName:
76− return index.row() == 0 ? "Favourites" : "All";
82+ return index.row() == 0 ? "Favorites" : "All";
77 case RoleIcon:
83 case RoleIcon:
78 return QVariant();
84 return QVariant();
79 case RoleRawRendererTemplate:
85 case RoleRawRendererTemplate:
@@ -117,7 +123,7 @@ ScopesOverviewResultsModel::ScopesOverviewResultsModel(Scopes *scopes, bool isFa
117
123
118QString ScopesOverviewResultsModel::categoryId() const
124QString ScopesOverviewResultsModel::categoryId() const
119{
125{
120− return m_isFavoriteCategory ? "favourites" : "all";
126+ return m_isFavoriteCategory ? "favorites" : "all";
121}
127}
122
128
123void ScopesOverviewResultsModel::setCategoryId(QString const& /*id*/)
129void ScopesOverviewResultsModel::setCategoryId(QString const& /*id*/)
tests/mocks/Unity/fake_scopesoverview.h+5−1
@@ -29,7 +29,11 @@ class ScopesOverview : public Scope
29public:
29public:
30 ScopesOverview(Scopes* parent = 0);
30 ScopesOverview(Scopes* parent = 0);
31
31
32− Q_INVOKABLE void activate(QVariant const& result) override;
32+ void setSearchQuery(const QString& search_query) override;
33+
34+private:
35+ unity::shell::scopes::CategoriesInterface *m_scopesOverviewCategories;
36+ unity::shell::scopes::CategoriesInterface *m_searchCategories;
33};
37};
34
38
35class ScopesOverviewCategories : public unity::shell::scopes::CategoriesInterface
39class ScopesOverviewCategories : public unity::shell::scopes::CategoriesInterface