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)
68 Q_PROPERTY(CacheMode cacheMode READ cacheMode WRITE setCacheMode)
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
119 QSize scaledSize();
120 void setScaledSize(const QSize &size);
121
122 CacheMode cacheMode() const;
123 void setCacheMode(CacheMode mode);
124
125Q_SIGNALS:
126 void started();
127 void resized(const QSize &size);
128 void updated(const QRect &rect);
129 void stateChanged(QMovie::MovieState state);
130 void error(QImageReader::ImageReaderError error);
131 void finished();
132 void frameChanged(int frameNumber);
133
134public Q_SLOTS:
135 void start();
136 bool jumpToNextFrame();
137 void setPaused(bool paused);
138 void stop();
139 void setSpeed(int percentSpeed);
140
141private:
142 Q_DISABLE_COPY(QMovie)
143 Q_PRIVATE_SLOT(d_func(), void _q_loadNextFrame())
144};
145
146QT_END_NAMESPACE
147
148#endif // QMOVIE_H
149