diff options
Diffstat (limited to 'src/declarative/fx/qfxrect.cpp')
-rw-r--r-- | src/declarative/fx/qfxrect.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp index 0722d26..29321b8 100644 --- a/src/declarative/fx/qfxrect.cpp +++ b/src/declarative/fx/qfxrect.cpp @@ -475,10 +475,17 @@ void QFxRect::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) { Q_D(QFxRect); if (d->radius > 0 || (d->pen && d->pen->isValid()) - || (d->gradient && d->gradient->gradient()) ) + || (d->gradient && d->gradient->gradient()) ) { drawRect(*p); - else + } + else { + bool oldAA = p->testRenderHint(QPainter::Antialiasing); + if (d->smooth) + p->setRenderHints(QPainter::Antialiasing, true); p->fillRect(QRect(0, 0, width(), height()), d->getColor()); + if (d->smooth) + p->setRenderHint(QPainter::Antialiasing, oldAA); + } } void QFxRect::drawRect(QPainter &p) @@ -488,7 +495,8 @@ void QFxRect::drawRect(QPainter &p) // XXX This path is still slower than the image path // Image path won't work for gradients though bool oldAA = p.testRenderHint(QPainter::Antialiasing); - p.setRenderHint(QPainter::Antialiasing); + if (d->smooth) + p.setRenderHint(QPainter::Antialiasing); if (d->pen && d->pen->isValid()) { QPen pn(QColor(d->pen->color()), d->pen->width()); p.setPen(pn); @@ -500,8 +508,14 @@ void QFxRect::drawRect(QPainter &p) p.drawRoundedRect(0, 0, width(), height(), d->radius, d->radius); else p.drawRect(0, 0, width(), height()); - p.setRenderHint(QPainter::Antialiasing, oldAA); + if (d->smooth) + p.setRenderHint(QPainter::Antialiasing, oldAA); } else { + bool oldAA = p.testRenderHint(QPainter::Antialiasing); + bool oldSmooth = p.testRenderHint(QPainter::SmoothPixmapTransform); + if (d->smooth) + p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth); + int offset = 0; const int pw = d->pen && d->pen->isValid() ? (d->pen->width()+1)/2*2 : 0; @@ -569,6 +583,11 @@ void QFxRect::drawRect(QPainter &p) // Lower Right p.drawPixmap(QPoint(width()-xOffset+pw/2, height() - yOffset+pw/2), d->rectImage, QRect(d->rectImage.width()-xOffset, d->rectImage.height() - yOffset, xOffset, yOffset)); + + if (d->smooth) { + p.setRenderHint(QPainter::Antialiasing, oldAA); + p.setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth); + } } } |