From 2fd36a6320aed7c2f825c2c38f2ef6d0b2703e17 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Mon, 8 Feb 2010 15:28:35 +1000 Subject: clip if tile mode is 'PreserveAspectCrop' and 'clip' property is true. --- src/declarative/graphicsitems/qmlgraphicsimage.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/declarative/graphicsitems/qmlgraphicsimage.cpp b/src/declarative/graphicsitems/qmlgraphicsimage.cpp index a1e8c17..7e63c8b 100644 --- a/src/declarative/graphicsitems/qmlgraphicsimage.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsimage.cpp @@ -126,13 +126,13 @@ QML_DEFINE_TYPE(Qt,4,6,Image,QmlGraphicsImage) */ QmlGraphicsImage::QmlGraphicsImage(QmlGraphicsItem *parent) - : QmlGraphicsImageBase(*(new QmlGraphicsImagePrivate), parent) + : QmlGraphicsImageBase(*(new QmlGraphicsImagePrivate), parent) { connect(this, SIGNAL(sourceChanged(QUrl)), this, SLOT(updatePaintedGeometry())); } QmlGraphicsImage::QmlGraphicsImage(QmlGraphicsImagePrivate &dd, QmlGraphicsItem *parent) - : QmlGraphicsImageBase(dd, parent) + : QmlGraphicsImageBase(dd, parent) { } @@ -343,12 +343,18 @@ void QmlGraphicsImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWid scale.translate(0, (height() - heightScale * d->pix.height()) / 2); } } - + if (clip()) { + p->save(); + p->setClipRect(boundingRect(), Qt::IntersectClip); + } scale.scale(widthScale, heightScale); QTransform old = p->transform(); p->setWorldTransform(scale * old); p->drawPixmap(0, 0, d->pix); p->setWorldTransform(old); + if (clip()) { + p->restore(); + } } } else { p->drawPixmap(0, 0, d->pix); -- cgit v0.12