Bug 478489 - Plasma 6 Panel - Ability to set lengthMode through API Scripting
Summary: Plasma 6 Panel - Ability to set lengthMode through API Scripting
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Panel (show other bugs)
Version: 5.90.0
Platform: Arch Linux Linux
: NOR wishlist
Target Milestone: 1.0
Assignee: fanzhuyifan
URL:
Keywords: qt6
Depends on:
Blocks:
 
Reported: 2023-12-13 23:23 UTC by Frank
Modified: 2024-02-26 23:33 UTC (History)
3 users (show)

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


Attachments
How to from GUI (20.00 KB, image/jpeg)
2023-12-13 23:23 UTC, Frank
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Frank 2023-12-13 23:23:44 UTC
Created attachment 164151 [details]
How to from GUI

SUMMARY
***
In Plasma 6 with new very much improved Panel, I am unable to set property "Length" through API Scripting.
I am also unable to find documentation on all of the Plasma 6 Panel's properties that can be used through API Scripting.

Tried the following documentation:
https://userbase.kde.org/Plasma/Create_a_Global_Theme_Package
https://userbase.kde.org/Plasma/How_to_create_a_Unity-like_look_and_feel_theme_using_Plasma%E2%80%99s_Desktop_Scripting_API
https://develop.kde.org/docs/plasma/
***


STEPS TO REPRODUCE
1. Use org.kde.plasma.desktop-layout.js to create a Global Theme, which creates, among other things, a bottom Panel ("Floating Dock" to be more precise).
2. From the following section:

    // Create bottom panel (Dock)
    const dock = new Panel

    // Basic Dock Geometry
    dock.alignment = “center”
    dock.height = Math.round(gridUnit * 2.8);
    dock.hiding = “windowscover”
    dock.location = “bottom”
    dock.panelLength = 1
    dock.maximumLenth = 1000
    dock.minimumLength = 250

Try various possibilities for the line "dock.panelLength = 1" (panelLengthMode, length, lengthMode, etc…).

3. Remove the Max and Min length lines (last 2) from the script above and try step 2 again.

OBSERVED RESULT
The Panel does not Fit Content and remain "Fill Width" in all 8 tries.


EXPECTED RESULT
File  ~/.config/plasmashellrc should have a line with "panelLengthMode = 1" under [PlasmaViews][Panel nnn] section, where "nnn" is a number.

See attached screenshot for what I am trying to achieve, which is extremely easy through GUI, but I need to set it through API.

Thank you very much for your guidance!

SOFTWARE/OS VERSIONS
Linux/KDE Plasma:  Yes, it's the best!
KDE Plasma Version: 5.90.90
KDE Frameworks Version: 5.247.0
Qt Version: 6.6.1

ADDITIONAL INFORMATION

I don't believe there is a bug here, at least not at this moment judging how not far I went with it. :)
Comment 1 fanzhuyifan 2023-12-14 00:51:11 UTC
This API doesn't seem implemented yet.
Comment 2 Bug Janitor Service 2023-12-14 01:23:52 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/3681
Comment 3 fanzhuyifan 2023-12-14 17:41:49 UTC
As a work around, just do `panel.setConfig("panelLengthMode", 1)` for setting fit.
Comment 4 Frank 2023-12-15 00:06:39 UTC
(In reply to fanzhuyifan from comment #3)
> As a work around, just do `panel.setConfig("panelLengthMode", 1)` for
> setting fit.

Thanks for the suggestion.
I'm missing something. Here's one of the 5 or 6 versions I tried following re-reading this documentation https://develop.kde.org/docs/plasma/scripting/api/#applets-containments-and-widgets

var plasma = getApiVersion(1)

-----
// Create bottom panel (Dock) //

const dock = new Panel

// Basic Dock Geometry
dock.alignment = "center"
dock.height = Math.round(gridUnit * 2.8);
dock.hiding = "windowscover"
dock.location = "bottom"
//dock.maximumLenth = 1000
//dock.minimumLength = 250

// Icons-Only Task Manager
var tasks = dock.addWidget("org.kde.plasma.icontasks")
tasks.currentConfigGroup = ["General"]
tasks.writeConfig("fill", false)
tasks.writeConfig("iconSpacing", 2)
tasks.writeConfig("launchers", "applications:garuda-welcome.desktop,applications:org.kde.konsole.desktop,preferred://browser,preferred://filemanager,applications:org.kde.plasma-systemmonitor.desktop,applications:snapper-tools.desktop,applications:systemsettings.desktop,applications:octopi.desktop")
tasks.writeConfig("maxStripes", 1)
tasks.writeConfig("showOnlyCurrentDesktop", false)
tasks.writeConfig("showOnlyCurrentScreen", false)

const panel = ConfigFile('plasmashellrc')
panel.group = 'PlasmaViews'
panel.setConfig("panelLenghtMode", 1)

// End of Dock creation //
-----

Nothing is written in plasmashellrc.
However if I use instead panel.writeEntry("panelLenghtMode", 1), I do get the following section written in plasmashellrc:

[PlasmaViews]
panelLenghtMode=1

It's alone in its own section, not associated to a Panel.
Comment 5 fanzhuyifan 2023-12-15 00:54:48 UTC
(In reply to fanzhuyifan from comment #3)
> As a work around, just do `panel.setConfig("panelLengthMode", 1)` for
> setting fit.
(In reply to Frank from comment #4)
> (In reply to fanzhuyifan from comment #3)
> > As a work around, just do `panel.setConfig("panelLengthMode", 1)` for
> > setting fit.
> 
> Thanks for the suggestion.
> I'm missing something. Here's one of the 5 or 6 versions I tried following
> re-reading this documentation
> https://develop.kde.org/docs/plasma/scripting/api/#applets-containments-and-
> widgets
> 
> var plasma = getApiVersion(1)
> 
> -----
> // Create bottom panel (Dock) //
> 
> const dock = new Panel
> 
> // Basic Dock Geometry
> dock.alignment = "center"
> dock.height = Math.round(gridUnit * 2.8);
> dock.hiding = "windowscover"
> dock.location = "bottom"
> //dock.maximumLenth = 1000
> //dock.minimumLength = 250
> 
> // Icons-Only Task Manager
> var tasks = dock.addWidget("org.kde.plasma.icontasks")
> tasks.currentConfigGroup = ["General"]
> tasks.writeConfig("fill", false)
> tasks.writeConfig("iconSpacing", 2)
> tasks.writeConfig("launchers",
> "applications:garuda-welcome.desktop,applications:org.kde.konsole.desktop,
> preferred://browser,preferred://filemanager,applications:org.kde.plasma-
> systemmonitor.desktop,applications:snapper-tools.desktop,applications:
> systemsettings.desktop,applications:octopi.desktop")
> tasks.writeConfig("maxStripes", 1)
> tasks.writeConfig("showOnlyCurrentDesktop", false)
> tasks.writeConfig("showOnlyCurrentScreen", false)
> 
> const panel = ConfigFile('plasmashellrc')
> panel.group = 'PlasmaViews'
> panel.setConfig("panelLenghtMode", 1)
> 
> // End of Dock creation //
> -----
> 
> Nothing is written in plasmashellrc.
> However if I use instead panel.writeEntry("panelLenghtMode", 1), I do get
> the following section written in plasmashellrc:
> 
> [PlasmaViews]
> panelLenghtMode=1
> 
> It's alone in its own section, not associated to a Panel.

Sorry I meant `writeConfig`, not `setConfig`. Also for support please use the KDE forums or the matrix channels. The bugzilla is only for reporting bugs.
Comment 6 Frank 2023-12-15 01:01:46 UTC
(In reply to fanzhuyifan from comment #5)
> Sorry I meant `writeConfig`, not `setConfig`.

Tried it part of my tests with same result, therefore plz read below:

> Also for support please use the KDE forums or the matrix channels. The bugzilla is only for reporting bugs.

That's true, sorry about that.
This is the correct Forum? https://discuss.kde.org/
Comment 7 fanzhuyifan 2023-12-16 01:06:50 UTC
Git commit bc6140284f661e1c7006f0be73f0e1b826e3dcf0 by Yifan Zhu.
Committed on 16/12/2023 at 01:54.
Pushed by fanzhuyifan into branch 'master'.

Implement panel lengthMode scripting api

M  +39   -0    shell/scripting/panel.cpp
M  +4    -0    shell/scripting/panel.h
M  +1    -0    shell/scripting/scriptengine_v1.cpp

https://invent.kde.org/plasma/plasma-workspace/-/commit/bc6140284f661e1c7006f0be73f0e1b826e3dcf0
Comment 8 Frank 2024-02-26 23:33:01 UTC
Tested and working.

Thank you so much! This saves our Theming so it can be automatically applied correctly.