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
This commit is contained in:
Marco Martin 2008-07-03 17:04:56 +00:00
parent 6d5bd4b176
commit 4c7e3d1d0b

View File

@ -50,7 +50,8 @@
#include <KDebug> #include <KDebug>
#include <KColorScheme> #include <KColorScheme>
#include <plasma/theme.h> #include <Plasma/Theme>
#include <Plasma/ImageEffects>
#include "animator.h" #include "animator.h"
#include "svg.h" #include "svg.h"
@ -573,8 +574,8 @@ void IconPrivate::drawBackground(QPainter *painter, IconState state)
break; break;
} }
border.setAlphaF(.2); border.setAlphaF(0.3*m_hoverAlpha);
shadow.setAlphaF(.6); shadow.setAlphaF(0.6*m_hoverAlpha);
painter->save(); painter->save();
painter->translate(0.5, 0.5); painter->translate(0.5, 0.5);
@ -924,6 +925,16 @@ void Icon::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid
QTextLayout labelLayout, infoLayout; QTextLayout labelLayout, infoLayout;
QRectF textBoundingRect; QRectF textBoundingRect;
d->layoutTextItems(option, icon, &labelLayout, &infoLayout, &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); d->drawTextItems(painter, option, labelLayout, infoLayout);
} }