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 m_quickList->appendAction(nameAction);
45 QuickListEntry pinningAction;
46 pinningAction.setActionId(QStringLiteral("pin_item"));
47 pinningAction.setText(gettext("Pin shortcut"));
48 m_quickList->appendAction(pinningAction);
50 m_quitAction.setActionId(QStringLiteral("stop_item"));
51 m_quitAction.setIcon(QStringLiteral("application-exit"));
52 m_quitAction.setText(gettext("Quit"));
55QString LauncherItem::appId() const
60QString LauncherItem::name() const
65void LauncherItem::setName(const QString &name)
70 entry.setActionId(QStringLiteral("launch_item"));
71 entry.setText(m_name);
72 m_quickList->updateAction(entry);
73 Q_EMIT nameChanged(name);
77QString LauncherItem::icon() const
82void LauncherItem::setIcon(const QString &icon)
86 Q_EMIT iconChanged(icon);
90bool LauncherItem::pinned() const
95void LauncherItem::setPinned(bool pinned)
97 if (m_pinned != pinned) {
99 Q_EMIT pinnedChanged(pinned);
102 // Even if pinned status didn't change, we want to update text in case
103 // the locale has changed since we last set pinned status.
104 QuickListEntry entry;
105 entry.setActionId(QStringLiteral("pin_item"));
106 entry.setText(pinned ? gettext("Unpin shortcut") : gettext("Pin shortcut"));
107 m_quickList->updateAction(entry);
110bool LauncherItem::running() const
115void LauncherItem::setRunning(bool running)
117 if (m_running != running) {
119 if (m_running) { // add the quit action
120 m_quickList->appendAction(m_quitAction);
121 } else { // remove the quit action
122 m_quickList->removeAction(m_quitAction);
124 Q_EMIT runningChanged(running);
128bool LauncherItem::recent() const
133void LauncherItem::setRecent(bool recent)
135 if (m_recent != recent) {
137 Q_EMIT recentChanged(recent);
141int LauncherItem::progress() const
146void LauncherItem::setProgress(int progress)
148 if (m_progress != progress) {
149 m_progress = progress;
150 Q_EMIT progressChanged(progress);
154int LauncherItem::count() const
159void LauncherItem::setCount(int count)
161 if (m_count != count) {
163 Q_EMIT countChanged(count);
164 if (m_countVisible) {
170bool LauncherItem::countVisible() const
172 return m_countVisible;
175void LauncherItem::setCountVisible(bool countVisible)
177 if (m_countVisible != countVisible) {
178 m_countVisible = countVisible;
179 Q_EMIT countVisibleChanged(countVisible);
186bool LauncherItem::focused() const
191void LauncherItem::setFocused(bool focused)
193 if (m_focused != focused) {
198 Q_EMIT focusedChanged(focused);
202bool LauncherItem::alerting() const
207void LauncherItem::setAlerting(bool alerting)
209 if (m_alerting != alerting) {
210 m_alerting = alerting;
211 Q_EMIT alertingChanged(alerting);
215unity::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