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 Q_ASSERT(parent != nullptr);
41 QuickListEntry nameAction;
42 nameAction.setActionId(QStringLiteral("launch_item"));
43 nameAction.setText(m_name);
44 m_quickList->appendAction(nameAction);
46 QuickListEntry pinningAction;
47 pinningAction.setActionId(QStringLiteral("pin_item"));
48 pinningAction.setText(gettext("Pin shortcut"));
49 m_quickList->appendAction(pinningAction);
51 m_quitAction.setActionId(QStringLiteral("stop_item"));
52 m_quitAction.setIcon(QStringLiteral("application-exit"));
53 m_quitAction.setText(gettext("Quit"));
56QString LauncherItem::appId() const
61QString LauncherItem::name() const
66void LauncherItem::setName(const QString &name)
71 entry.setActionId(QStringLiteral("launch_item"));
72 entry.setText(m_name);
73 m_quickList->updateAction(entry);
74 Q_EMIT nameChanged(name);
78QString LauncherItem::icon() const
83void LauncherItem::setIcon(const QString &icon)
87 Q_EMIT iconChanged(icon);
91bool LauncherItem::pinned() const
96void LauncherItem::setPinned(bool pinned)
98 if (m_pinned != pinned) {
100 Q_EMIT pinnedChanged(pinned);
103 // Even if pinned status didn't change, we want to update text in case
104 // the locale has changed since we last set pinned status.
105 QuickListEntry entry;
106 entry.setActionId(QStringLiteral("pin_item"));
107 entry.setText(pinned ? gettext("Unpin shortcut") : gettext("Pin shortcut"));
108 m_quickList->updateAction(entry);
111bool LauncherItem::running() const
116void LauncherItem::setRunning(bool running)
118 if (m_running != running) {
120 if (m_running) { // add the quit action
121 m_quickList->appendAction(m_quitAction);
122 } else { // remove the quit action
123 m_quickList->removeAction(m_quitAction);
125 Q_EMIT runningChanged(running);
129bool LauncherItem::recent() const
134void LauncherItem::setRecent(bool recent)
136 if (m_recent != recent) {
138 Q_EMIT recentChanged(recent);
142int LauncherItem::progress() const
147void LauncherItem::setProgress(int progress)
149 if (m_progress != progress) {
150 m_progress = progress;
151 Q_EMIT progressChanged(progress);
155int LauncherItem::count() const
160void LauncherItem::setCount(int count)
162 if (m_count != count) {
164 Q_EMIT countChanged(count);
165 if (m_countVisible) {
171bool LauncherItem::countVisible() const
173 return m_countVisible;
176void LauncherItem::setCountVisible(bool countVisible)
178 if (m_countVisible != countVisible) {
179 m_countVisible = countVisible;
180 Q_EMIT countVisibleChanged(countVisible);
187bool LauncherItem::focused() const
192void LauncherItem::setFocused(bool focused)
194 if (m_focused != focused) {
199 Q_EMIT focusedChanged(focused);
203bool LauncherItem::alerting() const
208void LauncherItem::setAlerting(bool alerting)
210 if (m_alerting != alerting) {
211 m_alerting = alerting;
212 Q_EMIT alertingChanged(alerting);
216unity::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