From d47456b4e858fa75dadcff4a1c6525ad0137d965 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Tue, 14 Jan 2014 15:12:00 -0200 Subject: 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 Signed-off-by: Dirk Hohndel --- qt-ui/profile/divelineitem.cpp | 24 ++++++++++++++++++++++++ qt-ui/profile/divelineitem.h | 17 +++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 qt-ui/profile/divelineitem.cpp create mode 100644 qt-ui/profile/divelineitem.h (limited to 'qt-ui') 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 + +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); +} diff --git a/qt-ui/profile/divelineitem.h b/qt-ui/profile/divelineitem.h new file mode 100644 index 000000000..497f803eb --- /dev/null +++ b/qt-ui/profile/divelineitem.h @@ -0,0 +1,17 @@ +#ifndef DIVELINEITEM_H +#define DIVELINEITEM_H + +#include +#include + +class DiveLineItem : public QObject, public QGraphicsLineItem { + Q_OBJECT + Q_PROPERTY(QPointF pos READ pos WRITE setPos) + Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity) +public: + DiveLineItem(QGraphicsItem *parent = 0); + void animatedHide(); + void animateMoveTo(qreal x, qreal y); +}; + +#endif \ No newline at end of file -- cgit v1.2.3-70-g09d2