summaryrefslogtreecommitdiffstats
path: root/qt-ui/globe.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-10-17 14:53:12 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-10-17 15:00:22 -0700
commit8f623c2c72dfcae6b9fa49339e40b946c8877ae6 (patch)
treef879f1cddd43bdbee47ec47d1a1ea84b4b6bad81 /qt-ui/globe.cpp
parent579d1cb91503ff3b51e94869a0234eaf2796f435 (diff)
downloadsubsurface-8f623c2c72dfcae6b9fa49339e40b946c8877ae6.tar.gz
Fix marble losting track of zoom level
Marble had a bug on the way it treats zoom level, there's no way for it to find out if it's user-input or algorithm input and when a user clicks on a dive, it spins and centers on it, but if the user clicks on another dive when it's still spinning, it will get the zoom in the actual state ( spinning, usually zoom is far away from the first position ) and continue the spin to the other position. This patch works by saving the first location and triggering a helper function with a timer that will only update the zoom level if the timer is not active ( and thus, will not get the bugged zoom state set by the animation. ). Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/globe.cpp')
-rw-r--r--qt-ui/globe.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/qt-ui/globe.cpp b/qt-ui/globe.cpp
index 966edda17..c2ae56536 100644
--- a/qt-ui/globe.cpp
+++ b/qt-ui/globe.cpp
@@ -7,6 +7,7 @@
#include "../helpers.h"
#include <QDebug>
+#include <QTimer>
#include <marble/AbstractFloatItem.h>
#include <marble/GeoDataPlacemark.h>
@@ -63,6 +64,9 @@ GlobeGPS::GlobeGPS(QWidget* parent) : MarbleWidget(parent), loadedDives(0)
setMinimumHeight(0);
setMinimumWidth(0);
editingDiveCoords = 0;
+ fixZoomTimer = new QTimer();
+ connect(fixZoomTimer, SIGNAL(timeout()), this, SLOT(fixZoom()));
+ fixZoomTimer->setSingleShot(true);
}
void GlobeGPS::mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit unit)
@@ -178,9 +182,21 @@ void GlobeGPS::centerOn(dive* dive)
if (!zoom())
zoomView(zoomFromDistance(3));
+ if (!fixZoomTimer->isActive())
+ currentZoomLevel = zoom();
+ // From the marble source code, the maximum time of
+ // 'spin and fit' is 2 seconds, so wait a bit them zoom again.
+ fixZoomTimer->start(2100);
+
centerOn(longitude,latitude, true);
}
+void GlobeGPS::fixZoom()
+{
+ zoomView(currentZoomLevel, Marble::Linear);
+}
+
+
void GlobeGPS::prepareForGetDiveCoordinates(dive* dive)
{
if (!messageWidget->isVisible()) {