Make the iconwidget's a teeny bit smaller when pressed down. This gives a good response when clicking buttons in plasma.

svn path=/trunk/KDE/kdelibs/; revision=946711
This commit is contained in:
Harald Hvaal 2009-03-30 06:42:19 +00:00
parent 183d79adb2
commit 570242531f
2 changed files with 7 additions and 3 deletions

View File

@ -618,7 +618,7 @@ void IconWidgetPrivate::drawBackground(QPainter *painter, IconWidgetState state)
}
}
QPixmap IconWidgetPrivate::decoration(const QStyleOptionGraphicsItem *option, bool useHoverEffect)
QPixmap IconWidgetPrivate::decoration(const QStyleOptionGraphicsItem *option, bool useHoverEffect, bool usePressedEffect)
{
QPixmap result;
@ -643,6 +643,10 @@ QPixmap IconWidgetPrivate::decoration(const QStyleOptionGraphicsItem *option, bo
result = icon.pixmap(size, mode, state);
}
if (usePressedEffect) {
result = result.scaled(result.size() * 0.9, Qt::KeepAspectRatio);
}
// We disable the iconeffect here since we cannot get it into sync with
// the fade animation. TODO: Enable it when animations are switched off
if (!result.isNull() && useHoverEffect) {
@ -934,7 +938,7 @@ void IconWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
state = IconWidgetPrivate::HoverState;
}
QPixmap icon = d->decoration(option, state != IconWidgetPrivate::NoState);
QPixmap icon = d->decoration(option, state != IconWidgetPrivate::NoState, state & IconWidgetPrivate::PressedState);
const QPointF iconPos = d->iconPosition(option, icon);
d->drawBackground(painter, state);

View File

@ -114,7 +114,7 @@ public:
void drawTextItems(QPainter *painter, const QStyleOptionGraphicsItem *option,
const QTextLayout &labelLayout, const QTextLayout &infoLayout) const;
QPixmap decoration(const QStyleOptionGraphicsItem *option, bool useHoverEffect);
QPixmap decoration(const QStyleOptionGraphicsItem *option, bool useHoverEffect, bool usePressedEffect);
QPointF iconPosition(const QStyleOptionGraphicsItem *option, const QPixmap &pixmap) const;
QSizeF displaySizeHint(const QStyleOptionGraphicsItem *option, const qreal width) const;