subsurface/qt-ui/profile/divelineitem.cpp
Tomaz Canabrava d47456b4e8 Added a class based on QGraphicsLineItem that can be animated.
This class has animatedHide, animatedMoveTo and QProperty
animations. it's very userful for the future creation of the
Cartesian Axis that will have the ticks 'flowing' around when
it's needed.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 10:12:29 +07:00

24 lines
710 B
C++

#include "divelineitem.h"
#include <QPropertyAnimation>
DiveLineItem::DiveLineItem(QGraphicsItem *parent) : QGraphicsLineItem(parent)
{
}
void DiveLineItem::animatedHide()
{
QPropertyAnimation *animation = new QPropertyAnimation(this, "opacity");
connect(animation, SIGNAL(finished()), SLOT(deleteLater()));
animation->setStartValue(1);
animation->setEndValue(0);
animation->start(QAbstractAnimation::DeleteWhenStopped);
}
void DiveLineItem::animateMoveTo(qreal x, qreal y)
{
QPropertyAnimation *animation = new QPropertyAnimation(this, "pos");
animation->setStartValue(property("pos").toPointF());
animation->setEndValue(QPointF(x, y));
animation->start(QAbstractAnimation::DeleteWhenStopped);
}