diff options
author | Samuel Fadel <samuelfadel@gmail.com> | 2016-02-11 03:11:06 -0200 |
---|---|---|
committer | Samuel Fadel <samuelfadel@gmail.com> | 2016-02-11 03:11:06 -0200 |
commit | 710e5d87d285ac4d3123597fe012ba7951d6542f (patch) | |
tree | 5af281aba03eeff9a7e75a5f8eee4243d8dc06f6 | |
parent | b45a21976bece19da81166324dc1cc4260a0e0f4 (diff) |
TransitionControl: only rewind when needed.
-rw-r--r-- | transitioncontrol.cpp | 14 | ||||
-rw-r--r-- | transitioncontrol.h | 2 |
2 files changed, 12 insertions, 4 deletions
diff --git a/transitioncontrol.cpp b/transitioncontrol.cpp index cf8f644..bd85405 100644 --- a/transitioncontrol.cpp +++ b/transitioncontrol.cpp @@ -11,6 +11,7 @@ static const Qt::MouseButton MOUSE_BUTTON = Qt::MiddleButton; TransitionControl::TransitionControl() : m_t(1.0) , m_startPos(-1) + , m_shouldRewind(false) { } @@ -41,6 +42,7 @@ void TransitionControl::mouseMoveEvent(QMouseEvent *event) return; } + m_shouldRewind = true; m_t = double(x) / m_startPos; emit tChanged(m_t); } @@ -54,8 +56,12 @@ void TransitionControl::mouseReleaseEvent(QMouseEvent *event) // Back to initial state m_startPos = -1; - // We now have to smoothly go back to m_t == 1.0 - m_rewindThread = new RewindWorkerThread(this); - connect(m_rewindThread, &QThread::finished, m_rewindThread, &QObject::deleteLater); - m_rewindThread->start(); + if (m_shouldRewind) { + m_shouldRewind = false; + + // We now have to smoothly go back to m_t == 1.0 + m_rewindThread = new RewindWorkerThread(this); + connect(m_rewindThread, &QThread::finished, m_rewindThread, &QObject::deleteLater); + m_rewindThread->start(); + } } diff --git a/transitioncontrol.h b/transitioncontrol.h index ac84786..4c76e8c 100644 --- a/transitioncontrol.h +++ b/transitioncontrol.h @@ -34,6 +34,8 @@ private: // The x pos where interaction started int m_startPos; + bool m_shouldRewind; + // Controls the smooth rewind transition QThread *m_rewindThread; }; |