Smarter desktop applet placement

Aaron J. Seigo aseigo at kde.org
Sat Aug 2 01:21:01 CEST 2008


On Friday 01 August 2008, Ambroz Bizjak wrote:
> Aaron J. Seigo wrote:

> > really, this is for Containments that have no layout management.
> >
> > so what *might* work better is turn this into a QGraphicsLayout subclass
> > that
> > is included with libplasma and let, e.g., DesktopContainment create a top
> > level layout. then DesktopContainment can, just as PanelContainment does,
> > connect to the appletAdded signal and add the applet to the layout.
> >
> > this would make it completely opt-in/out for containmets.
>
> Since I don't have a very good understanding of the architecture, I added
> the code specifically to the desktop containment and created a
> reimplementable function in Containment to position the applet. I think
> that would be fine, as the positioning is specific to the desktop.

this doesn't require a new virtual method in applet, atually; you can just 
connect to the appletAdded signal =)

i'm sure other Containments would like similar behaviour in the future and it 
would be nice to not have to copy and paste this code around ;) the solution 
for that is making a QGraphicsLayout subclass with this code in it, and then 
putting that class into libplasma.

> > I almost
> > wonder if a snap-to grid would be good enough though...
>
> Really, considering the varying size of applets?

probably; if there were snaps every, say, 100 pixels plus on any edge of an 
existing applet it should be pretty easy to align things.

> > i wonder if it would work out ok visually to place the item on
> > the
> > canvas first and then position it (e.g. would we get a repaint
> > immediately or
> > only later, allowing the applet to be moved first without visual
> > artifacts)
>
> Yes good idea, but that will come a little later.

this should come "for free" with a layout, actually.

> > one can query for the availableGeometry() from QDesktopWidget for the
> > screen
> > associated with the containment, if any...
>
> Good enough for now, but what do I call this method on? It doesn't seem to
> be a part of Containment.

no, it's parts of QDesktopWidget. you get to that via QAppliation... so sth 
like:

if (screen() != -1 ) {
    // we are associated with a screen, make sure not to overlap panels
    QDesktopWidget *desktop = qApp->desktop();
    QRect geom = desktop->availableGeometry(screen());
    ....
}

> >> - There is no spacing between applets
> >
> > shouldn't be hard to fix =)
>
> Already done :) default 20px on all sides of an applet

=)

only thing i'd suggest there is not to use a magic value of 20 in the code but 
create a const int APPLET_MARGIN = 20; somewhere and use that. makes the code 
a lot more readable (we emphasize maintainability a lot in this project; the 
code gets crazy enough without making it harder on ourselves ;)

with the change from the virtual to using the signal, this can probably go 
into svn, but i'd like this moved to a QGraphicsLayout subclass at some point 
still since that just makes oodles of sense.

-- 
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/plasma-devel/attachments/20080801/ae0e1d41/attachment.pgp 


More information about the Plasma-devel mailing list