summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demos/declarative/samegame/content/SpinBlock.qml2
-rw-r--r--demos/declarative/samegame/content/samegame.js2
-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
5 files changed, 52 insertions, 6 deletions
diff --git a/demos/declarative/samegame/content/SpinBlock.qml b/demos/declarative/samegame/content/SpinBlock.qml
index 42276d0..2597bfb 100644
--- a/demos/declarative/samegame/content/SpinBlock.qml
+++ b/demos/declarative/samegame/content/SpinBlock.qml
@@ -15,7 +15,7 @@ Item { id:block
} else {
"pics/gnome/greenStone.gif";
}
- playing: selected
+ paused: !selected
}
opacity: 0
y: targetY
diff --git a/demos/declarative/samegame/content/samegame.js b/demos/declarative/samegame/content/samegame.js
index 1814031..3592edc 100644
--- a/demos/declarative/samegame/content/samegame.js
+++ b/demos/declarative/samegame/content/samegame.js
@@ -49,7 +49,7 @@ function initBoard()
var fillFound;
var floodBoard;
-var lastHoveredIdx = -1
+var lastHoveredIdx = -2
function handleHover(x,y, btn)
{
xIdx = Math.floor(x/tileSize);
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;
};