User widgets / plasmoids can contain a custom icon in their contents/ folder by specifying in their etadata.json file with a leading "/" such as: "Icon" : "/lightstrands.png", (see also https://bugs.kde.org/show_bug.cgi?id=507678) However, this fails to display properly in configuration with the default AboutPlugin.qml file. I'd like to fix this. I'd like to update the method: https://invent.kde.org/frameworks/kcoreaddons/-/blob/master/src/lib/plugin/kpluginmetadata.cpp?ref_type=heads#L373-377 To include logic from the previous bug: https://invent.kde.org/plasma/plasma-workspace/-/blob/master/components/shellprivate/plasmaappletitemmodel.cpp?ref_type=heads#L62-67 1) In general, does this seem reasonable? 2) In particular, I'd need to include <KPackage/PackageLoader> in kcoreaddons. I've tried that, but my build fails: /home/mark/kde/src/kcoreaddons/src/lib/plugin/kpluginmetadata.cpp:16:10: fatal error: KPackage/PackageLoader: No such file or directory 16 | #include <KPackage/PackageLoader> Do I need to update the CMakeLists.txt file to support this? I'd need some very specific help here :-/
In this case, what does KPluginMetaData::iconName() return? Is it not "/lightstrands.png"?
Yes it is.
Alternatively, I could derive it like in an earlier WIP. const QString localAppletLocation = QStandardPaths::writableLocation( QStandardPaths::GenericDataLocation) + QLatin1String("/plasma/plasmoids/"); const QString localAppletContents = QLatin1String("/contents/"); const QString fullIconName = localAppletLocation + pluginName + localAppletContents + iconName;
In that case, all we need to do is teach the AboutPlugin and Widget Explorer (and maybe the System Tray's config window, for widgets that can live in the tray) about this type of Icon= path, as in your code example.
That's close to my understanding... I tried the last example just now and it works for AboutPlugin, but then WidgetExplorer panel breaks due to what is now duplicate code involving icon starting with "/". Removing the original code from https://invent.kde.org/plasma/plasma-workspace/-/blob/master/components/shellprivate/plasmaappletitemmodel.cpp?ref_type=heads#L62-67 and leaving the new block in .... kpluginmetadata.cpp works wonderfully ! It uniformly displays in the WidgetExplorer panel, & the AboutPlugin for desktop and plasmoidviewer :-) What do you mean by |System Tray's config window| ? It's About page shows a bell icon.
(In reply to Mark Capella from comment #5) > What do you mean by |System Tray's config window| ? It's About page shows a > bell icon. Widget icons are displayed in the table on the "Entries" page.
All looks well there. Icons for entries such as "Power and Battery" & "Audio Volume" are visible and representative.
So, would you like me to issue merge requests for the two repos with the proposed patches ? kcoreaddons & plasma-workspace
It's still not clear to me why kcoreaddons needs a patch.
I've tried three of my own approaches on this bug so far & you've lost me. Are you familiar with this section of code? Please suggest your complete solution to resolve this. I'd like to work on other things.
You can work on whatever you want; this isn't a big company. :) If you do want to work on this, it isn't yet clear to me why KPluginMetaData::iconName() needs any changes. It does its job of returning the value for the Icon key. In the code that makes use of this function in various places, we need to detect when the icon is a path rather than just a name, and handle it accordingly.
Thank you! AboutPlugin.qml for example https://invent.kde.org/plasma/plasma-sdk/-/blame/master/plasmoidviewer/qmlpackages/shell/contents/configuration/AboutPlugin.qml?ref_type=heads#L111 I can examine and modify iconName here at runtime. -BUT- I don't know how in QML to get the users home directory, or more specifically the applet install path. One of my initial patches in bug (1) built a new QML type provider so I could slip into C++ and get the users home directory. 1) https://bugs.kde.org/show_bug.cgi?id=507678 I'm very new to the QML, so you can't insult me with detail instructions. I may be missing something basic :-)
Check out https://doc.qt.io/qt-6/qml-qtcore-standardpaths.html! I think `StandardPaths.locate(StandardPaths.GenericDataLocation, [the filename of the icon])` might do what you're looking for.
Thank-you Nate! That broke my logjam :-) I think this patch solves this bug: diff --git a/desktoppackage/contents/configuration/AboutPlugin.qml b/desktoppackage/contents/configuration/AboutPlugin.qml index dcb57ad9c6..a7df13819a 100644 --- a/desktoppackage/contents/configuration/AboutPlugin.qml +++ b/desktoppackage/contents/configuration/AboutPlugin.qml @@ -5,6 +5,8 @@ SPDX-License-Identifier: LGPL-2.0-or-later */ +import QtCore + import QtQuick import QtQuick.Controls 2.4 as QQC2 import QtQuick.Layouts 1.3 @@ -114,7 +116,19 @@ KCM.SimpleKCM { Layout.preferredWidth: height Layout.maximumWidth: page.width / 3; Layout.rightMargin: Kirigami.Units.largeSpacing - source: page.metaData.iconName || page.metaData.pluginId + + source: { + const iconName = page.metaData.iconName; + if (iconName.charAt(0) == "/") { + const fileName = "plasma/plasmoids/" + + page.metaData.pluginId + "/contents/" + + iconName.substring(1); + return StandardPaths.locate(StandardPaths. + GenericDataLocation, fileName); + } + return page.metaData.iconName || + page.metaData.pluginId; + } fallback: "application-x-plasma" }