diff options
author | Yann Bodson <yann.bodson@nokia.com> | 2010-08-25 05:31:00 (GMT) |
---|---|---|
committer | Yann Bodson <yann.bodson@nokia.com> | 2010-08-25 05:31:00 (GMT) |
commit | b4bf4f754ba65da3ea751dd5508d29244a4b4db2 (patch) | |
tree | 8e60970e0510da8bef0f8129fbaa210075555ce3 /src/declarative/graphicsitems | |
parent | 675188b766b7b0f7eb65c2e9f3ee7d6017e63453 (diff) | |
download | Qt-b4bf4f754ba65da3ea751dd5508d29244a4b4db2.zip Qt-b4bf4f754ba65da3ea751dd5508d29244a4b4db2.tar.gz Qt-b4bf4f754ba65da3ea751dd5508d29244a4b4db2.tar.bz2 |
Setting one dimension of the sourceSize should set the other dimension.
The implicit width and height should also be set to the sourceSize.
Task-number: 13002
Diffstat (limited to 'src/declarative/graphicsitems')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativeimagebase.cpp | 48 |
1 files changed, 17 insertions, 31 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp index ba40443..d6b935b 100644 --- a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp @@ -147,10 +147,15 @@ void QDeclarativeImageBase::load() setImplicitWidth(0); setImplicitHeight(0); emit statusChanged(d->status); + d->sourcesize.setWidth(0); + d->sourcesize.setHeight(0); + emit sourceSizeChanged(); pixmapChange(); update(); } else { + d->status = Loading; + emit statusChanged(d->status); d->pix.load(qmlEngine(this), d->url, d->sourcesize, d->async); @@ -169,53 +174,34 @@ void QDeclarativeImageBase::load() d->pix.connectDownloadProgress(this, thisRequestProgress); } else { - QSize impsize = d->pix.implicitSize(); - setImplicitWidth(impsize.width()); - setImplicitHeight(impsize.height()); - - if (d->pix.isReady()) { - d->status = Ready; - - if (!d->sourcesize.isValid()) - emit sourceSizeChanged(); - - } else { - d->status = Error; - qmlInfo(this) << d->pix.error(); - } - d->progress = 1.0; - emit statusChanged(d->status); - emit progressChanged(d->progress); - pixmapChange(); - update(); + requestFinished(); } - } - - emit statusChanged(d->status); } void QDeclarativeImageBase::requestFinished() { Q_D(QDeclarativeImageBase); - QSize impsize = d->pix.implicitSize(); - if (d->pix.isError()) { d->status = Error; qmlInfo(this) << d->pix.error(); + } else { + d->status = Ready; } + emit statusChanged(d->status); - setImplicitWidth(impsize.width()); - setImplicitHeight(impsize.height()); + setImplicitWidth(d->pix.width()); + setImplicitHeight(d->pix.height()); - if (d->status == Loading) - d->status = Ready; d->progress = 1.0; - emit statusChanged(d->status); - emit progressChanged(1.0); - if (!d->sourcesize.isValid()) + emit progressChanged(d->progress); + + if (d->sourcesize.width() != d->pix.width() || d->sourcesize.height() != d->pix.height()) { + d->sourcesize.setWidth(d->pix.width()); + d->sourcesize.setHeight(d->pix.height()); emit sourceSizeChanged(); + } pixmapChange(); update(); } |