mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-02 23:20:20 +00:00
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>
This commit is contained in:
parent
579d1cb915
commit
8f623c2c72
2 changed files with 22 additions and 3 deletions
|
@ -7,6 +7,7 @@
|
||||||
#include "../helpers.h"
|
#include "../helpers.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include <marble/AbstractFloatItem.h>
|
#include <marble/AbstractFloatItem.h>
|
||||||
#include <marble/GeoDataPlacemark.h>
|
#include <marble/GeoDataPlacemark.h>
|
||||||
|
@ -63,6 +64,9 @@ GlobeGPS::GlobeGPS(QWidget* parent) : MarbleWidget(parent), loadedDives(0)
|
||||||
setMinimumHeight(0);
|
setMinimumHeight(0);
|
||||||
setMinimumWidth(0);
|
setMinimumWidth(0);
|
||||||
editingDiveCoords = 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)
|
void GlobeGPS::mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit unit)
|
||||||
|
@ -178,9 +182,21 @@ void GlobeGPS::centerOn(dive* dive)
|
||||||
if (!zoom())
|
if (!zoom())
|
||||||
zoomView(zoomFromDistance(3));
|
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);
|
centerOn(longitude,latitude, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GlobeGPS::fixZoom()
|
||||||
|
{
|
||||||
|
zoomView(currentZoomLevel, Marble::Linear);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void GlobeGPS::prepareForGetDiveCoordinates(dive* dive)
|
void GlobeGPS::prepareForGetDiveCoordinates(dive* dive)
|
||||||
{
|
{
|
||||||
if (!messageWidget->isVisible()) {
|
if (!messageWidget->isVisible()) {
|
||||||
|
|
|
@ -13,25 +13,28 @@ struct dive;
|
||||||
|
|
||||||
class GlobeGPS : public MarbleWidget{
|
class GlobeGPS : public MarbleWidget{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
void prepareForGetDiveCoordinates(struct dive* dive);
|
|
||||||
public:
|
public:
|
||||||
using MarbleWidget::centerOn;
|
using MarbleWidget::centerOn;
|
||||||
GlobeGPS(QWidget *parent);
|
GlobeGPS(QWidget *parent);
|
||||||
void reload();
|
void reload();
|
||||||
void centerOn(struct dive* dive);
|
void centerOn(struct dive* dive);
|
||||||
void resizeEvent(QResizeEvent *event);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void mousePressEvent(QMouseEvent* event);
|
/* reimp */ void resizeEvent(QResizeEvent *event);
|
||||||
|
/* reimp */ void mousePressEvent(QMouseEvent* event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void prepareForGetDiveCoordinates(struct dive* dive);
|
||||||
GeoDataDocument *loadedDives;
|
GeoDataDocument *loadedDives;
|
||||||
struct dive* editingDiveCoords;
|
struct dive* editingDiveCoords;
|
||||||
KMessageWidget* messageWidget;
|
KMessageWidget* messageWidget;
|
||||||
|
QTimer *fixZoomTimer;
|
||||||
|
int currentZoomLevel;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void changeDiveGeoPosition(qreal lon,qreal lat,GeoDataCoordinates::Unit);
|
void changeDiveGeoPosition(qreal lon,qreal lat,GeoDataCoordinates::Unit);
|
||||||
void mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit);
|
void mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit);
|
||||||
|
void fixZoom();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue