diff options
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/profilegraphics.cpp | 17 | ||||
-rw-r--r-- | qt-ui/profilegraphics.h | 2 |
2 files changed, 19 insertions, 0 deletions
diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp index cfd155132..164de13ff 100644 --- a/qt-ui/profilegraphics.cpp +++ b/qt-ui/profilegraphics.cpp @@ -179,6 +179,12 @@ void ProfileGraphicsView::mouseMoveEvent(QMouseEvent* event) bool ProfileGraphicsView::eventFilter(QObject* obj, QEvent* event) { + if (event->type() == QEvent::Leave) { + if (toolTip && toolTip->isExpanded()) + toolTip->collapse(); + return true; + } + // This will "Eat" the default tooltip behavior. if (event->type() == QEvent::GraphicsSceneHelp) { event->ignore(); @@ -1324,6 +1330,9 @@ void ToolTipItem::collapse() animation->setStartValue(boundingRect()); animation->setEndValue(QRect(0, 0, ICON_SMALL, ICON_SMALL)); animation->start(QAbstractAnimation::DeleteWhenStopped); + clear(); + + status = COLLAPSED; } void ToolTipItem::expand() @@ -1358,6 +1367,7 @@ void ToolTipItem::expand() animation->setEndValue(nextRectangle); animation->start(QAbstractAnimation::DeleteWhenStopped); + status = EXPANDED; } ToolTipItem::ToolTipItem(QGraphicsItem* parent): QGraphicsPathItem(parent), background(0) @@ -1368,6 +1378,8 @@ ToolTipItem::ToolTipItem(QGraphicsItem* parent): QGraphicsPathItem(parent), back setFlag(ItemIgnoresTransformations); setFlag(ItemIsMovable); + status = COLLAPSED; + updateTitlePosition(); setZValue(99); } @@ -1401,6 +1413,11 @@ void ToolTipItem::updateTitlePosition() } } +bool ToolTipItem::isExpanded() { + return status == EXPANDED; +} + + EventItem::EventItem(QGraphicsItem* parent): QGraphicsPolygonItem(parent) { setFlag(ItemIgnoresTransformations); diff --git a/qt-ui/profilegraphics.h b/qt-ui/profilegraphics.h index b440adf5d..9c1c5dbc1 100644 --- a/qt-ui/profilegraphics.h +++ b/qt-ui/profilegraphics.h @@ -32,6 +32,7 @@ public: void addToolTip(const QString& toolTip, const QIcon& icon = QIcon()); void removeToolTip(const QString& toolTip); void refresh(struct graphics_context* gc, QPointF pos); + bool isExpanded(); public Q_SLOTS: void setRect(const QRectF& rect); @@ -42,6 +43,7 @@ private: QGraphicsPathItem *background; QGraphicsLineItem *separator; QGraphicsSimpleTextItem *title; + Status status; QRectF rectangle; }; |