aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--transitioncontrol.cpp14
-rw-r--r--transitioncontrol.h2
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;
};