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 m_quickList->appendAction(nameAction);
47 QuickListEntry pinningAction;
48 pinningAction.setActionId(QStringLiteral("pin_item"));
49 pinningAction.setText(gettext("Pin shortcut"));
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"));
57QString LauncherItem::appId() const
62QString LauncherItem::name() const
67void LauncherItem::setName(const QString &name)
72 entry.setActionId(QStringLiteral("launch_item"));
73 entry.setText(m_name);
74 m_quickList->updateAction(entry);
75 Q_EMIT nameChanged(name);
79QString LauncherItem::icon() const
84void LauncherItem::setIcon(const QString &icon)
88 Q_EMIT iconChanged(icon);
92QStringList LauncherItem::keywords() const
97void LauncherItem::setKeywords(const QStringList &keywords)
99 if (m_keywords != keywords) {
100 m_keywords = keywords;
101 Q_EMIT keywordsChanged(keywords);
105bool LauncherItem::pinned() const
110void LauncherItem::setPinned(bool pinned)
112 if (m_pinned != pinned) {
114 Q_EMIT pinnedChanged(pinned);
117 // Even if pinned status didn't change, we want to update text in case
118 // the locale has changed since we last set pinned status.
119 QuickListEntry entry;
120 entry.setActionId(QStringLiteral("pin_item"));
121 entry.setText(pinned ? gettext("Unpin shortcut") : gettext("Pin shortcut"));
122 m_quickList->updateAction(entry);
125bool LauncherItem::running() const
130void LauncherItem::setRunning(bool running)
132 if (m_running != running) {
134 if (m_running) { // add the quit action
135 m_quickList->appendAction(m_quitAction);
136 } else { // remove the quit action
137 m_quickList->removeAction(m_quitAction);
139 Q_EMIT runningChanged(running);
143bool LauncherItem::recent() const
148void LauncherItem::setRecent(bool recent)
150 if (m_recent != recent) {
152 Q_EMIT recentChanged(recent);
156int LauncherItem::progress() const
161void LauncherItem::setProgress(int progress)
163 if (m_progress != progress) {
164 m_progress = progress;
165 Q_EMIT progressChanged(progress);
169int LauncherItem::count() const
174void LauncherItem::setCount(int count)
176 if (m_count != count) {
178 Q_EMIT countChanged(count);
182bool LauncherItem::countVisible() const
184 return m_countVisible;
187void LauncherItem::setCountVisible(bool countVisible)
189 if (m_countVisible != countVisible) {
190 m_countVisible = countVisible;
191 Q_EMIT countVisibleChanged(countVisible);
195bool LauncherItem::focused() const
200void LauncherItem::setFocused(bool focused)
202 if (m_focused != focused) {
204 Q_EMIT focusedChanged(focused);
208bool LauncherItem::alerting() const
213void LauncherItem::setAlerting(bool alerting)
215 if (m_alerting != alerting) {
216 m_alerting = alerting;
217 Q_EMIT alertingChanged(alerting);
221int LauncherItem::surfaceCount() const
223 return m_surfaceCount;
226void LauncherItem::setSurfaceCount(int surfaceCount)
228 if (m_surfaceCount != surfaceCount) {
229 m_surfaceCount = surfaceCount;
230 Q_EMIT surfaceCountChanged(surfaceCount);
234unity::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