plasmoid geometry event

Aaron J. Seigo aseigo at kde.org
Mon May 26 06:08:29 CEST 2008


On Sunday 25 May 2008, Toussis Manolis wrote:
> I have a plasmoid that is free-aspect-ratio when on desktop
> but when it is on a panel , I want to have a 2.4 ratio
> I tried this:
>
> void PlasmaTvGr::constraintsEvent(Plasma::Constraints constrains)
> {

first you should be checking for if (constraints & SizeConstraint) to avoid 
doing lots of unnecessary work here.

>     if(formFactor()==Plasma::Planar)
>     {
>       setMinimumSize(80,48);
>     };
>     if(formFactor()==Plasma::Horizontal)
>     {
>       kDebug()<<"contsRecH:"<<geometry().height();
>       setMinimumSize(geometry().height()*2.4,geometry().height());
>       setMaximumSize(geometry().height()*2.4,geometry().height());
>     };
>     if(formFactor()==Plasma::Vertical)
>     {
>
>     };


and this could be written nicer as:

if (formFactor() == Plasma::Planar)
{
    .. code ..
}
else if (formFactor() == Plasma::Horizontal) 
{
    .. code ..

etc.. preventing this check being made redundantly. a switch statement would 
probably be even nicer in the case, but anyways... you also don't need a ';' 
after each }; .. in fact, some compilers in more pedantic modes won't even 
compile that.

> but it ignores any geometry resize... any help?

define "ignores any geometry resize"? you mean this method isn't being called 
at all on resize? or..?

-- 
Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

KDE core developer sponsored by Trolltech
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 194 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/panel-devel/attachments/20080525/7a92e1dc/attachment-0001.pgp 


More information about the Panel-devel mailing list