[Panel-devel] Separate QGraphicsItems for applet border/background and content?

Robert Knight robertknight at gmail.com
Fri Aug 31 19:34:41 CEST 2007


Hi,

When working on the tasks and clock applet this past week  to make it
possible to use them in the panel layout I ran into a problem that the
applets cannot provide useful implementations of sizeHint() ,
minimumSize() and maximumSize() because they don't know about the
applet's borders.

There is a contentSize() method which is mis-named, because the
existing implementations return a size hint for the contents which
might be different from the actual applet size.

I suggest using a design like QMainWindow where the applet consists of
an outer 'shell' which renders the border and background and handles
input events to the border area, and a central Widget which fills the
entire content area of the applet.  This allows the central widget
which displays the content of interest to have its own sizeHint(),
minimumSize() , maximumSize() , expandingDirections() etc.  The applet
shell then provides its own sizeHint() , minimumSize() etc..
This should also fix problems where the content area of an applet
needs to re-implement some input handing event (eg. mouse handling)
and then forgets to call the base implementation which would break
input handling in the border area.

This would also simplify the painting of applets and remove the need
for the paintInterface() method.

There are different ways in which the API could work, some ideas:

1.  Each applet library provides a sub-class of Applet (as it does
now) which is the main exported plugin class.  This sub-class would
become very small and most of the code would be transferred to a
Widget class which is not exported.  In the applet's constructor,
there would be something like this:

MyApplet::MyApplet(QObject *parent , const QVariantList& args)
: Plasma::Applet(parent,args)
{
   ClockWidget *widget = new ClockWidget(this,args);
   setCentralWidget(widget);
}

2.  Each applet library just provides the central widget class and the
Plasma library loads this and creates an Applet shell into which the
central widget is placed.  There is a question then of how the applet
could control properties of the shell, such as turning the standard
background and border on or off.

Regards,
Robert.


More information about the Panel-devel mailing list