Qt 4.8
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
79  int speed;
80  CacheMode cacheMode;
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);
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:
153  Q_PRIVATE_SLOT(d_func(), void _q_loadNextFrame())
154 
155 public:
156 #ifdef QT3_SUPPORT
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
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
#define QT_MODULE(x)
Definition: qglobal.h:2783
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
#define error(msg)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
#define Q_PRIVATE_SLOT(d, signature)
Definition: qobjectdefs.h:73
#define Q_SLOTS
Definition: qobjectdefs.h:71
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_SIGNALS
Definition: qobjectdefs.h:72
#define Q_ENUMS(x)
Definition: qobjectdefs.h:84
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
handler setDevice(device)
#define Q_OBJECT
Definition: qobjectdefs.h:157
MovieState
This enum describes the different states of QMovie.
Definition: qmovie.h:82
ImageReaderError
This enum describes the different types of errors that can occur when reading images with QImageReade...
Definition: qimagereader.h:65
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
The QIODevice class is the base interface class of all I/O devices in Qt.
Definition: qiodevice.h:66
#define QT_END_HEADER
Definition: qglobal.h:137
static QString fileName(const QString &fileUrl)
static bool isNull(const QVariant::Private *d)
Definition: qvariant.cpp:300
CacheMode
This enum describes the different cache modes of QMovie.
Definition: qmovie.h:87