smooth animation until the end ensuring the repaint is scheduled before

the delete by emitting the signal in the paint event and with a
singleshot timer

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=863664
This commit is contained in:
Marco Martin 2008-09-22 19:28:11 +00:00
parent a90457d7a1
commit 2e8dba5df2
2 changed files with 9 additions and 4 deletions

View File

@ -224,6 +224,9 @@ void AppletHandle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
Q_UNUSED(widget);
if (qFuzzyCompare(m_opacity + 1.0, 1.0)) {
if (m_anim == FadeOut) {
QTimer::singleShot(0, this, SLOT(emitDisappear()));
}
return;
}
@ -379,6 +382,11 @@ void AppletHandle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
painter->restore();
}
void AppletHandle::emitDisappear()
{
emit disappearDone(this);
}
AppletHandle::ButtonType AppletHandle::mapToButton(const QPointF &point) const
{
int iconMargin = m_iconSize / 2;
@ -872,10 +880,6 @@ void AppletHandle::fadeAnimation(qreal progress)
m_animId = 0;
delete m_backgroundBuffer;
m_backgroundBuffer = 0;
if (m_anim == FadeOut) {
emit disappearDone(this);
}
}
update();

View File

@ -74,6 +74,7 @@ class AppletHandle : public QObject, public QGraphicsItem
void appletResized();
void fadeIn();
void leaveTimeout();
void emitDisappear();
private:
static const int HANDLE_MARGIN = 3;