Make tooltips work in the profile toolbar

This patch enables tooltips on the profile toolbar. Tooltips were
being treated as text to be shown at notification area. Now it is
verified if the cursor was positioned over the toolbar when it
activated the event. If so, tooltip is shown normally.

Fixes #238

Signed-off-by: exhora <exhora.tat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Taiane Ramos 2013-11-14 23:54:35 -02:00 committed by Dirk Hohndel
parent 711f2ddf8c
commit 7e859da939

View file

@ -137,10 +137,12 @@ bool ProfileGraphicsView::eventFilter(QObject* obj, QEvent* event)
return true; return true;
} }
// This will "Eat" the default tooltip behavior. // This will "Eat" the default tooltip behavior if it is not on the toolBar.
if (event->type() == QEvent::GraphicsSceneHelp) { if (event->type() == QEvent::GraphicsSceneHelp) {
event->ignore(); if(!toolBarProxy->geometry().contains(mapFromGlobal(QCursor::pos()))){
return true; event->ignore();
return true;
}
} }
return QGraphicsView::eventFilter(obj, event); return QGraphicsView::eventFilter(obj, event);
} }
@ -383,6 +385,8 @@ void ProfileGraphicsView::addControlItems(struct dive *d)
QAction *scaleAction = new QAction(QIcon(":scale"), tr("Scale"), this); QAction *scaleAction = new QAction(QIcon(":scale"), tr("Scale"), this);
QAction *rulerAction = new QAction(QIcon(":ruler"), tr("Ruler"), this); QAction *rulerAction = new QAction(QIcon(":ruler"), tr("Ruler"), this);
QToolBar *toolBar = new QToolBar("", 0); QToolBar *toolBar = new QToolBar("", 0);
rulerAction->setToolTip(tr("Show a ruler to nit pecking your dive"));
scaleAction->setToolTip(tr("Scale your dive to screen size"));
toolBar->addAction(rulerAction); toolBar->addAction(rulerAction);
toolBar->addAction(scaleAction); toolBar->addAction(scaleAction);
toolBar->setOrientation(Qt::Vertical); toolBar->setOrientation(Qt::Vertical);