make fade animation works again using qpropertyanimation, when added in a group use the same group timer
svn path=/trunk/KDE/kdelibs/; revision=1058490
This commit is contained in:
parent
c9d1959026
commit
1e06025000
|
@ -102,7 +102,7 @@ protected:
|
|||
*/
|
||||
virtual void setDuration(int duration = 250);
|
||||
|
||||
void updateCurrentTime(int currentTime);
|
||||
virtual void updateCurrentTime(int currentTime);
|
||||
|
||||
private:
|
||||
AnimationPrivate *const d;
|
||||
|
|
|
@ -108,6 +108,9 @@ void AnimationGroup::remove(int id)
|
|||
void AnimationGroup::updateCurrentTime(int currentTime)
|
||||
{
|
||||
Q_UNUSED(currentTime)
|
||||
|
||||
//we really need it?
|
||||
d->anim->setCurrentTime(currentTime);
|
||||
}
|
||||
|
||||
void AnimationGroup::calculateGroupDuration()
|
||||
|
|
|
@ -67,6 +67,17 @@ void FadeAnimation::setWidgetToAnimate(QGraphicsWidget *widget)
|
|||
if (widget) {
|
||||
widget->setOpacity(m_startOpacity);
|
||||
}
|
||||
|
||||
if(m_anim.data()) {
|
||||
delete m_anim.data();
|
||||
m_anim.clear();
|
||||
}
|
||||
|
||||
QPropertyAnimation *anim = new QPropertyAnimation(widget, "opacity", widget);
|
||||
anim->setStartValue(startOpacity());
|
||||
anim->setEndValue(targetOpacity());
|
||||
|
||||
m_anim = anim;
|
||||
}
|
||||
|
||||
void FadeAnimation::updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState)
|
||||
|
@ -76,21 +87,18 @@ void FadeAnimation::updateState(QAbstractAnimation::State oldState, QAbstractAni
|
|||
return;
|
||||
}
|
||||
|
||||
if (oldState == Stopped && newState == Running) {
|
||||
w->setOpacity(direction() == Forward ? m_startOpacity : m_targetOpacity);
|
||||
} else if (newState == Stopped) {
|
||||
w->setOpacity(direction() == Forward ? m_targetOpacity : m_startOpacity);
|
||||
if( (oldState == QAbstractAnimation::Stopped) &&
|
||||
(newState == QAbstractAnimation::Running)) {
|
||||
QPropertyAnimation *anim = m_anim.data();
|
||||
|
||||
anim->setDirection(direction());
|
||||
anim->start();
|
||||
}
|
||||
}
|
||||
|
||||
void FadeAnimation::updateCurrentTime(int currentTime)
|
||||
{
|
||||
QGraphicsWidget *w = widgetToAnimate();
|
||||
if (w) {
|
||||
qreal delta = currentTime / qreal(duration());
|
||||
delta = (m_startOpacity - m_targetOpacity) * delta;
|
||||
w->setOpacity(m_startOpacity - delta);
|
||||
}
|
||||
m_anim.data()->setCurrentTime(currentTime);
|
||||
|
||||
Animation::updateCurrentTime(currentTime);
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ protected:
|
|||
private:
|
||||
qreal m_startOpacity;
|
||||
qreal m_targetOpacity;
|
||||
QWeakPointer<QPropertyAnimation> m_anim;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user