summaryrefslogtreecommitdiffstats
path: root/examples/effects/fademessage
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-11-10 11:05:36 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-11-10 12:18:58 (GMT)
commit6d4acbe94c71f7c0049cd08944855c23a716bee3 (patch)
tree7fefc3c55896e9f50175ba275f34e7ceb1542d21 /examples/effects/fademessage
parentd845505fd57ad4b06499b5b125703e80bbae692a (diff)
downloadQt-6d4acbe94c71f7c0049cd08944855c23a716bee3.zip
Qt-6d4acbe94c71f7c0049cd08944855c23a716bee3.tar.gz
Qt-6d4acbe94c71f7c0049cd08944855c23a716bee3.tar.bz2
Make the new examples for effects use the Qt Animation Framework
Task-number: QTBUG-5640 Reviewed-by: Leo
Diffstat (limited to 'examples/effects/fademessage')
-rw-r--r--examples/effects/fademessage/fademessage.cpp18
-rw-r--r--examples/effects/fademessage/fademessage.h5
2 files changed, 12 insertions, 11 deletions
diff --git a/examples/effects/fademessage/fademessage.cpp b/examples/effects/fademessage/fademessage.cpp
index 818d00f..a65c748 100644
--- a/examples/effects/fademessage/fademessage.cpp
+++ b/examples/effects/fademessage/fademessage.cpp
@@ -43,7 +43,7 @@
#include <QtGui>
-FadeMessage::FadeMessage(QWidget *parent): QGraphicsView(parent), m_index(0.0)
+FadeMessage::FadeMessage(QWidget *parent): QGraphicsView(parent)
{
setScene(&m_scene);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
@@ -51,9 +51,12 @@ FadeMessage::FadeMessage(QWidget *parent): QGraphicsView(parent), m_index(0.0)
setupScene();
- m_timeLine = new QTimeLine(500, this);
- m_timeLine->setCurveShape(QTimeLine::EaseInOutCurve);
- connect(m_timeLine, SIGNAL(valueChanged(qreal)), m_effect, SLOT(setStrength(qreal)));
+ m_animation = new QPropertyAnimation(m_effect, "strength", this);
+ m_animation->setDuration(500);
+ m_animation->setEasingCurve(QEasingCurve::InOutSine);
+ m_animation->setStartValue(0);
+ m_animation->setEndValue(1);
+
setRenderHint(QPainter::Antialiasing, true);
setFrameStyle(QFrame::NoFrame);
@@ -63,13 +66,12 @@ void FadeMessage::togglePopup()
{
if (m_message->isVisible()) {
m_message->setVisible(false);
- m_timeLine->setDirection(QTimeLine::Backward);
- m_timeLine->start();
+ m_animation->setDirection(QAbstractAnimation::Backward);
} else {
m_message->setVisible(true);
- m_timeLine->setDirection(QTimeLine::Forward);
- m_timeLine->start();
+ m_animation->setDirection(QAbstractAnimation::Forward);
}
+ m_animation->start();
}
void FadeMessage::setupScene()
diff --git a/examples/effects/fademessage/fademessage.h b/examples/effects/fademessage/fademessage.h
index 34e2fb8..e73ef6b 100644
--- a/examples/effects/fademessage/fademessage.h
+++ b/examples/effects/fademessage/fademessage.h
@@ -44,7 +44,7 @@
#include <QGraphicsEffect>
#include <QGraphicsView>
-#include <QTimeLine>
+#include <QPropertyAnimation>
#include "fademessage.h"
@@ -62,11 +62,10 @@ private slots:
void togglePopup();
private:
- qreal m_index;
QGraphicsScene m_scene;
QGraphicsColorizeEffect *m_effect;
QGraphicsItem *m_message;
- QTimeLine *m_timeLine;
+ QPropertyAnimation *m_animation;
};
#endif // FADEMESSAGE_H