qanimationstate.cpp Example File
animation/sub-attaq/qanimationstate.cpp
#include "qanimationstate.h"
#include <QtCore/qstate.h>
#ifndef QT_NO_ANIMATION
QAnimationState::QAnimationState(QState *parent)
: QState(parent), m_animation(0)
{
}
QAnimationState::~QAnimationState()
{
}
void QAnimationState::setAnimation(QAbstractAnimation *animation)
{
if (animation == m_animation)
return;
if(m_animation)
disconnect(m_animation, SIGNAL(finished()), this, SIGNAL(animationFinished()));
m_animation = animation;
if (m_animation) {
connect(m_animation, SIGNAL(finished()), this, SIGNAL(animationFinished()));
}
}
QAbstractAnimation* QAnimationState::animation() const
{
return m_animation;
}
void QAnimationState::onEntry(QEvent *)
{
if (m_animation)
m_animation->start();
}
void QAnimationState::onExit(QEvent *)
{
if (m_animation)
m_animation->stop();
}
bool QAnimationState::event(QEvent *e)
{
return QState::event(e);
}
#endif