Merge lp:~stolowski/unity-scopes-shell/prepopulate-scopes-when-locked into lp:unity-scopes-shell

Proposed by Paweł Stołowski
Status: Merged
Approved by: Marcus Tomlinson
Approved revision: 306
Merged at revision: 312
Proposed branch: lp:~stolowski/unity-scopes-shell/prepopulate-scopes-when-locked
Merge into: lp:unity-scopes-shell
Diff against target: 80 lines (+28/-0)
3 files modified
src/Unity/scopes.cpp (+24/-0)
src/Unity/scopes.h (+2/-0)
tests/filtersendtoendtest.cpp (+2/-0)
To merge this branch: bzr merge lp:~stolowski/unity-scopes-shell/prepopulate-scopes-when-locked
Reviewer Review Type Date Requested Status
Marcus Tomlinson (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+292129@code.launchpad.net

Commit message

Pre-populate first scope on startup (even if the screen is locked).

Description of the change

Pre-populate first scope on startup (even if the screen is locked).

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

Looks good. Just a question: What was the motivation behind the UNITY_SCOPES_NO_PREPOPULATE_FIRST variable?

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

> Looks good. Just a question: What was the motivation behind the
> UNITY_SCOPES_NO_PREPOPULATE_FIRST variable?

Solely to leave backdoor for disabling this enhancement in tests. All tests which fully utilize scope-harness (such as resultstest) work fine, but all the filters tests (which haven't been migrated to scope harness) which rely TestUtils::performSearch broke because the scope is not in the expected state when tests starts (search is already in progress due to pre-population logic, and TestUtils::performSearch doesn't expect that). After some failed attempts to work around this in the tests I concluded it's probably now worth the effort.

Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

Awesome. Works well. +Silo 22 is looking good now.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Unity/scopes.cpp'
2--- src/Unity/scopes.cpp 2016-02-04 11:43:34 +0000
3+++ src/Unity/scopes.cpp 2016-04-18 10:11:05 +0000
4@@ -106,6 +106,7 @@
5 , m_overviewScope(nullptr)
6 , m_listThread(nullptr)
7 , m_loaded(false)
8+ , m_prepopulateFirstScope(true)
9 , m_priv(new Priv())
10 {
11 QByteArray noFav = qgetenv("UNITY_SCOPES_NO_FAVORITES");
12@@ -113,6 +114,11 @@
13 m_noFavorites = true;
14 }
15
16+ QByteArray noPrep = qgetenv("UNITY_SCOPES_NO_PREPOPULATE_FIRST");
17+ if (!noPrep.isNull()) {
18+ m_prepopulateFirstScope = false;
19+ }
20+
21 connect(m_priv.get(), SIGNAL(safeInvalidateScopeResults(const QString&)), this,
22 SLOT(invalidateScopeResults(const QString &)), Qt::QueuedConnection);
23
24@@ -345,6 +351,24 @@
25 Q_EMIT metadataRefreshed();
26
27 m_listThread = nullptr;
28+
29+ if (m_prepopulateFirstScope) {
30+ m_prepopulateFirstScope = false;
31+ prepopulateFirstScope();
32+ }
33+}
34+
35+void Scopes::prepopulateFirstScope()
36+{
37+ if (!m_scopes.isEmpty()) {
38+ auto& scope = m_scopes.front();
39+ if (!scope->initialQueryDone()) {
40+ qDebug() << "Pre-populating first scope";
41+ scope->setSearchQuery(QLatin1String(""));
42+ // must dispatch search explicitly since setSearchQuery will not do that for inactive scope
43+ scope->dispatchSearch();
44+ }
45+ }
46 }
47
48 void Scopes::prepopulateNextScopes()
49
50=== modified file 'src/Unity/scopes.h'
51--- src/Unity/scopes.h 2015-09-24 12:41:23 +0000
52+++ src/Unity/scopes.h 2016-04-18 10:11:05 +0000
53@@ -95,6 +95,7 @@
54 void discoveryFinished();
55 void refreshFinished();
56 void invalidateScopeResults(QString const&);
57+ void prepopulateFirstScope();
58 void prepopulateNextScopes();
59
60 void initPopulateScopes();
61@@ -121,6 +122,7 @@
62 QList<QPair<QString, QString>> m_versions;
63 QString m_userAgent;
64 bool m_loaded;
65+ bool m_prepopulateFirstScope;
66
67 QSharedPointer<LocationService> m_locationService;
68 QTimer m_startupQueryTimeout;
69
70=== modified file 'tests/filtersendtoendtest.cpp'
71--- tests/filtersendtoendtest.cpp 2016-03-02 15:14:30 +0000
72+++ tests/filtersendtoendtest.cpp 2016-04-18 10:11:05 +0000
73@@ -61,6 +61,8 @@
74
75 void init()
76 {
77+ qputenv("UNITY_SCOPES_NO_PREPOPULATE_FIRST", "1");
78+
79 const QStringList favs {"scope://mock-scope-filters"};
80 TestUtils::setFavouriteScopes(favs);
81

Subscribers

People subscribed via source and target branches

to all changes: