summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-05-10 11:45:07 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-05-10 08:16:00 -0700
commitea5353025f58aaaf31d7cf9d1ca92c93d9357c16 (patch)
tree76bc512c2be41670d0346f4c4aacb3ca33cda35e /qt-ui
parent2052e44ba19b4bc9689792bbff2170fc3426d42a (diff)
downloadsubsurface-ea5353025f58aaaf31d7cf9d1ca92c93d9357c16.tar.gz
Only drag the tooltip panel when not zooming.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/profilegraphics.cpp18
-rw-r--r--qt-ui/profilegraphics.h1
2 files changed, 14 insertions, 5 deletions
diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp
index 9441f3ae3..aeeccc875 100644
--- a/qt-ui/profilegraphics.cpp
+++ b/qt-ui/profilegraphics.cpp
@@ -144,12 +144,13 @@ void ProfileGraphicsView::wheelEvent(QWheelEvent* event)
// Scale the view / do the zoom
QPoint toolTipPos = mapFromScene(toolTip->pos());
double scaleFactor = 1.15;
- if(event->delta() > 0) {
- // Zoom in
+ if(event->delta() > 0 && zoomLevel <= 10) {
scale(scaleFactor, scaleFactor);
- } else {
+ zoomLevel++;
+ } else if (zoomLevel >= 0) {
// Zooming out
scale(1.0 / scaleFactor, 1.0 / scaleFactor);
+ zoomLevel--;
}
toolTip->setPos(mapToScene(toolTipPos).x(), mapToScene(toolTipPos).y());
}
@@ -162,7 +163,9 @@ void ProfileGraphicsView::mouseMoveEvent(QMouseEvent* event)
ensureVisible(event->pos().x(), event->pos().y(), 10, 10, 100, 100);
toolTip->setPos(mapToScene(toolTipPos).x(), mapToScene(toolTipPos).y());
- QGraphicsView::mouseMoveEvent(event);
+ if (zoomLevel < 0){
+ QGraphicsView::mouseMoveEvent(event);
+ }
}
bool ProfileGraphicsView::eventFilter(QObject* obj, QEvent* event)
@@ -192,7 +195,12 @@ void ProfileGraphicsView::plot(struct dive *d)
{
scene()->clear();
- dive = d;
+ if (dive != d){
+ resetTransform();
+ zoomLevel = 0;
+ dive = d;
+ }
+
if(!dive)
return;
diff --git a/qt-ui/profilegraphics.h b/qt-ui/profilegraphics.h
index b9b57db08..288c9230a 100644
--- a/qt-ui/profilegraphics.h
+++ b/qt-ui/profilegraphics.h
@@ -96,6 +96,7 @@ private:
ToolTipItem *toolTip;
graphics_context gc;
struct dive *dive;
+ int zoomLevel;
};
#endif