Usage of constrainted size hints in Plasma

Ingomar Wesp ingomar at wesp.name
Wed Oct 20 00:01:48 CEST 2010


Hey (again),

I might be opening a can of worms here, because I don't know if the underlying 
problem is in QGraphicsScene (or its layouts) or in Plasma, but I noticed that 
Plasma containments like the panel don't appear to use constraints when asking 
for sizeHints, but just use the unconstrained minimumSize, preferredSize, ... 
of an applet for layouting.

This means, that in order to be layed out correctly, applets have to take into 
account their current size in order to compute the preferred size they report, 
which seems bad for the following reasons:

1) It leads to unnecessary resize operations: When an applet is added to the 
panel or a panel resize happens, the applet is given a certain size. Based on 
this size (say the height on a horizontal panel), it will change its preferred 
size. Then the panel layout needs to resize it again in order to accommodate 
the new size hint.

2) Applets need to recompute their preferred size unnecessarily often. Since 
the preferredSize is not invariant with regards to the current size (which it 
should be if I understood the intentions behind constraints correctly), it 
needs to be recomputed on every resize.

3) It forces applet developers to introduce workarounds for the missing 
functionality, which raises the entry barrier and makes writing of layouts 
more complicated than it already is. See the hackedConstraint method in the 
systemtray's CompactLayout class for instance:
<http://lxr.kde.org/source/KDE/kdebase/workspace/plasma/generic/applets/systemtray/ui/compactlayout.cpp#371>

So, without having looked at the panel's source: Is there any benefit to doing 
it this way? Are constraints not properly supported in Qt's QGraphicsLayouts?  
I browsed the Qt bug tracker, but couldn't find any related issue. Am I 
missing something?

Thanks and best regards,
Ingo


More information about the Plasma-devel mailing list