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);
|
virtual void setDuration(int duration = 250);
|
||||||
|
|
||||||
void updateCurrentTime(int currentTime);
|
virtual void updateCurrentTime(int currentTime);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AnimationPrivate *const d;
|
AnimationPrivate *const d;
|
||||||
|
|
|
@ -108,6 +108,9 @@ void AnimationGroup::remove(int id)
|
||||||
void AnimationGroup::updateCurrentTime(int currentTime)
|
void AnimationGroup::updateCurrentTime(int currentTime)
|
||||||
{
|
{
|
||||||
Q_UNUSED(currentTime)
|
Q_UNUSED(currentTime)
|
||||||
|
|
||||||
|
//we really need it?
|
||||||
|
d->anim->setCurrentTime(currentTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationGroup::calculateGroupDuration()
|
void AnimationGroup::calculateGroupDuration()
|
||||||
|
|
|
@ -67,6 +67,17 @@ void FadeAnimation::setWidgetToAnimate(QGraphicsWidget *widget)
|
||||||
if (widget) {
|
if (widget) {
|
||||||
widget->setOpacity(m_startOpacity);
|
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)
|
void FadeAnimation::updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState)
|
||||||
|
@ -76,21 +87,18 @@ void FadeAnimation::updateState(QAbstractAnimation::State oldState, QAbstractAni
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldState == Stopped && newState == Running) {
|
if( (oldState == QAbstractAnimation::Stopped) &&
|
||||||
w->setOpacity(direction() == Forward ? m_startOpacity : m_targetOpacity);
|
(newState == QAbstractAnimation::Running)) {
|
||||||
} else if (newState == Stopped) {
|
QPropertyAnimation *anim = m_anim.data();
|
||||||
w->setOpacity(direction() == Forward ? m_targetOpacity : m_startOpacity);
|
|
||||||
|
anim->setDirection(direction());
|
||||||
|
anim->start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FadeAnimation::updateCurrentTime(int currentTime)
|
void FadeAnimation::updateCurrentTime(int currentTime)
|
||||||
{
|
{
|
||||||
QGraphicsWidget *w = widgetToAnimate();
|
m_anim.data()->setCurrentTime(currentTime);
|
||||||
if (w) {
|
|
||||||
qreal delta = currentTime / qreal(duration());
|
|
||||||
delta = (m_startOpacity - m_targetOpacity) * delta;
|
|
||||||
w->setOpacity(m_startOpacity - delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
Animation::updateCurrentTime(currentTime);
|
Animation::updateCurrentTime(currentTime);
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
qreal m_startOpacity;
|
qreal m_startOpacity;
|
||||||
qreal m_targetOpacity;
|
qreal m_targetOpacity;
|
||||||
|
QWeakPointer<QPropertyAnimation> m_anim;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user