on xenial help sign in
Launcher - remove support for pinning items in the backend
e878ba0Michael Zanetti
plugins/Unity/Launcher/backend/launcherbackend.cpp−33
@@ -30,12 +30,9 @@
30class LauncherBackendItem
30class LauncherBackendItem
31{
31{
32public:
32public:
33− LauncherBackendItem(): pinned(false) {}
34−
35 QString desktopFile;
33 QString desktopFile;
36 QString displayName;
34 QString displayName;
37 QString icon;
35 QString icon;
38− bool pinned;
39};
36};
40
37
41LauncherBackend::LauncherBackend(QObject *parent):
38LauncherBackend::LauncherBackend(QObject *parent):
@@ -135,32 +132,6 @@ QString LauncherBackend::icon(const QString &appId) const
135 return iconName;
132 return iconName;
136}
133}
137
134
138−bool LauncherBackend::isPinned(const QString &appId) const
139−{
140− LauncherBackendItem *item = m_itemCache.value(appId);
141− if (item) {
142− return item->pinned;
143− }
144− return false;
145−}
146−
147−void LauncherBackend::setPinned(const QString &appId, bool pinned)
148−{
149− if (!m_storedApps.contains(appId)) {
150− return;
151− }
152−
153− LauncherBackendItem *item = m_itemCache.value(appId);
154− if (!item) {
155− item = new LauncherBackendItem();
156− m_itemCache.insert(appId, item);
157− }
158− if (item->pinned != pinned) {
159− item->pinned = pinned;
160− syncToAccounts();
161− }
162−}
163−
164QList<QuickListEntry> LauncherBackend::quickList(const QString &appId) const
135QList<QuickListEntry> LauncherBackend::quickList(const QString &appId) const
165{
136{
166 // TODO: Get static (from .desktop file) and dynamic (from the app itself)
137 // TODO: Get static (from .desktop file) and dynamic (from the app itself)
@@ -233,7 +204,6 @@ void LauncherBackend::syncFromAccounts()
233 if (!m_itemCache.contains(appId)) {
204 if (!m_itemCache.contains(appId)) {
234 m_itemCache.insert(appId, parseDesktopFile(df));
205 m_itemCache.insert(appId, parseDesktopFile(df));
235 }
206 }
236− m_itemCache.value(appId)->pinned = true;
237 }
207 }
238 }
208 }
239 }
209 }
@@ -305,7 +275,6 @@ LauncherBackendItem* LauncherBackend::parseDesktopFile(const QString &desktopFil
305 } else {
275 } else {
306 item->icon = "image://theme/" + iconString;
276 item->icon = "image://theme/" + iconString;
307 }
277 }
308− item->pinned = false;
309 return item;
278 return item;
310}
279}
311
280
@@ -326,7 +295,6 @@ void LauncherBackend::loadFromVariant(const QVariantMap &details)
326 item->desktopFile = details.value("desktopFile").toString();
295 item->desktopFile = details.value("desktopFile").toString();
327 item->displayName = details.value("name").toString();
296 item->displayName = details.value("name").toString();
328 item->icon = details.value("icon").toString();
297 item->icon = details.value("icon").toString();
329− item->pinned = details.value("is-pinned").toBool();
330
298
331 m_itemCache.insert(appId, item);
299 m_itemCache.insert(appId, item);
332 m_storedApps.append(appId);
300 m_storedApps.append(appId);
@@ -340,7 +308,6 @@ QVariantMap LauncherBackend::itemToVariant(const QString &appId) const
340 details.insert("name", item->displayName);
308 details.insert("name", item->displayName);
341 details.insert("icon", item->icon);
309 details.insert("icon", item->icon);
342 details.insert("desktopFile", item->desktopFile);
310 details.insert("desktopFile", item->desktopFile);
343− details.insert("is-pinned", item->pinned);
344 return details;
311 return details;
345}
312}
346
313
plugins/Unity/Launcher/backend/launcherbackend.h−15
@@ -88,21 +88,6 @@ public:
88 */
88 */
89 QString icon(const QString &appId) const;
89 QString icon(const QString &appId) const;
90
90
91− /**
92− * @brief Is the app manually pinned?
93− * @returns true if pinned, otherwise false.
94− */
95− bool isPinned(const QString &appId) const;
96−
97− /**
98− * @brief Change the pinned state of an application.
99− * @param appId The application where the pinned flag should be set.
100− * @param pinned true if pinned, otherwise false.
101− */
102− void setPinned(const QString &appId, bool pinned);
103−
104− //TODO: Fill in getters for all the other things needed from the .desktop file.
105−
106 /**
91 /**
107 * @brief Get the QuickList for an application.
92 * @brief Get the QuickList for an application.
108 * @param appId The ID of the application.
93 * @param appId The ID of the application.
plugins/Unity/Launcher/launchermodel.cpp+3−7
@@ -38,11 +38,7 @@ LauncherModel::LauncherModel(QObject *parent):
38 m_backend->displayName(entry),
38 m_backend->displayName(entry),
39 m_backend->icon(entry),
39 m_backend->icon(entry),
40 this);
40 this);
41− if (m_backend->isPinned(entry)) {
42− item->setPinned(true);
41+ item->setPinned(true);
43− } else {
44− item->setRecent(true);
45− }
46 m_list.append(item);
42 m_list.append(item);
47 }
43 }
48}
44}
@@ -129,11 +125,12 @@ void LauncherModel::pin(const QString &appId, int index)
129 if (currentIndex >= 0) {
125 if (currentIndex >= 0) {
130 if (index == -1 || index == currentIndex) {
126 if (index == -1 || index == currentIndex) {
131 m_list.at(currentIndex)->setPinned(true);
127 m_list.at(currentIndex)->setPinned(true);
132− m_backend->setPinned(appId, true);
133 QModelIndex modelIndex = this->index(currentIndex);
128 QModelIndex modelIndex = this->index(currentIndex);
134 Q_EMIT dataChanged(modelIndex, modelIndex);
129 Q_EMIT dataChanged(modelIndex, modelIndex);
135 } else {
130 } else {
136 move(currentIndex, index);
131 move(currentIndex, index);
132+ // move() will store the list to the backend itself, so just exit at this point.
133+ return;
137 }
134 }
138 } else {
135 } else {
139 if (index == -1) {
136 if (index == -1) {
@@ -144,7 +141,6 @@ void LauncherModel::pin(const QString &appId, int index)
144 m_backend->displayName(appId),
141 m_backend->displayName(appId),
145 m_backend->icon(appId));
142 m_backend->icon(appId));
146 item->setPinned(true);
143 item->setPinned(true);
147− m_backend->setPinned(appId, true);
148 m_list.insert(index, item);
144 m_list.insert(index, item);
149 endInsertRows();
145 endInsertRows();
150 }
146 }
tests/plugins/Unity/Launcher/launcherbackendtest.cpp−21
@@ -43,27 +43,6 @@ private Q_SLOTS:
43 QCOMPARE(backend.storedApplications(), QStringList() << "rel-icon" << "abs-icon");
43 QCOMPARE(backend.storedApplications(), QStringList() << "rel-icon" << "abs-icon");
44 }
44 }
45
45
46− void testPinning()
47− {
48− LauncherBackend backend;
49−
50− backend.setStoredApplications(QStringList() << "rel-icon" << "abs-icon");
51− QCOMPARE(backend.isPinned("rel-icon"), false);
52− QCOMPARE(backend.isPinned("abs-icon"), false);
53−
54− backend.setPinned("rel-icon", true);
55− QCOMPARE(backend.isPinned("rel-icon"), true);
56−
57− backend.setStoredApplications(QStringList() << "rel-icon" << "abs-icon" << "no-name");
58− QCOMPARE(backend.isPinned("rel-icon"), true);
59− QCOMPARE(backend.isPinned("no-name"), false);
60−
61− backend.setPinned("no-name", true);
62− backend.setStoredApplications(QStringList() << "rel-icon" << "abs-icon");
63− QCOMPARE(backend.isPinned("rel-icon"), true);
64− QCOMPARE(backend.isPinned("no-name"), false); // doesn't exist anymore!
65− }
66−
67 void testIcon_data() {
46 void testIcon_data() {
68 QTest::addColumn<QString>("appId");
47 QTest::addColumn<QString>("appId");
69 QTest::addColumn<QString>("expectedIcon");
48 QTest::addColumn<QString>("expectedIcon");