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();
149void Scope::setId(const QString &id)
157void Scope::setName(const QString &name)
159 if (name != m_name) {
161 Q_EMIT nameChanged();
165void Scope::setSearchInProgress(const bool inProg)
167 if (inProg != m_searching) {
168 m_searching = inProg;
169 Q_EMIT searchInProgressChanged();
173void Scope::setNoResultsHint(const QString& str)
175 if (str != m_noResultsHint) {
176 m_noResultsHint = str;
177 Q_EMIT noResultsHintChanged();
181void Scope::activate(QVariant const& result)
183 qDebug() << "Called activate on scope" << m_id << "with result" << result;
184 if (result.toString() == "Result.2.2") {
185 Scopes *scopes = dynamic_cast<Scopes*>(parent());
186 m_openScope = scopes->getScopeFromAll("MockScope9");
187 Q_EMIT openScope(m_openScope);
191PreviewStack* Scope::preview(QVariant const& result)
195 // This probably leaks, do we don't care
196 // it's a test after all
197 return new PreviewStack;
200void Scope::cancelActivation()
204void Scope::closeScope(unity::shell::scopes::ScopeInterface* scope)
206 if (scope != m_openScope) {
207 qDebug() << scope << m_openScope;
208 qFatal("Scope::closeScope got wrong scope in closeScope");
210 m_openScope = nullptr;
213QString Scope::currentNavigationId() const
215 return m_currentNavigationId;
218bool Scope::hasNavigation() const
223QString Scope::currentAltNavigationId() const
225 return m_currentAltNavigationId;
228bool Scope::hasAltNavigation() const
233Scope::Status Scope::status() const
238QVariantMap Scope::customizations() const
241 if (m_id == "clickscope") {
242 h["foreground-color"] = "yellow";
243 m["background-color"] = "red";
244 m["foreground-color"] = "blue";
245 m["page-header"] = h;
246 } else if (m_id == "MockScope4") {
247 h["navigation-background"] = QUrl("../../../tests/qmltests/Dash/artwork/background.png");
248 m["page-header"] = h;
249 } else if (m_id == "MockScope5") {
250 h["background"] = "gradient:///lightgrey/grey";
251 h["logo"] = QUrl("../../../tests/qmltests/Dash/tst_PageHeader/logo-ubuntu-orange.svg");
252 h["divider-color"] = "red";
253 h["navigation-background"] = "color:///black";
254 m["page-header"] = h;
255 } else if (m_id == "MockScope6") {
256 h["navigation-background"] = "gradient:///blue/red";
257 m["page-header"] = h;
264 qDebug() << "Scope::refresh is currently not implmented in the fake scopes plugin";
267unity::shell::scopes::NavigationInterface* Scope::getNavigation(const QString& id)
274 if (id.startsWith("middle")) {
276 parentLabel = "root";
277 } else if (id.startsWith("child")) {
278 parentId = id.mid(5, 7);
279 parentLabel = parentId;
281 return new Navigation(id, id, "all"+id, parentId, parentLabel, this);
284unity::shell::scopes::NavigationInterface* Scope::getAltNavigation(QString const& id)
291 if (id != "altroot") {
292 parentId = "altroot";
293 parentLabel = "altroot";
295 auto result = new Navigation(id, id, "all"+id, parentId, parentLabel, this);
296 if (id == "altroot") {
297 m_currentAltNavigationId = "altrootChild1";
298 Q_EMIT currentAltNavigationIdChanged();
303void Scope::setNavigationState(const QString &navigationId, bool isAltNavigation)
305 if (isAltNavigation) {
306 m_currentAltNavigationId = navigationId;
307 Q_EMIT currentAltNavigationIdChanged();
309 m_currentNavigationId = navigationId;
310 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