1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtGui module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QMOVIE_H
41#define QMOVIE_H
42
43#include <QtGui/qtguiglobal.h>
44
45#include <QtCore/qobject.h>
46#include <QtCore/qbytearray.h>
47#include <QtCore/qlist.h>
48#include <QtGui/qimagereader.h>
49
50QT_REQUIRE_CONFIG(movie);
51
52QT_BEGIN_NAMESPACE
53
54class QByteArray;
55class QColor;
56class QIODevice;
57class QImage;
58class QPixmap;
59class QRect;
60class QSize;
61
62class QMoviePrivate;
63class Q_GUI_EXPORT QMovie : public QObject
64{
65 Q_OBJECT
66 Q_DECLARE_PRIVATE(QMovie)
67 Q_PROPERTY(int speed READ speed WRITE setSpeed BINDABLE bindableSpeed)
68 Q_PROPERTY(CacheMode cacheMode READ cacheMode WRITE setCacheMode BINDABLE bindableCacheMode)
69public:
70 enum MovieState {
71 NotRunning,
72 Paused,
73 Running
74 };
75 Q_ENUM(MovieState)
76 enum CacheMode {
77 CacheNone,
78 CacheAll
79 };
80 Q_ENUM(CacheMode)
81
82 explicit QMovie(QObject *parent = nullptr);
83 explicit QMovie(QIODevice *device, const QByteArray &format = QByteArray(), QObject *parent = nullptr);
84 explicit QMovie(const QString &fileName, const QByteArray &format = QByteArray(), QObject *parent = nullptr);
85 ~QMovie();
86
87 static QList<QByteArray> supportedFormats();
88
89 void setDevice(QIODevice *device);
90 QIODevice *device() const;
91
92 void setFileName(const QString &fileName);
93 QString fileName() const;
94
95 void setFormat(const QByteArray &format);
96 QByteArray format() const;
97
98 void setBackgroundColor(const QColor &color);
99 QColor backgroundColor() const;
100
101 MovieState state() const;
102
103 QRect frameRect() const;
104 QImage currentImage() const;
105 QPixmap currentPixmap() const;
106
107 bool isValid() const;
108 QImageReader::ImageReaderError lastError() const;
109 QString lastErrorString() const;
110
111 bool jumpToFrame(int frameNumber);
112 int loopCount() const;
113 int frameCount() const;
114 int nextFrameDelay() const;
115 int currentFrameNumber() const;
116
117 int speed() const;
118 QBindable<int> bindableSpeed();
119
120 QSize scaledSize();
121 void setScaledSize(const QSize &size);
122
123 CacheMode cacheMode() const;
124 void setCacheMode(CacheMode mode);
125 QBindable<CacheMode> bindableCacheMode();
126
127Q_SIGNALS:
128 void started();
129 void resized(const QSize &size);
130 void updated(const QRect &rect);
131 void stateChanged(QMovie::MovieState state);
132 void error(QImageReader::ImageReaderError error);
133 void finished();
134 void frameChanged(int frameNumber);
135
136public Q_SLOTS:
137 void start();
138 bool jumpToNextFrame();
139 void setPaused(bool paused);
140 void stop();
141 void setSpeed(int percentSpeed);
142
143private:
144 Q_DISABLE_COPY(QMovie)
145 Q_PRIVATE_SLOT(d_func(), void _q_loadNextFrame())
146};
147
148QT_END_NAMESPACE
149
150#endif // QMOVIE_H
151