} else if (!driver->isRunning()) {
if (pauseTimer.isActive())
pauseTimer.stop();
+ driver->setStartTime(time.isValid() ? time.elapsed() : 0);
driver->start();
}
if (driver->isRunning() && !pauseTimer.isActive()) {
//we changed the timing interval
driver->stop();
+ driver->setStartTime(time.isValid() ? time.elapsed() : 0);
driver->start();
}
}
if (driver->isRunning()) {
driver->stop();
+ d->setStartTime(time.isValid() ? time.elapsed() : 0);
d->start();
}
if (d->isRunning()) {
d->stop();
+ driver->setStartTime(time.isValid() ? time.elapsed() : 0);
driver->start();
}
}
}
+/*!
+ Sets the time at which an animation driver should start at.
+
+ This is to take into account that pauses can occur in running
+ animations which will stop the driver, but the time still
+ increases.
+ */
+void QAnimationDriver::setStartTime(qint64 startTime)
+{
+ Q_D(QAnimationDriver);
+ d->startTime = startTime;
+}
+
+/*!
+ Returns the start time of the animation.
+ */
+qint64 QAnimationDriver::startTime() const
+{
+ Q_D(const QAnimationDriver);
+ return d->startTime;
+}
+
/*!
Advances the animation based to the specified \a timeStep. This function should
qint64 QAnimationDriver::elapsed() const
{
+ // The default implementation picks up the elapsed time from the
+ // unified timer and can ignore the time offset.
return QUnifiedTimer::instance()->time.elapsed();
}
class Q_CORE_EXPORT QAnimationDriverPrivate : public QObjectPrivate
{
public:
- QAnimationDriverPrivate() : running(false) {}
+ QAnimationDriverPrivate() : running(false), startTime(0) {}
bool running;
+ qint64 startTime;
};
class Q_CORE_EXPORT QAbstractAnimationTimer : public QObject