on 5dbd13d help sign in
unity8/plugins/Unity/Launcher/launcheritem.cpp
177 lines 3.8 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 "launcheritem.h"
21#include "quicklistmodel.h"
23#include <libintl.h>
25LauncherItem::LauncherItem(const QString &appId, const QString &name, const QString &icon, QObject *parent) :
26 LauncherItemInterface(parent),
27 m_appId(appId),
28 m_name(name),
29 m_icon(icon),
30 m_pinned(false),
31 m_running(false),
32 m_recent(false),
33 m_progress(-1),
34 m_count(0),
35 m_countVisible(false),
36 m_focused(false),
37 m_quickList(new QuickListModel(this))
39 QuickListEntry nameAction;
40 nameAction.setText(m_name);
41 m_quickList->appendAction(nameAction);
42 QuickListEntry pinningAction;
43 pinningAction.setActionId("pin_item");
44 pinningAction.setText(gettext("Pin shortcut"));
45 m_quickList->appendAction(pinningAction);
48QString LauncherItem::appId() const
50 return m_appId;
53QString LauncherItem::name() const
55 return m_name;
58void LauncherItem::setName(const QString &name)
60 if (m_name != name) {
61 m_name = name;
62 Q_EMIT nameChanged(name);
63 }
66QString LauncherItem::icon() const
68 return m_icon;
71void LauncherItem::setIcon(const QString &icon)
73 if (m_icon != icon) {
74 m_icon = icon;
75 Q_EMIT iconChanged(icon);
76 }
79bool LauncherItem::pinned() const
81 return m_pinned;
84void LauncherItem::setPinned(bool pinned)
86 if (m_pinned != pinned) {
87 m_pinned = pinned;
88 QuickListEntry entry;
89 entry.setActionId("pin_item");
90 entry.setText(pinned ? gettext("Unpin shortcut") : gettext("Pin shortcut"));
91 m_quickList->updateAction(entry);
92 Q_EMIT pinnedChanged(pinned);
93 }
96bool LauncherItem::running() const
98 return m_running;
101void LauncherItem::setRunning(bool running)
103 if (m_running != running) {
104 m_running = running;
105 Q_EMIT runningChanged(running);
106 }
109bool LauncherItem::recent() const
111 return m_recent;
114void LauncherItem::setRecent(bool recent)
116 if (m_recent != recent) {
117 m_recent = recent;
118 Q_EMIT recentChanged(recent);
119 }
122int LauncherItem::progress() const
124 return m_progress;
127void LauncherItem::setProgress(int progress)
129 if (m_progress != progress) {
130 m_progress = progress;
131 Q_EMIT progressChanged(progress);
132 }
135int LauncherItem::count() const
137 return m_count;
140void LauncherItem::setCount(int count)
142 if (m_count != count) {
143 m_count = count;
144 Q_EMIT countChanged(count);
145 }
148bool LauncherItem::countVisible() const
150 return m_countVisible;
153void LauncherItem::setCountVisible(bool countVisible)
155 if (m_countVisible != countVisible) {
156 m_countVisible = countVisible;
157 Q_EMIT countVisibleChanged(countVisible);
158 }
161bool LauncherItem::focused() const
163 return m_focused;
166void LauncherItem::setFocused(bool focused)
168 if (m_focused != focused) {
169 m_focused = focused;
170 Q_EMIT focusedChanged(focused);
171 }
174unity::shell::launcher::QuickListModelInterface *LauncherItem::quickList() const
176 return m_quickList;