on xenial help sign in
add support for finding icons from click package apps in the launcher.
8fbf399Michael Zanetti
plugins/Unity/Launcher/backend/launcherbackend.cpp+6−1
@@ -300,7 +300,12 @@ LauncherBackendItem* LauncherBackend::parseDesktopFile(const QString &desktopFil
300 LauncherBackendItem* item = new LauncherBackendItem();
300 LauncherBackendItem* item = new LauncherBackendItem();
301 item->desktopFile = desktopFile;
301 item->desktopFile = desktopFile;
302 item->displayName = settings.value("Desktop Entry/Name").toString();
302 item->displayName = settings.value("Desktop Entry/Name").toString();
303+
304+ if (settings.contains("Desktop Entry/Path")) {
303− item->icon = settings.value("Desktop Entry/Icon").toString();
305+ item->icon = settings.value("Desktop Entry/Path").toString() + "/" + settings.value("Desktop Entry/Icon").toString();
306+ } else {
307+ item->icon = settings.value("Desktop Entry/Icon").toString();
308+ }
304 item->pinned = false;
309 item->pinned = false;
305 return item;
310 return item;
306}
311}
tests/plugins/Unity/Launcher/CMakeLists.txt+9
@@ -57,3 +57,12 @@ foreach(DESKTOP_FILE ${DESKTOP_FILES})
57 DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
57 DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
58 )
58 )
59endforeach()
59endforeach()
60+
61+# copy .svg files into build directory for shadow builds
62+file(GLOB DESKTOP_FILES *.svg)
63+
64+foreach(DESKTOP_FILE ${DESKTOP_FILES})
65+ file(COPY "${DESKTOP_FILE}"
66+ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
67+ )
68+endforeach()
tests/plugins/Unity/Launcher/click-icon.desktopnew file+4
@@ -0,0 +1,4 @@
1+[Desktop Entry]
2+Name=Click Package Icon
3+Icon=click-icon.svg
4+Path=/path/to/some/click/app
tests/plugins/Unity/Launcher/launcherbackendtest.cpp+25
@@ -54,6 +54,31 @@ private Q_SLOTS:
54 QCOMPARE(backend.isPinned("rel-icon"), true);
54 QCOMPARE(backend.isPinned("rel-icon"), true);
55 QCOMPARE(backend.isPinned("no-name"), false); // doesn't exist anymore!
55 QCOMPARE(backend.isPinned("no-name"), false); // doesn't exist anymore!
56 }
56 }
57+
58+ void testIcon_data() {
59+ QTest::addColumn<QString>("appId");
60+ QTest::addColumn<QString>("expectedIcon");
61+
62+ // Needs to expand a relative icon to the absolute path
63+ QTest::newRow("relative icon path") << "rel-icon" << QDir::currentPath() + "/rel-icon.svg";
64+
65+ // In case an icon is not found on disk, it needs to fallback on image://theme/ for it
66+ QTest::newRow("fallback on theme") << "abs-icon" << "image://theme//path/to/icon.png";
67+
68+ // Click packages have a relative icon path but an absolute path as a separate entry
69+ // As we don't want to rely on a click app being installed for the test, accept it with the image://theme fallback
70+ QTest::newRow("click package icon") << "click-icon" << "image://theme//path/to/some/click/app/click-icon.svg";
71+ }
72+
73+ void testIcon() {
74+ QFETCH(QString, appId);
75+ QFETCH(QString, expectedIcon);
76+
77+ LauncherBackend backend(false);
78+ backend.setStoredApplications(QStringList() << appId);
79+
80+ QCOMPARE(backend.icon(appId), expectedIcon);
81+ }
57};
82};
58
83
59QTEST_GUILESS_MAIN(LauncherBackendTest)
84QTEST_GUILESS_MAIN(LauncherBackendTest)
tests/plugins/Unity/Launcher/rel-icon.desktop+1−1
@@ -1,3 +1,3 @@
1[Desktop Entry]
1[Desktop Entry]
2Name=Relative Icon
2Name=Relative Icon
3−Icon=rel-icon
3+Icon=rel-icon.svg
tests/plugins/Unity/Launcher/rel-icon.svgnew file

No changes to the content.