This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Customizing KDE panels (2)

Tags: plasma, panels, customizatioms, scripting, widget size plasma, panels, customizatioms, scripting, widget size plasma, panels, customizatioms, scripting, widget size
(comma "," separated)
Tommy Vercetti
Registered Member
Posts
27
Karma
0
OS

Customizing KDE panels (2)

Sat Oct 05, 2013 9:42 pm
I want to create right-aligned horizontal panel, fill it with widgets and set it's length just enough to display all of them. I was not able to find panel's property "autosize" or similar to. So I supposed that I had to set the panel's length equal to sum of widths of all widgets added to the panel. This code should do that:
Code: Select all
// Top panel
var top_panel = new Panel;
top_panel.location = "bottom";
top_panel.alignment = "right";
// Here we add some widgets
top_panel.addWidget("showdashboard").globalShortcut = "Meta+-";
top_panel.addWidget("showdesktop").globalShortcut = "Meta+D";
top_panel.addWidget("pager");
top_panel.addWidget("activitymanager").globalShortcut = "Meta+A";
top_panel.addWidget("systemtray");
top_panel.addWidget("digital-clock");
top_panel.addWidget("lockout");
// And here we count top_panel's width
top_panel.length = top_panel.widgets().reduce(
  function ( width, widget ) {
    print(widget.type + ':' + widget.geometry.width); // Logging widget width
    return width + widget.geometry.width;
  },
  0
);

But it does it in a wrong way. On the picture below top panel is created manually, and bottom one — by this script:
Image
As you can see, the bottom panel is longer than it should be. After inspecting the script's run log I've got that widget.geometry.width, which I used to determine widget's width, does not represent widget's visual width, e. g. first four widgets should have nearly equal widths, but there's an appreciable dispersion, and system tray's width is displayed as the smallest, while the tray itself is the longest from the widgets added. But what should I use instead of geometry.width then? Thanks in advance.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: Customizing KDE panels (2)

Sat Oct 12, 2013 9:06 am
I would suggest asking about this on the Plasma Development mailing list (plasma-devel@kde.org), as the width/height properties to use have been a source of problems in the past. If you get a solution, please post it here.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
Tommy Vercetti
Registered Member
Posts
27
Karma
0
OS

  Topic is solved

Sun Nov 17, 2013 8:45 pm
I've talked to Aaron Seigo, and he adviced to set panel min length's value to something less than needed, and panel max length equal to screen width. The problem is that max/min length properties used to be inaccessible via plasma script, but recently Seigo has implemented them there, so now that should work.

UPD: This will work only with scriptingVersion ≥ 7. There's still 6th one in KDE 4.11 and SC 4.12.

UPD2: KDE 4.12 release brings plasma scriptingVersion 7. "minLength"/"maxLength" available and work okay.


Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot], Yahoo [Bot]