https://bugs.kde.org/show_bug.cgi?id=523675
Bug ID: 523675
Summary: All widgets in the panel have an index of -1 in Plasma
scripting
Classification: Plasma
Product: plasmashell
Version First 6.6.6
Reported In:
Platform: Ubuntu
OS: Linux
Status: REPORTED
Severity: normal
Priority: NOR
Component: Scripting
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: 1.0
DESCRIPTION
I'm attempting to write a Plasma script that will add a clickable icon widget
next to an existing widget already in my panel. (This could be done via edit
mode, but I'm scripting it so I can automate it across multiple machines.)
According to https://develop.kde.org/docs/plasma/scripting/api/#widgets, I read
a widget's `index` property to determine where it is in the panel, and can
write to that property to change where it is in the panel. This however does
not work; all widgets have an index of -1 when reading them, and writing a new
value to a widget's index appears to be a no-op.
STEPS TO REPRODUCE
1. Open plasma-interactiveconsole.
2. Paste the following code in and run it:
```
panelIds.forEach((panelId) => {
let panel = panelById(panelId);
if (!panel) {
return;
}
panel.widgetIds.forEach((appletWidgetId) => {
let appletWidget = panel.widgetById(appletWidgetId);
if (appletWidget.type === "org.kde.plasma.kickoff") {
const newWidget = panel.addWidget('org.kde.plasma.icon');
newWidget.index = appletWidget.index;
newWidget.writeConfig( 'localpath',
'/usr/share/applications/org.kde.kate.desktop' );
newWidget.currentConfigGroup = [ 'General' ];
newWidget.writeConfig( 'url',
'file:///usr/share/applications/org.kde.kate.desktop' );
}
});
});
```
OBSERVED RESULT
A Kate launcher icon is added at the "end" of the panel (the far right edge if
using a horizontal panel at the bottom of the screen), far away from the
Application Launcher button. If you print `appletWidget.index`, you will see it
has a value of -1. Setting `newWidget.index` to a hardcoded positive value has
no effect on the behavior.
EXPECTED RESULT
A Kate launcher icon is added right next to the Application Launcher button.
SOFTWARE/OS VERSIONS
Operating System: Kubuntu 26.04 LTS
KDE Plasma Version: 6.6.6
KDE Frameworks Version: 6.24.0
Qt Version: 6.10.2
ADDITIONAL INFORMATION
n/a
--
You are receiving this mail because:
You are watching all bug changes.