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),
39 m_quickList(new QuickListModel(this))
41 Q_ASSERT(parent != nullptr);
42 QuickListEntry nameAction;
43 nameAction.setActionId(QStringLiteral("launch_item"));
44 nameAction.setText(m_name);
45 nameAction.setHasSeparator(true);
46 m_quickList->appendAction(nameAction);
48 QuickListEntry pinningAction;
49 pinningAction.setActionId(QStringLiteral("pin_item"));
50 pinningAction.setText(gettext("Pin shortcut"));
51 pinningAction.setIsPrivate(true);
52 m_quickList->appendAction(pinningAction);
54 m_quitAction.setActionId(QStringLiteral("stop_item"));
55 m_quitAction.setIcon(QStringLiteral("application-exit"));
56 m_quitAction.setText(gettext("Quit"));
57 m_quitAction.setIsPrivate(true);
60QString LauncherItem::appId() const
65QString LauncherItem::name() const
70void LauncherItem::setName(const QString &name)
75 entry.setActionId(QStringLiteral("launch_item"));
76 entry.setText(m_name);
77 m_quickList->updateAction(entry);
78 Q_EMIT nameChanged(name);
82QString LauncherItem::icon() const
87void LauncherItem::setIcon(const QString &icon)
91 Q_EMIT iconChanged(icon);
95QStringList LauncherItem::keywords() const
100void LauncherItem::setKeywords(const QStringList &keywords)
102 if (m_keywords != keywords) {
103 m_keywords = keywords;
104 Q_EMIT keywordsChanged(keywords);
108bool LauncherItem::pinned() const
113void LauncherItem::setPinned(bool pinned)
115 if (m_pinned != pinned) {
117 Q_EMIT pinnedChanged(pinned);
120 // Even if pinned status didn't change, we want to update text in case
121 // the locale has changed since we last set pinned status.
122 QuickListEntry entry;
123 entry.setActionId(QStringLiteral("pin_item"));
124 entry.setText(pinned ? gettext("Unpin shortcut") : gettext("Pin shortcut"));
125 m_quickList->updateAction(entry);
128bool LauncherItem::running() const
133void LauncherItem::setRunning(bool running)
135 if (m_running != running) {
137 if (m_running) { // add the quit action
138 m_quickList->appendAction(m_quitAction);
139 } else { // remove the quit action
140 m_quickList->removeAction(m_quitAction);
142 Q_EMIT runningChanged(running);
146bool LauncherItem::recent() const
151void LauncherItem::setRecent(bool recent)
153 if (m_recent != recent) {
155 Q_EMIT recentChanged(recent);
159int LauncherItem::progress() const
164void LauncherItem::setProgress(int progress)
166 if (m_progress != progress) {
167 m_progress = progress;
168 Q_EMIT progressChanged(progress);
172int LauncherItem::count() const
177void LauncherItem::setCount(int count)
179 if (m_count != count) {
181 Q_EMIT countChanged(count);
185bool LauncherItem::countVisible() const
187 return m_countVisible;
190void LauncherItem::setCountVisible(bool countVisible)
192 if (m_countVisible != countVisible) {
193 m_countVisible = countVisible;
194 Q_EMIT countVisibleChanged(countVisible);
198bool LauncherItem::focused() const
203void LauncherItem::setFocused(bool focused)
205 if (m_focused != focused) {
207 Q_EMIT focusedChanged(focused);
211bool LauncherItem::alerting() const
216void LauncherItem::setAlerting(bool alerting)
218 if (m_alerting != alerting) {
219 m_alerting = alerting;
220 Q_EMIT alertingChanged(alerting);
224int LauncherItem::surfaceCount() const
226 return m_surfaceCount;
229void LauncherItem::setSurfaceCount(int surfaceCount)
231 if (m_surfaceCount != surfaceCount) {
232 m_surfaceCount = surfaceCount;
233 Q_EMIT surfaceCountChanged(surfaceCount);
237unity::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