mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-03 15:43:09 +00:00
Hide/Show tooltip on mouse over view widget
Proper hide/show tooltip under ProfileGraphicsView. Events are not properly handled and no custom tolltip status was stored. Text are properly hidden now when tooltip is collapsed. Reported-by: Tomaz Canabrava Signed-off-by: Helio Chissini de Castro <helio@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
3677f4e5ea
commit
ef873b4082
2 changed files with 19 additions and 0 deletions
|
@ -179,6 +179,12 @@ void ProfileGraphicsView::mouseMoveEvent(QMouseEvent* event)
|
||||||
|
|
||||||
bool ProfileGraphicsView::eventFilter(QObject* obj, QEvent* 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.
|
// This will "Eat" the default tooltip behavior.
|
||||||
if (event->type() == QEvent::GraphicsSceneHelp) {
|
if (event->type() == QEvent::GraphicsSceneHelp) {
|
||||||
event->ignore();
|
event->ignore();
|
||||||
|
@ -1324,6 +1330,9 @@ void ToolTipItem::collapse()
|
||||||
animation->setStartValue(boundingRect());
|
animation->setStartValue(boundingRect());
|
||||||
animation->setEndValue(QRect(0, 0, ICON_SMALL, ICON_SMALL));
|
animation->setEndValue(QRect(0, 0, ICON_SMALL, ICON_SMALL));
|
||||||
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
||||||
|
clear();
|
||||||
|
|
||||||
|
status = COLLAPSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolTipItem::expand()
|
void ToolTipItem::expand()
|
||||||
|
@ -1358,6 +1367,7 @@ void ToolTipItem::expand()
|
||||||
animation->setEndValue(nextRectangle);
|
animation->setEndValue(nextRectangle);
|
||||||
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
||||||
|
|
||||||
|
status = EXPANDED;
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolTipItem::ToolTipItem(QGraphicsItem* parent): QGraphicsPathItem(parent), background(0)
|
ToolTipItem::ToolTipItem(QGraphicsItem* parent): QGraphicsPathItem(parent), background(0)
|
||||||
|
@ -1368,6 +1378,8 @@ ToolTipItem::ToolTipItem(QGraphicsItem* parent): QGraphicsPathItem(parent), back
|
||||||
setFlag(ItemIgnoresTransformations);
|
setFlag(ItemIgnoresTransformations);
|
||||||
setFlag(ItemIsMovable);
|
setFlag(ItemIsMovable);
|
||||||
|
|
||||||
|
status = COLLAPSED;
|
||||||
|
|
||||||
updateTitlePosition();
|
updateTitlePosition();
|
||||||
setZValue(99);
|
setZValue(99);
|
||||||
}
|
}
|
||||||
|
@ -1401,6 +1413,11 @@ void ToolTipItem::updateTitlePosition()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ToolTipItem::isExpanded() {
|
||||||
|
return status == EXPANDED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
EventItem::EventItem(QGraphicsItem* parent): QGraphicsPolygonItem(parent)
|
EventItem::EventItem(QGraphicsItem* parent): QGraphicsPolygonItem(parent)
|
||||||
{
|
{
|
||||||
setFlag(ItemIgnoresTransformations);
|
setFlag(ItemIgnoresTransformations);
|
||||||
|
|
|
@ -32,6 +32,7 @@ public:
|
||||||
void addToolTip(const QString& toolTip, const QIcon& icon = QIcon());
|
void addToolTip(const QString& toolTip, const QIcon& icon = QIcon());
|
||||||
void removeToolTip(const QString& toolTip);
|
void removeToolTip(const QString& toolTip);
|
||||||
void refresh(struct graphics_context* gc, QPointF pos);
|
void refresh(struct graphics_context* gc, QPointF pos);
|
||||||
|
bool isExpanded();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void setRect(const QRectF& rect);
|
void setRect(const QRectF& rect);
|
||||||
|
@ -42,6 +43,7 @@ private:
|
||||||
QGraphicsPathItem *background;
|
QGraphicsPathItem *background;
|
||||||
QGraphicsLineItem *separator;
|
QGraphicsLineItem *separator;
|
||||||
QGraphicsSimpleTextItem *title;
|
QGraphicsSimpleTextItem *title;
|
||||||
|
Status status;
|
||||||
|
|
||||||
QRectF rectangle;
|
QRectF rectangle;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue