diff options
author | Damian Jansen <damian.jansen@nokia.com> | 2012-07-11 17:01:09 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-13 13:17:12 +0200 |
commit | 2ec0df06aa61d23a1a7ad5bdf87c772f376259b7 (patch) | |
tree | a472ba74488c8ebc7ee301736f884a447d6d3a03 /src/quick/items/qquickimagebase.cpp | |
parent | 04fc2234562507a071e214635e6fe7dc63eda95b (diff) |
Fix signal emission for the Image based items when loading.
StatusChanged signals are now always emitted.
Other properties only emit when altered.
AnimatedImage local and remote loading was also unified in this fix.
BorderImage duplicated loading code is streamlined.
Task-number: QTBUG-26405
Change-Id: Ib412d5879e0007229a8098e1fa960003051508de
Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
Diffstat (limited to 'src/quick/items/qquickimagebase.cpp')
-rw-r--r-- | src/quick/items/qquickimagebase.cpp | 57 |
1 files changed, 33 insertions, 24 deletions
diff --git a/src/quick/items/qquickimagebase.cpp b/src/quick/items/qquickimagebase.cpp index 798050d776..e42b0ee2e2 100644 --- a/src/quick/items/qquickimagebase.cpp +++ b/src/quick/items/qquickimagebase.cpp @@ -187,27 +187,37 @@ void QQuickImageBase::load() if (d->url.isEmpty()) { d->pix.clear(this); - d->status = Null; - d->progress = 0.0; + if (d->progress != 0.0) { + d->progress = 0.0; + emit progressChanged(d->progress); + } pixmapChange(); - emit progressChanged(d->progress); + d->status = Null; emit statusChanged(d->status); + + if (sourceSize() != d->oldSourceSize) { + d->oldSourceSize = sourceSize(); + emit sourceSizeChanged(); + } update(); + } else { QQuickPixmap::Options options; if (d->async) options |= QQuickPixmap::Asynchronous; if (d->cache) options |= QQuickPixmap::Cache; - d->pix.clear(this); - pixmapChange(); d->pix.load(qmlEngine(this), d->url, d->sourcesize, options); if (d->pix.isLoading()) { - d->progress = 0.0; - d->status = Loading; - emit progressChanged(d->progress); - emit statusChanged(d->status); + if (d->progress != 0.0) { + d->progress = 0.0; + emit progressChanged(d->progress); + } + if (d->status != Loading) { + d->status = Loading; + emit statusChanged(d->status); + } static int thisRequestProgress = -1; static int thisRequestFinished = -1; @@ -231,28 +241,27 @@ void QQuickImageBase::requestFinished() { Q_D(QQuickImageBase); - QQuickImageBase::Status oldStatus = d->status; - qreal oldProgress = d->progress; - if (d->pix.isError()) { - d->status = Error; qmlInfo(this) << d->pix.error(); + d->pix.clear(this); + d->status = Error; + if (d->progress != 0.0) { + d->progress = 0.0; + emit progressChanged(d->progress); + } } else { d->status = Ready; + if (d->progress != 1.0) { + d->progress = 1.0; + emit progressChanged(d->progress); + } } - - d->progress = 1.0; - pixmapChange(); - - if (d->sourcesize.width() != d->pix.width() || d->sourcesize.height() != d->pix.height()) + emit statusChanged(d->status); + if (sourceSize() != d->oldSourceSize) { + d->oldSourceSize = sourceSize(); emit sourceSizeChanged(); - - if (d->status != oldStatus) - emit statusChanged(d->status); - if (d->progress != oldProgress) - emit progressChanged(d->progress); - + } update(); } |