Merge lp:~stolowski/unity-2d/no-results-hint into lp:unity-2d

Proposed by Paweł Stołowski
Status: Merged
Approved by: Gerry Boland
Approved revision: 1014
Merged at revision: 1022
Proposed branch: lp:~stolowski/unity-2d/no-results-hint
Merge into: lp:unity-2d
Diff against target: 241 lines (+130/-0)
4 files modified
libunity-2d-private/src/lens.cpp (+30/-0)
libunity-2d-private/src/lens.h (+6/-0)
shell/dash/LensView.qml (+42/-0)
tests/dash/dash-tests.rb (+52/-0)
To merge this branch: bzr merge lp:~stolowski/unity-2d/no-results-hint
Reviewer Review Type Date Requested Status
Gerry Boland (community) Approve
Xi Zhu Pending
Review via email: mp+98472@code.launchpad.net

Commit message

[dash] Implemented support for no-results-hint. Hint message is now displayed in the dash if there were no search results for user query.

Description of the change

[dash] Implemented support for no-results-hint. Hint message is now displayed in the dash if there were no search results for user query.

To post a comment you must log in.
Revision history for this message
Paweł Stołowski (stolowski) wrote :

Here is a screenshot of no-progress-hint support in unity 2d: http://imgur.com/IxKCn

Revision history for this message
Paweł Stołowski (stolowski) wrote :

> Here is a screenshot of no-progress-hint support in unity 2d:
> http://imgur.com/IxKCn

I meant no-results-hint of course.

Revision history for this message
Xi Zhu (xi.zhu) wrote :

Hi, could you have a look at the font please? Is it in 17pt Ubuntu regular? It looks bolder than the mockup, and is the dimed "Filter results" missing on the top right corner? Thank you :)

Revision history for this message
Paweł Stołowski (stolowski) wrote :

Hi, are you sure it was 17pt on the mockup? I've set font to Ubuntu, size = 17 pixels, bold = false, but it still doesn't exactly match the mockup (but it's very close). And with size = 17pt it's bigger and bolder than mockup. Here is the new screenshot: http://i.imgur.com/X2e5D.png
'Filter results' in the top right corner is only visible on lenses other then 'Home'.

Revision history for this message
Florian Boucault (fboucault) wrote :

Please don't hardcode font sizes but use TextCustom.qml from common instead.
As for the font being bold it's a bug in Ubuntu: https://bugs.launchpad.net/ubuntu-font-family/+bug/744812

Revision history for this message
Paweł Stołowski (stolowski) wrote :

Changed to fontSize: "large" as suggested offline by Florian.

Revision history for this message
Michal Hruby (mhr3) wrote :

41 m_unityLens->search_finished.connect(sigc::mem_fun(this, &Lens::searchFinished));
42 m_unityLens->global_search_finished.connect(sigc::mem_fun(this, &Lens::globalSearchFinished));
43 + connect(this, SIGNAL(searchFinished(unity::dash::Lens::Hints const &)), SLOT(onSearchFinished(unity::dash::Lens::Hints const &)));
44 + connect(this, SIGNAL(globalSearchFinished(unity::dash::Lens::Hints const &)), SLOT(onSearchFinished(unity::dash::Lens::Hints const &)));

You probably don't need to connect to global_search_finished, since we have the HomeLens now which wraps around global searches (and emits standard search_finished), connecting to the global_search_finished is no longer relevant - moreover it will cause the callback to be called multiple times (for each lens doing global search) instead of just once when all the lenses finish searching.

Revision history for this message
Gerry Boland (gerboland) wrote :

Hi Pawel,
going for pixel perfection, can you move the text vertically to match the mock-up, see this comparison image I made:
http://ubuntuone.com/4m8iJRmwjae5fiXsJXsqf7

Comments:
+ UQ_DEBUG << "no-results-hint is" << m_noResultsHint;
is not really needed?

Also your test failed on me:
http://pastebin.ubuntu.com/900288/
because for some reason my Documents lens is not searching & always outputting the same data (so I can't test Home lens with zero results). Test looks fine, as I'm not sure how you can make that more robust.

review: Needs Fixing
Revision history for this message
Gerry Boland (gerboland) wrote :

Works great, thank you

review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

No commit message specified.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libunity-2d-private/src/lens.cpp'
2--- libunity-2d-private/src/lens.cpp 2012-02-16 11:24:19 +0000
3+++ libunity-2d-private/src/lens.cpp 2012-03-29 12:30:31 +0000
4@@ -22,6 +22,7 @@
5
6 // libunity-2d
7 #include <debug_p.h>
8+#include <unity2dtr.h>
9 #include "application.h"
10 #include "filters.h"
11
12@@ -126,6 +127,11 @@
13 {
14 return m_globalSearchQuery;
15 }
16+
17+QString Lens::noResultsHint() const
18+{
19+ return m_noResultsHint;
20+}
21
22 void Lens::setViewType(const Lens::ViewType& viewType)
23 {
24@@ -159,6 +165,13 @@
25 Q_EMIT globalSearchQueryChanged();
26 }
27 }
28+
29+void Lens::setNoResultsHint(const QString& hint) {
30+ if (hint != m_noResultsHint) {
31+ m_noResultsHint = hint;
32+ Q_EMIT noResultsHintChanged();
33+ }
34+}
35
36 void Lens::activate(const QString& uri)
37 {
38@@ -263,6 +276,7 @@
39 /* Signals forwarding */
40 m_unityLens->search_finished.connect(sigc::mem_fun(this, &Lens::searchFinished));
41 m_unityLens->global_search_finished.connect(sigc::mem_fun(this, &Lens::globalSearchFinished));
42+ connect(this, SIGNAL(searchFinished(unity::dash::Lens::Hints const &)), SLOT(onSearchFinished(unity::dash::Lens::Hints const &)));
43
44 /* FIXME: signal should be forwarded instead of calling the handler directly */
45 m_unityLens->activated.connect(sigc::mem_fun(this, &Lens::onActivated));
46@@ -321,5 +335,21 @@
47 {
48 Q_EMIT viewTypeChanged( (Lens::ViewType) viewType);
49 }
50+
51+void Lens::onSearchFinished(unity::dash::Lens::Hints const &hints)
52+{
53+ QString hint;
54+
55+ if (!m_unityLens->results()->count()) {
56+ unity::dash::Lens::Hints::const_iterator it = hints.find("no-results-hint");
57+ if (it != hints.end()) {
58+ hint = QString::fromStdString(it->second.GetString());
59+ } else {
60+ hint = u2dTr("Sorry, there is nothing that matches your search.");
61+ }
62+ }
63+
64+ setNoResultsHint(hint);
65+}
66
67 #include "lens.moc"
68
69=== modified file 'libunity-2d-private/src/lens.h'
70--- libunity-2d-private/src/lens.h 2011-12-14 22:45:04 +0000
71+++ libunity-2d-private/src/lens.h 2012-03-29 12:30:31 +0000
72@@ -59,6 +59,7 @@
73
74 Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)
75 Q_PROPERTY(QString globalSearchQuery READ globalSearchQuery WRITE setGlobalSearchQuery NOTIFY globalSearchQueryChanged)
76+ Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged)
77
78 public:
79 explicit Lens(QObject *parent = 0);
80@@ -88,11 +89,13 @@
81 Filters* filters() const;
82 QString searchQuery() const;
83 QString globalSearchQuery() const;
84+ QString noResultsHint() const;
85
86 /* setters */
87 void setViewType(const ViewType& viewType);
88 void setSearchQuery(const QString& search_query);
89 void setGlobalSearchQuery(const QString& search_query);
90+ void setNoResultsHint(const QString& hint);
91
92 Q_INVOKABLE void activate(const QString& uri);
93 void setUnityLens(unity::dash::Lens::Ptr lens);
94@@ -118,9 +121,11 @@
95 void globalSearchFinished(unity::dash::Lens::Hints const&);
96 void searchQueryChanged();
97 void globalSearchQueryChanged();
98+ void noResultsHintChanged();
99
100 private Q_SLOTS:
101 void synchronizeStates();
102+ void onSearchFinished(unity::dash::Lens::Hints const &);
103
104 private:
105 void onResultsSwarmNameChanged(std::string);
106@@ -140,6 +145,7 @@
107 DeeListModel* m_categories;
108 QString m_searchQuery;
109 QString m_globalSearchQuery;
110+ QString m_noResultsHint;
111 Filters* m_filters;
112 };
113
114
115=== modified file 'shell/dash/LensView.qml'
116--- shell/dash/LensView.qml 2012-03-13 20:29:15 +0000
117+++ shell/dash/LensView.qml 2012-03-29 12:30:31 +0000
118@@ -18,6 +18,7 @@
119
120 import QtQuick 1.0
121 import Unity2d 1.0
122+import "../common"
123 import "../common/utils.js" as Utils
124
125 FocusScope {
126@@ -66,6 +67,47 @@
127 dash.activateUriWithLens(model, uri, mimetype)
128 }
129
130+ /* Optional 'No results...' hint for lens search results.
131+ */
132+ TextCustom {
133+ id: noResultsText
134+ objectName: "noResultsText"
135+ fontSize: "large"
136+ color: "white"
137+ visible: lensView.model == undefined ? false : lensView.model.noResultsHint != ""
138+ text: lensView.model != undefined ? lensView.model.noResultsHint : ""
139+ anchors.centerIn: parent
140+ anchors.verticalCenterOffset: -6
141+
142+ Connections {
143+ target: lensView.model != undefined ? lensView.model : null
144+ onSearchQueryChanged: {
145+ if (noResultsText.visible) {
146+ hideNoResultHintAnimation.start()
147+ }
148+ }
149+
150+ onSearchFinished: {
151+ hideNoResultHintAnimation.stop();
152+ noResultsText.opacity = 1.0
153+ }
154+ }
155+
156+ Connections {
157+ target: lensView != undefined ? lensView : null
158+ onModelChanged: {
159+ lensView.model.noResultsHint = "";
160+ }
161+ }
162+
163+ SequentialAnimation {
164+ id: hideNoResultHintAnimation
165+ PropertyAction { target: noResultsText; property: "opacity"; value: 1.0 }
166+ PauseAnimation { duration: 150 }
167+ NumberAnimation { target: noResultsText; property: "opacity"; from: 1.0; to: 0; duration: 150; easing.type: Easing.InOutQuad }
168+ }
169+ }
170+
171 ListViewWithScrollbar {
172 id: results
173
174
175=== modified file 'tests/dash/dash-tests.rb'
176--- tests/dash/dash-tests.rb 2012-03-12 11:40:24 +0000
177+++ tests/dash/dash-tests.rb 2012-03-29 12:30:31 +0000
178@@ -7,6 +7,7 @@
179 *
180 * Authors:
181 * - Albert Astals Cid <albert.astals@canonical.com>
182+ * - Pawel Stolowski <pawel.stolowski@canonical.com>
183 *
184 * This program is free software; you can redistribute it and/or modify
185 * it under the terms of the GNU General Public License as published by
186@@ -436,4 +437,55 @@
187 @app.QDeclarativeLoader( { :objectName => "pageLoader" } )['activeFocus']
188 }
189 end
190+
191+ # Test case objectives:
192+ # * Check no-results-hint text is displayed in search yields no results
193+ # Pre-conditions
194+ # Test steps
195+ # * Invoke dash
196+ # * Verify there is no no-results-hint
197+ # * Type "qwqwqw" in the dash search entry
198+ # * Verify that the no-results-hint is displayed and its not empty
199+ # * Press Backspace 6 times to clear search entry
200+ # * Verify that hint is no longer visible
201+ # Post-conditions
202+ # * None
203+ # References
204+ # * https://bugs.launchpad.net/unity-2d/+bug/711199
205+ test "Check no-results-hint is displayed on no search results" do
206+ XDo::Keyboard.super
207+
208+ verify_equal("true", TIMEOUT, 'There should be a Dash declarative view after pressing Super') {
209+ @app.Dash()['active']
210+ }
211+
212+ verify_not(TIMEOUT, 'There should be no noResultsText hint') {
213+ @app.TextCustom( { :objectName => "noResultsText" } )
214+ }
215+
216+ 3.times {
217+ XDo::Keyboard.q
218+ XDo::Keyboard.w
219+ }
220+
221+ hint = {}
222+
223+ verify(TIMEOUT, 'There should be noResultsText hint') {
224+ hint = @app.TextCustom( { :objectName => "noResultsText" } )
225+ }
226+
227+ verify_true(TIMEOUT, 'Hint should contain a message and be visible') {
228+ hint['text'].length > 0 &&
229+ hint['opacity'].to_f > 0.9 &&
230+ hint['visible'] == "true"
231+ }
232+
233+ 6.times {
234+ XDo::Keyboard.simulate("{BS}")
235+ }
236+
237+ verify_not(TIMEOUT, 'There should be no noResultsText hint') {
238+ @app.TextCustom( { :objectName => "noResultsText" } )
239+ }
240+ end
241 end

Subscribers

People subscribed via source and target branches