Ignore:
Timestamp:
Aug 2, 2010, 9:27:30 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.3 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/demos/composition/composition.cpp

    r651 r769  
    4848#include <QMouseEvent>
    4949#include <qmath.h>
     50
     51const int animationInterval = 15; // update every 16 ms = ~60FPS
    5052
    5153CompositionWidget::CompositionWidget(QWidget *parent)
     
    237239{
    238240    m_animation_enabled = true;
     241    m_animationTimer = startTimer(animationInterval);
    239242#ifdef Q_WS_QWS
    240243    m_image = QPixmap(":res/composition/flower.jpg");
     
    263266    rect.translate(-size.width()/2, -size.height()/2);
    264267    return rect;
     268}
     269
     270void CompositionRenderer::setAnimationEnabled(bool enabled)
     271{
     272    if (m_animation_enabled == enabled)
     273        return;
     274    m_animation_enabled = enabled;
     275    if (enabled) {
     276        Q_ASSERT(!m_animationTimer);
     277        m_animationTimer = startTimer(animationInterval);
     278    } else {
     279        killTimer(m_animationTimer);
     280        m_animationTimer = 0;
     281    }
    265282}
    266283
     
    472489#endif
    473490    }
    474 
    475     if (m_animation_enabled && m_current_object == NoObject) {
    476         updateCirclePos();
    477     }
    478491}
    479492
     
    490503        m_current_object = NoObject;
    491504    }
     505    if (m_animation_enabled) {
     506        killTimer(m_animationTimer);
     507        m_animationTimer = 0;
     508    }
    492509}
    493510
     
    501518    m_current_object = NoObject;
    502519
    503     if (m_animation_enabled)
     520    if (m_animation_enabled) {
     521        Q_ASSERT(!m_animationTimer);
     522        m_animationTimer = startTimer(animationInterval);
     523    }
     524}
     525
     526void CompositionRenderer::timerEvent(QTimerEvent *event)
     527{
     528    if (event->timerId() == m_animationTimer)
    504529        updateCirclePos();
    505530}
Note: See TracChangeset for help on using the changeset viewer.