- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qmovie.h

Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    00004 ** All rights reserved.
    00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
    00006 **
    00007 ** This file is part of the QtGui module of the Qt Toolkit.
    00008 **
    00009 ** $QT_BEGIN_LICENSE:LGPL$
    00010 ** Commercial Usage
    00011 ** Licensees holding valid Qt Commercial licenses may use this file in
    00012 ** accordance with the Qt Commercial License Agreement provided with the
    00013 ** Software or, alternatively, in accordance with the terms contained in
    00014 ** a written agreement between you and Nokia.
    00015 **
    00016 ** GNU Lesser General Public License Usage
    00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
    00018 ** General Public License version 2.1 as published by the Free Software
    00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
    00020 ** packaging of this file.  Please review the following information to
    00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00023 **
    00024 ** In addition, as a special exception, Nokia gives you certain additional
    00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
    00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
    00027 **
    00028 ** GNU General Public License Usage
    00029 ** Alternatively, this file may be used under the terms of the GNU
    00030 ** General Public License version 3.0 as published by the Free Software
    00031 ** Foundation and appearing in the file LICENSE.GPL included in the
    00032 ** packaging of this file.  Please review the following information to
    00033 ** ensure the GNU General Public License version 3.0 requirements will be
    00034 ** met: http://www.gnu.org/copyleft/gpl.html.
    00035 **
    00036 ** If you have questions regarding the use of this file, please contact
    00037 ** Nokia at qt-info@nokia.com.
    00038 ** $QT_END_LICENSE$
    00039 **
    00040 ****************************************************************************/
    00041
    00042 #ifndef QMOVIE_H
    00043 #define QMOVIE_H
    00044
    00045 #include <QtCore/qobject.h>
    00046
    00047 #ifndef QT_NO_MOVIE
    00048
    00049 #include <QtCore/qbytearray.h>
    00050 #include <QtCore/qlist.h>
    00051 #include <QtCore/qobject.h>
    00052 #include <QtGui/qimagereader.h>
    00053
    00054 #ifdef QT3_SUPPORT
    00055 #include <QtGui/qimage.h>
    00056 #include <QtGui/qpixmap.h>
    00057 #endif
    00058
    00059 QT_BEGIN_HEADER
    00060
    00061 QT_BEGIN_NAMESPACE
    00062
    00063 QT_MODULE(Gui)
    00064
    00065 class QByteArray;
    00066 class QColor;
    00067 class QIODevice;
    00068 class QImage;
    00069 class QPixmap;
    00070 class QRect;
    00071 class QSize;
    00072
    00073 class QMoviePrivate;
    00074 class Q_GUI_EXPORT QMovie : public QObject
    00075 {
    00076     Q_OBJECT
    00077     Q_DECLARE_PRIVATE(QMovie)
    00078     Q_ENUMS(MovieState CacheMode)
    00079     Q_PROPERTY(int speed READ speed WRITE setSpeed)
    00080     Q_PROPERTY(CacheMode cacheMode READ cacheMode WRITE setCacheMode)
    00081 public:
    00082     enum MovieState {
    00083         NotRunning,
    00084         Paused,
    00085         Running
    00086     };
    00087     enum CacheMode {
    00088         CacheNone,
    00089         CacheAll
    00090     };
    00091
    00092     QMovie(QObject *parent = 0);
    00093     explicit QMovie(QIODevice *device, const QByteArray &format = QByteArray(), QObject *parent = 0);
    00094     explicit QMovie(const QString &fileName, const QByteArray &format = QByteArray(), QObject *parent = 0);
    00095     ~QMovie();
    00096
    00097     static QList<QByteArray> supportedFormats();
    00098
    00099     void setDevice(QIODevice *device);
    00100     QIODevice *device() const;
    00101
    00102     void setFileName(const QString &fileName);
    00103     QString fileName() const;
    00104
    00105     void setFormat(const QByteArray &format);
    00106     QByteArray format() const;
    00107
    00108     void setBackgroundColor(const QColor &color);
    00109     QColor backgroundColor() const;
    00110
    00111     MovieState state() const;
    00112
    00113     QRect frameRect() const;
    00114     QImage currentImage() const;
    00115     QPixmap currentPixmap() const;
    00116
    00117     bool isValid() const;
    00118
    00119     bool jumpToFrame(int frameNumber);
    00120     int loopCount() const;
    00121     int frameCount() const;
    00122     int nextFrameDelay() const;
    00123     int currentFrameNumber() const;
    00124
    00125     int speed() const;
    00126
    00127     QSize scaledSize();
    00128     void setScaledSize(const QSize &size);
    00129
    00130     CacheMode cacheMode() const;
    00131     void setCacheMode(CacheMode mode);
    00132
    00133     CacheMode cacheMode(); // ### Qt 5: remove me
    00134
    00135 Q_SIGNALS:
    00136     void started();
    00137     void resized(const QSize &size);
    00138     void updated(const QRect &rect);
    00139     void stateChanged(QMovie::MovieState state);
    00140     void error(QImageReader::ImageReaderError error);
    00141     void finished();
    00142     void frameChanged(int frameNumber);
    00143
    00144 public Q_SLOTS:
    00145     void start();
    00146     bool jumpToNextFrame();
    00147     void setPaused(bool paused);
    00148     void stop();
    00149     void setSpeed(int percentSpeed);
    00150
    00151 private:
    00152     Q_DISABLE_COPY(QMovie)
    00153     Q_PRIVATE_SLOT(d_func(), void _q_loadNextFrame())
    00154
    00155 #ifdef QT3_SUPPORT
    00156 public:
    00157     inline QT3_SUPPORT bool isNull() const { return isValid(); }
    00158     inline QT3_SUPPORT int frameNumber() const { return currentFrameNumber(); }
    00159     inline QT3_SUPPORT bool running() const { return state() == Running; }
    00160     inline QT3_SUPPORT bool paused() const { return state() == Paused; }
    00161     inline QT3_SUPPORT bool finished() const { return state() == NotRunning; }
    00162     inline QT3_SUPPORT void restart() { stop(); start(); }
    00163     inline QT3_SUPPORT QImage frameImage() const { return currentImage(); }
    00164     inline QT3_SUPPORT QPixmap framePixmap() const { return currentPixmap(); }
    00165     inline QT3_SUPPORT void step() { jumpToNextFrame(); }
    00166     inline QT3_SUPPORT void pause() { setPaused(true); }
    00167     inline QT3_SUPPORT void unpause() { setPaused(false); }
    00168 #endif
    00169 };
    00170
    00171 QT_END_NAMESPACE
    00172
    00173 QT_END_HEADER
    00174
    00175 #endif // QT_NO_MOVIE
    00176
    00177 #endif // QMOVIE_H