on xenial help sign in
distinguish between appId and desktopFile
commit1a631512ac2dedccd55a0315d162a133eab2c78c authorMichael Zanetti <michael.zanetti@canonical.com> dateWed 3 Jul 2013, 12:16 (13 years ago) parentd8ecddf
6 files changed+31−6
Launcher/LauncherPanel.qml+1−1 plugins/Unity/Launcher/backend/launcherbackend.cpp+6 plugins/Unity/Launcher/backend/launcherbackend.h+6 plugins/Unity/Launcher/launcheritem.cpp+7−1 plugins/Unity/Launcher/launcheritem.h+4−1 plugins/Unity/Launcher/launchermodel.cpp+7−3
Launcher/LauncherPanel.qml+1−1
@@ -140,7 +140,7 @@ Item {
140140 maxAngle: 60
141141
142142 onClicked: {
143− root.applicationSelected("/usr/share/applications/" + LauncherModel.get(index).desktopFile);
143+ root.applicationSelected(LauncherModel.get(index).desktopFile);
144144 }
145145 }
146146
plugins/Unity/Launcher/backend/launcherbackend.cpp+6
@@ -56,6 +56,12 @@ void LauncherBackend::setStoredApplications(const QStringList &appIds)
5656 // TODO: Cleanup pinned state from settings for apps not in list any more.
5757}
5858
59+QString LauncherBackend::desktopFile(const QString &appId) const
60+{
61+ // TODO: return real path instead of this hardcoded one
62+ return QLatin1String("/usr/share/applications/") + appId;
63+}
64+
5965QString LauncherBackend::displayName(const QString &appId) const
6066{
6167 // TODO: get stuff from desktop files instead this hardcoded map
plugins/Unity/Launcher/backend/launcherbackend.h+6
@@ -54,6 +54,12 @@ public:
5454 */
5555 void setStoredApplications(const QStringList &appIds);
5656
57+ /**
58+ * @brief Get the full path to the .desktop file.
59+ * @returns The full path to the .dekstop file.
60+ */
61+ QString desktopFile(const QString &appId) const;
62+
5763 /**
5864 * @brief Get the user friendly name of an application.
5965 * @param appId The ID of the application.
plugins/Unity/Launcher/launcheritem.cpp+7−1
@@ -19,8 +19,9 @@
1919
2020#include "launcheritem.h"
2121
22−LauncherItem::LauncherItem(const QString &desktopFile, const QString &name, const QString &icon, QObject *parent) :
22+LauncherItem::LauncherItem(const QString &appId, const QString &desktopFile, const QString &name, const QString &icon, QObject *parent) :
2323 LauncherItemInterface(parent),
24+ m_appId(appId),
2425 m_desktopFile(desktopFile),
2526 m_name(name),
2627 m_icon(icon),
@@ -33,6 +34,11 @@ LauncherItem::LauncherItem(const QString &desktopFile, const QString &name, cons
3334
3435}
3536
37+QString LauncherItem::appId()
38+{
39+ return m_appId;
40+}
41+
3642QString LauncherItem::desktopFile() const
3743{
3844 return m_desktopFile;
plugins/Unity/Launcher/launcheritem.h+4−1
@@ -28,7 +28,9 @@ class LauncherItem: public LauncherItemInterface
2828{
2929 Q_OBJECT
3030public:
31− LauncherItem(const QString &desktopFile, const QString &name, const QString &icon, QObject *parent = 0);
31+ LauncherItem(const QString &appId, const QString &desktopFile, const QString &name, const QString &icon, QObject *parent = 0);
32+
33+ QString appId();
3234
3335 QString desktopFile() const;
3436
@@ -55,6 +57,7 @@ Q_SIGNALS:
5557 void runningChanged(bool running);
5658
5759private:
60+ QString m_appId;
5861 QString m_desktopFile;
5962 QString m_name;
6063 QString m_icon;
plugins/Unity/Launcher/launchermodel.cpp+7−3
@@ -29,7 +29,11 @@ LauncherModel::LauncherModel(QObject *parent):
2929{
3030 Q_FOREACH (const QString &entry, m_backend->storedApplications()) {
3131 qDebug() << "adding app" << entry;
32− LauncherItem *item = new LauncherItem(entry, m_backend->displayName(entry), m_backend->icon(entry), this);
32+ LauncherItem *item = new LauncherItem(entry,
33+ m_backend->desktopFile(entry),
34+ m_backend->displayName(entry),
35+ m_backend->icon(entry),
36+ this);
3337 if (m_backend->isPinned(entry)) {
3438 item->setFavorite(true);
3539 } else {
@@ -97,7 +101,7 @@ void LauncherModel::pin(int index)
97101 item->setFavorite(true);
98102 item->setRecent(false);
99103
100− m_backend->setPinned(item->desktopFile(), true);
104+ m_backend->setPinned(item->appId(), true);
101105
102106 QModelIndex modelIndex = this->index(index);
103107 Q_EMIT dataChanged(modelIndex, modelIndex);
@@ -122,7 +126,7 @@ void LauncherModel::storeAppList()
122126 QStringList appIds;
123127 Q_FOREACH(LauncherItem *item, m_list) {
124128 if (item->favorite() || item->recent()) {
125− appIds << item->desktopFile();
129+ appIds << item->appId();
126130 }
127131 }
128132 m_backend->setStoredApplications(appIds);