Merge lp:~knitzsche/scope-aggregator/hints-dismiss-via-cannedquery-user-data into lp:scope-aggregator

Proposed by Kyle Nitzsche
Status: Merged
Merged at revision: 160
Proposed branch: lp:~knitzsche/scope-aggregator/hints-dismiss-via-cannedquery-user-data
Merge into: lp:scope-aggregator
Diff against target: 146 lines (+60/-19)
4 files modified
CMakeLists.txt (+1/-1)
include/query.h (+2/-2)
src/query.cpp (+51/-12)
src/utils.cpp (+6/-4)
To merge this branch: bzr merge lp:~knitzsche/scope-aggregator/hints-dismiss-via-cannedquery-user-data
Reviewer Review Type Date Requested Status
Gary.Wang Approve
Jin Pending
Zhang Enwei Pending
Review via email: mp+287373@code.launchpad.net

Description of the change

this MR is 1 of 2 needed to remove the problem of hints quickstart help using the query string to signal back to the agg scope not to show quickstart any more.

I found that we can use canned query's user_data to contain the signal and this can be retrieved inside the agg scope.

The other MR is against hints scope. And of course the agg scopes that use this feature (photos and today that I know of) will also need to be updated and released with these.

To post a comment you must log in.
Revision history for this message
Gary.Wang (gary-wzl77) wrote :

Looks good to me
Thanks.

P.S I was not aware that we have an api to handle this. I will make some code change to use user_data instead query_string, alongside with new features added or bug fixing.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2016-02-25 22:10:24 +0000
3+++ CMakeLists.txt 2016-02-26 22:05:20 +0000
4@@ -1,4 +1,4 @@
5-set(VERSION "4.3")
6+set(VERSION "4.3.1")
7
8 # Supress qDebug() output
9 ADD_DEFINITIONS( -DQT_NO_DEBUG_OUTPUT )
10
11=== modified file 'include/query.h'
12--- include/query.h 2015-12-01 08:56:26 +0000
13+++ include/query.h 2016-02-26 22:05:20 +0000
14@@ -201,14 +201,14 @@
15 bool uses_hints = false;
16 unity::scopes::ScopeProxy hints_scope;
17 bool hints_quickstart = false;
18- QString hints_is_hidden = "hints_is_hidden";
19+ QString hints_file = "hints_is_hidden";
20 QString firstboot = "firstboot";
21
22 void load_hints();
23 bool hints_exists();
24 void display_hints_quickstart(us::SearchReplyProxy const& upstream_reply_);
25 bool show_hints(us::SearchReplyProxy const& upstream_reply_);
26- bool is_hints_quickstart_dismissed();
27+ bool hints_hidden();
28 void dismiss_hints_quickstart();
29 std::string HINTS_SCOPE_ID;//fqn of hints scope
30 std::string HINTS_THIS_SCOPE;//tells hints which agg scope this is
31
32=== modified file 'src/query.cpp'
33--- src/query.cpp 2016-02-11 21:36:15 +0000
34+++ src/query.cpp 2016-02-26 22:05:20 +0000
35@@ -103,22 +103,61 @@
36
37 load_hints();
38
39+ bool hide_hints_quickstart = false;
40+
41 qDebug() << "==== HINTS. uses_hints" << uses_hints;
42 qDebug() << "==== HINTS. display_hints_on_firstuse" << hints_quickstart;
43 qDebug() << "==== HINTS. query_string" << qstr(query_string);
44
45- if (uses_hints && hints_quickstart && hints_exists() && query_string == HINTS_HIDE)
46- {
47- dismiss_hints_quickstart();
48- // when dismissing hints, query string must be set to "" to prevent subsearching
49- // child scopes.
50- query_string = "";
51- }
52-
53- if (uses_hints && hints_quickstart && hints_exists() && !is_hints_quickstart_dismissed())
54- {
55- display_hints_quickstart(upstream_reply);
56- return;
57+ // user data can show whether to hide hints quickstart
58+ if (query().has_user_data())
59+ {
60+ try
61+ {
62+ std::string data = query().user_data().get_string();
63+ if (data == "hide_quickstart")
64+ {
65+ hide_hints_quickstart = true;
66+ }
67+ } catch (unity::LogicException &e)
68+ {
69+ qWarning() << "=== HINTS. cannot get data from canned query";
70+ }
71+ }
72+
73+ qDebug() << "=== HINTS CQ hide hints: " << hide_hints_quickstart;
74+ qDebug() << "=== HINTS hints_hidden: " << hints_hidden();
75+ bool show_normal = true;
76+
77+ /*
78+ * Note: To redisplay hints at runtime, touch "hints_is_hidden" in cache dir
79+ * and restart unity8-dash. Restart is needed because the incoming canned
80+ * query tends to persist, so once the user has dimissed hints quickstart
81+ * and that signal was sent via the canned query user_data, it sticks around
82+ */
83+ if (hide_hints_quickstart)
84+ {
85+ show_normal = true;
86+ if (!hints_hidden())// checks for "hints_is_hidden" cache file
87+ dismiss_hints_quickstart();// write "hints_is_hidden" cache file
88+ } else {
89+ if (hints_hidden())// checks for "hints_is_hidden" cache file
90+ {
91+ qDebug() << "=== HINTS CASE 3";
92+ show_normal = true;
93+ } else {
94+ qDebug() << "=== HINTS CASE 4";
95+ show_normal = false;
96+ }
97+ }
98+
99+ if (!show_normal)
100+ {
101+ qDebug() << "==== HINTS. show_normal is FALSE, show hints";
102+ if (uses_hints && hints_quickstart && hints_exists()) {
103+ display_hints_quickstart(upstream_reply);
104+ return;
105+ }
106 }
107
108 bool has_network = true;
109
110=== modified file 'src/utils.cpp'
111--- src/utils.cpp 2016-02-09 16:11:02 +0000
112+++ src/utils.cpp 2016-02-26 22:05:20 +0000
113@@ -1278,6 +1278,7 @@
114
115 void Query::display_hints_quickstart(us::SearchReplyProxy const& upstream_reply_)
116 {
117+
118 Category::SCPtr hint_cat;
119 SearchMetadata metadata(search_metadata());
120
121@@ -1290,9 +1291,9 @@
122 metadata, reply);
123 }
124
125-bool Query::is_hints_quickstart_dismissed(){
126+bool Query::hints_hidden(){
127
128- auto filepath1 = QString::fromStdString(cache_dir_) +"/" + hints_is_hidden;
129+ auto filepath1 = QString::fromStdString(cache_dir_) +"/" + hints_file;
130 auto filepath2 = QString::fromStdString(cache_dir_) +"/" + firstboot;
131 if (QFile::exists(filepath1) || QFile::exists(filepath2))
132 return true;
133@@ -1301,10 +1302,11 @@
134 }
135
136 void Query::dismiss_hints_quickstart() {
137- auto filepath= QString::fromStdString(cache_dir_) +"/" + hints_is_hidden;
138+ qDebug() << "==== HINTS in dismiss()";
139+ auto filepath= QString::fromStdString(cache_dir_) +"/" + hints_file;
140 QFile file(filepath);
141 file.open(QIODevice::WriteOnly);
142- QString msg = QString("Timestamp for %1").arg(qstr(HINTS_THIS_SCOPE));
143+ QString msg = QString("Timestamp for %1 %2").arg(qstr(HINTS_THIS_SCOPE), QDateTime::currentDateTime().toString());
144 file.write(sstr(msg).c_str(), sstr(msg).size());
145 file.close();
146 }

Subscribers

People subscribed via source and target branches