summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-11-03 05:31:07 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-11-03 05:32:28 (GMT)
commitc8be1c487994fda855b9f2dc7c005db4686981c0 (patch)
tree2629236ce0cbfdc94ac454a14368f0a46bca42d7 /src/declarative
parent43c15688888b433d6d3c01c0d68168fec81cf06a (diff)
downloadQt-c8be1c487994fda855b9f2dc7c005db4686981c0.zip
Qt-c8be1c487994fda855b9f2dc7c005db4686981c0.tar.gz
Qt-c8be1c487994fda855b9f2dc7c005db4686981c0.tar.bz2
Get AnimatedImage + autotests working again.
There are still failures, but at least the tests no longer crash.
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/extra/qmlgraphicsanimatedimageitem.cpp48
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsimage.cpp14
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsimage_p_p.h2
3 files changed, 54 insertions, 10 deletions
diff --git a/src/declarative/extra/qmlgraphicsanimatedimageitem.cpp b/src/declarative/extra/qmlgraphicsanimatedimageitem.cpp
index 5dbffc0..f3c2058 100644
--- a/src/declarative/extra/qmlgraphicsanimatedimageitem.cpp
+++ b/src/declarative/extra/qmlgraphicsanimatedimageitem.cpp
@@ -40,7 +40,6 @@
****************************************************************************/
#include <QMovie>
-#include <QtDeclarative/qmlcontext.h>
#include <QtDeclarative/qmlengine.h>
#include "qmlgraphicsanimatedimageitem_p.h"
#include "qmlgraphicsanimatedimageitem_p_p.h"
@@ -179,6 +178,14 @@ int QmlGraphicsAnimatedImageItem::frameCount() const
return d->_movie->frameCount();
}
+static QString toLocalFileOrQrc(const QUrl& url)
+{
+ QString r = url.toLocalFile();
+ if (r.isEmpty() && url.scheme() == QLatin1String("qrc"))
+ r = QLatin1Char(':') + url.path();
+ return r;
+}
+
void QmlGraphicsAnimatedImageItem::setSource(const QUrl &url)
{
Q_D(QmlGraphicsAnimatedImageItem);
@@ -193,15 +200,46 @@ void QmlGraphicsAnimatedImageItem::setSource(const QUrl &url)
d->reply = 0;
}
- d->url = qmlContext(this)->resolvedUrl(url);
+ d->url = url;
if (url.isEmpty()) {
delete d->_movie;
d->status = Null;
} else {
+#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
+ QString lf = toLocalFileOrQrc(url);
+ if (!lf.isEmpty()) {
+ //### should be unified with movieRequestFinished
+ d->_movie = new QMovie(lf);
+ if (!d->_movie->isValid()){
+ qWarning() << "Error Reading Animated Image File " << d->url;
+ delete d->_movie;
+ d->_movie = 0;
+ return;
+ }
+ connect(d->_movie, SIGNAL(stateChanged(QMovie::MovieState)),
+ this, SLOT(playingStatusChanged()));
+ connect(d->_movie, SIGNAL(frameChanged(int)),
+ this, SLOT(movieUpdate()));
+ d->_movie->setCacheMode(QMovie::CacheAll);
+ if(d->playing)
+ d->_movie->start();
+ else
+ d->_movie->jumpToFrame(0);
+ if(d->paused)
+ d->_movie->setPaused(true);
+ d->setPixmap(d->_movie->currentPixmap());
+ d->status = Ready;
+ d->progress = 1.0;
+ emit statusChanged(d->status);
+ emit sourceChanged(d->url);
+ emit progressChanged(d->progress);
+ return;
+ }
+#endif
d->status = Loading;
QNetworkRequest req(d->url);
- d->reply = qmlContext(this)->engine()->networkAccessManager()->get(req);
+ d->reply = qmlEngine(this)->networkAccessManager()->get(req);
QObject::connect(d->reply, SIGNAL(finished()),
this, SLOT(movieRequestFinished()));
}
@@ -230,13 +268,13 @@ void QmlGraphicsAnimatedImageItem::movieRequestFinished()
d->_movie->jumpToFrame(0);
if(d->paused)
d->_movie->setPaused(true);
- setPixmap(d->_movie->currentPixmap());
+ d->setPixmap(d->_movie->currentPixmap());
}
void QmlGraphicsAnimatedImageItem::movieUpdate()
{
Q_D(QmlGraphicsAnimatedImageItem);
- setPixmap(d->_movie->currentPixmap());
+ d->setPixmap(d->_movie->currentPixmap());
emit frameChanged();
}
diff --git a/src/declarative/graphicsitems/qmlgraphicsimage.cpp b/src/declarative/graphicsitems/qmlgraphicsimage.cpp
index fd220a3..938fe2a 100644
--- a/src/declarative/graphicsitems/qmlgraphicsimage.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsimage.cpp
@@ -152,12 +152,18 @@ void QmlGraphicsImage::setPixmap(const QPixmap &pix)
Q_D(QmlGraphicsImage);
if (!d->url.isEmpty())
return;
- d->pix = pix;
+ d->setPixmap(pix);
+}
+
+void QmlGraphicsImagePrivate::setPixmap(const QPixmap &pixmap)
+{
+ Q_Q(QmlGraphicsImage);
+ pix = pixmap;
- setImplicitWidth(d->pix.width());
- setImplicitHeight(d->pix.height());
+ q->setImplicitWidth(pix.width());
+ q->setImplicitHeight(pix.height());
- update();
+ q->update();
}
/*!
diff --git a/src/declarative/graphicsitems/qmlgraphicsimage_p_p.h b/src/declarative/graphicsitems/qmlgraphicsimage_p_p.h
index 62a4d1e..f6b4e51 100644
--- a/src/declarative/graphicsitems/qmlgraphicsimage_p_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsimage_p_p.h
@@ -69,7 +69,7 @@ public:
}
QmlGraphicsImage::FillMode fillMode;
-
+ void setPixmap(const QPixmap &pix);
};
QT_END_NAMESPACE