diff options
author | Bea Lam <bea.lam@nokia.com> | 2010-03-03 23:46:59 (GMT) |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2010-03-03 23:46:59 (GMT) |
commit | 340d7982be8929be065981a0dcb30efd4dffc50f (patch) | |
tree | 05483bed8ca9768cac0a564f72e9a3952e6c120d | |
parent | e8916f0b69abad1de5767ac6ca1a555f40e3f675 (diff) | |
parent | 8fdd8a85a48f778de0295ff0b409860f85b7af20 (diff) | |
download | Qt-340d7982be8929be065981a0dcb30efd4dffc50f.zip Qt-340d7982be8929be065981a0dcb30efd4dffc50f.tar.gz Qt-340d7982be8929be065981a0dcb30efd4dffc50f.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativerectangle.cpp | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativerectangle.cpp b/src/declarative/graphicsitems/qdeclarativerectangle.cpp index d534f21..05fe0f7 100644 --- a/src/declarative/graphicsitems/qdeclarativerectangle.cpp +++ b/src/declarative/graphicsitems/qdeclarativerectangle.cpp @@ -393,9 +393,10 @@ void QDeclarativeRectangle::paint(QPainter *p, const QStyleOptionGraphicsItem *, void QDeclarativeRectangle::drawRect(QPainter &p) { Q_D(QDeclarativeRectangle); - if (d->gradient && d->gradient->gradient()) { + if ((d->gradient && d->gradient->gradient()) + || d->radius > width()/2 || d->radius > height()/2) { // XXX This path is still slower than the image path - // Image path won't work for gradients though + // Image path won't work for gradients or invalid radius though bool oldAA = p.testRenderHint(QPainter::Antialiasing); if (d->smooth) p.setRenderHint(QPainter::Antialiasing); @@ -405,11 +406,23 @@ void QDeclarativeRectangle::drawRect(QPainter &p) } else { p.setPen(Qt::NoPen); } - p.setBrush(*d->gradient->gradient()); - if (d->radius > 0.) - p.drawRoundedRect(0, 0, width(), height(), d->radius, d->radius); + if (d->gradient && d->gradient->gradient()) + p.setBrush(*d->gradient->gradient()); else - p.drawRect(0, 0, width(), height()); + p.setBrush(d->color); + const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0; + QRectF rect; + if (pw%2) + rect = QRectF(0.5, 0.5, width()-1, height()-1); + else + rect = QRectF(0, 0, width(), height()); + qreal radius = d->radius; + if (radius > width()/2 || radius > height()/2) + radius = qMin(width()/2, height()/2); + if (radius > 0.) + p.drawRoundedRect(rect, radius, radius); + else + p.drawRect(rect); if (d->smooth) p.setRenderHint(QPainter::Antialiasing, oldAA); } else { |