2 * Copyright 2013 Canonical Ltd.
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.
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.
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/>.
17 * Michael Zanetti <michael.zanetti@canonical.com>
20#include "launcheritem.h"
21#include "quicklistmodel.h"
25LauncherItem::LauncherItem(const QString &appId, const QString &name, const QString &icon, QObject *parent) :
26 LauncherItemInterface(parent),
35 m_countVisible(false),
38 m_quickList(new QuickListModel(this))
40 QuickListEntry nameAction;
41 nameAction.setActionId(QStringLiteral("launch_item"));
42 nameAction.setText(m_name);
43 nameAction.setHasSeparator(true);
44 m_quickList->appendAction(nameAction);
46 QuickListEntry pinningAction;
47 pinningAction.setActionId(QStringLiteral("pin_item"));
48 pinningAction.setText(gettext("Pin shortcut"));
49 pinningAction.setIsPrivate(true);
50 m_quickList->appendAction(pinningAction);
52 m_quitAction.setActionId(QStringLiteral("stop_item"));
53 m_quitAction.setIcon(QStringLiteral("application-exit"));
54 m_quitAction.setText(gettext("Quit"));
55 m_quitAction.setIsPrivate(true);
58QString LauncherItem::appId() const
63QString LauncherItem::name() const
68void LauncherItem::setName(const QString &name)
73 entry.setActionId(QStringLiteral("launch_item"));
74 entry.setText(m_name);
75 m_quickList->updateAction(entry);
76 Q_EMIT nameChanged(name);
80QString LauncherItem::icon() const
85void LauncherItem::setIcon(const QString &icon)
89 Q_EMIT iconChanged(icon);
93QStringList LauncherItem::keywords() const
98void LauncherItem::setKeywords(const QStringList &keywords)
100 if (m_keywords != keywords) {
101 m_keywords = keywords;
102 Q_EMIT keywordsChanged(keywords);
106bool LauncherItem::pinned() const
111void LauncherItem::setPinned(bool pinned)
113 if (m_pinned != pinned) {
115 Q_EMIT pinnedChanged(pinned);
118 // Even if pinned status didn't change, we want to update text in case
119 // the locale has changed since we last set pinned status.
120 QuickListEntry entry;
121 entry.setActionId(QStringLiteral("pin_item"));
122 entry.setText(pinned ? gettext("Unpin shortcut") : gettext("Pin shortcut"));
123 entry.setIsPrivate(true);
124 m_quickList->updateAction(entry);
127bool LauncherItem::running() const
132void LauncherItem::setRunning(bool running)
134 if (m_running != running) {
136 if (m_running) { // add the quit action
137 m_quickList->appendAction(m_quitAction);
138 } else { // remove the quit action
139 m_quickList->removeAction(m_quitAction);
141 Q_EMIT runningChanged(running);
145bool LauncherItem::recent() const
150void LauncherItem::setRecent(bool recent)
152 if (m_recent != recent) {
154 Q_EMIT recentChanged(recent);
158int LauncherItem::progress() const
163void LauncherItem::setProgress(int progress)
165 if (m_progress != progress) {
166 m_progress = progress;
167 Q_EMIT progressChanged(progress);
171int LauncherItem::count() const
176void LauncherItem::setCount(int count)
178 if (m_count != count) {
180 Q_EMIT countChanged(count);
184bool LauncherItem::countVisible() const
186 return m_countVisible;
189void LauncherItem::setCountVisible(bool countVisible)
191 if (m_countVisible != countVisible) {
192 m_countVisible = countVisible;
193 Q_EMIT countVisibleChanged(countVisible);
197bool LauncherItem::focused() const
202void LauncherItem::setFocused(bool focused)
204 if (m_focused != focused) {
206 Q_EMIT focusedChanged(focused);
210bool LauncherItem::alerting() const
215void LauncherItem::setAlerting(bool alerting)
217 if (m_alerting != alerting) {
218 m_alerting = alerting;
219 Q_EMIT alertingChanged(alerting);
223int LauncherItem::surfaceCount() const
225 return m_surfaces.count();
228void LauncherItem::setSurfaces(const QList<QPair<QString, QString> > &surfaces)
230 if (m_surfaces != surfaces) {
231 m_surfaces = surfaces;
233 QList<QuickListEntry> removedEntries;
234 for (int i = 0; i < m_quickList->rowCount(); ++i) {
235 QuickListEntry entry = m_quickList->get(i);
236 if (entry.actionId().startsWith(QStringLiteral("surface_"))) {
237 removedEntries.append(entry);
240 Q_FOREACH (const QuickListEntry &entry, removedEntries) {
241 m_quickList->removeAction(entry);
243 for (int i = 0; i < surfaces.count(); ++i) {
244 QuickListEntry entry;
245 entry.setActionId(QStringLiteral("surface_") + surfaces.at(i).first);
246 entry.setText(surfaces.at(i).second);
247 entry.setIsPrivate(true);
248 if (i == surfaces.count() - 1) {
249 entry.setHasSeparator(true);
251 m_quickList->insertAction(entry, i + 1);
254 Q_EMIT surfaceCountChanged(m_surfaces.count());
258uint LauncherItem::popularity() const
263void LauncherItem::setPopularity(uint popularity)
265 if (m_popularity != popularity) {
266 m_popularity = popularity;
267 Q_EMIT popularityChanged(popularity);
271unity::shell::launcher::QuickListModelInterface *LauncherItem::quickList() const
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list