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 <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2014-06-11 09:25:55 -07:00
parent 6ab95af9ac
commit b42df1dab6
2 changed files with 18 additions and 3 deletions

View file

@ -88,17 +88,25 @@ GlobeGPS::GlobeGPS(QWidget *parent) : MarbleWidget(parent),
bool GlobeGPS::eventFilter(QObject *obj, QEvent *ev) 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. // This disables Zooming when a double click occours on the scene.
if (ev->type() == QEvent::MouseButtonDblClick && !editingDiveLocation) if (type == QEvent::MouseButtonDblClick && !editingDiveLocation)
return true; return true;
// This disables the Marble's Context Menu // This disables the Marble's Context Menu
// we need to move this to our 'contextMenuEvent' // we need to move this to our 'contextMenuEvent'
// if we plan to do a different one in the future. // if we plan to do a different one in the future.
if (ev->type() == QEvent::ContextMenu) { if (type == QEvent::ContextMenu) {
contextMenuEvent(static_cast<QContextMenuEvent *>(ev)); contextMenuEvent(static_cast<QContextMenuEvent *>(ev));
return true; return true;
} }
if (ev->type() == QEvent::MouseButtonPress) { if (type == QEvent::MouseButtonPress) {
QMouseEvent *e = static_cast<QMouseEvent *>(ev); QMouseEvent *e = static_cast<QMouseEvent *>(ev);
if (e->button() == Qt::RightButton) if (e->button() == Qt::RightButton)
return true; return true;
@ -116,6 +124,12 @@ void GlobeGPS::contextMenuEvent(QContextMenuEvent *ev)
void GlobeGPS::mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit unit) 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 // don't mess with the selection while the user is editing a dive
if (MainWindow::instance()->information()->isEditing() || messageWidget->isVisible()) if (MainWindow::instance()->information()->isEditing() || messageWidget->isVisible())
return; return;

View file

@ -34,6 +34,7 @@ private:
int currentZoomLevel; int currentZoomLevel;
bool needResetZoom; bool needResetZoom;
bool editingDiveLocation; bool editingDiveLocation;
bool doubleClick;
public public
slots: slots: