when an applet is in another applet return a constrained formfactor if
the parent applet is too little popupapplet uses the parent size insted of the containment to decide the switch between full and popup, in all normal cases parent is the containment, except for the ugly applet in applet cases svn path=/trunk/KDE/kdelibs/; revision=1008775
This commit is contained in:
parent
3421342f5e
commit
32ac2f11fb
14
applet.cpp
14
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<QGraphicsWidget *>(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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user