diff --git a/dialog.cpp b/dialog.cpp index d538b9739..38cd2b6af 100644 --- a/dialog.cpp +++ b/dialog.cpp @@ -79,6 +79,7 @@ public: void adjustView(); void updateResizeCorners(); void progressHide(qreal amount); + void progressShow(qreal amount); Plasma::Dialog *q; @@ -247,19 +248,14 @@ void Dialog::paintEvent(QPaintEvent *e) target = rect(); source = target; switch (d->hideDirection) { - case Plasma::Up: { + case Plasma::Up: + case Plasma::Down: { int bottomMargin = height() - d->view->geometry().bottom(); target.setBottom(d->view->viewport()->geometry().bottom() - bottomMargin); source.setTop(-d->view->viewport()->y() + bottomMargin); } break; - case Plasma::Down: - target.setX(d->view->viewport()->x() + d->view->x()); - target.setY(d->view->viewport()->y() + d->view->y()); - source.moveTo(0, 0); - break; - case Plasma::Right: { target.setLeft(d->view->viewport()->x()); source.setRight(target.width() - 1); @@ -553,6 +549,58 @@ void Dialog::animatedHide(Plasma::Direction direction) } } +void Dialog::animatedShow(Plasma::Direction direction) +{ + if (d->hideAnimId) { + // already hiding + return; + } + + if (KWindowSystem::compositingActive() && d->view) { + //TODO: implement for the QWidget scenario too + d->hideDirection = direction; + d->hideAnimId = Animator::self()->customAnimation(20, 200, Animator::EaseInCurve, + this, "progressShow"); + } +} + +void DialogPrivate::progressShow(qreal amount) +{ + //kDebug() << amount; + if (qFuzzyCompare(amount, 1.0)) { + view->viewport()->move(0, 0); + hideAnimId = 0; + q->update(); + q->show(); + return; + } + + int xtrans = 0; + int ytrans = 0; + + switch (hideDirection) { + case Plasma::Up: + ytrans = (1.0 - amount) * view->height(); + break; + + case Plasma::Down: + ytrans = (amount * view->height()) - view->height(); + break; + + case Plasma::Right: + xtrans = (amount * view->width()) - view->width(); + break; + + case Plasma::Left: + xtrans = (1.0 - amount) * view->width(); + break; + } + + view->viewport()->move(xtrans, ytrans); + q->update(); + q->show(); +} + void DialogPrivate::progressHide(qreal amount) { //kDebug() << amount; @@ -566,7 +614,6 @@ void DialogPrivate::progressHide(qreal amount) int xtrans = 0; int ytrans = 0; - //TODO: switch between directions switch (hideDirection) { case Plasma::Up: ytrans = -(amount * view->height()); diff --git a/dialog.h b/dialog.h index 97348b625..0fa75231c 100644 --- a/dialog.h +++ b/dialog.h @@ -93,6 +93,12 @@ class PLASMA_EXPORT Dialog : public QWidget */ void animatedHide(Plasma::Direction direction); + /** + * Causes an animated hide; requires compositing to work, otherwise + * the dialog will simply hide. + */ + void animatedShow(Plasma::Direction direction); + Q_SIGNALS: /** * Fires when the dialog automatically resizes. @@ -136,6 +142,7 @@ class PLASMA_EXPORT Dialog : public QWidget */ Q_PRIVATE_SLOT(d, void themeUpdated()) Q_PRIVATE_SLOT(d, void progressHide(qreal)) + Q_PRIVATE_SLOT(d, void progressShow(qreal)) }; } // Plasma namespace diff --git a/popupapplet.cpp b/popupapplet.cpp index b8118581a..65801cc65 100644 --- a/popupapplet.cpp +++ b/popupapplet.cpp @@ -524,7 +524,11 @@ void PopupAppletPrivate::internalTogglePopup() ToolTipManager::self()->hide(q); updateDialogPosition(); KWindowSystem::setState(dialog->winId(), NET::SkipTaskbar | NET::SkipPager); - dialog->show(); + if (q->location() != Floating) { + dialog->animatedShow(locationToDirection(q->location())); + } else { + dialog->hide(); + } } dialog->clearFocus();