diff --git a/desktoptoolbox.cpp b/desktoptoolbox.cpp index 1eef36e98..192892f38 100644 --- a/desktoptoolbox.cpp +++ b/desktoptoolbox.cpp @@ -115,15 +115,20 @@ QPainterPath DesktopToolbox::shape() const void DesktopToolbox::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { + if (m_showing) { + QGraphicsItem::hoverEnterEvent(event); + return; + } + int maxwidth = 0; foreach (QGraphicsItem* tool, QGraphicsItem::children()) { if (!tool->isEnabled()) { continue; } - maxwidth = qMax(static_cast(tool->boundingRect().width()), - maxwidth); + maxwidth = qMax(static_cast(tool->boundingRect().width()), maxwidth); } - // put tools 5px from screen edge + + // put tools 5px from icon edge const int iconWidth = 32; int x = m_size*2 - maxwidth - iconWidth - 5; int y = 5; // pos().y(); @@ -140,6 +145,9 @@ void DesktopToolbox::hoverEnterEvent(QGraphicsSceneHoverEvent *event) y += static_cast(tool->boundingRect().height()) + 5; } + //NOTE: this will not work if the item is rotated, but this way we don't need use a QRegion + m_toolsRect = QRect(mapToScene(QPoint(x, 5)).toPoint(), QSize(maxwidth, y - 10)).adjusted(1, 1, -1, -1); + if (m_animId) { phase->stopCustomAnimation(m_animId); } @@ -153,6 +161,12 @@ void DesktopToolbox::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void DesktopToolbox::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { + //kDebug() << m_toolsRect << event->pos() << event->scenePos() << m_toolsRect.contains(event->scenePos().toPoint()); + if (!m_toolsRect.isNull() && m_toolsRect.contains(event->scenePos().toPoint())) { + QGraphicsItem::hoverLeaveEvent(event); + return; + } + int x = m_size*2; int y = 0; Plasma::Phase* phase = Plasma::Phase::self(); @@ -167,6 +181,7 @@ void DesktopToolbox::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) m_showing = false; m_animId = phase->customAnimation(10, 150, Plasma::Phase::EaseOutCurve, this, "animate"); + m_toolsRect = QRect(); QGraphicsItem::hoverLeaveEvent(event); } diff --git a/desktoptoolbox_p.h b/desktoptoolbox_p.h index e40c5a599..b37e007c8 100644 --- a/desktoptoolbox_p.h +++ b/desktoptoolbox_p.h @@ -57,7 +57,8 @@ protected slots: private: KIcon m_icon; - int m_size; + const int m_size; + QRect m_toolsRect; bool m_hidden; bool m_showing; Plasma::Phase::AnimId m_animId;