summaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-02-20 13:41:40 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-02-20 13:41:40 (GMT)
commit5c4234aa7499d879f50d1475aff8cce7d3ff6c11 (patch)
tree10c930f9d1526cb2bc779469e7b97cebc21619a0 /demos
parentd05f83919949fd9604e6d96858a8404c9a580def (diff)
parentc9d73831910d4959e17899497335bd7fc4e08935 (diff)
downloadQt-5c4234aa7499d879f50d1475aff8cce7d3ff6c11.zip
Qt-5c4234aa7499d879f50d1475aff8cce7d3ff6c11.tar.gz
Qt-5c4234aa7499d879f50d1475aff8cce7d3ff6c11.tar.bz2
Merge branch 'qt-master-from-4.6' of scm.dev.nokia.troll.no:qt/qt-integration into master-integration
* 'qt-master-from-4.6' of scm.dev.nokia.troll.no:qt/qt-integration: (323 commits) Doc: these files are NOT part of the test suite of the Qt toolkit Autotest: make the licenseCheck test also check .qdoc files use egl properties when creating surfaces on symbian work around the current include file structure on Symbian^3 Get rid of the dependency on the Symbian app layer Fix incorrect license headers Fix incorrect license headers tst_qnetworkreply: Check if TCP/HTTP connection got re-used Fix bad conflict resolution from 4baa9dfb5273d7b501dcb3f456983262c53cc8d1 Fix building in a namespace on Windows Supressed Icon sizes on QPushButton in QS60Style Ensure that posted events are sent on Windows Fixed off-by-one blending errors in the NEON drawhelper code. Fixed libstdcpp.dll version autodetection for Symbian Fixed linkage failure when building qmake on Unix platforms Factored epocRoot implementation out of qmake Factored readRegistryKey implementation out of qmake Cetest extensions for Windows Mobile device power operations. Remote lib extensions for Windows Mobile device power operations. ColorDialog is always shown as stripped-down version (for QVGA) ...
Diffstat (limited to 'demos')
-rw-r--r--demos/composition/composition.cpp35
-rw-r--r--demos/composition/composition.h13
2 files changed, 38 insertions, 10 deletions
diff --git a/demos/composition/composition.cpp b/demos/composition/composition.cpp
index e03f3e6..deca5dc 100644
--- a/demos/composition/composition.cpp
+++ b/demos/composition/composition.cpp
@@ -48,6 +48,8 @@
#include <QMouseEvent>
#include <qmath.h>
+const int animationInterval = 15; // update every 16 ms = ~60FPS
+
CompositionWidget::CompositionWidget(QWidget *parent)
: QWidget(parent)
{
@@ -236,6 +238,7 @@ CompositionRenderer::CompositionRenderer(QWidget *parent)
: ArthurFrame(parent)
{
m_animation_enabled = true;
+ m_animationTimer = startTimer(animationInterval);
#ifdef Q_WS_QWS
m_image = QPixmap(":res/composition/flower.jpg");
m_image.setAlphaChannel(QPixmap(":res/composition/flower_alpha.jpg"));
@@ -264,6 +267,20 @@ QRectF rectangle_around(const QPointF &p, const QSizeF &size = QSize(250, 200))
return rect;
}
+void CompositionRenderer::setAnimationEnabled(bool enabled)
+{
+ if (m_animation_enabled == enabled)
+ return;
+ m_animation_enabled = enabled;
+ if (enabled) {
+ Q_ASSERT(!m_animationTimer);
+ m_animationTimer = startTimer(animationInterval);
+ } else {
+ killTimer(m_animationTimer);
+ m_animationTimer = 0;
+ }
+}
+
void CompositionRenderer::updateCirclePos()
{
if (m_current_object != NoObject)
@@ -471,10 +488,6 @@ void CompositionRenderer::paint(QPainter *painter)
painter->drawImage(0, 0, m_buffer);
#endif
}
-
- if (m_animation_enabled && m_current_object == NoObject) {
- updateCirclePos();
- }
}
void CompositionRenderer::mousePressEvent(QMouseEvent *e)
@@ -489,6 +502,10 @@ void CompositionRenderer::mousePressEvent(QMouseEvent *e)
} else {
m_current_object = NoObject;
}
+ if (m_animation_enabled) {
+ killTimer(m_animationTimer);
+ m_animationTimer = 0;
+ }
}
void CompositionRenderer::mouseMoveEvent(QMouseEvent *e)
@@ -500,7 +517,15 @@ void CompositionRenderer::mouseReleaseEvent(QMouseEvent *)
{
m_current_object = NoObject;
- if (m_animation_enabled)
+ if (m_animation_enabled) {
+ Q_ASSERT(!m_animationTimer);
+ m_animationTimer = startTimer(animationInterval);
+ }
+}
+
+void CompositionRenderer::timerEvent(QTimerEvent *event)
+{
+ if (event->timerId() == m_animationTimer)
updateCirclePos();
}
diff --git a/demos/composition/composition.h b/demos/composition/composition.h
index 1123531..f5a9fc3 100644
--- a/demos/composition/composition.h
+++ b/demos/composition/composition.h
@@ -109,10 +109,6 @@ public:
void paint(QPainter *);
- void mousePressEvent(QMouseEvent *);
- void mouseMoveEvent(QMouseEvent *);
- void mouseReleaseEvent(QMouseEvent *);
-
void setCirclePos(const QPointF &pos);
QSize sizeHint() const { return QSize(500, 400); }
@@ -121,6 +117,12 @@ public:
int circleColor() const { return m_circle_hue; }
int circleAlpha() const { return m_circle_alpha; }
+protected:
+ void mousePressEvent(QMouseEvent *);
+ void mouseMoveEvent(QMouseEvent *);
+ void mouseReleaseEvent(QMouseEvent *);
+ void timerEvent(QTimerEvent *);
+
public slots:
void setClearMode() { m_composition_mode = QPainter::CompositionMode_Clear; update(); }
void setSourceMode() { m_composition_mode = QPainter::CompositionMode_Source; update(); }
@@ -150,7 +152,7 @@ public slots:
void setCircleAlpha(int alpha) { m_circle_alpha = alpha; update(); }
void setCircleColor(int hue) { m_circle_hue = hue; update(); }
- void setAnimationEnabled(bool enabled) { m_animation_enabled = enabled; update(); }
+ void setAnimationEnabled(bool enabled);
private:
void updateCirclePos();
@@ -177,6 +179,7 @@ private:
ObjectType m_current_object;
bool m_animation_enabled;
+ int m_animationTimer;
#ifdef QT_OPENGL_SUPPORT
QGLPixelBuffer *m_pbuffer;