summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsborderimage.cpp7
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsimagebase.cpp21
-rw-r--r--src/declarative/util/qmlpixmapcache.cpp17
-rw-r--r--src/declarative/util/qmlpixmapcache_p.h2
4 files changed, 30 insertions, 17 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp b/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp
index d7627ac..6f953bc 100644
--- a/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp
@@ -176,12 +176,10 @@ void QmlGraphicsBorderImage::setSource(const QUrl &url)
if (url.isEmpty()) {
d->pix = QPixmap();
d->status = Null;
- d->progress = 1.0;
setImplicitWidth(0);
setImplicitHeight(0);
emit statusChanged(d->status);
emit sourceChanged(d->url);
- emit progressChanged(1.0);
update();
} else {
d->status = Loading;
@@ -219,7 +217,7 @@ void QmlGraphicsBorderImage::setSource(const QUrl &url)
d->progress = 1.0;
emit statusChanged(d->status);
emit sourceChanged(d->url);
- emit progressChanged(1.0);
+ emit progressChanged(d->progress);
update();
}
}
@@ -395,7 +393,8 @@ void QmlGraphicsBorderImage::paint(QPainter *p, const QStyleOptionGraphicsItem *
if (d->smooth)
p->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth);
- QMargins margins(border()->top(), border()->left(), border()->bottom(), border()->right());
+ const QmlGraphicsScaleGrid *border = d->getScaleGrid();
+ QMargins margins(border->top(), border->left(), border->bottom(), border->right());
QTileRules rules((Qt::TileRule)d->horizontalTileMode, (Qt::TileRule)d->verticalTileMode);
qDrawBorderPixmap(p, QRect(0, 0, (int)d->width, (int)d->height), margins, d->pix, d->pix.rect(), margins, rules);
if (d->smooth) {
diff --git a/src/declarative/graphicsitems/qmlgraphicsimagebase.cpp b/src/declarative/graphicsitems/qmlgraphicsimagebase.cpp
index 0b57540..3e86a7c 100644
--- a/src/declarative/graphicsitems/qmlgraphicsimagebase.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsimagebase.cpp
@@ -108,16 +108,15 @@ void QmlGraphicsImageBase::setSource(const QUrl &url)
if (url.isEmpty()) {
d->pix = QPixmap();
d->status = Null;
- d->progress = 1.0;
setImplicitWidth(0);
setImplicitHeight(0);
emit statusChanged(d->status);
emit sourceChanged(d->url);
- emit progressChanged(1.0);
update();
} else {
d->status = Loading;
- QNetworkReply *reply = QmlPixmapCache::get(qmlEngine(this), d->url, &d->pix);
+ bool ok = true;
+ QNetworkReply *reply = QmlPixmapCache::get(qmlEngine(this), d->url, &d->pix, &ok);
if (reply) {
d->pendingPixmapCache = true;
connect(reply, SIGNAL(finished()), this, SLOT(requestFinished()));
@@ -125,15 +124,19 @@ void QmlGraphicsImageBase::setSource(const QUrl &url)
this, SLOT(requestProgress(qint64,qint64)));
} else {
//### should be unified with requestFinished
- setImplicitWidth(d->pix.width());
- setImplicitHeight(d->pix.height());
-
- if (d->status == Loading)
- d->status = Ready;
+ if (ok) {
+ setImplicitWidth(d->pix.width());
+ setImplicitHeight(d->pix.height());
+
+ if (d->status == Loading)
+ d->status = Ready;
+ } else {
+ d->status = Error;
+ }
d->progress = 1.0;
emit statusChanged(d->status);
emit sourceChanged(d->url);
- emit progressChanged(1.0);
+ emit progressChanged(d->progress);
update();
}
}
diff --git a/src/declarative/util/qmlpixmapcache.cpp b/src/declarative/util/qmlpixmapcache.cpp
index ba7895a..b8a9bd7 100644
--- a/src/declarative/util/qmlpixmapcache.cpp
+++ b/src/declarative/util/qmlpixmapcache.cpp
@@ -213,23 +213,34 @@ bool QmlPixmapCache::find(const QUrl& url, QPixmap *pixmap)
The returned QNetworkReply will be deleted when all get() calls are
matched by a corresponding find() call.
+
+ If the \a ok parameter is passed and \a url is a local file,
+ its value will be set to false if the pixmap could not be loaded;
+ otherwise the pixmap was loaded and *ok will be true.
*/
-QNetworkReply *QmlPixmapCache::get(QmlEngine *engine, const QUrl& url, QPixmap *pixmap)
+QNetworkReply *QmlPixmapCache::get(QmlEngine *engine, const QUrl& url, QPixmap *pixmap, bool *ok)
{
#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
QString lf = toLocalFileOrQrc(url);
if (!lf.isEmpty()) {
QString key = url.toString();
if (!QPixmapCache::find(key,pixmap)) {
+ bool loaded = true;
QFile f(lf);
if (f.open(QIODevice::ReadOnly)) {
if (!readImage(&f, pixmap)) {
qWarning() << "Format error loading" << url;
*pixmap = QPixmap();
+ loaded = false;
}
- } else
+ } else {
+ qWarning() << "Cannot open" << url;
*pixmap = QPixmap();
- QPixmapCache::insert(key, *pixmap);
+ loaded = false;
+ }
+ if (loaded)
+ QPixmapCache::insert(key, *pixmap);
+ if (ok) *ok = loaded;
}
return 0;
}
diff --git a/src/declarative/util/qmlpixmapcache_p.h b/src/declarative/util/qmlpixmapcache_p.h
index e6ed452..d2e272c 100644
--- a/src/declarative/util/qmlpixmapcache_p.h
+++ b/src/declarative/util/qmlpixmapcache_p.h
@@ -56,7 +56,7 @@ class QNetworkReply;
class Q_DECLARATIVE_EXPORT QmlPixmapCache
{
public:
- static QNetworkReply *get(QmlEngine *, const QUrl& url, QPixmap *pixmap);
+ static QNetworkReply *get(QmlEngine *, const QUrl& url, QPixmap *pixmap, bool *ok=0);
static void cancelGet(const QUrl& url, QObject* obj);
static bool find(const QUrl& url, QPixmap *pixmap); // url must have been passed to QmlPixmapCache::get, and any returned reply finished.