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 nameAction.setHasSeparator(true);
45 m_quickList->appendAction(nameAction);
47 QuickListEntry pinningAction;
48 pinningAction.setActionId(QStringLiteral("pin_item"));
49 pinningAction.setText(gettext("Pin shortcut"));
50 pinningAction.setIsPrivate(true);
51 m_quickList->appendAction(pinningAction);
53 m_quitAction.setActionId(QStringLiteral("stop_item"));
54 m_quitAction.setIcon(QStringLiteral("application-exit"));
55 m_quitAction.setText(gettext("Quit"));
56 m_quitAction.setIsPrivate(true);
59QString LauncherItem::appId() const
64QString LauncherItem::name() const
69void LauncherItem::setName(const QString &name)
74 entry.setActionId(QStringLiteral("launch_item"));
75 entry.setText(m_name);
76 m_quickList->updateAction(entry);
77 Q_EMIT nameChanged(name);
81QString LauncherItem::icon() const
86void LauncherItem::setIcon(const QString &icon)
90 Q_EMIT iconChanged(icon);
94QStringList LauncherItem::keywords() const
99void LauncherItem::setKeywords(const QStringList &keywords)
101 if (m_keywords != keywords) {
102 m_keywords = keywords;
103 Q_EMIT keywordsChanged(keywords);
107bool LauncherItem::pinned() const
112void LauncherItem::setPinned(bool pinned)
114 if (m_pinned != pinned) {
116 Q_EMIT pinnedChanged(pinned);
119 // Even if pinned status didn't change, we want to update text in case
120 // the locale has changed since we last set pinned status.
121 QuickListEntry entry;
122 entry.setActionId(QStringLiteral("pin_item"));
123 entry.setText(pinned ? gettext("Unpin shortcut") : gettext("Pin shortcut"));
124 entry.setIsPrivate(true);
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_surfaces.count();
229void LauncherItem::setSurfaces(const QList<QPair<QString, QString> > &surfaces)
231 if (m_surfaces != surfaces) {
232 m_surfaces = surfaces;
234 QList<QuickListEntry> removedEntries;
235 for (int i = 0; i < m_quickList->rowCount(); ++i) {
236 QuickListEntry entry = m_quickList->get(i);
237 if (entry.actionId().startsWith(QStringLiteral("surface_"))) {
238 removedEntries.append(entry);
241 Q_FOREACH (const QuickListEntry &entry, removedEntries) {
242 m_quickList->removeAction(entry);
244 for (int i = 0; i < surfaces.count(); ++i) {
245 QuickListEntry entry;
246 entry.setActionId(QStringLiteral("surface_") + surfaces.at(i).first);
247 entry.setText(surfaces.at(i).second);
248 entry.setIsPrivate(true);
249 if (i == surfaces.count() - 1) {
250 entry.setHasSeparator(true);
252 m_quickList->insertAction(entry, i + 1);
255 Q_EMIT surfaceCountChanged(m_surfaces.count());
259unity::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