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>
This commit is contained in:
Tomaz Canabrava 2014-01-14 15:12:00 -02:00 committed by Dirk Hohndel
parent 639123a1e8
commit d47456b4e8
3 changed files with 45 additions and 2 deletions

View file

@ -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);
}

View file

@ -0,0 +1,17 @@
#ifndef DIVELINEITEM_H
#define DIVELINEITEM_H
#include <QObject>
#include <QGraphicsLineItem>
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

View file

@ -65,7 +65,8 @@ HEADERS = \
qt-ui/usermanual.h \
qt-ui/profile/profilewidget2.h \
qt-ui/profile/diverectitem.h \
qt-ui/profile/divepixmapitem.h
qt-ui/profile/divepixmapitem.h \
qt-ui/profile/divelineitem.h
SOURCES = \
deco.c \
@ -118,7 +119,8 @@ SOURCES = \
qt-ui/usermanual.cpp \
qt-ui/profile/profilewidget2.cpp \
qt-ui/profile/diverectitem.cpp \
qt-ui/profile/divepixmapitem.cpp
qt-ui/profile/divepixmapitem.cpp \
qt-ui/profile/divelineitem.cpp
linux*: SOURCES += linux.c
mac: SOURCES += macos.c