Bug 509896 - Allow Icons embedded in plasmoids to display correctly in AboutPlugin config page
Summary: Allow Icons embedded in plasmoids to display correctly in AboutPlugin config ...
Status: CONFIRMED
Alias: None
Product: plasmashell
Classification: Plasma
Component: general (other bugs)
Version First Reported In: 6.4.5
Platform: Other Linux
: NOR wishlist
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-09-24 21:05 UTC by Mark Capella
Modified: 2025-10-01 01:12 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Capella 2025-09-24 21:05:07 UTC
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   :-/
Comment 1 Nate Graham 2025-09-24 21:11:22 UTC
In this case, what does KPluginMetaData::iconName() return? Is it not "/lightstrands.png"?
Comment 2 Mark Capella 2025-09-24 22:02:38 UTC
Yes it is.
Comment 3 Mark Capella 2025-09-24 22:16:58 UTC
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;
Comment 4 Nate Graham 2025-09-24 22:38:04 UTC
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.
Comment 5 Mark Capella 2025-09-24 23:32:55 UTC
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.
Comment 6 Nate Graham 2025-09-24 23:42:10 UTC
(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.
Comment 7 Mark Capella 2025-09-25 00:07:36 UTC
All looks well there. Icons for entries such as "Power and Battery" & "Audio Volume" are visible and representative.
Comment 8 Mark Capella 2025-09-26 00:15:30 UTC
So, would you like me to issue merge requests for the two repos with the proposed patches ?

kcoreaddons & plasma-workspace
Comment 9 Nate Graham 2025-09-26 15:41:19 UTC
It's still not clear to me why kcoreaddons needs a patch.
Comment 10 Mark Capella 2025-09-26 16:32:53 UTC
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.
Comment 11 Nate Graham 2025-09-29 16:57:03 UTC
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.
Comment 12 Mark Capella 2025-09-29 19:29:25 UTC
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 :-)
Comment 13 Nate Graham 2025-09-30 18:44:21 UTC
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.
Comment 14 Mark Capella 2025-10-01 01:12:39 UTC
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"
                 }