mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 13:10:19 +00:00
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>
This commit is contained in:
parent
e175b1d1ab
commit
97fd22b1be
1 changed files with 24 additions and 7 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue