Addition of applets to a panel require different geometry handling than

to a desktop. This patch just splits the handling into two branches so as
to make the upcoming changes easier to read.

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=752327
This commit is contained in:
Jason Stubbs 2007-12-24 07:49:33 +00:00
parent 45c7a63a1f
commit efcc2c6128

View File

@ -399,25 +399,30 @@ Applet* Containment::addApplet(const QString& name, const QVariantList& args, ui
applet = new Applet; applet = new Applet;
} }
//panels don't want backgrounds, which is important when setting geometry switch (containmentType()) {
if (containmentType() == PanelContainment) { case PanelContainment:
//panels don't want backgrounds, which is important when setting geometry
applet->setDrawStandardBackground(false); applet->setDrawStandardBackground(false);
}
addApplet(applet); addApplet(applet);
break;
//the applet needs to be given constraints before it can set its geometry default:
applet->updateConstraints(Plasma::AllConstraints); addApplet(applet);
//kDebug() << "adding applet" << applet->name() << "with a default geometry of" << appletGeometry << appletGeometry.isValid(); //the applet needs to be given constraints before it can set its geometry
if (appletGeometry.isValid()) { applet->updateConstraints(Plasma::AllConstraints);
applet->setGeometry(appletGeometry);
} else if (appletGeometry.x() != -1 && appletGeometry.y() != -1) { //kDebug() << "adding applet" << applet->name() << "with a default geometry of" << appletGeometry << appletGeometry.isValid();
// yes, this means we can't have items start -1, -1 if (appletGeometry.isValid()) {
applet->setGeometry(QRectF(appletGeometry.topLeft(), applet->setGeometry(appletGeometry);
applet->sizeHint())); } else if (appletGeometry.x() != -1 && appletGeometry.y() != -1) {
} else if (geometry().isValid()) { // yes, this means we can't have items start -1, -1
applet->setGeometry(geometryForApplet(applet)); applet->setGeometry(QRectF(appletGeometry.topLeft(),
applet->sizeHint()));
} else if (geometry().isValid()) {
applet->setGeometry(geometryForApplet(applet));
}
} }
//kDebug() << applet->name() << "sizehint:" << applet->sizeHint() << "geometry:" << applet->geometry(); //kDebug() << applet->name() << "sizehint:" << applet->sizeHint() << "geometry:" << applet->geometry();