2 * Copyright (C) 2013, 2014 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20#include "fake_scope.h"
22#include "fake_navigation.h"
23#include "fake_resultsmodel.h"
24#include "fake_scopes.h"
25#include "fake_settingsmodel.h"
27Scope::Scope(Scopes* parent) : Scope(QString(), QString(), false, parent)
31Scope::Scope(QString const& id, QString const& name, bool favorite, Scopes* parent, int categories)
32 : unity::shell::scopes::ScopeInterface(parent)
36 , m_favorite(favorite)
38 , m_currentNavigationId("root")
39 , m_currentAltNavigationId("altroot")
40 , m_previewRendererName("preview-generic")
41 , m_categories(new Categories(categories, this))
42 , m_openScope(nullptr)
43 , m_settings(new SettingsModel(this))
47QString Scope::id() const
52QString Scope::name() const
57QString Scope::searchQuery() const
62QString Scope::iconHint() const
67QString Scope::description() const
72QString Scope::searchHint() const
74 return QString("Search %1").arg(m_name);
77QString Scope::shortcut() const
82bool Scope::searchInProgress() const
87bool Scope::favorite() const
92unity::shell::scopes::CategoriesInterface* Scope::categories() const
97unity::shell::scopes::SettingsModelInterface* Scope::settings() const
102QString Scope::noResultsHint() const
104 return m_noResultsHint;
107QString Scope::formFactor() const
112bool Scope::isActive() const
117void Scope::setSearchQuery(const QString &str)
119 if (str != m_searchQuery) {
121 Q_EMIT searchQueryChanged();
125void Scope::setFormFactor(const QString &str)
127 if (str != m_formFactor) {
129 Q_EMIT formFactorChanged();
133void Scope::setActive(const bool active)
135 if (active != m_isActive) {
137 Q_EMIT isActiveChanged();
141void Scope::setFavorite(const bool favorite)
143 if (favorite != m_favorite) {
144 m_favorite = favorite;
145 Q_EMIT favoriteChanged();
148void Scope::setSearchInProgress(const bool inProg)
150 if (inProg != m_searching) {
151 m_searching = inProg;
152 Q_EMIT searchInProgressChanged();
156void Scope::setNoResultsHint(const QString& str)
158 if (str != m_noResultsHint) {
159 m_noResultsHint = str;
160 Q_EMIT noResultsHintChanged();
164void Scope::activate(QVariant const& result)
166 qDebug() << "Called activate on scope" << m_id << "with result" << result;
167 if (result.toString() == "Result.2.2") {
168 Scopes *scopes = dynamic_cast<Scopes*>(parent());
169 m_openScope = scopes->getScopeFromAll("MockScope9");
170 Q_EMIT openScope(m_openScope);
174PreviewStack* Scope::preview(QVariant const& result)
178 // This probably leaks, do we don't care
179 // it's a test after all
180 return new PreviewStack;
183void Scope::cancelActivation()
187void Scope::closeScope(unity::shell::scopes::ScopeInterface* scope)
189 if (scope != m_openScope) {
190 qDebug() << scope << m_openScope;
191 qFatal("Scope::closeScope got wrong scope in closeScope");
193 m_openScope = nullptr;
196QString Scope::currentNavigationId() const
198 return m_currentNavigationId;
201bool Scope::hasNavigation() const
206QString Scope::currentAltNavigationId() const
208 return m_currentAltNavigationId;
211bool Scope::hasAltNavigation() const
216Scope::Status Scope::status() const
221QVariantMap Scope::customizations() const
224 if (m_id == "clickscope") {
225 h["foreground-color"] = "yellow";
226 m["background-color"] = "red";
227 m["foreground-color"] = "blue";
228 m["page-header"] = h;
229 } else if (m_id == "MockScope4") {
230 h["navigation-background"] = QUrl("../../../tests/qmltests/Dash/artwork/background.png");
231 m["page-header"] = h;
232 } else if (m_id == "MockScope5") {
233 h["background"] = "gradient:///lightgrey/grey";
234 h["logo"] = QUrl("../../../tests/qmltests/Dash/tst_PageHeader/logo-ubuntu-orange.svg");
235 h["divider-color"] = "red";
236 h["navigation-background"] = "color:///black";
237 m["page-header"] = h;
238 } else if (m_id == "MockScope6") {
239 h["navigation-background"] = "gradient:///blue/red";
240 m["page-header"] = h;
247 qDebug() << "Scope::refresh is currently not implmented in the fake scopes plugin";
250unity::shell::scopes::NavigationInterface* Scope::getNavigation(const QString& id)
257 if (id.startsWith("middle")) {
259 parentLabel = "root";
260 } else if (id.startsWith("child")) {
261 parentId = id.mid(5, 7);
262 parentLabel = parentId;
264 return new Navigation(id, id, "all"+id, parentId, parentLabel, this);
267unity::shell::scopes::NavigationInterface* Scope::getAltNavigation(QString const& id)
274 if (id != "altroot") {
275 parentId = "altroot";
276 parentLabel = "altroot";
278 auto result = new Navigation(id, id, "all"+id, parentId, parentLabel, this);
279 if (id == "altroot") {
280 m_currentAltNavigationId = "altrootChild1";
281 Q_EMIT currentAltNavigationIdChanged();
286void Scope::setNavigationState(const QString &navigationId, bool isAltNavigation)
288 if (isAltNavigation) {
289 m_currentAltNavigationId = navigationId;
290 Q_EMIT currentAltNavigationIdChanged();
292 m_currentNavigationId = navigationId;
293 Q_EMIT currentNavigationIdChanged();
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list