on 96870d5 help sign in
unity8/plugins/Greeter/Unity/Launcher/launcheritem.cpp
174 lines 3.6 kB history raw
1/*
2 * Copyright 2014 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);
45QString LauncherItem::appId() const
47 return m_appId;
50QString LauncherItem::name() const
52 return m_name;
55void LauncherItem::setName(const QString &name)
57 if (m_name != name) {
58 m_name = name;
59 QuickListEntry entry;
60 entry.setActionId("launch_item");
61 entry.setText(m_name);
62 m_quickList->updateAction(entry);
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 Q_EMIT pinnedChanged(pinned);
90 }
93bool LauncherItem::running() const
95 return m_running;
98void LauncherItem::setRunning(bool running)
100 if (m_running != running) {
101 m_running = running;
102 Q_EMIT runningChanged(running);
103 }
106bool LauncherItem::recent() const
108 return m_recent;
111void LauncherItem::setRecent(bool recent)
113 if (m_recent != recent) {
114 m_recent = recent;
115 Q_EMIT recentChanged(recent);
116 }
119int LauncherItem::progress() const
121 return m_progress;
124void LauncherItem::setProgress(int progress)
126 if (m_progress != progress) {
127 m_progress = progress;
128 Q_EMIT progressChanged(progress);
129 }
132int LauncherItem::count() const
134 return m_count;
137void LauncherItem::setCount(int count)
139 if (m_count != count) {
140 m_count = count;
141 Q_EMIT countChanged(count);
142 }
145bool LauncherItem::countVisible() const
147 return m_countVisible;
150void LauncherItem::setCountVisible(bool countVisible)
152 if (m_countVisible != countVisible) {
153 m_countVisible = countVisible;
154 Q_EMIT countVisibleChanged(countVisible);
155 }
158bool LauncherItem::focused() const
160 return m_focused;
163void LauncherItem::setFocused(bool focused)
165 if (m_focused != focused) {
166 m_focused = focused;
167 Q_EMIT focusedChanged(focused);
168 }
171unity::shell::launcher::QuickListModelInterface *LauncherItem::quickList() const
173 return m_quickList;