on 3efba52 help sign in
unity8/plugins/Unity/Launcher/launcheritem.cpp
151 lines 3.3 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"
23LauncherItem::LauncherItem(const QString &appId, const QString &desktopFile, const QString &name, const QString &icon, QObject *parent) :
24 LauncherItemInterface(parent),
25 m_appId(appId),
26 m_desktopFile(desktopFile),
27 m_name(name),
28 m_icon(icon),
29 m_pinned(false),
30 m_running(false),
31 m_recent(false),
32 m_progress(-1),
33 m_count(0),
34 m_focused(false),
35 m_quickList(new QuickListModel(this))
37 QuickListEntry nameAction;
38 nameAction.setText(m_name);
39 m_quickList->appendAction(nameAction);
40 QuickListEntry pinningAction;
41 pinningAction.setActionId("pin_item");
42 pinningAction.setText("Pin to Launcher");
43 m_quickList->appendAction(pinningAction);
46QString LauncherItem::appId() const
48 return m_appId;
51QString LauncherItem::desktopFile() const
53 return m_desktopFile;
56QString LauncherItem::name() const
58 return m_name;
61QString LauncherItem::icon() const
63 return m_icon;
66bool LauncherItem::pinned() const
68 return m_pinned;
71void LauncherItem::setPinned(bool pinned)
73 if (m_pinned != pinned) {
74 m_pinned = pinned;
75 QuickListEntry entry;
76 entry.setActionId("pin_item");
77 entry.setText(pinned ? "Remove from Launcher": "Pin to Launcher");
78 m_quickList->updateAction(entry);
79 Q_EMIT pinnedChanged(pinned);
80 }
83bool LauncherItem::running() const
85 return m_running;
88void LauncherItem::setRunning(bool running)
90 if (m_running != running) {
91 m_running = running;
92 Q_EMIT runningChanged(running);
93 }
96bool LauncherItem::recent() const
98 return m_recent;
101void LauncherItem::setRecent(bool recent)
103 if (m_recent != recent) {
104 m_recent = recent;
105 Q_EMIT recentChanged(recent);
106 }
109int LauncherItem::progress() const
111 return m_progress;
114void LauncherItem::setProgress(int progress)
116 if (m_progress != progress) {
117 m_progress = progress;
118 Q_EMIT progressChanged(progress);
119 }
122int LauncherItem::count() const
124 return m_count;
127void LauncherItem::setCount(int count)
129 if (m_count != count) {
130 m_count = count;
131 Q_EMIT countChanged(count);
132 }
135bool LauncherItem::focused() const
137 return m_focused;
140void LauncherItem::setFocused(bool focused)
142 if (m_focused != focused) {
143 m_focused = focused;
144 Q_EMIT focusedChanged(focused);
145 }
148unity::shell::launcher::QuickListModelInterface *LauncherItem::quickList() const
150 return m_quickList;