From 4c7e3d1d0bdbcd6eb10f9f2bf1416a61ae00d03c Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 3 Jul 2008 17:04:56 +0000 Subject: [PATCH] drop shadow behind the icon text, so now the icon background is gone and appears only on mouse over svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=827715 --- widgets/icon.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/widgets/icon.cpp b/widgets/icon.cpp index a9b7ec9ce..4ae71a0f1 100644 --- a/widgets/icon.cpp +++ b/widgets/icon.cpp @@ -50,7 +50,8 @@ #include #include -#include +#include +#include #include "animator.h" #include "svg.h" @@ -572,9 +573,9 @@ void IconPrivate::drawBackground(QPainter *painter, IconState state) default: break; } - - border.setAlphaF(.2); - shadow.setAlphaF(.6); + + border.setAlphaF(0.3*m_hoverAlpha); + shadow.setAlphaF(0.6*m_hoverAlpha); painter->save(); painter->translate(0.5, 0.5); @@ -924,6 +925,16 @@ void Icon::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid QTextLayout labelLayout, infoLayout; QRectF textBoundingRect; d->layoutTextItems(option, icon, &labelLayout, &infoLayout, &textBoundingRect); + + QImage shadow(textBoundingRect.size().toSize()+QSize(6,6), QImage::Format_ARGB32_Premultiplied); + shadow.fill(Qt::transparent); + { + QPainter buffPainter(&shadow); + buffPainter.translate(-textBoundingRect.x(), -textBoundingRect.y()); + d->drawTextItems(&buffPainter, option, labelLayout, infoLayout); + } + Plasma::ImageEffects::shadowBlur(shadow, 3, d->shadowColor); + painter->drawImage(textBoundingRect.topLeft()+QPoint(2,2), shadow); d->drawTextItems(painter, option, labelLayout, infoLayout); }