allow setting the background of icon on/off ... a little sad about this, but no time to do something else atm
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=756868
This commit is contained in:
parent
ac040130bf
commit
f07d73ff53
@ -61,7 +61,8 @@ Icon::Private::Private()
|
||||
iconSize(48, 48),
|
||||
states(Private::NoState),
|
||||
orientation(Qt::Vertical),
|
||||
invertLayout(false)
|
||||
invertLayout(false),
|
||||
drawBg(false)
|
||||
{
|
||||
textColor = KColorScheme(QPalette::Active, KColorScheme::Window,
|
||||
Plasma::Theme::self()->colors()).foreground().color();
|
||||
@ -345,6 +346,19 @@ QSizeF Icon::sizeHint() const
|
||||
return d->currentSize;
|
||||
}
|
||||
|
||||
void Icon::setDrawBackground(bool draw)
|
||||
{
|
||||
if (d->drawBg != draw) {
|
||||
d->drawBg = draw;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
bool Icon::drawBackground() const
|
||||
{
|
||||
return d->drawBg;
|
||||
}
|
||||
|
||||
QSizeF Icon::Private::displaySizeHint(const QStyleOptionGraphicsItem *option, const qreal width) const
|
||||
{
|
||||
if (text.isEmpty() && infoText.isEmpty()) {
|
||||
@ -487,12 +501,16 @@ void Icon::setSvg(const QString &svgFilePath, const QString &elementId)
|
||||
|
||||
void Icon::Private::drawBackground(QPainter *painter, IconState state)
|
||||
{
|
||||
bool darkShadow = shadowColor.value() < 128;
|
||||
QColor shadow = shadowColor;
|
||||
if (!drawBg) {
|
||||
return;
|
||||
}
|
||||
|
||||
shadow.setAlphaF(.35);
|
||||
bool darkShadow = shadowColor.value() < 128;
|
||||
QColor shadow = shadowColor;
|
||||
|
||||
switch (state) {
|
||||
shadow.setAlphaF(.35);
|
||||
|
||||
switch (state) {
|
||||
case Private::HoverState:
|
||||
shadow.setHsv(shadow.hue(),
|
||||
shadow.saturation(),
|
||||
@ -780,6 +798,8 @@ QBrush Icon::Private::backgroundBrush(const QStyleOptionGraphicsItem *option) co
|
||||
void Icon::Private::drawTextItems(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
const QTextLayout &labelLayout, const QTextLayout &infoLayout) const
|
||||
{
|
||||
Q_UNUSED(option)
|
||||
|
||||
painter->setPen(textColor);
|
||||
labelLayout.draw(painter, QPointF());
|
||||
|
||||
|
@ -184,6 +184,17 @@ public:
|
||||
*/
|
||||
QSizeF sizeHint() const;
|
||||
|
||||
/**
|
||||
* Sets whether or not to draw a background area for the icon
|
||||
*
|
||||
* @arg draw true if a background should be drawn or not
|
||||
*/
|
||||
void setDrawBackground(bool draw);
|
||||
|
||||
/**
|
||||
* @return true if a background area is to be drawn for the icon
|
||||
*/
|
||||
bool drawBackground() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
/**
|
||||
|
@ -173,6 +173,7 @@ public:
|
||||
Qt::Orientation orientation;
|
||||
int numDisplayLines;
|
||||
bool invertLayout;
|
||||
bool drawBg;
|
||||
QSizeF currentSize;
|
||||
|
||||
QList<IconAction*> cornerActions;
|
||||
|
Loading…
Reference in New Issue
Block a user