From b42df1dab67d2f90934e24f428475ae5f5f88e86 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 11 Jun 2014 09:25:55 -0700 Subject: Globe: do a better job detecting double clicks and setting GPS coordinates For some reasons Marble appears to sometimes not detect double clicks and call the correct callback. With this commit we manually intercept the double clocks and route them to the right function. Signed-off-by: Dirk Hohndel --- qt-ui/globe.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'qt-ui/globe.cpp') diff --git a/qt-ui/globe.cpp b/qt-ui/globe.cpp index 8d234194e..c21417990 100644 --- a/qt-ui/globe.cpp +++ b/qt-ui/globe.cpp @@ -88,17 +88,25 @@ GlobeGPS::GlobeGPS(QWidget *parent) : MarbleWidget(parent), bool GlobeGPS::eventFilter(QObject *obj, QEvent *ev) { + // sometimes Marble seems not to notice double clicks and consequently not call + // the right callback - so let's remember here if the last 'click' is a 'double' or not + enum QEvent::Type type = ev->type(); + if (type == QEvent::MouseButtonDblClick) + doubleClick = true; + else if (type == QEvent::MouseButtonPress) + doubleClick = false; + // This disables Zooming when a double click occours on the scene. - if (ev->type() == QEvent::MouseButtonDblClick && !editingDiveLocation) + if (type == QEvent::MouseButtonDblClick && !editingDiveLocation) return true; // This disables the Marble's Context Menu // we need to move this to our 'contextMenuEvent' // if we plan to do a different one in the future. - if (ev->type() == QEvent::ContextMenu) { + if (type == QEvent::ContextMenu) { contextMenuEvent(static_cast(ev)); return true; } - if (ev->type() == QEvent::MouseButtonPress) { + if (type == QEvent::MouseButtonPress) { QMouseEvent *e = static_cast(ev); if (e->button() == Qt::RightButton) return true; @@ -116,6 +124,12 @@ void GlobeGPS::contextMenuEvent(QContextMenuEvent *ev) void GlobeGPS::mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit unit) { + if (doubleClick) { + // strangely sometimes we don't get the changeDiveGeoPosition callback + // and end up here instead + changeDiveGeoPosition(lon, lat, unit); + return; + } // don't mess with the selection while the user is editing a dive if (MainWindow::instance()->information()->isEditing() || messageWidget->isVisible()) return; -- cgit v1.2.3-70-g09d2