File indexing completed on 2026-09-30 09:08:13
0001
0002
0003
0004
0005 #ifndef QTIMELINE_H
0006 #define QTIMELINE_H
0007
0008 #include <QtCore/qglobal.h>
0009
0010 QT_REQUIRE_CONFIG(easingcurve);
0011
0012 #include <QtCore/qeasingcurve.h>
0013 #include <QtCore/qobject.h>
0014
0015 QT_BEGIN_NAMESPACE
0016
0017
0018 class QTimeLinePrivate;
0019 class Q_CORE_EXPORT QTimeLine : public QObject
0020 {
0021 Q_OBJECT
0022 Q_PROPERTY(int duration READ duration WRITE setDuration BINDABLE bindableDuration)
0023 Q_PROPERTY(int updateInterval READ updateInterval WRITE setUpdateInterval
0024 BINDABLE bindableUpdateInterval)
0025 Q_PROPERTY(int currentTime READ currentTime WRITE setCurrentTime BINDABLE bindableCurrentTime)
0026 Q_PROPERTY(Direction direction READ direction WRITE setDirection BINDABLE bindableDirection)
0027 Q_PROPERTY(int loopCount READ loopCount WRITE setLoopCount BINDABLE bindableLoopCount)
0028 Q_PROPERTY(QEasingCurve easingCurve READ easingCurve WRITE setEasingCurve
0029 BINDABLE bindableEasingCurve)
0030 public:
0031 enum State {
0032 NotRunning,
0033 Paused,
0034 Running
0035 };
0036 enum Direction {
0037 Forward,
0038 Backward
0039 };
0040
0041 explicit QTimeLine(int duration = 1000, QObject *parent = nullptr);
0042 virtual ~QTimeLine();
0043
0044 State state() const;
0045
0046 int loopCount() const;
0047 void setLoopCount(int count);
0048 QBindable<int> bindableLoopCount();
0049
0050 Direction direction() const;
0051 void setDirection(Direction direction);
0052 QBindable<Direction> bindableDirection();
0053
0054 int duration() const;
0055 void setDuration(int duration);
0056 QBindable<int> bindableDuration();
0057
0058 int startFrame() const;
0059 void setStartFrame(int frame);
0060 int endFrame() const;
0061 void setEndFrame(int frame);
0062 void setFrameRange(int startFrame, int endFrame);
0063
0064 int updateInterval() const;
0065 void setUpdateInterval(int interval);
0066 QBindable<int> bindableUpdateInterval();
0067
0068 QEasingCurve easingCurve() const;
0069 void setEasingCurve(const QEasingCurve &curve);
0070 QBindable<QEasingCurve> bindableEasingCurve();
0071
0072 int currentTime() const;
0073 QBindable<int> bindableCurrentTime();
0074 int currentFrame() const;
0075 qreal currentValue() const;
0076
0077 int frameForTime(int msec) const;
0078 virtual qreal valueForTime(int msec) const;
0079
0080 public Q_SLOTS:
0081 void start();
0082 void resume();
0083 void stop();
0084 void setPaused(bool paused);
0085 void setCurrentTime(int msec);
0086 void toggleDirection();
0087
0088 Q_SIGNALS:
0089 void valueChanged(qreal x, QPrivateSignal);
0090 void frameChanged(int, QPrivateSignal);
0091 void stateChanged(QTimeLine::State newState, QPrivateSignal);
0092 void finished(QPrivateSignal);
0093
0094 protected:
0095 void timerEvent(QTimerEvent *event) override;
0096
0097 private:
0098 Q_DISABLE_COPY(QTimeLine)
0099 Q_DECLARE_PRIVATE(QTimeLine)
0100 };
0101
0102 QT_END_NAMESPACE
0103
0104 #endif
0105