mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 21:03:23 +00:00
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:
parent
6ab95af9ac
commit
b42df1dab6
2 changed files with 18 additions and 3 deletions
|
@ -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<QContextMenuEvent *>(ev));
|
||||
return true;
|
||||
}
|
||||
if (ev->type() == QEvent::MouseButtonPress) {
|
||||
if (type == QEvent::MouseButtonPress) {
|
||||
QMouseEvent *e = static_cast<QMouseEvent *>(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;
|
||||
|
|
|
@ -34,6 +34,7 @@ private:
|
|||
int currentZoomLevel;
|
||||
bool needResetZoom;
|
||||
bool editingDiveLocation;
|
||||
bool doubleClick;
|
||||
|
||||
public
|
||||
slots:
|
||||
|
|
Loading…
Add table
Reference in a new issue