on c8adabc help sign in
unity8/plugins/Unity/Launcher/launcheritem.cpp
178 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.setActionId("launch_item");
41 nameAction.setText(m_name);
42 m_quickList->appendAction(nameAction);
43 QuickListEntry pinningAction;
44 pinningAction.setActionId("pin_item");
45 pinningAction.setText(gettext("Pin shortcut"));
46 m_quickList->appendAction(pinningAction);
49QString LauncherItem::appId() const
51 return m_appId;
54QString LauncherItem::name() const
56 return m_name;
59void LauncherItem::setName(const QString &name)
61 if (m_name != name) {
62 m_name = name;
63 Q_EMIT nameChanged(name);
64 }
67QString LauncherItem::icon() const
69 return m_icon;
72void LauncherItem::setIcon(const QString &icon)
74 if (m_icon != icon) {
75 m_icon = icon;
76 Q_EMIT iconChanged(icon);
77 }
80bool LauncherItem::pinned() const
82 return m_pinned;
85void LauncherItem::setPinned(bool pinned)
87 if (m_pinned != pinned) {
88 m_pinned = pinned;
89 QuickListEntry entry;
90 entry.setActionId("pin_item");
91 entry.setText(pinned ? gettext("Unpin shortcut") : gettext("Pin shortcut"));
92 m_quickList->updateAction(entry);
93 Q_EMIT pinnedChanged(pinned);
94 }
97bool LauncherItem::running() const
99 return m_running;
102void LauncherItem::setRunning(bool running)
104 if (m_running != running) {
105 m_running = running;
106 Q_EMIT runningChanged(running);
107 }
110bool LauncherItem::recent() const
112 return m_recent;
115void LauncherItem::setRecent(bool recent)
117 if (m_recent != recent) {
118 m_recent = recent;
119 Q_EMIT recentChanged(recent);
120 }
123int LauncherItem::progress() const
125 return m_progress;
128void LauncherItem::setProgress(int progress)
130 if (m_progress != progress) {
131 m_progress = progress;
132 Q_EMIT progressChanged(progress);
133 }
136int LauncherItem::count() const
138 return m_count;
141void LauncherItem::setCount(int count)
143 if (m_count != count) {
144 m_count = count;
145 Q_EMIT countChanged(count);
146 }
149bool LauncherItem::countVisible() const
151 return m_countVisible;
154void LauncherItem::setCountVisible(bool countVisible)
156 if (m_countVisible != countVisible) {
157 m_countVisible = countVisible;
158 Q_EMIT countVisibleChanged(countVisible);
159 }
162bool LauncherItem::focused() const
164 return m_focused;
167void LauncherItem::setFocused(bool focused)
169 if (m_focused != focused) {
170 m_focused = focused;
171 Q_EMIT focusedChanged(focused);
172 }
175unity::shell::launcher::QuickListModelInterface *LauncherItem::quickList() const
177 return m_quickList;