From 14fed09f70d4924e8584532b7f881e6b7609d161 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Sun, 27 Sep 2009 17:32:49 +0000 Subject: [PATCH] give a really light gradient to the text background, it gives a more finished look svn path=/trunk/KDE/kdelibs/; revision=1028591 --- widgets/iconwidget.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/widgets/iconwidget.cpp b/widgets/iconwidget.cpp index aaffccf39..60ad45569 100644 --- a/widgets/iconwidget.cpp +++ b/widgets/iconwidget.cpp @@ -1037,14 +1037,21 @@ void IconWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option if (d->textBgColor != QColor() && !(d->text.isEmpty() && d->infoText.isEmpty()) && - !textBoundingRect.isEmpty()) { - QRectF rect = textBoundingRect.adjusted(-2, -2, 4, 4); + !textBoundingRect.isEmpty() && + !qFuzzyCompare(d->hoverAlpha, (qreal)1.0)) { + QRectF rect = textBoundingRect.adjusted(-2, -2, 4, 4).toAlignedRect(); painter->setPen(Qt::transparent); QColor color = d->textBgColor; color.setAlpha(60 * (1.0 - d->hoverAlpha)); - painter->setBrush(color); + QLinearGradient gradient(rect.topLeft(), rect.bottomLeft()); + gradient.setColorAt(0, color.lighter(120)); + gradient.setColorAt(1, color.darker(120)); + painter->setBrush(gradient); + gradient.setColorAt(0, color.lighter(130)); + gradient.setColorAt(1, color.darker(130)); + painter->setPen(QPen(gradient, 0)); painter->setRenderHint(QPainter::Antialiasing); - painter->drawPath(PaintUtils::roundedRectangle(rect, 4)); + painter->drawPath(PaintUtils::roundedRectangle(rect.translated(0.5, 0.5), 4)); } PaintUtils::shadowBlur(shadow, 2, d->shadowColor);