SVN commit 670285 by aseigo: applets are no aware of their constraints. the simple solution is often the best one. M +13 -0 applet.cpp M +17 -0 applet.h M +1 -0 corona.cpp M +6 -0 corona.h --- trunk/KDE/kdebase/workspace/plasma/lib/applet.cpp #670284:670285 @@ -28,6 +28,8 @@ #include #include #include + +#include "corona.h" #include "dataenginemanager.h" namespace Plasma @@ -135,8 +137,19 @@ void Applet::constraintsUpdated() { + kDebug() << "constraints are FormFactor: " << formFactor() << ", Location: " << location() << endl; } +FormFactor Applet::formFactor() const +{ + return static_cast(scene())->formFactor(); +} + +Location Applet::location() const +{ + return static_cast(scene())->location(); +} + QString Applet::globalName() const { return d->appletDescription->service()->library(); --- trunk/KDE/kdebase/workspace/plasma/lib/applet.h #670284:670285 @@ -98,17 +98,34 @@ * 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 * * @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 --- trunk/KDE/kdebase/workspace/plasma/lib/corona.cpp #670284:670285 @@ -198,6 +198,7 @@ Applet* applet = Applet::loadApplet(name); if (applet) { addItem(applet); + //applet->constraintsUpdated(); d->applets << applet; } else { kDebug() << "Plasmoid " << name << " could not be loaded." << endl; --- trunk/KDE/kdebase/workspace/plasma/lib/corona.h #670284:670285 @@ -73,6 +73,12 @@ 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: