on c2d47ba help sign in
unity8/plugins/Greeter/Unity/Launcher/launcheritem.cpp
185 lines 3.8 kB history raw
1/*
2 * Copyright 2014-2015 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 */
17#include "launcheritem.h"
18#include "quicklistmodel.h"
20#include <libintl.h>
22LauncherItem::LauncherItem(const QString &appId, const QString &name, const QString &icon, QObject *parent) :
23 LauncherItemInterface(parent),
24 m_appId(appId),
25 m_name(name),
26 m_icon(icon),
27 m_pinned(false),
28 m_running(false),
29 m_recent(false),
30 m_progress(-1),
31 m_count(0),
32 m_countVisible(false),
33 m_focused(false),
34 m_alerting(false),
35 m_quickList(new QuickListModel(this))
37 QuickListEntry nameAction;
38 nameAction.setActionId(QStringLiteral("launch_item"));
39 nameAction.setText(m_name);
40 m_quickList->appendAction(nameAction);
43QString LauncherItem::appId() const
45 return m_appId;
48QString LauncherItem::name() const
50 return m_name;
53void LauncherItem::setName(const QString &name)
55 if (m_name != name) {
56 m_name = name;
57 QuickListEntry entry;
58 entry.setActionId(QStringLiteral("launch_item"));
59 entry.setText(m_name);
60 m_quickList->updateAction(entry);
61 Q_EMIT nameChanged(name);
62 }
65QString LauncherItem::icon() const
67 return m_icon;
70void LauncherItem::setIcon(const QString &icon)
72 if (m_icon != icon) {
73 m_icon = icon;
74 Q_EMIT iconChanged(icon);
75 }
78bool LauncherItem::pinned() const
80 return m_pinned;
83void LauncherItem::setPinned(bool pinned)
85 if (m_pinned != pinned) {
86 m_pinned = pinned;
87 Q_EMIT pinnedChanged(pinned);
88 }
91bool LauncherItem::running() const
93 return m_running;
96void LauncherItem::setRunning(bool running)
98 if (m_running != running) {
99 m_running = running;
100 Q_EMIT runningChanged(running);
101 }
104bool LauncherItem::recent() const
106 return m_recent;
109void LauncherItem::setRecent(bool recent)
111 if (m_recent != recent) {
112 m_recent = recent;
113 Q_EMIT recentChanged(recent);
114 }
117int LauncherItem::progress() const
119 return m_progress;
122void LauncherItem::setProgress(int progress)
124 if (m_progress != progress) {
125 m_progress = progress;
126 Q_EMIT progressChanged(progress);
127 }
130int LauncherItem::count() const
132 return m_count;
135void LauncherItem::setCount(int count)
137 if (m_count != count) {
138 m_count = count;
139 Q_EMIT countChanged(count);
140 }
143bool LauncherItem::countVisible() const
145 return m_countVisible;
148void LauncherItem::setCountVisible(bool countVisible)
150 if (m_countVisible != countVisible) {
151 m_countVisible = countVisible;
152 Q_EMIT countVisibleChanged(countVisible);
153 }
156bool LauncherItem::focused() const
158 return m_focused;
161void LauncherItem::setFocused(bool focused)
163 if (m_focused != focused) {
164 m_focused = focused;
165 Q_EMIT focusedChanged(focused);
166 }
169bool LauncherItem::alerting() const
171 return m_alerting;
174void LauncherItem::setAlerting(bool alerting)
176 if (m_alerting != alerting) {
177 m_alerting = alerting;
178 Q_EMIT alertingChanged(alerting);
179 }
182unity::shell::launcher::QuickListModelInterface *LauncherItem::quickList() const
184 return m_quickList;