animated shows as well
svn path=/trunk/KDE/kdelibs/; revision=954617
This commit is contained in:
parent
f714329630
commit
406a0fac5f
63
dialog.cpp
63
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());
|
||||
|
7
dialog.h
7
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
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user