diff --git a/applet.cpp b/applet.cpp index aee513060..06699e1c2 100644 --- a/applet.cpp +++ b/applet.cpp @@ -1289,6 +1289,20 @@ void Applet::paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *o FormFactor Applet::formFactor() const { Containment *c = containment(); + QGraphicsWidget *p = dynamic_cast(parentItem()); + + + //if the applet is in a widget that isn't a containment + //try to retrieve the formFactor from the parent size + //we can't use our own sizeHint here because it needs formFactor, so endless recursion + if (p && p != c && c != this && layout()) { + if (p->size().width() < layout()->effectiveSizeHint(Qt::MinimumSize).width()) { + return Plasma::Vertical; + } else if (p->size().height() < layout()->effectiveSizeHint(Qt::MinimumSize).height()) { + return Plasma::Horizontal; + } + } + return c ? c->d->formFactor : Plasma::Planar; } diff --git a/popupapplet.cpp b/popupapplet.cpp index b935aa020..c8835a3c3 100644 --- a/popupapplet.cpp +++ b/popupapplet.cpp @@ -171,7 +171,7 @@ void PopupAppletPrivate::popupConstraintsEvent(Plasma::Constraints constraints) } QSizeF minimum; - QSizeF containmentSize; + QSizeF parentSize; QGraphicsWidget *gWidget = q->graphicsWidget(); //kDebug() << "graphics widget is" << (QObject*)gWidget; @@ -189,14 +189,15 @@ void PopupAppletPrivate::popupConstraintsEvent(Plasma::Constraints constraints) minimum = qWidget->minimumSizeHint(); } - if (q->containment()) { - containmentSize = q->containment()->size(); + //99% of the times q->parentWidget() is the containment, but using it we can also manage the applet-in-applet case (i.e. systray) + if (q->parentWidget()) { + parentSize = q->parentWidget()->size(); } //Applet on desktop if (icon && !icon->icon().isNull() && ((f != Plasma::Vertical && f != Plasma::Horizontal) || - ((f == Plasma::Vertical && containmentSize.width() >= minimum.width()) || - (f == Plasma::Horizontal && containmentSize.height() >= minimum.height())))) { + ((f == Plasma::Vertical && parentSize.width() >= minimum.width()) || + (f == Plasma::Horizontal && parentSize.height() >= minimum.height())))) { //kDebug() << "we are expanding the popupapplet"; // we only switch to expanded if we aren't horiz/vert constrained and