on bba3e90 help sign in
unity8/tests/mocks/Unity/Launcher/MockLauncherItem.cpp
202 lines 4.1 kB history raw
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
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 Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Michael Zanetti <michael.zanetti@canonical.com>
18 */
20#include "MockLauncherItem.h"
21#include "MockQuickListModel.h"
23#include <paths.h>
25using namespace unity::shell::launcher;
27MockLauncherItem::MockLauncherItem(const QString &appId, const QString& desktopFile, const QString& name, const QString& icon, QObject* parent):
28 LauncherItemInterface(parent),
29 m_appId(appId),
30 m_desktopFile(desktopFile),
31 m_name(name),
32 m_icon("../../tests/graphics/applicationIcons/" + icon + ".png"),
33 m_pinned(false),
34 m_running(false),
35 m_recent(false),
36 m_progress(-1),
37 m_count(0),
38 m_countVisible(false),
39 m_focused(false),
40 m_alerting(false),
41 m_surfaceCount(0),
42 m_quickList(new MockQuickListModel(this))
46MockLauncherItem::~MockLauncherItem()
50QString MockLauncherItem::appId() const
52 return m_appId;
55QString MockLauncherItem::desktopFile() const
57 return m_desktopFile;
60QString MockLauncherItem::name() const
62 return m_name;
65QString MockLauncherItem::icon() const
67 return m_icon;
70bool MockLauncherItem::pinned() const
72 return m_pinned;
75void MockLauncherItem::setPinned(bool pinned)
77 if (m_pinned != pinned)
78 {
79 m_pinned = pinned;
80 Q_EMIT pinnedChanged(m_pinned);
81 }
84bool MockLauncherItem::running() const
86 return m_running;
89void MockLauncherItem::setRunning(bool running)
91 if (m_running != running)
92 {
93 m_running = running;
94 Q_EMIT runningChanged(running);
95 }
98bool MockLauncherItem::recent() const
100 return m_recent;
103void MockLauncherItem::setRecent(bool recent)
105 if (m_recent != recent)
106 {
107 m_recent = recent;
108 Q_EMIT recentChanged(recent);
109 }
112int MockLauncherItem::progress() const
114 return m_progress;
117void MockLauncherItem::setProgress(int progress)
119 if (m_progress != progress)
120 {
121 m_progress = progress;
122 Q_EMIT progressChanged(progress);
123 }
126int MockLauncherItem::count() const
128 return m_count;
131void MockLauncherItem::setCount(int count)
133 if (m_count != count)
134 {
135 m_count = count;
136 Q_EMIT countChanged(count);
137 if (m_countVisible) {
138 setAlerting(true);
139 }
140 }
143bool MockLauncherItem::countVisible() const
145 return m_countVisible;
148void MockLauncherItem::setCountVisible(bool countVisible)
150 if (m_countVisible != countVisible) {
151 m_countVisible = countVisible;
152 Q_EMIT countVisibleChanged(countVisible);
153 if (countVisible) {
154 setAlerting(true);
155 }
156 }
159bool MockLauncherItem::focused() const
161 return m_focused;
164void MockLauncherItem::setFocused(bool focused)
166 if (m_focused != focused)
167 {
168 m_focused = focused;
169 Q_EMIT focusedChanged(focused);
170 }
173bool MockLauncherItem::alerting() const
175 return m_alerting;
178void MockLauncherItem::setAlerting(bool alerting)
180 if (m_alerting != alerting) {
181 m_alerting = alerting;
182 Q_EMIT alertingChanged(alerting);
183 }
186int MockLauncherItem::surfaceCount() const
188 return m_surfaceCount;
191void MockLauncherItem::setSurfaceCount(int surfaceCount)
193 if (m_surfaceCount != surfaceCount) {
194 m_surfaceCount = surfaceCount;
195 Q_EMIT surfaceCountChanged(surfaceCount);
196 }
199unity::shell::launcher::QuickListModelInterface *MockLauncherItem::quickList() const
201 return m_quickList;