IconWidget background looked freaking old, now uses the svg backgrond from
the folderview icons (and as a bonus it's even less code :D) svn path=/trunk/KDE/kdelibs/; revision=913758
This commit is contained in:
parent
7bd898f55e
commit
e2e814e9bf
@ -314,6 +314,10 @@ void IconWidgetPrivate::init()
|
||||
|
||||
setActiveMargins();
|
||||
currentSize = QSizeF(-1, -1);
|
||||
|
||||
background = new Plasma::FrameSvg(q);
|
||||
background->setImagePath("widgets/viewitem");
|
||||
background->setCacheAllRenderedFrames(true);
|
||||
}
|
||||
|
||||
void IconWidget::addIconAction(QAction *action)
|
||||
@ -565,44 +569,24 @@ void IconWidgetPrivate::drawBackground(QPainter *painter, IconWidgetState state)
|
||||
return;
|
||||
}
|
||||
|
||||
bool darkShadow = shadowColor.value() < 128;
|
||||
QColor shadow = shadowColor;
|
||||
QColor border = textColor;
|
||||
|
||||
switch (state) {
|
||||
case IconWidgetPrivate::HoverState:
|
||||
shadow.setHsv(
|
||||
shadow.hue(),
|
||||
shadow.saturation(),
|
||||
shadow.value() + (int)(darkShadow ? 50 * hoverAlpha: -50 * hoverAlpha),
|
||||
200 + (int)hoverAlpha * 55); // opacity
|
||||
break;
|
||||
case IconWidgetPrivate::PressedState:
|
||||
shadow.setHsv(
|
||||
shadow.hue(),
|
||||
shadow.saturation(),
|
||||
shadow.value() + (darkShadow ?
|
||||
(int)(50 * hoverAlpha) : (int)(-50 * hoverAlpha)),
|
||||
204); //80% opacity
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
if (state == IconWidgetPrivate::PressedState) {
|
||||
background->setElementPrefix("selected");
|
||||
} else {
|
||||
background->setElementPrefix("hover");
|
||||
}
|
||||
|
||||
border.setAlphaF(0.3 * hoverAlpha);
|
||||
shadow.setAlphaF(0.6 * hoverAlpha);
|
||||
|
||||
painter->save();
|
||||
painter->translate(0.5, 0.5);
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
painter->setBrush(shadow);
|
||||
painter->setPen(QPen(border, 1));
|
||||
painter->drawPath(
|
||||
PaintUtils::roundedRectangle(
|
||||
QRectF(QPointF(1, 1), QSize((int)currentSize.width() - 2,
|
||||
(int)currentSize.height() - 2)),
|
||||
5.0));
|
||||
painter->restore();
|
||||
if (qFuzzyCompare(hoverAlpha, 1)) {
|
||||
background->resizeFrame(currentSize);
|
||||
background->paintFrame(painter);
|
||||
} else if (!qFuzzyCompare(hoverAlpha+1, 1)) {
|
||||
background->resizeFrame(currentSize);
|
||||
QPixmap frame = background->framePixmap();
|
||||
QPainter bufferPainter(&frame);
|
||||
bufferPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
|
||||
bufferPainter.fillRect(frame.rect(), QColor(0,0,0, 255*hoverAlpha));
|
||||
bufferPainter.end();
|
||||
painter->drawPixmap(QPoint(0,0), frame);
|
||||
}
|
||||
}
|
||||
|
||||
QPixmap IconWidgetPrivate::decoration(const QStyleOptionGraphicsItem *option, bool useHoverEffect)
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <QtGui/QTextOption>
|
||||
|
||||
#include <plasma/plasma_export.h>
|
||||
#include <plasma/framesvg.h>
|
||||
#include <plasma/svg.h>
|
||||
|
||||
#include "iconwidget.h"
|
||||
@ -188,6 +189,7 @@ public:
|
||||
QString text;
|
||||
QString infoText;
|
||||
Svg *iconSvg;
|
||||
FrameSvg *background;
|
||||
QString iconSvgElement;
|
||||
bool iconSvgElementChanged;
|
||||
QPixmap iconSvgPixmap;
|
||||
|
Loading…
x
Reference in New Issue
Block a user