1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). |
4 | ** Contact: http://www.qt-project.org/ |
5 | ** |
6 | ** This file is part of the QtGui module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** GNU Lesser General Public License Usage |
10 | ** This file may be used under the terms of the GNU Lesser General Public |
11 | ** License version 2.1 as published by the Free Software Foundation and |
12 | ** appearing in the file LICENSE.LGPL included in the packaging of this |
13 | ** file. Please review the following information to ensure the GNU Lesser |
14 | ** General Public License version 2.1 requirements will be met: |
15 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
16 | ** |
17 | ** In addition, as a special exception, Nokia gives you certain additional |
18 | ** rights. These rights are described in the Nokia Qt LGPL Exception |
19 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
20 | ** |
21 | ** GNU General Public License Usage |
22 | ** Alternatively, this file may be used under the terms of the GNU General |
23 | ** Public License version 3.0 as published by the Free Software Foundation |
24 | ** and appearing in the file LICENSE.GPL included in the packaging of this |
25 | ** file. Please review the following information to ensure the GNU General |
26 | ** Public License version 3.0 requirements will be met: |
27 | ** http://www.gnu.org/copyleft/gpl.html. |
28 | ** |
29 | ** Other Usage |
30 | ** Alternatively, this file may be used in accordance with the terms and |
31 | ** conditions contained in a signed written agreement between you and Nokia. |
32 | ** |
33 | ** |
34 | ** |
35 | ** |
36 | ** |
37 | ** |
38 | ** $QT_END_LICENSE$ |
39 | ** |
40 | ****************************************************************************/ |
41 | |
42 | #ifndef QMOVIE_H |
43 | #define QMOVIE_H |
44 | |
45 | #include <QtCore/qobject.h> |
46 | |
47 | #ifndef QT_NO_MOVIE |
48 | |
49 | #include <QtCore/qbytearray.h> |
50 | #include <QtCore/qlist.h> |
51 | #include <QtCore/qobject.h> |
52 | #include <QtGui/qimagereader.h> |
53 | |
54 | #ifdef QT3_SUPPORT |
55 | #include <QtGui/qimage.h> |
56 | #include <QtGui/qpixmap.h> |
57 | #endif |
58 | |
59 | QT_BEGIN_HEADER |
60 | |
61 | QT_BEGIN_NAMESPACE |
62 | |
63 | QT_MODULE(Gui) |
64 | |
65 | class QByteArray; |
66 | class QColor; |
67 | class QIODevice; |
68 | class QImage; |
69 | class QPixmap; |
70 | class QRect; |
71 | class QSize; |
72 | |
73 | class QMoviePrivate; |
74 | class Q_GUI_EXPORT QMovie : public QObject |
75 | { |
76 | Q_OBJECT |
77 | Q_DECLARE_PRIVATE(QMovie) |
78 | Q_ENUMS(MovieState CacheMode) |
79 | Q_PROPERTY(int speed READ speed WRITE setSpeed) |
80 | Q_PROPERTY(CacheMode cacheMode READ cacheMode WRITE setCacheMode) |
81 | public: |
82 | enum MovieState { |
83 | NotRunning, |
84 | Paused, |
85 | Running |
86 | }; |
87 | enum CacheMode { |
88 | CacheNone, |
89 | CacheAll |
90 | }; |
91 | |
92 | QMovie(QObject *parent = 0); |
93 | explicit QMovie(QIODevice *device, const QByteArray &format = QByteArray(), QObject *parent = 0); |
94 | explicit QMovie(const QString &fileName, const QByteArray &format = QByteArray(), QObject *parent = 0); |
95 | ~QMovie(); |
96 | |
97 | static QList<QByteArray> supportedFormats(); |
98 | |
99 | void setDevice(QIODevice *device); |
100 | QIODevice *device() const; |
101 | |
102 | void setFileName(const QString &fileName); |
103 | QString fileName() const; |
104 | |
105 | void setFormat(const QByteArray &format); |
106 | QByteArray format() const; |
107 | |
108 | void setBackgroundColor(const QColor &color); |
109 | QColor backgroundColor() const; |
110 | |
111 | MovieState state() const; |
112 | |
113 | QRect frameRect() const; |
114 | QImage currentImage() const; |
115 | QPixmap currentPixmap() const; |
116 | |
117 | bool isValid() const; |
118 | |
119 | bool jumpToFrame(int ); |
120 | int loopCount() const; |
121 | int frameCount() const; |
122 | int nextFrameDelay() const; |
123 | int () const; |
124 | |
125 | int speed() const; |
126 | |
127 | QSize scaledSize(); |
128 | void setScaledSize(const QSize &size); |
129 | |
130 | CacheMode cacheMode() const; |
131 | void setCacheMode(CacheMode mode); |
132 | |
133 | CacheMode cacheMode(); // ### Qt 5: remove me |
134 | |
135 | Q_SIGNALS: |
136 | void started(); |
137 | void resized(const QSize &size); |
138 | void updated(const QRect &rect); |
139 | void stateChanged(QMovie::MovieState state); |
140 | void error(QImageReader::ImageReaderError error); |
141 | void finished(); |
142 | void frameChanged(int ); |
143 | |
144 | public Q_SLOTS: |
145 | void start(); |
146 | bool jumpToNextFrame(); |
147 | void setPaused(bool paused); |
148 | void stop(); |
149 | void setSpeed(int percentSpeed); |
150 | |
151 | private: |
152 | Q_DISABLE_COPY(QMovie) |
153 | Q_PRIVATE_SLOT(d_func(), void _q_loadNextFrame()) |
154 | |
155 | #ifdef QT3_SUPPORT |
156 | public: |
157 | inline QT3_SUPPORT bool isNull() const { return isValid(); } |
158 | inline QT3_SUPPORT int frameNumber() const { return currentFrameNumber(); } |
159 | inline QT3_SUPPORT bool running() const { return state() == Running; } |
160 | inline QT3_SUPPORT bool paused() const { return state() == Paused; } |
161 | inline QT3_SUPPORT bool finished() const { return state() == NotRunning; } |
162 | inline QT3_SUPPORT void restart() { stop(); start(); } |
163 | inline QT3_SUPPORT QImage frameImage() const { return currentImage(); } |
164 | inline QT3_SUPPORT QPixmap framePixmap() const { return currentPixmap(); } |
165 | inline QT3_SUPPORT void step() { jumpToNextFrame(); } |
166 | inline QT3_SUPPORT void pause() { setPaused(true); } |
167 | inline QT3_SUPPORT void unpause() { setPaused(false); } |
168 | #endif |
169 | }; |
170 | |
171 | QT_END_NAMESPACE |
172 | |
173 | QT_END_HEADER |
174 | |
175 | #endif // QT_NO_MOVIE |
176 | |
177 | #endif // QMOVIE_H |
178 | |