aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/items/qsgimage.cpp
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@nokia.com>2011-05-04 10:21:47 +0200
committerGunnar Sletta <gunnar.sletta@nokia.com>2011-05-04 10:21:47 +0200
commit16f58282bc5a1f81f7346ac6560df68761ad277d (patch)
tree38cc24d17ea4d868ee3cffd8ca99e96ac08e76dd /src/declarative/items/qsgimage.cpp
parent280242a5a14a99cc10857e35da61ac5b894d5f6b (diff)
parent1b7c1b6ef86d3d56ff01b2eab118062a229b0d19 (diff)
Merge branch 'qtquick2' of scm.dev.nokia.troll.no:qt/qtdeclarative-staging into qtquick2
Diffstat (limited to 'src/declarative/items/qsgimage.cpp')
-rw-r--r--src/declarative/items/qsgimage.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/declarative/items/qsgimage.cpp b/src/declarative/items/qsgimage.cpp
index d24db9f670..10670f4015 100644
--- a/src/declarative/items/qsgimage.cpp
+++ b/src/declarative/items/qsgimage.cpp
@@ -1,4 +1,4 @@
-// Commit: 695a39410c8ce186a2ce78cef51093c55fc32643
+// Commit: 051a76c1d65d698f71dc75c89f91ae9021357eae
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
@@ -77,12 +77,10 @@ void QSGImagePrivate::setPixmap(const QPixmap &pixmap)
Q_Q(QSGImage);
pix.setPixmap(pixmap);
- q->setImplicitWidth(pix.width());
- q->setImplicitHeight(pix.height());
+ q->pixmapChange();
status = pix.isNull() ? QSGImageBase::Null : QSGImageBase::Ready;
q->update();
- q->pixmapChange();
}
QSGImage::FillMode QSGImage::fillMode() const
@@ -119,8 +117,11 @@ void QSGImage::updatePaintedGeometry()
Q_D(QSGImage);
if (d->fillMode == PreserveAspectFit) {
- if (!d->pix.width() || !d->pix.height())
+ if (!d->pix.width() || !d->pix.height()) {
+ setImplicitWidth(0);
+ setImplicitHeight(0);
return;
+ }
qreal w = widthValid() ? width() : d->pix.width();
qreal widthScale = w / qreal(d->pix.width());
qreal h = heightValid() ? height() : d->pix.height();
@@ -134,9 +135,13 @@ void QSGImage::updatePaintedGeometry()
}
if (widthValid() && !heightValid()) {
setImplicitHeight(d->paintedHeight);
+ } else {
+ setImplicitHeight(d->pix.height());
}
if (heightValid() && !widthValid()) {
setImplicitWidth(d->paintedWidth);
+ } else {
+ setImplicitWidth(d->pix.width());
}
} else if (d->fillMode == PreserveAspectCrop) {
if (!d->pix.width() || !d->pix.height())
@@ -280,7 +285,12 @@ QSGNode *QSGImage::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
void QSGImage::pixmapChange()
{
Q_D(QSGImage);
-
+ // PreserveAspectFit calculates the implicit size differently so we
+ // don't call our superclass pixmapChange(), since that would
+ // result in the implicit size being set incorrectly, then updated
+ // in updatePaintedGeometry()
+ if (d->fillMode != PreserveAspectFit)
+ QSGImageBase::pixmapChange();
updatePaintedGeometry();
d->pixmapChanged = true;
}