QtGui/qmovie.h Source File

qmovie.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
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 Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
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 
60 
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)
79  Q_PROPERTY(int speed READ speed WRITE setSpeed)
80  Q_PROPERTY(CacheMode cacheMode READ cacheMode WRITE setCacheMode)
81 public:
82  enum MovieState {
85  Running
86  };
87  enum CacheMode {
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 frameNumber);
120  int loopCount() const;
121  int frameCount() const;
122  int nextFrameDelay() const;
123  int currentFrameNumber() 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 frameNumber);
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 
172 
174 
175 #endif // QT_NO_MOVIE
176 
177 #endif // QMOVIE_H
GLint mode
Definition: GLee.h:4479
Definition: qmovie.h:74
#define QT_END_NAMESPACE
Definition: qglobal.h:128
#define Q_PROPERTY(text)
Definition: qobjectdefs.h:80
GLuint start
Definition: GLee.h:872
#define QT_BEGIN_HEADER
Definition: qglobal.h:141
#define Q_PRIVATE_SLOT(d, signature)
Definition: qobjectdefs.h:73
Definition: qcolor.h:67
#define Q_SLOTS
Definition: qobjectdefs.h:71
CacheMode
Definition: qmovie.h:87
MovieState
Definition: qmovie.h:82
#define Q_SIGNALS
Definition: qobjectdefs.h:72
#define Q_ENUMS(x)
Definition: qobjectdefs.h:84
#define QT_BEGIN_NAMESPACE
Definition: qglobal.h:127
GLenum GLsizei GLenum format
Definition: GLee.h:873
Definition: qimage.h:87
#define Q_OBJECT
Definition: qobjectdefs.h:157
Definition: qrect.h:58
Definition: qsize.h:53
#define QT_END_HEADER
Definition: qglobal.h:142
GLsizeiptr size
Definition: GLee.h:1561
GLuint color
Definition: GLee.h:8456