on 156d4fe help sign in
unity8/plugins/Unity/Launcher/backend/launcherbackend.cpp
145 lines 4.8 kB history raw
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * Authors:
5 * Michael Zanetti <michael.zanetti@canonical.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 3.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
20#include "launcherbackend.h"
22#include <QHash>
24LauncherBackend::LauncherBackend(QObject *parent):
25 QObject(parent)
28 // TODO: load default pinned ones from default config, instead of hardcoding here...
30 m_storedApps <<
31 QLatin1String("phone-app.desktop") <<
32 QLatin1String("camera-app.desktop") <<
33 QLatin1String("gallery-app.desktop") <<
34 QLatin1String("facebook-webapp.desktop") <<
35 QLatin1String("webbrowser-app.desktop") <<
36 QLatin1String("twitter-webapp.desktop") <<
37 QLatin1String("gmail-webapp.desktop") <<
38 QLatin1String("ubuntu-weather-app.desktop") <<
39 QLatin1String("notes-app.desktop") <<
40 QLatin1String("ubuntu-calendar-app.desktop");
42 // TODO: get stuff from desktop files instead this hardcoded map
43 m_displayNameMap.insert("phone-app.desktop", "Phone");
44 m_displayNameMap.insert("camera-app.desktop", "Camera");
45 m_displayNameMap.insert("gallery-app.desktop", "Gallery");
46 m_displayNameMap.insert("facebook-webapp.desktop", "Facebook");
47 m_displayNameMap.insert("webbrowser-app.desktop", "Browser");
48 m_displayNameMap.insert("twitter-webapp.desktop", "Twitter");
49 m_displayNameMap.insert("gmail-webapp.desktop", "GMail");
50 m_displayNameMap.insert("ubuntu-weather-app.desktop", "Weather");
51 m_displayNameMap.insert("notes-app.desktop", "Notes");
52 m_displayNameMap.insert("ubuntu-calendar-app.desktop", "Calendar");
54 // TODO: get stuff from desktop files instead this hardcoded map
55 m_iconMap.insert("phone-app.desktop", "phone-app");
56 m_iconMap.insert("camera-app.desktop", "camera");
57 m_iconMap.insert("gallery-app.desktop", "gallery");
58 m_iconMap.insert("facebook-webapp.desktop", "facebook");
59 m_iconMap.insert("webbrowser-app.desktop", "browser");
60 m_iconMap.insert("twitter-webapp.desktop", "twitter");
61 m_iconMap.insert("gmail-webapp.desktop", "gmail");
62 m_iconMap.insert("ubuntu-weather-app.desktop", "weather");
63 m_iconMap.insert("notes-app.desktop", "notepad");
64 m_iconMap.insert("ubuntu-calendar-app.desktop", "calendar");
68LauncherBackend::~LauncherBackend()
73QStringList LauncherBackend::storedApplications() const
75 return m_storedApps;
78void LauncherBackend::setStoredApplications(const QStringList &appIds)
80 m_storedApps = appIds;
81 // TODO: Cleanup pinned state from settings for apps not in list any more.
84QString LauncherBackend::desktopFile(const QString &appId) const
86 // TODO: return real path instead of this hardcoded one
87 return QLatin1String("/usr/share/applications/") + appId;
90QString LauncherBackend::displayName(const QString &appId) const
92 return m_displayNameMap.value(appId);
95QString LauncherBackend::icon(const QString &appId) const
97 return m_iconMap.value(appId);
100bool LauncherBackend::isPinned(const QString &appId) const
102 // TODO: return app's pinned state from settings
103 Q_UNUSED(appId)
104 return true;
107void LauncherBackend::setPinned(const QString &appId, bool pinned)
109 // TODO: Store pinned state in settings.
110 Q_UNUSED(appId)
111 Q_UNUSED(pinned)
114QList<QuickListEntry> LauncherBackend::quickList(const QString &appId) const
116 // TODO: Get static (from .desktop file) and dynamic (from the app itself)
117 // entries and return them here. Frontend related entries (like "Pin to launcher")
118 // don't matter here. This is just the backend part.
119 // TODO: emit quickListChanged() when the dynamic part changes
120 Q_UNUSED(appId)
121 return QList<QuickListEntry>();
124int LauncherBackend::progress(const QString &appId) const
126 // TODO: Return value for progress emblem.
127 // TODO: emit progressChanged() when this value changes.
128 Q_UNUSED(appId)
129 return -1;
132int LauncherBackend::count(const QString &appId) const
134 // TODO: Return value for count emblem.
135 // TODO: emit countChanged() when this value changes.
136 Q_UNUSED(appId)
137 return 0;
140void LauncherBackend::triggerQuickListAction(const QString &appId, const QString &quickListId)
142 // TODO: execute the given quicklist action
143 Q_UNUSED(appId)
144 Q_UNUSED(quickListId)