Add a scaleTo animation

ScaleTo animation will scale or shrinks an graphical element in an
animated way. This is going primarelly to be used on the pictures on the
profile, but can be used on anything else later.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2014-06-08 12:22:45 -03:00 committed by Dirk Hohndel
parent 0b5e1f700d
commit 38ac6ed35f
2 changed files with 11 additions and 0 deletions

View file

@ -36,6 +36,16 @@ namespace Animations {
}
}
void scaleTo(QObject *obj, qreal scale)
{
QPropertyAnimation *animation = new QPropertyAnimation(obj, "scale");
animation->setDuration(prefs.animation);
animation->setStartValue(obj->property("scale").toReal());
animation->setEndValue(QVariant::fromValue(scale));
animation->setEasingCurve(QEasingCurve::InCubic);
animation->start(QAbstractAnimation::DeleteWhenStopped);
}
void moveTo(QObject *obj, const QPointF &pos)
{
moveTo(obj, pos.x(), pos.y());

View file

@ -11,6 +11,7 @@ namespace Animations {
void moveTo(QObject *obj, qreal x, qreal y);
void moveTo(QObject *obj, const QPointF &pos);
void animDelete(QObject *obj);
void scaleTo(QObject *obj, qreal scale);
}
#endif // ANIMATIONFUNCTIONS_H