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();
|
setActiveMargins();
|
||||||
currentSize = QSizeF(-1, -1);
|
currentSize = QSizeF(-1, -1);
|
||||||
|
|
||||||
|
background = new Plasma::FrameSvg(q);
|
||||||
|
background->setImagePath("widgets/viewitem");
|
||||||
|
background->setCacheAllRenderedFrames(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IconWidget::addIconAction(QAction *action)
|
void IconWidget::addIconAction(QAction *action)
|
||||||
@ -565,44 +569,24 @@ void IconWidgetPrivate::drawBackground(QPainter *painter, IconWidgetState state)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool darkShadow = shadowColor.value() < 128;
|
if (state == IconWidgetPrivate::PressedState) {
|
||||||
QColor shadow = shadowColor;
|
background->setElementPrefix("selected");
|
||||||
QColor border = textColor;
|
} else {
|
||||||
|
background->setElementPrefix("hover");
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
border.setAlphaF(0.3 * hoverAlpha);
|
if (qFuzzyCompare(hoverAlpha, 1)) {
|
||||||
shadow.setAlphaF(0.6 * hoverAlpha);
|
background->resizeFrame(currentSize);
|
||||||
|
background->paintFrame(painter);
|
||||||
painter->save();
|
} else if (!qFuzzyCompare(hoverAlpha+1, 1)) {
|
||||||
painter->translate(0.5, 0.5);
|
background->resizeFrame(currentSize);
|
||||||
painter->setRenderHint(QPainter::Antialiasing);
|
QPixmap frame = background->framePixmap();
|
||||||
painter->setBrush(shadow);
|
QPainter bufferPainter(&frame);
|
||||||
painter->setPen(QPen(border, 1));
|
bufferPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
|
||||||
painter->drawPath(
|
bufferPainter.fillRect(frame.rect(), QColor(0,0,0, 255*hoverAlpha));
|
||||||
PaintUtils::roundedRectangle(
|
bufferPainter.end();
|
||||||
QRectF(QPointF(1, 1), QSize((int)currentSize.width() - 2,
|
painter->drawPixmap(QPoint(0,0), frame);
|
||||||
(int)currentSize.height() - 2)),
|
}
|
||||||
5.0));
|
|
||||||
painter->restore();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap IconWidgetPrivate::decoration(const QStyleOptionGraphicsItem *option, bool useHoverEffect)
|
QPixmap IconWidgetPrivate::decoration(const QStyleOptionGraphicsItem *option, bool useHoverEffect)
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include <QtGui/QTextOption>
|
#include <QtGui/QTextOption>
|
||||||
|
|
||||||
#include <plasma/plasma_export.h>
|
#include <plasma/plasma_export.h>
|
||||||
|
#include <plasma/framesvg.h>
|
||||||
#include <plasma/svg.h>
|
#include <plasma/svg.h>
|
||||||
|
|
||||||
#include "iconwidget.h"
|
#include "iconwidget.h"
|
||||||
@ -188,6 +189,7 @@ public:
|
|||||||
QString text;
|
QString text;
|
||||||
QString infoText;
|
QString infoText;
|
||||||
Svg *iconSvg;
|
Svg *iconSvg;
|
||||||
|
FrameSvg *background;
|
||||||
QString iconSvgElement;
|
QString iconSvgElement;
|
||||||
bool iconSvgElementChanged;
|
bool iconSvgElementChanged;
|
||||||
QPixmap iconSvgPixmap;
|
QPixmap iconSvgPixmap;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user