diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2011-03-21 16:38:25 (GMT) |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2011-03-21 16:38:25 (GMT) |
commit | 123a3aacd6a40fb07a225ef4db34ff7f986363ce (patch) | |
tree | 69744fb08a3b0dd4e246b90d2e90d4f533ca768b /src/declarative/graphicsitems/qdeclarativeimage.cpp | |
parent | f92501a82f5bca1ccac07ed17850c84b281a1fb1 (diff) | |
parent | 12689cc05936d675c8a7065cf39b8334b83f95bb (diff) | |
download | Qt-123a3aacd6a40fb07a225ef4db34ff7f986363ce.zip Qt-123a3aacd6a40fb07a225ef4db34ff7f986363ce.tar.gz Qt-123a3aacd6a40fb07a225ef4db34ff7f986363ce.tar.bz2 |
Merge remote-tracking branch 'mainline/4.7' into 4.7
Conflicts:
dist/changes-4.7.4
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativeimage.cpp')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativeimage.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp index 2c9bde5..ed5d5fc 100644 --- a/src/declarative/graphicsitems/qdeclarativeimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp @@ -147,8 +147,8 @@ void QDeclarativeImagePrivate::setPixmap(const QPixmap &pixmap) /*! \qmlproperty enumeration Image::fillMode - Set this property to define what happens when the image set for the item is smaller - than the size of the item. + Set this property to define what happens when the source image has a different size + than the item. \list \o Image.Stretch - the image is scaled to fit @@ -234,6 +234,9 @@ void QDeclarativeImagePrivate::setPixmap(const QPixmap &pixmap) \endtable + Note that \c clip is \c false by default which means that the element might + paint outside its bounding rectangle even if the fillMode is set to \c PreserveAspectCrop. + \sa {declarative/imageelements/image}{Image example} */ QDeclarativeImage::FillMode QDeclarativeImage::fillMode() const @@ -386,14 +389,16 @@ void QDeclarativeImage::updatePaintedGeometry() if (d->fillMode == PreserveAspectFit) { if (!d->pix.width() || !d->pix.height()) return; - qreal widthScale = width() / qreal(d->pix.width()); - qreal heightScale = height() / qreal(d->pix.height()); + qreal w = widthValid() ? width() : d->pix.width(); + qreal widthScale = w / qreal(d->pix.width()); + qreal h = heightValid() ? height() : d->pix.height(); + qreal heightScale = h / qreal(d->pix.height()); if (widthScale <= heightScale) { - d->paintedWidth = width(); + d->paintedWidth = w; d->paintedHeight = widthScale * qreal(d->pix.height()); } else if(heightScale < widthScale) { d->paintedWidth = heightScale * qreal(d->pix.width()); - d->paintedHeight = height(); + d->paintedHeight = h; } if (widthValid() && !heightValid()) { setImplicitHeight(d->paintedHeight); |