Ensure that the containment's corona is properly calculated.

The used corona is either the containment's parent or, in case the parent
is an applet, it's containment's corona. With this change we ensure the
proper corona is always found.
This change requires screenContainment to be able to walk through the
object tree in case it's not a containment directly managed by it.

BUG: 334500
This commit is contained in:
Aleix Pol 2014-06-17 16:02:08 +02:00
parent 34226faec1
commit e1051994ad

View File

@ -300,7 +300,17 @@ void Containment::setContainmentType(Plasma::Types::ContainmentType type)
Corona *Containment::corona() const
{
return qobject_cast<Corona *>(parent());
if(Plasma::Corona* corona = qobject_cast<Corona *>(parent())) {
return corona;
//case in which this containment is child of an applet, hello systray :)
} else {
Plasma::Applet *parentApplet = qobject_cast<Plasma::Applet *>(parent());
if (parentApplet) {
return parentApplet->containment()->corona();
}
}
return nullptr;
}
void Containment::setFormFactor(Types::FormFactor formFactor)
@ -448,16 +458,9 @@ QList<Applet *> Containment::applets() const
int Containment::screen() const
{
if (corona()) {
return corona()->screenForContainment(this);
//case in which this containment is child of an applet, hello systray :)
} else if (Plasma::Applet *parentApplet = qobject_cast<Plasma::Applet *>(parent())) {
if (parentApplet->containment()) {
return parentApplet->containment()->screen();
} else {
return -1;
}
Q_ASSERT(corona());
if (Corona* c = corona()) {
return c->screenForContainment(this);
} else {
return -1;
}