applets are no aware of their constraints. the simple solution is often the best one.

svn path=/trunk/KDE/kdebase/workspace/plasma/lib/; revision=670285
This commit is contained in:
Aaron J. Seigo 2007-05-31 22:40:38 +00:00
parent 2c5f8a75bf
commit 7212ae5b5f
4 changed files with 37 additions and 0 deletions

View File

@ -28,6 +28,8 @@
#include <KStandardDirs>
#include <KService>
#include <KServiceTypeTrader>
#include "corona.h"
#include "dataenginemanager.h"
namespace Plasma
@ -135,6 +137,17 @@ bool Applet::loadDataEngine( const QString& name )
void Applet::constraintsUpdated()
{
kDebug() << "constraints are FormFactor: " << formFactor() << ", Location: " << location() << endl;
}
FormFactor Applet::formFactor() const
{
return static_cast<Corona*>(scene())->formFactor();
}
Location Applet::location() const
{
return static_cast<Corona*>(scene())->location();
}
QString Applet::globalName() const

View File

@ -98,10 +98,26 @@ class PLASMA_EXPORT Applet : public QObject, public QGraphicsItemGroup
* called when any of the geometry constraints have been updated
* this is always called prior to painting and should be used as an
* opportunity to layout the widget, calculate sizings, etc.
*
* Do not call update() from this method; an update() will be triggered
* at the appropriate time for the applet.
*
* @property constraint
*/
virtual void constraintsUpdated();
/**
* Returns the current form factor the applet is being displayed in.
* @see Plasma::FormFactor
*/
FormFactor formFactor() const;
/**
* Returns the location of the scene which is displaying applet.
* @see Plasma::Location
*/
Location location() const;
/**
* Returns a list of all known applets in a hash keyed by a unique
* identifier for each applet
@ -109,6 +125,7 @@ class PLASMA_EXPORT Applet : public QObject, public QGraphicsItemGroup
* @return list of applets
**/
static KPluginInfo::List knownApplets();
/**
* Reimplement this slot to show a configuration dialog and let the user
* play with the plasmoid options. Called when the user selects the configure entry

View File

@ -198,6 +198,7 @@ void Corona::addPlasmoid(const QString& name)
Applet* applet = Applet::loadApplet(name);
if (applet) {
addItem(applet);
//applet->constraintsUpdated();
d->applets << applet;
} else {
kDebug() << "Plasmoid " << name << " could not be loaded." << endl;

View File

@ -73,6 +73,12 @@ public:
void setFormFactor(FormFactor formFactor);
public Q_SLOTS:
/**
* Adds a plasmoid applet to the scene
*
* @param name the plugin name for the applet, as given by
* KPluginInfo::pluginName()
*/
void addPlasmoid(const QString& name);
protected: