diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2013-11-26 16:04:21 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-11-26 11:25:50 -0800 |
commit | 97fd22b1be8370ae2bebfaa8054fd7636ad829f6 (patch) | |
tree | 44119a587545a6de55ec23fe842704d761537135 /qt-ui/profilegraphics.cpp | |
parent | e175b1d1ab76ee8edcd3beb1c027a58a336af96e (diff) | |
download | subsurface-97fd22b1be8370ae2bebfaa8054fd7636ad829f6.tar.gz |
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 <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profilegraphics.cpp')
-rw-r--r-- | qt-ui/profilegraphics.cpp | 31 |
1 files changed, 24 insertions, 7 deletions
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); |