@@ -43,6 +43,8 @@ Scope::Scope(QObject *parent) : QObject(parent)
43 , m_searchInProgress(false)
43 , m_searchInProgress(false)
45 m_categories.reset(new Categories(this));
45 m_categories.reset(new Categories(this));
47+ connect(this, &Scope::isActiveChanged, this, &Scope::scopeIsActiveChanged);
48QString Scope::id() const
50QString Scope::id() const
@@ -110,6 +112,11 @@ QString Scope::formFactor() const
110 return m_formFactor;
112 return m_formFactor;
115+bool Scope::isActive() const
113Filters* Scope::filters() const
120Filters* Scope::filters() const
115 return m_filters.get();
122 return m_filters.get();
@@ -127,10 +134,12 @@ void Scope::setSearchQuery(const QString& search_query)
127 if (m_searchQuery.isNull() || search_query != m_searchQuery) {
134 if (m_searchQuery.isNull() || search_query != m_searchQuery) {
128 m_searchQuery = search_query;
135 m_searchQuery = search_query;
129 m_cancellable.Renew();
136 m_cancellable.Renew();
130− m_searchInProgress = true;
131 m_unityScope->Search(search_query.toStdString(), std::bind(&Scope::onSearchFinished, this, _1, _2, _3), m_cancellable);
137 m_unityScope->Search(search_query.toStdString(), std::bind(&Scope::onSearchFinished, this, _1, _2, _3), m_cancellable);
132 Q_EMIT searchQueryChanged();
138 Q_EMIT searchQueryChanged();
139+ if (!m_searchInProgress) {
140+ m_searchInProgress = true;
133− Q_EMIT searchInProgressChanged();
141+ Q_EMIT searchInProgressChanged();
@@ -152,6 +161,13 @@ void Scope::setFormFactor(const QString& form_factor) {
164+void Scope::setActive(const bool active) {
165+ if (active != m_isActive) {
166+ m_isActive = active;
167+ Q_EMIT isActiveChanged(m_isActive);
155unity::dash::LocalResult Scope::createLocalResult(const QVariant &uri, const QVariant &icon_hint,
171unity::dash::LocalResult Scope::createLocalResult(const QVariant &uri, const QVariant &icon_hint,
156 const QVariant &category, const QVariant &result_type,
172 const QVariant &category, const QVariant &result_type,
157 const QVariant &mimetype, const QVariant &title,
173 const QVariant &mimetype, const QVariant &title,
@@ -306,6 +322,7 @@ void Scope::setUnityScope(const unity::dash::Scope::Ptr& scope)
306 m_unityScope->visible.changed.connect(sigc::mem_fun(this, &Scope::visibleChanged));
322 m_unityScope->visible.changed.connect(sigc::mem_fun(this, &Scope::visibleChanged));
307 m_unityScope->shortcut.changed.connect(sigc::mem_fun(this, &Scope::shortcutChanged));
323 m_unityScope->shortcut.changed.connect(sigc::mem_fun(this, &Scope::shortcutChanged));
308 m_unityScope->connected.changed.connect(sigc::mem_fun(this, &Scope::connectedChanged));
324 m_unityScope->connected.changed.connect(sigc::mem_fun(this, &Scope::connectedChanged));
325+ m_unityScope->results_dirty.changed.connect(sigc::mem_fun(this, &Scope::resultsDirtyToggled));
310 /* FIXME: signal should be forwarded instead of calling the handler directly */
327 /* FIXME: signal should be forwarded instead of calling the handler directly */
311 m_unityScope->activated.connect(sigc::mem_fun(this, &Scope::onActivated));
328 m_unityScope->activated.connect(sigc::mem_fun(this, &Scope::onActivated));
@@ -332,13 +349,31 @@ void Scope::synchronizeStates()
332 /* Forward local states to m_unityScope */
349 /* Forward local states to m_unityScope */
333 if (!m_searchQuery.isNull()) {
350 if (!m_searchQuery.isNull()) {
334 m_cancellable.Renew();
351 m_cancellable.Renew();
335− m_searchInProgress = true;
336 m_unityScope->Search(m_searchQuery.toStdString(), std::bind(&Scope::onSearchFinished, this, _1, _2, _3), m_cancellable);
352 m_unityScope->Search(m_searchQuery.toStdString(), std::bind(&Scope::onSearchFinished, this, _1, _2, _3), m_cancellable);
353+ if (!m_searchInProgress) {
354+ m_searchInProgress = true;
337− Q_EMIT searchInProgressChanged();
355+ Q_EMIT searchInProgressChanged();
361+void Scope::scopeIsActiveChanged()
363+ if (!isActive() || !m_unityScope || !m_unityScope->results_dirty()) return;
366+ synchronizeStates();
369+void Scope::resultsDirtyToggled(bool results_dirty)
371+ if (!results_dirty || !isActive()) return;
374+ synchronizeStates();
342void Scope::onSearchFinished(std::string const& /* query */, unity::glib::HintsMap const& hints, unity::glib::Error const& err)
377void Scope::onSearchFinished(std::string const& /* query */, unity::glib::HintsMap const& hints, unity::glib::Error const& err)
344 QString hint;
379 QString hint;
@@ -346,8 +381,10 @@ void Scope::onSearchFinished(std::string const& /* query */, unity::glib::HintsM
346 GError* error = const_cast<unity::glib::Error&>(err);
381 GError* error = const_cast<unity::glib::Error&>(err);
348 if (!err || !g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
383 if (!err || !g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
384+ if (m_searchInProgress) {
349− m_searchInProgress = false;
385+ m_searchInProgress = false;
350− Q_EMIT searchInProgressChanged();
386+ Q_EMIT searchInProgressChanged();
352 // no need to check the results hint, we're still searching
389 // no need to check the results hint, we're still searching