on xenial help sign in
add support for finding icons from click package apps in the launcher.

Approved by PS Jenkins bot, Gerry Boland.

commit8fbf399b50ffbded458e865915760de94695cecc authorMichael Zanetti <michael.zanetti@canonical.com> dateWed 11 Sep 2013, 16:54 (13 years ago) parentd1548487e8832e
6 files changed+45−2
plugins/Unity/Launcher/backend/launcherbackend.cpp+6−1 tests/plugins/Unity/Launcher/CMakeLists.txt+9 tests/plugins/Unity/Launcher/click-icon.desktop+4 tests/plugins/Unity/Launcher/launcherbackendtest.cpp+25 tests/plugins/Unity/Launcher/rel-icon.desktop+1−1 tests/plugins/Unity/Launcher/rel-icon.svg
plugins/Unity/Launcher/backend/launcherbackend.cpp+6−1
@@ -300,7 +300,12 @@ LauncherBackendItem* LauncherBackend::parseDesktopFile(const QString &desktopFil
300300 LauncherBackendItem* item = new LauncherBackendItem();
301301 item->desktopFile = desktopFile;
302302 item->displayName = settings.value("Desktop Entry/Name").toString();
303− item->icon = settings.value("Desktop Entry/Icon").toString();
303+
304+ if (settings.contains("Desktop Entry/Path")) {
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+ }
304309 item->pinned = false;
305310 return item;
306311}
tests/plugins/Unity/Launcher/CMakeLists.txt+9
@@ -57,3 +57,12 @@ foreach(DESKTOP_FILE ${DESKTOP_FILES})
5757 DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
5858 )
5959endforeach()
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:
5454 QCOMPARE(backend.isPinned("rel-icon"), true);
5555 QCOMPARE(backend.isPinned("no-name"), false); // doesn't exist anymore!
5656 }
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+ }
5782};
5883
5984QTEST_GUILESS_MAIN(LauncherBackendTest)
tests/plugins/Unity/Launcher/rel-icon.desktop+1−1
@@ -1,3 +1,3 @@
11[Desktop Entry]
22Name=Relative Icon
3−Icon=rel-icon
3+Icon=rel-icon.svg
tests/plugins/Unity/Launcher/rel-icon.svgnew file

No changes to the content.