From 5691d2a48b09aaaea2391085fd1807ebc82bbbd9 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Mon, 12 Oct 2009 17:17:46 +0000 Subject: [PATCH] keep the mouseover state ourselves since it won't be updated when the widget is disabled svn path=/trunk/KDE/kdelibs/; revision=1034427 --- widgets/toolbutton.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/widgets/toolbutton.cpp b/widgets/toolbutton.cpp index d79f0a7db..0b6edb8ad 100644 --- a/widgets/toolbutton.cpp +++ b/widgets/toolbutton.cpp @@ -50,7 +50,8 @@ public: animId(0), fadeIn(false), svg(0), - customFont(false) + customFont(false), + underMouse(false) { } @@ -118,6 +119,7 @@ public: Svg *svg; QString svgElement; bool customFont; + bool underMouse; }; void ToolButtonPrivate::syncActiveRect() @@ -330,7 +332,7 @@ void ToolButton::paint(QPainter *painter, 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)) { d->background->setElementPrefix("pressed"); } else { @@ -374,6 +376,7 @@ void ToolButton::paint(QPainter *painter, void ToolButton::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { + d->underMouse = true; if (nativeWidget()->isDown() || !nativeWidget()->autoRaise()) { return; } @@ -394,6 +397,7 @@ void ToolButton::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void ToolButton::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { + d->underMouse = false; if (nativeWidget()->isDown() || !nativeWidget()->autoRaise()) { return; } @@ -418,6 +422,8 @@ void ToolButton::changeEvent(QEvent *event) { if (event->type() == QEvent::FontChange) { d->customFont = true; + } else if (event->type() == QEvent::EnabledChange && !isEnabled()) { + d->underMouse = false; } QGraphicsProxyWidget::changeEvent(event);