diff --git a/applet.cpp b/applet.cpp index 925124b11..f5a599be9 100644 --- a/applet.cpp +++ b/applet.cpp @@ -474,15 +474,15 @@ const Package* Applet::package() const return d->package; } -void Applet::updateConstraints() +void Applet::updateConstraints(Plasma::Constraints constraints) { - constraintsUpdated(); + constraintsUpdated(constraints); setShadowShown(formFactor() == Planar); } -void Applet::constraintsUpdated() +void Applet::constraintsUpdated(Plasma::Constraints constraints) { - kDebug() << "Applet::constraintsUpdate(): constraints are FormFactor: " << formFactor() << ", Location: " << location(); + kDebug() << constraints << "constraints are FormFactor: " << formFactor() << ", Location: " << location(); } QString Applet::name() const diff --git a/applet.h b/applet.h index 4e734b574..e0582cd44 100644 --- a/applet.h +++ b/applet.h @@ -182,8 +182,10 @@ class PLASMA_EXPORT Applet : public Widget * Called when any of the geometry constraints have been updated. * This method calls constraintsUpdated, which may be reimplemented, * once the Applet has been prepared for updating the constraints. + * + * @param constraints the type of constraints that were updated */ - void updateConstraints(); + void updateConstraints(Plasma::Constraints constraints); /** * Called when any of the geometry constraints have been updated. @@ -194,9 +196,10 @@ class PLASMA_EXPORT Applet : public Widget * Do not call update() from this method; an update() will be triggered * at the appropriate time for the applet. * + * @param constraints the type of constraints that were updated * @property constraint */ - virtual void constraintsUpdated(); + virtual void constraintsUpdated(Plasma::Constraints constraints); /** * Returns the current form factor the applet is being displayed in. diff --git a/containment.cpp b/containment.cpp index 7f1ba52f8..4ef54a9e0 100644 --- a/containment.cpp +++ b/containment.cpp @@ -427,8 +427,10 @@ void Containment::setFormFactor(FormFactor formFactor) foreach (Applet* applet, d->applets) { d->layout->addItem(applet); - applet->updateConstraints(); + applet->updateConstraints(Plasma::FormFactorConstraint); } + + updateConstraints(Plasma::FormFactorConstraint); } FormFactor Containment::formFactor() const @@ -445,8 +447,10 @@ void Containment::setLocation(Location location) d->location = location; foreach (Applet* applet, d->applets) { - applet->updateConstraints(); + applet->updateConstraints(Plasma::LocationConstraint); } + + updateConstraints(Plasma::LocationConstraint); } Location Containment::location() const @@ -493,7 +497,7 @@ Applet* Containment::addApplet(const QString& name, const QVariantList& args, ui d->layout->addItem(applet); } - applet->updateConstraints(); + applet->updateConstraints(Plasma::AllConstraints); kDebug() << applet->name() << "sizehint:" << applet->sizeHint() << "geometry:" << applet->geometry(); @@ -555,6 +559,7 @@ void Containment::setScreen(int screen) } d->screen = screen; + updateConstraints(Plasma::ScreenConstraint); } int Containment::screen() const diff --git a/plasma.h b/plasma.h index 1395847e7..435a45352 100644 --- a/plasma.h +++ b/plasma.h @@ -30,6 +30,18 @@ namespace Plasma { +/** + * The Constriants enumeration lists the various constraints that Plasma + * objects have managed for them and which they may wish to react to, + * for instance in Applet::constraintsUpdated + */ +enum Constraint { FormFactorConstraint = 1 /** The FormFactor for an object */, + LocationConstraint = 2 /** The Location of an object */, + ScreenConstraint = 4 /** Which screen an object is on */, + AllConstraints = FormFactorConstraint | LocationConstraint | ScreenConstraint +}; +Q_DECLARE_FLAGS(Constraints, Constraint) + /** * The FormFactor enumeration describes how a Plasma::Applet should arrange * itself. The value is derived from the container managing the Applet @@ -125,4 +137,6 @@ PLASMA_EXPORT Direction locationToDirection(Location location); } // Plasma namespace +Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::Constraints) + #endif // multiple inclusion guard