Unity 8
 All Classes Functions Properties
launcherbackend.h
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  */
18 
19 #ifndef LAUNCHERBACKEND_H
20 #define LAUNCHERBACKEND_H
21 
22 #include "common/quicklistentry.h"
23 
24 #include <QObject>
25 #include <QSettings>
26 #include <QStringList>
27 
28 class AccountsServiceDBusAdaptor;
29 
34 class LauncherBackendItem;
35 
36 class LauncherBackend : public QObject
37 {
38  Q_OBJECT
39 
40 
41 public:
42  LauncherBackend(QObject *parent = 0);
43  virtual ~LauncherBackend();
44 
49  QStringList storedApplications() const;
50 
60  void setStoredApplications(const QStringList &appIds);
61 
69  QString desktopFile(const QString &appId) const;
70 
79  QString displayName(const QString &appId) const;
80 
89  QString icon(const QString &appId) const;
90 
96  QList<QuickListEntry> quickList(const QString &appId) const;
97 
103  void triggerQuickListAction(const QString &appId, const QString &entryId);
104 
110  int progress(const QString &appId) const;
111 
117  int count(const QString &appId) const;
118 
123  void setUser(const QString &username);
124 
125 Q_SIGNALS:
126  void quickListChanged(const QString &appId, const QList<QuickListEntry> &quickList);
127  void progressChanged(const QString &appId, int progress);
128  void countChanged(const QString &appId, int count);
129 
130 private:
131  QString findDesktopFile(const QString &appId) const;
132  LauncherBackendItem* parseDesktopFile(const QString &desktopFile) const;
133 
134  QVariantMap itemToVariant(const QString &appId) const;
135  void loadFromVariant(const QVariantMap &details);
136 
137  bool isDefaultsItem(const QList<QVariantMap> &apps) const;
138  void syncFromAccounts();
139  void syncToAccounts();
140 
141  QList<QString> m_storedApps;
142  mutable QHash<QString, LauncherBackendItem*> m_itemCache;
143 
144  AccountsServiceDBusAdaptor *m_accounts;
145  QString m_user;
146 };
147 
148 #endif // LAUNCHERBACKEND_H