mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Only drag the tooltip panel when not zooming.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
2052e44ba1
commit
ea5353025f
2 changed files with 14 additions and 5 deletions
|
@ -144,12 +144,13 @@ void ProfileGraphicsView::wheelEvent(QWheelEvent* event)
|
||||||
// Scale the view / do the zoom
|
// Scale the view / do the zoom
|
||||||
QPoint toolTipPos = mapFromScene(toolTip->pos());
|
QPoint toolTipPos = mapFromScene(toolTip->pos());
|
||||||
double scaleFactor = 1.15;
|
double scaleFactor = 1.15;
|
||||||
if(event->delta() > 0) {
|
if(event->delta() > 0 && zoomLevel <= 10) {
|
||||||
// Zoom in
|
|
||||||
scale(scaleFactor, scaleFactor);
|
scale(scaleFactor, scaleFactor);
|
||||||
} else {
|
zoomLevel++;
|
||||||
|
} else if (zoomLevel >= 0) {
|
||||||
// Zooming out
|
// Zooming out
|
||||||
scale(1.0 / scaleFactor, 1.0 / scaleFactor);
|
scale(1.0 / scaleFactor, 1.0 / scaleFactor);
|
||||||
|
zoomLevel--;
|
||||||
}
|
}
|
||||||
toolTip->setPos(mapToScene(toolTipPos).x(), mapToScene(toolTipPos).y());
|
toolTip->setPos(mapToScene(toolTipPos).x(), mapToScene(toolTipPos).y());
|
||||||
}
|
}
|
||||||
|
@ -162,8 +163,10 @@ void ProfileGraphicsView::mouseMoveEvent(QMouseEvent* event)
|
||||||
ensureVisible(event->pos().x(), event->pos().y(), 10, 10, 100, 100);
|
ensureVisible(event->pos().x(), event->pos().y(), 10, 10, 100, 100);
|
||||||
toolTip->setPos(mapToScene(toolTipPos).x(), mapToScene(toolTipPos).y());
|
toolTip->setPos(mapToScene(toolTipPos).x(), mapToScene(toolTipPos).y());
|
||||||
|
|
||||||
|
if (zoomLevel < 0){
|
||||||
QGraphicsView::mouseMoveEvent(event);
|
QGraphicsView::mouseMoveEvent(event);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool ProfileGraphicsView::eventFilter(QObject* obj, QEvent* event)
|
bool ProfileGraphicsView::eventFilter(QObject* obj, QEvent* event)
|
||||||
{
|
{
|
||||||
|
@ -192,7 +195,12 @@ void ProfileGraphicsView::plot(struct dive *d)
|
||||||
{
|
{
|
||||||
scene()->clear();
|
scene()->clear();
|
||||||
|
|
||||||
|
if (dive != d){
|
||||||
|
resetTransform();
|
||||||
|
zoomLevel = 0;
|
||||||
dive = d;
|
dive = d;
|
||||||
|
}
|
||||||
|
|
||||||
if(!dive)
|
if(!dive)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,7 @@ private:
|
||||||
ToolTipItem *toolTip;
|
ToolTipItem *toolTip;
|
||||||
graphics_context gc;
|
graphics_context gc;
|
||||||
struct dive *dive;
|
struct dive *dive;
|
||||||
|
int zoomLevel;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue