on bbab3ce help sign in
unity8/plugins/Unity/Launcher/launcheritem.cpp
137 lines 3.1 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_quickList(new QuickListModel(this))
36 QuickListEntry nameAction;
37 nameAction.setText(m_name);
38 m_quickList->appendAction(nameAction);
39 QuickListEntry pinningAction;
40 pinningAction.setActionId("pin_item");
41 pinningAction.setText("Pin to Launcher");
42 m_quickList->appendAction(pinningAction);
45QString LauncherItem::appId() const
47 return m_appId;
50QString LauncherItem::desktopFile() const
52 return m_desktopFile;
55QString LauncherItem::name() const
57 return m_name;
60QString LauncherItem::icon() const
62 return m_icon;
65bool LauncherItem::pinned() const
67 return m_pinned;
70void LauncherItem::setPinned(bool pinned)
72 if (m_pinned != pinned) {
73 m_pinned = pinned;
74 QuickListEntry entry;
75 entry.setActionId("pin_item");
76 entry.setText(pinned ? "Remove from Launcher": "Pin to Launcher");
77 m_quickList->updateAction(entry);
78 Q_EMIT pinnedChanged(pinned);
79 }
82bool LauncherItem::running() const
84 return m_running;
87void LauncherItem::setRunning(bool running)
89 if (m_running != running) {
90 m_running = running;
91 Q_EMIT runningChanged(running);
92 }
95bool LauncherItem::recent() const
97 return m_recent;
100void LauncherItem::setRecent(bool recent)
102 if (m_recent != recent) {
103 m_recent = recent;
104 Q_EMIT recentChanged(recent);
105 }
108int LauncherItem::progress() const
110 return m_progress;
113void LauncherItem::setProgress(int progress)
115 if (m_progress != progress) {
116 m_progress = progress;
117 Q_EMIT progressChanged(progress);
118 }
121int LauncherItem::count() const
123 return m_count;
126void LauncherItem::setCount(int count)
128 if (m_count != count) {
129 m_count = count;
130 Q_EMIT countChanged(count);
131 }
134unity::shell::launcher::QuickListModelInterface *LauncherItem::quickList() const
136 return m_quickList;