* update the direction on location changes

* update the dialog, if it exists, when checking the border of the extender
BUG:177113

svn path=/trunk/KDE/kdelibs/; revision=894469
This commit is contained in:
Aaron J. Seigo 2008-12-08 18:03:23 +00:00
parent 1d7144e6f7
commit e42452e847
2 changed files with 33 additions and 21 deletions

View File

@ -108,6 +108,24 @@ QGraphicsWidget *PopupApplet::graphicsWidget()
return static_cast<Applet*>(this)->d->extender; return static_cast<Applet*>(this)->d->extender;
} }
void PopupAppletPrivate::checkExtenderAppearance(Plasma::FormFactor f)
{
Extender *extender = qobject_cast<Extender*>(q->graphicsWidget());
if (extender) {
if (f != Plasma::Horizontal && f != Plasma::Vertical) {
extender->setAppearance(Extender::NoBorders);
} else if (q->location() == TopEdge) {
extender->setAppearance(Extender::TopDownStacked);
} else {
extender->setAppearance(Extender::BottomUpStacked);
}
}
if (dialog) {
dialog->setGraphicsWidget(extender);
}
}
void PopupAppletPrivate::popupConstraintsEvent(Plasma::Constraints constraints) void PopupAppletPrivate::popupConstraintsEvent(Plasma::Constraints constraints)
{ {
if (constraints & Plasma::StartupCompletedConstraint) { if (constraints & Plasma::StartupCompletedConstraint) {
@ -119,6 +137,13 @@ void PopupAppletPrivate::popupConstraintsEvent(Plasma::Constraints constraints)
} }
Plasma::FormFactor f = q->formFactor(); Plasma::FormFactor f = q->formFactor();
kDebug() << "whoop!" << constraints;
if (constraints & Plasma::LocationConstraint) {
checkExtenderAppearance(f);
}
if (constraints & Plasma::FormFactorConstraint || if (constraints & Plasma::FormFactorConstraint ||
(constraints & Plasma::SizeConstraint && (constraints & Plasma::SizeConstraint &&
(f == Plasma::Vertical || f == Plasma::Horizontal))) { (f == Plasma::Vertical || f == Plasma::Horizontal))) {
@ -132,13 +157,17 @@ void PopupAppletPrivate::popupConstraintsEvent(Plasma::Constraints constraints)
QSizeF containmentSize; QSizeF containmentSize;
QGraphicsWidget *gWidget = q->graphicsWidget(); QGraphicsWidget *gWidget = q->graphicsWidget();
kDebug() << "graphics widget is" << (QObject*)gWidget; //kDebug() << "graphics widget is" << (QObject*)gWidget;
QWidget *qWidget = q->widget(); QWidget *qWidget = q->widget();
if (gWidget) { if (gWidget) {
minimum = gWidget->minimumSize(); minimum = gWidget->minimumSize();
// our layout may have been replaced on us in the call to graphicsWidget! // our layout may have been replaced on us in the call to graphicsWidget!
lay = dynamic_cast<QGraphicsLinearLayout *>(q->layout()); lay = dynamic_cast<QGraphicsLinearLayout *>(q->layout());
if (!(constraints & LocationConstraint)) {
checkExtenderAppearance(f);
}
} else if (qWidget) { } else if (qWidget) {
minimum = qWidget->minimumSizeHint(); minimum = qWidget->minimumSizeHint();
} }
@ -187,11 +216,6 @@ void PopupAppletPrivate::popupConstraintsEvent(Plasma::Constraints constraints)
QSize prefSize; QSize prefSize;
if (gWidget) { if (gWidget) {
Extender *extender = qobject_cast<Extender*>(gWidget);
if (extender) {
extender->setAppearance(Extender::NoBorders);
}
lay->addItem(gWidget); lay->addItem(gWidget);
prefSize = gWidget->preferredSize().toSize(); prefSize = gWidget->preferredSize().toSize();
} else if (qWidget) { } else if (qWidget) {
@ -256,25 +280,12 @@ void PopupAppletPrivate::popupConstraintsEvent(Plasma::Constraints constraints)
KWindowSystem::setState(dialog->winId(), NET::SkipTaskbar | NET::SkipPager); KWindowSystem::setState(dialog->winId(), NET::SkipTaskbar | NET::SkipPager);
dialog->installEventFilter(q); dialog->installEventFilter(q);
QObject::connect(dialog, SIGNAL(dialogResized()), QObject::connect(dialog, SIGNAL(dialogResized()), q, SLOT(dialogSizeChanged()));
q, SLOT(dialogSizeChanged())); QObject::connect(dialog, SIGNAL(dialogVisible(bool)), q, SLOT(dialogStatusChanged(bool)));
QObject::connect(dialog, SIGNAL(dialogVisible(bool)),
q, SLOT(dialogStatusChanged(bool)));
q->setMinimumSize(QSize(0, 0)); q->setMinimumSize(QSize(0, 0));
if (gWidget) { if (gWidget) {
Corona *corona = qobject_cast<Corona *>(gWidget->scene()); Corona *corona = qobject_cast<Corona *>(gWidget->scene());
Extender *extender = qobject_cast<Extender*>(gWidget);
if (extender) {
if (q->formFactor() == MediaCenter || q->formFactor() == Planar) {
extender->setAppearance(Extender::NoBorders);
} else if (q->location() == TopEdge) {
extender->setAppearance(Extender::TopDownStacked);
} else {
extender->setAppearance(Extender::BottomUpStacked);
}
}
//could that cast ever fail?? //could that cast ever fail??
if (corona) { if (corona) {
corona->addOffscreenWidget(gWidget); corona->addOffscreenWidget(gWidget);

View File

@ -36,6 +36,7 @@ public:
void dialogStatusChanged(bool status); void dialogStatusChanged(bool status);
void updateDialogPosition(); void updateDialogPosition();
void popupConstraintsEvent(Plasma::Constraints constraints); void popupConstraintsEvent(Plasma::Constraints constraints);
void checkExtenderAppearance(Plasma::FormFactor f);
PopupApplet *q; PopupApplet *q;
Plasma::IconWidget *icon; Plasma::IconWidget *icon;