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
=== modified file 'src/Unity/scopes.cpp'
--- src/Unity/scopes.cpp 2016-02-04 11:43:34 +0000
+++ src/Unity/scopes.cpp 2016-04-18 10:11:05 +0000
@@ -106,6 +106,7 @@
106 , m_overviewScope(nullptr)106 , m_overviewScope(nullptr)
107 , m_listThread(nullptr)107 , m_listThread(nullptr)
108 , m_loaded(false)108 , m_loaded(false)
109 , m_prepopulateFirstScope(true)
109 , m_priv(new Priv())110 , m_priv(new Priv())
110{111{
111 QByteArray noFav = qgetenv("UNITY_SCOPES_NO_FAVORITES");112 QByteArray noFav = qgetenv("UNITY_SCOPES_NO_FAVORITES");
@@ -113,6 +114,11 @@
113 m_noFavorites = true;114 m_noFavorites = true;
114 }115 }
115116
117 QByteArray noPrep = qgetenv("UNITY_SCOPES_NO_PREPOPULATE_FIRST");
118 if (!noPrep.isNull()) {
119 m_prepopulateFirstScope = false;
120 }
121
116 connect(m_priv.get(), SIGNAL(safeInvalidateScopeResults(const QString&)), this,122 connect(m_priv.get(), SIGNAL(safeInvalidateScopeResults(const QString&)), this,
117 SLOT(invalidateScopeResults(const QString &)), Qt::QueuedConnection);123 SLOT(invalidateScopeResults(const QString &)), Qt::QueuedConnection);
118124
@@ -345,6 +351,24 @@
345 Q_EMIT metadataRefreshed();351 Q_EMIT metadataRefreshed();
346352
347 m_listThread = nullptr;353 m_listThread = nullptr;
354
355 if (m_prepopulateFirstScope) {
356 m_prepopulateFirstScope = false;
357 prepopulateFirstScope();
358 }
359}
360
361void Scopes::prepopulateFirstScope()
362{
363 if (!m_scopes.isEmpty()) {
364 auto& scope = m_scopes.front();
365 if (!scope->initialQueryDone()) {
366 qDebug() << "Pre-populating first scope";
367 scope->setSearchQuery(QLatin1String(""));
368 // must dispatch search explicitly since setSearchQuery will not do that for inactive scope
369 scope->dispatchSearch();
370 }
371 }
348}372}
349373
350void Scopes::prepopulateNextScopes()374void Scopes::prepopulateNextScopes()
351375
=== modified file 'src/Unity/scopes.h'
--- src/Unity/scopes.h 2015-09-24 12:41:23 +0000
+++ src/Unity/scopes.h 2016-04-18 10:11:05 +0000
@@ -95,6 +95,7 @@
95 void discoveryFinished();95 void discoveryFinished();
96 void refreshFinished();96 void refreshFinished();
97 void invalidateScopeResults(QString const&);97 void invalidateScopeResults(QString const&);
98 void prepopulateFirstScope();
98 void prepopulateNextScopes();99 void prepopulateNextScopes();
99100
100 void initPopulateScopes();101 void initPopulateScopes();
@@ -121,6 +122,7 @@
121 QList<QPair<QString, QString>> m_versions;122 QList<QPair<QString, QString>> m_versions;
122 QString m_userAgent;123 QString m_userAgent;
123 bool m_loaded;124 bool m_loaded;
125 bool m_prepopulateFirstScope;
124126
125 QSharedPointer<LocationService> m_locationService;127 QSharedPointer<LocationService> m_locationService;
126 QTimer m_startupQueryTimeout;128 QTimer m_startupQueryTimeout;
127129
=== modified file 'tests/filtersendtoendtest.cpp'
--- tests/filtersendtoendtest.cpp 2016-03-02 15:14:30 +0000
+++ tests/filtersendtoendtest.cpp 2016-04-18 10:11:05 +0000
@@ -61,6 +61,8 @@
6161
62 void init()62 void init()
63 {63 {
64 qputenv("UNITY_SCOPES_NO_PREPOPULATE_FIRST", "1");
65
64 const QStringList favs {"scope://mock-scope-filters"};66 const QStringList favs {"scope://mock-scope-filters"};
65 TestUtils::setFavouriteScopes(favs);67 TestUtils::setFavouriteScopes(favs);
6668

Subscribers

People subscribed via source and target branches

to all changes: