6#include <private/qproperty_p.h>
7#include <private/qobject_p.h>
8#include <QtCore/qcoreevent.h>
9#include <QtCore/qmath.h>
10#include <QtCore/qelapsedtimer.h>
23 void setDuration(
int duration) { q_func()->setDuration(duration); }
60 qreal lastValue =
q->currentValue();
61 int lastFrame =
q->currentFrame();
65 int loopCountNow =
elapsed / duration;
69 qDebug() <<
"QTimeLinePrivate::setCurrentTime:" << msecs << duration <<
"with loopCountNow"
70 << loopCountNow <<
"currentLoopCount" <<
currentLoopCount <<
"looping" << looping;
81 bool finished =
false;
90 qDebug() <<
"QTimeLinePrivate::setCurrentTime: frameForTime" <<
currentTime << currentFrame;
93 emit q->valueChanged(
q->currentValue(), QTimeLine::QPrivateSignal());
94 if (lastFrame != currentFrame) {
96 if (looping && !finished && transitionframe != currentFrame) {
98 qDebug(
"QTimeLinePrivate::setCurrentTime: transitionframe");
100 emit q->frameChanged(transitionframe, QTimeLine::QPrivateSignal());
102#ifdef QTIMELINE_DEBUG
106 reason +=
" not looping";
110 reason +=
" finished";
112 if (transitionframe == currentFrame) {
115 reason +=
" transitionframe is equal to currentFrame: " +
QByteArray::number(currentFrame);
117 qDebug(
"QTimeLinePrivate::setCurrentTime: not transitionframe because %s", reason.
constData());
120 emit q->frameChanged(currentFrame, QTimeLine::QPrivateSignal());
124 emit q->finished(QTimeLine::QPrivateSignal());
132 return &
d->currentTime;
312 return &
d->loopCount;
337 auto previousDirection =
d->direction.value();
339 d->startTime =
d->currentTime;
341 if (previousDirection !=
d->direction.value())
342 d->direction.notify();
348 return &
d->direction;
372 qWarning(
"QTimeLine::setDuration: cannot set duration <= 0");
376 d->duration.removeBindingUnlessInWrapper();
380 d->duration.notify();
398 return d->startFrame;
469 return d->updateInterval;
474 d->updateInterval = interval;
479 return &
d->updateInterval;
496 return d->easingCurve;
502 d->easingCurve = curve;
508 return &
d->easingCurve;
529 return d->currentTime;
535 d->currentLoopCount = 0;
537 d->setCurrentTime(msec);
573 return d->startFrame + int((
d->endFrame -
d->startFrame) *
valueForTime(msec));
590 msec =
qBound(0, msec,
d->duration.value());
593 return d->easingCurve.value().valueForProgress(
value);
613 qWarning(
"QTimeLine::start: already running");
618 curTime =
d->duration;
620 d->startTime = curTime;
621 d->currentLoopCount = 0;
624 d->setCurrentTime(curTime);
641 qWarning(
"QTimeLine::resume: already running");
645 d->startTime =
d->currentTime;
676 qWarning(
"QTimeLine::setPaused: Not running");
679 if (paused &&
d->state !=
Paused) {
680 d->startTime =
d->currentTime;
684 }
else if (!paused &&
d->state ==
Paused) {
687 d->startTime =
d->currentTime;
713 if (
event->timerId() !=
d->timerId) {
720 d->setCurrentTime(
d->startTime +
d->timer.elapsed());
722 d->setCurrentTime(
d->startTime -
d->timer.elapsed());
728#include "moc_qtimeline.cpp"
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
static QByteArray number(int, int base=10)
Returns a byte-array representing the whole number n as text.
int startTimer(int interval, Qt::TimerType timerType=Qt::CoarseTimer)
This is an overloaded function that will start a timer of type timerType and a timeout of interval mi...
void killTimer(int id)
Kills the timer with timer identifier, id.
void setCurrentTimeForwardToQ(int time)
Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS(QTimeLinePrivate, int, duration, &QTimeLinePrivate::setDuration, 1000) int startFrame=0
void setDirection(QTimeLine::Direction direction)
Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(QTimeLinePrivate, QEasingCurve, easingCurve, QEasingCurve::InOutSine) int startTime=0
void setCurrentTime(int msecs)
Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS(QTimeLinePrivate, int, currentTime, &QTimeLinePrivate::setCurrentTimeForwardToQ, 0) int timerId=0
void setDuration(int duration)
Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS(QTimeLinePrivate, QTimeLine::Direction, direction, &QTimeLinePrivate::setDirection, QTimeLine::Forward) QTimeLine void setState(QTimeLine::State newState)
int currentTime
the current time of the time line.
int loopCount
the number of times the timeline should loop before it's finished.
void timerEvent(QTimerEvent *event) override
\reimp
int currentFrame() const
Returns the frame corresponding to the current time.
QTimeLine(int duration=1000, QObject *parent=nullptr)
Constructs a timeline with a duration of duration milliseconds.
int startFrame() const
Returns the start frame, which is the frame corresponding to the start of the timeline (i....
qreal currentValue() const
Returns the value corresponding to the current time.
State state() const
Returns the state of the timeline.
void setPaused(bool paused)
If paused is true, the timeline is paused, causing QTimeLine to enter Paused state.
int duration
the total duration of the timeline in milliseconds.
QBindable< int > bindableCurrentTime()
int frameForTime(int msec) const
Returns the frame corresponding to the time msec.
void setEasingCurve(const QEasingCurve &curve)
int endFrame() const
Returns the end frame, which is the frame corresponding to the end of the timeline (i....
void setUpdateInterval(int interval)
QBindable< QEasingCurve > bindableEasingCurve()
int updateInterval
the time in milliseconds between each time QTimeLine updates its current time.
QBindable< int > bindableLoopCount()
virtual qreal valueForTime(int msec) const
Returns the timeline value for the time msec.
QBindable< int > bindableDuration()
void start()
Starts the timeline.
void setLoopCount(int count)
void setDirection(Direction direction)
void setStartFrame(int frame)
Sets the start frame, which is the frame corresponding to the start of the timeline (i....
Direction direction
the direction of the timeline when QTimeLine is in \l Running state.
QBindable< int > bindableUpdateInterval()
State
This enum describes the state of the timeline.
void setFrameRange(int startFrame, int endFrame)
Sets the timeline's frame counter to start at startFrame, and end and endFrame.
void setCurrentTime(int msec)
QBindable< Direction > bindableDirection()
void setDuration(int duration)
void stop()
Stops the timeline, causing QTimeLine to enter NotRunning state.
void toggleDirection()
Toggles the direction of the timeline.
Direction
This enum describes the direction of the timeline when in \l Running state.
void setEndFrame(int frame)
Sets the end frame, which is the frame corresponding to the end of the timeline (i....
virtual ~QTimeLine()
Destroys the timeline.
void resume()
Resumes the timeline from the current time.
void newState(QList< State > &states, const char *token, const char *lexem, bool pre)
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
constexpr const T & qBound(const T &min, const T &val, const T &max)
GLenum GLenum GLsizei count
GLdouble GLdouble GLdouble GLdouble q
#define Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(...)
#define Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS(...)
static double elapsed(qint64 after, qint64 before)
static double currentTime()
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent