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("MockScope5", "Mock Scope", false, parent)
31Scope::Scope(QString const& id, QString const& name, bool favorite, Scopes* parent, int categories, bool returnNullPreview)
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))
44 , m_returnNullPreview(returnNullPreview)
48QString Scope::id() const
53QString Scope::name() const
58QString Scope::searchQuery() const
63QString Scope::iconHint() const
68QString Scope::description() const
73QString Scope::searchHint() const
75 return QString("Search %1").arg(m_name);
78QString Scope::shortcut() const
83bool Scope::searchInProgress() const
88bool Scope::favorite() const
93unity::shell::scopes::CategoriesInterface* Scope::categories() const
98unity::shell::scopes::SettingsModelInterface* Scope::settings() const
103QString Scope::noResultsHint() const
105 return m_noResultsHint;
108QString Scope::formFactor() const
113bool Scope::isActive() const
118void Scope::setSearchQuery(const QString &str)
120 if (str != m_searchQuery) {
122 Q_EMIT searchQueryChanged();
126void Scope::setFormFactor(const QString &str)
128 if (str != m_formFactor) {
130 Q_EMIT formFactorChanged();
134void Scope::setActive(const bool active)
136 if (active != m_isActive) {
138 Q_EMIT isActiveChanged();
142void Scope::setFavorite(const bool favorite)
144 if (favorite != m_favorite) {
145 m_favorite = favorite;
146 Q_EMIT favoriteChanged();
149void Scope::setSearchInProgress(const bool inProg)
151 if (inProg != m_searching) {
152 m_searching = inProg;
153 Q_EMIT searchInProgressChanged();
157void Scope::setNoResultsHint(const QString& str)
159 if (str != m_noResultsHint) {
160 m_noResultsHint = str;
161 Q_EMIT noResultsHintChanged();
165void Scope::activate(QVariant const& result)
167 qDebug() << "Called activate on scope" << m_id << "with result" << result;
168 if (result.toString() == "Result.2.2") {
169 Scopes *scopes = dynamic_cast<Scopes*>(parent());
170 m_openScope = scopes->getScopeFromAll("MockScope9");
171 Q_EMIT openScope(m_openScope);
175PreviewStack* Scope::preview(QVariant const& result)
179 if (m_returnNullPreview) {
183 // This probably leaks, do we don't care
184 // it's a test after all
185 return new PreviewStack;
189void Scope::cancelActivation()
193void Scope::closeScope(unity::shell::scopes::ScopeInterface* scope)
195 if (scope != m_openScope) {
196 qDebug() << scope << m_openScope;
197 qFatal("Scope::closeScope got wrong scope in closeScope");
199 m_openScope = nullptr;
202QString Scope::currentNavigationId() const
204 return m_currentNavigationId;
207bool Scope::hasNavigation() const
212QString Scope::currentAltNavigationId() const
214 return m_currentAltNavigationId;
217bool Scope::hasAltNavigation() const
222Scope::Status Scope::status() const
227QVariantMap Scope::customizations() const
230 if (m_id == "clickscope") {
231 h["foreground-color"] = "yellow";
232 m["background-color"] = "red";
233 m["foreground-color"] = "blue";
234 m["page-header"] = h;
235 } else if (m_id == "MockScope4") {
236 h["navigation-background"] = QUrl("../../../tests/qmltests/Dash/artwork/background.png");
237 m["page-header"] = h;
238 } else if (m_id == "MockScope5") {
239 h["background"] = "gradient:///lightgrey/grey";
240 h["logo"] = QUrl("../../../tests/qmltests/Dash/tst_PageHeader/logo-ubuntu-orange.svg");
241 h["divider-color"] = "red";
242 h["navigation-background"] = "color:///black";
243 m["page-header"] = h;
244 } else if (m_id == "MockScope6") {
245 h["navigation-background"] = "gradient:///blue/red";
246 m["page-header"] = h;
253 qDebug() << "Scope::refresh is currently not implmented in the fake scopes plugin";
256unity::shell::scopes::NavigationInterface* Scope::getNavigation(const QString& id)
263 if (id.startsWith("middle")) {
265 parentLabel = "root";
266 } else if (id.startsWith("child")) {
267 parentId = id.mid(5, 7);
268 parentLabel = parentId;
270 return new Navigation(id, id, "all"+id, parentId, parentLabel, this);
273unity::shell::scopes::NavigationInterface* Scope::getAltNavigation(QString const& id)
280 if (id != "altroot") {
281 parentId = "altroot";
282 parentLabel = "altroot";
284 auto result = new Navigation(id, id, "all"+id, parentId, parentLabel, this);
285 if (id == "altroot") {
286 m_currentAltNavigationId = "altrootChild1";
287 Q_EMIT currentAltNavigationIdChanged();
292void Scope::setNavigationState(const QString &navigationId, bool isAltNavigation)
294 if (isAltNavigation) {
295 m_currentAltNavigationId = navigationId;
296 Q_EMIT currentAltNavigationIdChanged();
298 m_currentNavigationId = navigationId;
299 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