keep the mouseover state ourselves since it won't be updated when the

widget is disabled

svn path=/trunk/KDE/kdelibs/; revision=1034427
This commit is contained in:
Marco Martin 2009-10-12 17:17:46 +00:00
parent 0d1e72248e
commit 5691d2a48b

View File

@ -50,7 +50,8 @@ public:
animId(0), animId(0),
fadeIn(false), fadeIn(false),
svg(0), svg(0),
customFont(false) customFont(false),
underMouse(false)
{ {
} }
@ -118,6 +119,7 @@ public:
Svg *svg; Svg *svg;
QString svgElement; QString svgElement;
bool customFont; bool customFont;
bool underMouse;
}; };
void ToolButtonPrivate::syncActiveRect() void ToolButtonPrivate::syncActiveRect()
@ -330,7 +332,7 @@ void ToolButton::paint(QPainter *painter,
buttonOpt.toolButtonStyle = button->toolButtonStyle(); buttonOpt.toolButtonStyle = button->toolButtonStyle();
if (button->isEnabled() && (d->animId || !button->autoRaise() || (buttonOpt.state & QStyle::State_MouseOver) || (buttonOpt.state & QStyle::State_On))) { if (button->isEnabled() && (d->animId || !button->autoRaise() || d->underMouse || (buttonOpt.state & QStyle::State_On))) {
if (button->isDown() || (buttonOpt.state & QStyle::State_On)) { if (button->isDown() || (buttonOpt.state & QStyle::State_On)) {
d->background->setElementPrefix("pressed"); d->background->setElementPrefix("pressed");
} else { } else {
@ -374,6 +376,7 @@ void ToolButton::paint(QPainter *painter,
void ToolButton::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void ToolButton::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{ {
d->underMouse = true;
if (nativeWidget()->isDown() || !nativeWidget()->autoRaise()) { if (nativeWidget()->isDown() || !nativeWidget()->autoRaise()) {
return; return;
} }
@ -394,6 +397,7 @@ void ToolButton::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
void ToolButton::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) void ToolButton::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{ {
d->underMouse = false;
if (nativeWidget()->isDown() || !nativeWidget()->autoRaise()) { if (nativeWidget()->isDown() || !nativeWidget()->autoRaise()) {
return; return;
} }
@ -418,6 +422,8 @@ void ToolButton::changeEvent(QEvent *event)
{ {
if (event->type() == QEvent::FontChange) { if (event->type() == QEvent::FontChange) {
d->customFont = true; d->customFont = true;
} else if (event->type() == QEvent::EnabledChange && !isEnabled()) {
d->underMouse = false;
} }
QGraphicsProxyWidget::changeEvent(event); QGraphicsProxyWidget::changeEvent(event);