mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Disables zooming by double click and context menu on marble.
Marble is a weird piece of Qt software, it seems that it wasn't thought of being a library when first written. Most of its features are not achieved by subclassing && overriding one of Qt default methods, instead we need to eventFilter for almost everything ( which is a pain, and a bit error prone - see our combo box delegate *puke*. ) This one's ready, only one thing though - if we want to implement our own context menu, we will need to use the eventFilter, and not the contextMenuEvent. Fixes #291 [Dirk Hohndel: this does not disable the context menu for me...] Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
6fd0087a27
commit
abc81fbd01
2 changed files with 21 additions and 2 deletions
|
@ -38,6 +38,7 @@ GlobeGPS::GlobeGPS(QWidget* parent) : MarbleWidget(parent), loadedDives(0)
|
|||
foundGoogleMap = true;
|
||||
if (!foundGoogleMap) {
|
||||
subsurfaceDataPath = getSubsurfaceDataPath("marbledata");
|
||||
qDebug() << subsurfaceDataPath;
|
||||
if (subsurfaceDataPath != "")
|
||||
MarbleDirs::setMarbleDataPath(subsurfaceDataPath);
|
||||
}
|
||||
|
@ -67,6 +68,25 @@ GlobeGPS::GlobeGPS(QWidget* parent) : MarbleWidget(parent), loadedDives(0)
|
|||
fixZoomTimer = new QTimer();
|
||||
connect(fixZoomTimer, SIGNAL(timeout()), this, SLOT(fixZoom()));
|
||||
fixZoomTimer->setSingleShot(true);
|
||||
installEventFilter(this);
|
||||
}
|
||||
|
||||
bool GlobeGPS::eventFilter(QObject *obj, QEvent *ev)
|
||||
{
|
||||
// This disables Zooming when a double click occours on the scene.
|
||||
if (ev->type() == QEvent::MouseButtonDblClick)
|
||||
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)
|
||||
return true;
|
||||
if (ev->type() == QEvent::MouseButtonPress){
|
||||
QMouseEvent *e = static_cast<QMouseEvent*>(ev);
|
||||
if(e->button() == Qt::RightButton)
|
||||
return true;
|
||||
}
|
||||
return QObject::eventFilter(obj,ev );
|
||||
}
|
||||
|
||||
void GlobeGPS::mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit unit)
|
||||
|
|
|
@ -20,11 +20,10 @@ public:
|
|||
void repopulateLabels();
|
||||
void centerOn(struct dive* dive);
|
||||
void diveEditMode();
|
||||
|
||||
bool eventFilter(QObject*, QEvent*);
|
||||
protected:
|
||||
/* reimp */ void resizeEvent(QResizeEvent *event);
|
||||
/* reimp */ void mousePressEvent(QMouseEvent* event);
|
||||
|
||||
private:
|
||||
void prepareForGetDiveCoordinates(struct dive* dive);
|
||||
GeoDataDocument *loadedDives;
|
||||
|
|
Loading…
Add table
Reference in a new issue