From 38ac6ed35fc4e3a99cbf1ea1ae271ddea7a06661 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Sun, 8 Jun 2014 12:22:45 -0300 Subject: [PATCH] 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 Signed-off-by: Dirk Hohndel --- qt-ui/profile/animationfunctions.cpp | 10 ++++++++++ qt-ui/profile/animationfunctions.h | 1 + 2 files changed, 11 insertions(+) diff --git a/qt-ui/profile/animationfunctions.cpp b/qt-ui/profile/animationfunctions.cpp index bd08a22ee..c680e11a5 100644 --- a/qt-ui/profile/animationfunctions.cpp +++ b/qt-ui/profile/animationfunctions.cpp @@ -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()); diff --git a/qt-ui/profile/animationfunctions.h b/qt-ui/profile/animationfunctions.h index 9269e6dd3..d8e44be0c 100644 --- a/qt-ui/profile/animationfunctions.h +++ b/qt-ui/profile/animationfunctions.h @@ -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