src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp
changeset 33 3e2da88830cd
parent 30 5dc02b23752f
child 37 758a864f9613
equal deleted inserted replaced
30:5dc02b23752f 33:3e2da88830cd
    61 /*!
    61 /*!
    62     \qmlclass AnimatedImage QDeclarativeAnimatedImage
    62     \qmlclass AnimatedImage QDeclarativeAnimatedImage
    63     \inherits Image
    63     \inherits Image
    64     \since 4.7
    64     \since 4.7
    65 
    65 
    66     This item provides for playing animations stored as images containing a series of frames,
    66     The AnimatedImage element provides for playing animations stored as images containing a series of frames,
    67     such as GIF files. The full list of supported formats can be determined with
    67     such as GIF files. 
    68     QMovie::supportedFormats().
    68     
       
    69     The full list of supported formats can be determined with QMovie::supportedFormats().
    69 
    70 
    70     \table
    71     \table
    71     \row
    72     \row
    72     \o \image animatedimageitem.gif
    73     \o \image animatedimageitem.gif
    73     \o
    74     \o
    74     \qml
    75     \qml
    75 Item {
    76     import Qt 4.7
    76     width: anim.width; height: anim.height+8
    77 
    77     AnimatedImage { id: anim; source: "pics/games-anim.gif" }
    78     Rectangle {
    78     Rectangle { color: "red"; width: 4; height: 8; y: anim.height
    79         width: animation.width; height: animation.height + 8
    79         x: (anim.width-width)*anim.currentFrame/(anim.frameCount-1)
    80 
    80     }
    81         AnimatedImage { id: animation; source: "animation.gif" }
    81 }
    82 
       
    83         Rectangle { 
       
    84             property int frames: animation.frameCount
       
    85 
       
    86             width: 4; height: 8
       
    87             x: (animation.width - width) * animation.currentFrame / frames
       
    88             y: animation.height
       
    89             color: "red"
       
    90         }
       
    91     }
    82     \endqml
    92     \endqml
    83     \endtable
    93     \endtable
    84 */
    94 */
    85 
    95 
    86 QDeclarativeAnimatedImage::QDeclarativeAnimatedImage(QDeclarativeItem *parent)
    96 QDeclarativeAnimatedImage::QDeclarativeAnimatedImage(QDeclarativeItem *parent)
    94     delete d->_movie;
   104     delete d->_movie;
    95 }
   105 }
    96 
   106 
    97 /*!
   107 /*!
    98   \qmlproperty bool AnimatedImage::paused
   108   \qmlproperty bool AnimatedImage::paused
    99   This property holds whether the animated image is paused or not
   109   This property holds whether the animated image is paused.
   100 
   110 
   101   Defaults to false, and can be set to true when you want to pause.
   111   Defaults to false, and can be set to true when you want to pause.
   102 */
   112 */
   103 bool QDeclarativeAnimatedImage::isPaused() const
   113 bool QDeclarativeAnimatedImage::isPaused() const
   104 {
   114 {
   118         return;
   128         return;
   119     d->_movie->setPaused(pause);
   129     d->_movie->setPaused(pause);
   120 }
   130 }
   121 /*!
   131 /*!
   122   \qmlproperty bool AnimatedImage::playing
   132   \qmlproperty bool AnimatedImage::playing
   123   This property holds whether the animated image is playing or not
   133   This property holds whether the animated image is playing.
   124 
   134 
   125   Defaults to true, so as to start playing immediately.
   135   Defaults to true, so as to start playing immediately.
   126 */
   136 */
   127 bool QDeclarativeAnimatedImage::isPlaying() const
   137 bool QDeclarativeAnimatedImage::isPlaying() const
   128 {
   138 {
   261     }
   271     }
   262     d->redirectCount=0;
   272     d->redirectCount=0;
   263 
   273 
   264     d->_movie = new QMovie(d->reply);
   274     d->_movie = new QMovie(d->reply);
   265     if (!d->_movie->isValid()){
   275     if (!d->_movie->isValid()){
       
   276 #ifndef QT_NO_DEBUG_STREAM
   266         qmlInfo(this) << "Error Reading Animated Image File " << d->url;
   277         qmlInfo(this) << "Error Reading Animated Image File " << d->url;
       
   278 #endif
   267         delete d->_movie;
   279         delete d->_movie;
   268         d->_movie = 0;
   280         d->_movie = 0;
   269         return;
   281         return;
   270     }
   282     }
   271     connect(d->_movie, SIGNAL(stateChanged(QMovie::MovieState)),
   283     connect(d->_movie, SIGNAL(stateChanged(QMovie::MovieState)),