on 2563253 help sign in
unity8/plugins/Unity/Launcher/backend/launcherbackend.h
132 lines 4.2 kB history raw
1/* Copyright (C) 2013 Canonical, Ltd.
2 *
3 * Authors:
4 * Michael Zanetti <michael.zanetti@canonical.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
19#ifndef LAUNCHERBACKEND_H
20#define LAUNCHERBACKEND_H
22#include "common/quicklistentry.h"
24#include <QObject>
25#include <QStringList>
26#include <QHash>
28/**
29 * @brief An interface that provides all the data needed by the launcher.
30 */
32class LauncherBackend : public QObject
34 Q_OBJECT
37public:
38 LauncherBackend(QObject *parent = 0);
39 virtual ~LauncherBackend();
41 /**
42 * @brief Returns a list of stored applications.
43 * @returns A list of application IDs.
44 */
45 QStringList storedApplications() const;
47 /**
48 * @brief Set the list of stored applications.
49 *
50 * Any previously stored information for apps not contained
51 * in the list any more, e.g. the pinned state, will be
52 * discarded.
53 *
54 * @param appIds The new list of stored applications.
55 */
56 void setStoredApplications(const QStringList &appIds);
58 /**
59 * @brief Get the full path to the .desktop file.
60 * @returns The full path to the .dekstop file.
61 */
62 QString desktopFile(const QString &appId) const;
64 /**
65 * @brief Get the user friendly name of an application.
66 * @param appId The ID of the application.
67 * @returns The user friendly name of the application.
68 */
69 QString displayName(const QString &appId) const;
71 /**
72 * @brief Get the icon of an application.
73 * @param appId The ID of the application.
74 * @returns The full path to the icon for the application.
75 */
76 QString icon(const QString &appId) const;
78 /**
79 * @brief Is the app manually pinned?
80 * @returns true if pinned, otherwise false.
81 */
82 bool isPinned(const QString &appId) const;
84 /**
85 * @brief Change the pinned state of an application.
86 * @param appId The application where the pinned flag should be set.
87 * @param pinned true if pinned, otherwise false.
88 */
89 void setPinned(const QString &appId, bool pinned);
91 //TODO: Fill in getters for all the other things needed from the .desktop file.
93 /**
94 * @brief Get the QuickList for an application.
95 * @param appId The ID of the application.
96 * @returns A QuickListModelInterface containing the QuickList.
97 */
98 QList<QuickListEntry> quickList(const QString &appId) const;
100 /**
101 * @brief Execute an action from the quickList
102 * @param appId The app ID for which the action was triggered
103 * @param the quicklist ID of the action that was triggered
104 */
105 void triggerQuickListAction(const QString &appId, const QString &entryId);
107 /**
108 * @brief Get the progress for the progress overlay of an application.
109 * @param appId The ID of the application.
110 * @returns The percentage of the overlay progress bar. -1 if no progress bar available.
111 */
112 int progress(const QString &appId) const;
114 /**
115 * @brief Get the count of the count overlay of an application.
116 * @param appId The ID of the application.
117 * @returns The number to be displayed in the overlay. -1 if no count overlay is available.
118 */
119 int count(const QString &appId) const;
121Q_SIGNALS:
122 void quickListChanged(const QString &appId, const QList<QuickListEntry> &quickList);
123 void progressChanged(const QString &appId, int progress);
124 void countChanged(const QString &appId, int count);
126private:
127 QStringList m_storedApps;
128 QHash<QString, QString> m_displayNameMap;
129 QHash<QString, QString> m_iconMap;
130};
132#endif // LAUNCHERBACKEND_H