on daa5708 help sign in
unity8/plugins/Greeter/Unity/Launcher/launcheritem.cpp
171 lines 3.5 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_quickList(new QuickListModel(this))
36 QuickListEntry nameAction;
37 nameAction.setActionId("launch_item");
38 nameAction.setText(m_name);
39 m_quickList->appendAction(nameAction);
42QString LauncherItem::appId() const
44 return m_appId;
47QString LauncherItem::name() const
49 return m_name;
52void LauncherItem::setName(const QString &name)
54 if (m_name != name) {
55 m_name = name;
56 QuickListEntry entry;
57 entry.setActionId("launch_item");
58 entry.setText(m_name);
59 m_quickList->updateAction(entry);
60 Q_EMIT nameChanged(name);
61 }
64QString LauncherItem::icon() const
66 return m_icon;
69void LauncherItem::setIcon(const QString &icon)
71 if (m_icon != icon) {
72 m_icon = icon;
73 Q_EMIT iconChanged(icon);
74 }
77bool LauncherItem::pinned() const
79 return m_pinned;
82void LauncherItem::setPinned(bool pinned)
84 if (m_pinned != pinned) {
85 m_pinned = pinned;
86 Q_EMIT pinnedChanged(pinned);
87 }
90bool LauncherItem::running() const
92 return m_running;
95void LauncherItem::setRunning(bool running)
97 if (m_running != running) {
98 m_running = running;
99 Q_EMIT runningChanged(running);
100 }
103bool LauncherItem::recent() const
105 return m_recent;
108void LauncherItem::setRecent(bool recent)
110 if (m_recent != recent) {
111 m_recent = recent;
112 Q_EMIT recentChanged(recent);
113 }
116int LauncherItem::progress() const
118 return m_progress;
121void LauncherItem::setProgress(int progress)
123 if (m_progress != progress) {
124 m_progress = progress;
125 Q_EMIT progressChanged(progress);
126 }
129int LauncherItem::count() const
131 return m_count;
134void LauncherItem::setCount(int count)
136 if (m_count != count) {
137 m_count = count;
138 Q_EMIT countChanged(count);
139 }
142bool LauncherItem::countVisible() const
144 return m_countVisible;
147void LauncherItem::setCountVisible(bool countVisible)
149 if (m_countVisible != countVisible) {
150 m_countVisible = countVisible;
151 Q_EMIT countVisibleChanged(countVisible);
152 }
155bool LauncherItem::focused() const
157 return m_focused;
160void LauncherItem::setFocused(bool focused)
162 if (m_focused != focused) {
163 m_focused = focused;
164 Q_EMIT focusedChanged(focused);
165 }
168unity::shell::launcher::QuickListModelInterface *LauncherItem::quickList() const
170 return m_quickList;