From 97fd22b1be8370ae2bebfaa8054fd7636ad829f6 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Tue, 26 Nov 2013 16:04:21 -0200 Subject: Fixes the positioning of the ToolBar This is a workaround, I plan to remove that toolbar from inside of the Profile for the next version, but since it's there for now, let's keep it. This patch hides the toolbar when the zoomLevel != 0, since the profile is unclickable while zoomed... Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/profilegraphics.cpp | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'qt-ui/profilegraphics.cpp') diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp index 7bd00c73f..e55b2e52c 100644 --- a/qt-ui/profilegraphics.cpp +++ b/qt-ui/profilegraphics.cpp @@ -47,6 +47,10 @@ extern struct ev_select *ev_namelist; extern int evn_allocated; extern int evn_used; +#define TOOLBAR_POS \ +QPoint(viewport()->geometry().width() - toolBarProxy->boundingRect().width(), \ +viewport()->geometry().height() - toolBarProxy->boundingRect().height() ) + ProfileGraphicsView::ProfileGraphicsView(QWidget* parent) : QGraphicsView(parent), toolTip(0) , dive(0), diveDC(0), rulerItem(0), toolBarProxy(0) { printMode = false; @@ -110,8 +114,15 @@ void ProfileGraphicsView::wheelEvent(QWheelEvent* event) scale(1.0 / scaleFactor, 1.0 / scaleFactor); zoomLevel--; } + scrollViewTo(event->pos()); - toolTip->setPos(mapToScene(toolTipPos).x(), mapToScene(toolTipPos).y()); + toolTip->setPos(mapToScene(toolTipPos)); + toolBarProxy->setPos(mapToScene(TOOLBAR_POS)); + if(zoomLevel != 0){ + toolBarProxy->hide(); + }else{ + toolBarProxy->show(); + } } void ProfileGraphicsView::contextMenuEvent(QContextMenuEvent* event) @@ -233,12 +244,15 @@ void ProfileGraphicsView::mouseMoveEvent(QMouseEvent* event) toolTip->refresh(&gc, mapToScene(event->pos())); QPoint toolTipPos = mapFromScene(toolTip->pos()); + QPoint toolBarPos = mapFromScene(toolBarProxy->pos()); scrollViewTo(event->pos()); if (zoomLevel == 0) QGraphicsView::mouseMoveEvent(event); - else - toolTip->setPos(mapToScene(toolTipPos).x(), mapToScene(toolTipPos).y()); + else{ + toolTip->setPos(mapToScene(toolTipPos)); + toolBarProxy->setPos(mapToScene(TOOLBAR_POS)); + } } bool ProfileGraphicsView::eventFilter(QObject* obj, QEvent* event) @@ -284,6 +298,8 @@ void ProfileGraphicsView::showEvent(QShowEvent* event) dive = 0; plot(get_dive(selected_dive)); } + if (toolBarProxy) + toolBarProxy->setPos(mapToScene(TOOLBAR_POS)); } void ProfileGraphicsView::clear() @@ -516,7 +532,8 @@ void ProfileGraphicsView::addControlItems(struct dive *d) connect(editAction, SIGNAL(triggered()), mainWindow(), SLOT(editCurrentDive())); } toolBarProxy = scene()->addWidget(toolBar); - toolBarProxy->setPos(gc.maxx-toolBar->width(), gc.maxy-toolBar->height()); + toolBarProxy->setPos(mapToScene(TOOLBAR_POS)); + toolBarProxy->setFlag(QGraphicsItem::ItemIgnoresTransformations); } void ProfileGraphicsView::plot_pp_text() @@ -896,9 +913,9 @@ void ProfileGraphicsView::plot_events(struct divecomputer *dc) { struct event *event = dc->events; -// if (gc->printer) { -// return; -// } +// if (gc->printer) { +// return; +// } while (event) { plot_one_event(event); -- cgit v1.2.3-70-g09d2