on 8393c49 help sign in
unity8/plugins/Unity/Launcher/launcheritem.cpp
148 lines 3.2 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_focused(false),
36 m_quickList(new QuickListModel(this))
38 QuickListEntry nameAction;
39 nameAction.setActionId("launch_item");
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;
58QString LauncherItem::icon() const
60 return m_icon;
63bool LauncherItem::pinned() const
65 return m_pinned;
68void LauncherItem::setPinned(bool pinned)
70 if (m_pinned != pinned) {
71 m_pinned = pinned;
72 QuickListEntry entry;
73 entry.setActionId("pin_item");
74 entry.setText(pinned ? gettext("Unpin shortcut") : gettext("Pin shortcut"));
75 m_quickList->updateAction(entry);
76 Q_EMIT pinnedChanged(pinned);
77 }
80bool LauncherItem::running() const
82 return m_running;
85void LauncherItem::setRunning(bool running)
87 if (m_running != running) {
88 m_running = running;
89 Q_EMIT runningChanged(running);
90 }
93bool LauncherItem::recent() const
95 return m_recent;
98void LauncherItem::setRecent(bool recent)
100 if (m_recent != recent) {
101 m_recent = recent;
102 Q_EMIT recentChanged(recent);
103 }
106int LauncherItem::progress() const
108 return m_progress;
111void LauncherItem::setProgress(int progress)
113 if (m_progress != progress) {
114 m_progress = progress;
115 Q_EMIT progressChanged(progress);
116 }
119int LauncherItem::count() const
121 return m_count;
124void LauncherItem::setCount(int count)
126 if (m_count != count) {
127 m_count = count;
128 Q_EMIT countChanged(count);
129 }
132bool LauncherItem::focused() const
134 return m_focused;
137void LauncherItem::setFocused(bool focused)
139 if (m_focused != focused) {
140 m_focused = focused;
141 Q_EMIT focusedChanged(focused);
142 }
145unity::shell::launcher::QuickListModelInterface *LauncherItem::quickList() const
147 return m_quickList;