summaryrefslogtreecommitdiffstats
path: root/qt-ui/profile/divelineitem.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2014-01-14 15:12:00 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-01-16 10:12:29 +0700
commitd47456b4e858fa75dadcff4a1c6525ad0137d965 (patch)
tree7dbd34c60e7842e98c4272202e6a3285f8b5a4af /qt-ui/profile/divelineitem.cpp
parent639123a1e8bb510a4f8dd37e864032d718bd88f4 (diff)
downloadsubsurface-d47456b4e858fa75dadcff4a1c6525ad0137d965.tar.gz
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>
Diffstat (limited to 'qt-ui/profile/divelineitem.cpp')
-rw-r--r--qt-ui/profile/divelineitem.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/qt-ui/profile/divelineitem.cpp b/qt-ui/profile/divelineitem.cpp
new file mode 100644
index 000000000..9ceea1e70
--- /dev/null
+++ b/qt-ui/profile/divelineitem.cpp
@@ -0,0 +1,24 @@
+#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);
+}