summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/declarative/extra/qfxanimatedimageitem.cpp45
-rw-r--r--src/declarative/extra/qfxanimatedimageitem.h6
-rw-r--r--src/declarative/extra/qfxanimatedimageitem_p.h3
3 files changed, 50 insertions, 4 deletions
diff --git a/src/declarative/extra/qfxanimatedimageitem.cpp b/src/declarative/extra/qfxanimatedimageitem.cpp
index 5516a00..4c74f6f 100644
--- a/src/declarative/extra/qfxanimatedimageitem.cpp
+++ b/src/declarative/extra/qfxanimatedimageitem.cpp
@@ -96,6 +96,30 @@ QFxAnimatedImageItem::~QFxAnimatedImageItem()
}
/*!
+ \qmlproperty bool AnimatedImage::paused
+ This property holds whether the animated image is paused or not
+
+ Defaults to false, and can be set to true when you want to pause.
+*/
+bool QFxAnimatedImageItem::isPaused() const
+{
+ Q_D(const QFxAnimatedImageItem);
+ if(!d->_movie)
+ return false;
+ return d->_movie->state()==QMovie::Paused;
+}
+
+void QFxAnimatedImageItem::setPaused(bool pause)
+{
+ Q_D(QFxAnimatedImageItem);
+ if(pause == d->paused)
+ return;
+ d->paused = pause;
+ if(!d->_movie)
+ return;
+ d->_movie->setPaused(pause);
+}
+/*!
\qmlproperty bool AnimatedImage::playing
This property holds whether the animated image is playing or not
@@ -106,7 +130,7 @@ bool QFxAnimatedImageItem::isPlaying() const
Q_D(const QFxAnimatedImageItem);
if (!d->_movie)
return false;
- return d->_movie->state()==QMovie::Running;
+ return d->_movie->state()!=QMovie::NotRunning;
}
void QFxAnimatedImageItem::setPlaying(bool play)
@@ -120,7 +144,7 @@ void QFxAnimatedImageItem::setPlaying(bool play)
if (play)
d->_movie->start();
else
- d->_movie->setPaused(true);
+ d->_movie->stop();
}
/*!
@@ -197,7 +221,7 @@ void QFxAnimatedImageItem::movieRequestFinished()
return;
}
connect(d->_movie, SIGNAL(stateChanged(QMovie::MovieState)),
- this, SIGNAL(playingChanged()));
+ this, SLOT(playingStatusChanged()));
connect(d->_movie, SIGNAL(frameChanged(int)),
this, SLOT(movieUpdate()));
d->_movie->setCacheMode(QMovie::CacheAll);
@@ -205,6 +229,8 @@ void QFxAnimatedImageItem::movieRequestFinished()
d->_movie->start();
else
d->_movie->jumpToFrame(0);
+ if(d->paused)
+ d->_movie->setPaused(true);
setPixmap(d->_movie->currentPixmap());
}
@@ -215,4 +241,17 @@ void QFxAnimatedImageItem::movieUpdate()
emit frameChanged();
}
+void QFxAnimatedImageItem::playingStatusChanged()
+{
+ Q_D(QFxAnimatedImageItem);
+ if((d->_movie->state() != QMovie::NotRunning) != d->playing){
+ d->playing = (d->_movie->state() != QMovie::NotRunning);
+ emit playingChanged();
+ }
+ if((d->_movie->state() == QMovie::Paused) != d->paused){
+ d->playing = (d->_movie->state() == QMovie::Paused);
+ emit pausedChanged();
+ }
+}
+
QT_END_NAMESPACE
diff --git a/src/declarative/extra/qfxanimatedimageitem.h b/src/declarative/extra/qfxanimatedimageitem.h
index 720d187..2d531ee 100644
--- a/src/declarative/extra/qfxanimatedimageitem.h
+++ b/src/declarative/extra/qfxanimatedimageitem.h
@@ -58,6 +58,7 @@ class Q_DECLARATIVE_EXPORT QFxAnimatedImageItem : public QFxImage
Q_OBJECT
Q_PROPERTY(bool playing READ isPlaying WRITE setPlaying NOTIFY playingChanged)
+ Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
Q_PROPERTY(int currentFrame READ currentFrame WRITE setCurrentFrame NOTIFY frameChanged)
Q_PROPERTY(int frameCount READ frameCount)
public:
@@ -67,6 +68,9 @@ public:
bool isPlaying() const;
void setPlaying(bool play);
+ bool isPaused() const;
+ void setPaused(bool pause);
+
int currentFrame() const;
void setCurrentFrame(int frame);
@@ -77,11 +81,13 @@ public:
Q_SIGNALS:
void playingChanged();
+ void pausedChanged();
void frameChanged();
private Q_SLOTS:
void movieUpdate();
void movieRequestFinished();
+ void playingStatusChanged();
protected:
QFxAnimatedImageItem(QFxAnimatedImageItemPrivate &dd, QFxItem *parent);
diff --git a/src/declarative/extra/qfxanimatedimageitem_p.h b/src/declarative/extra/qfxanimatedimageitem_p.h
index d743ba4..859f869 100644
--- a/src/declarative/extra/qfxanimatedimageitem_p.h
+++ b/src/declarative/extra/qfxanimatedimageitem_p.h
@@ -65,11 +65,12 @@ class QFxAnimatedImageItemPrivate : public QFxImagePrivate
public:
QFxAnimatedImageItemPrivate()
- : playing(true), _movie(0)
+ : playing(true), paused(false), _movie(0)
{
}
bool playing;
+ bool paused;
QMovie *_movie;
};