1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QMOVIE_H
5#define QMOVIE_H
6
7#include <QtGui/qtguiglobal.h>
8
9#include <QtCore/qobject.h>
10#include <QtCore/qbytearray.h>
11#include <QtCore/qlist.h>
12#include <QtGui/qimagereader.h>
13
14QT_REQUIRE_CONFIG(movie);
15
16QT_BEGIN_NAMESPACE
17
18class QByteArray;
19class QColor;
20class QIODevice;
21class QImage;
22class QPixmap;
23class QRect;
24class QSize;
25
26class QMoviePrivate;
27class Q_GUI_EXPORT QMovie : public QObject
28{
29 Q_OBJECT
30 Q_DECLARE_PRIVATE(QMovie)
31 Q_PROPERTY(int speed READ speed WRITE setSpeed BINDABLE bindableSpeed)
32 Q_PROPERTY(CacheMode cacheMode READ cacheMode WRITE setCacheMode BINDABLE bindableCacheMode)
33public:
34 enum MovieState {
35 NotRunning,
36 Paused,
37 Running
38 };
39 Q_ENUM(MovieState)
40 enum CacheMode {
41 CacheNone,
42 CacheAll
43 };
44 Q_ENUM(CacheMode)
45
46 explicit QMovie(QObject *parent = nullptr);
47 explicit QMovie(QIODevice *device, const QByteArray &format = QByteArray(), QObject *parent = nullptr);
48 explicit QMovie(const QString &fileName, const QByteArray &format = QByteArray(), QObject *parent = nullptr);
49 ~QMovie();
50
51 static QList<QByteArray> supportedFormats();
52
53 void setDevice(QIODevice *device);
54 QIODevice *device() const;
55
56 void setFileName(const QString &fileName);
57 QString fileName() const;
58
59 void setFormat(const QByteArray &format);
60 QByteArray format() const;
61
62 void setBackgroundColor(const QColor &color);
63 QColor backgroundColor() const;
64
65 MovieState state() const;
66
67 QRect frameRect() const;
68 QImage currentImage() const;
69 QPixmap currentPixmap() const;
70
71 bool isValid() const;
72 QImageReader::ImageReaderError lastError() const;
73 QString lastErrorString() const;
74
75 bool jumpToFrame(int frameNumber);
76 int loopCount() const;
77 int frameCount() const;
78 int nextFrameDelay() const;
79 int currentFrameNumber() const;
80
81 int speed() const;
82 QBindable<int> bindableSpeed();
83
84 QSize scaledSize();
85 void setScaledSize(const QSize &size);
86
87 CacheMode cacheMode() const;
88 void setCacheMode(CacheMode mode);
89 QBindable<CacheMode> bindableCacheMode();
90
91Q_SIGNALS:
92 void started();
93 void resized(const QSize &size);
94 void updated(const QRect &rect);
95 void stateChanged(QMovie::MovieState state);
96 void error(QImageReader::ImageReaderError error);
97 void finished();
98 void frameChanged(int frameNumber);
99
100public Q_SLOTS:
101 void start();
102 bool jumpToNextFrame();
103 void setPaused(bool paused);
104 void stop();
105 void setSpeed(int percentSpeed);
106
107private:
108 Q_DISABLE_COPY(QMovie)
109 Q_PRIVATE_SLOT(d_func(), void _q_loadNextFrame())
110};
111
112QT_END_NAMESPACE
113
114#endif // QMOVIE_H
115

source code of qtbase/src/gui/image/qmovie.h