Skip to content
Permalink
Browse files

[Feature] Add contextMenuAboutToShow to QgsMapCanvas

Adds a contextMenuAboutToShow( QMenu *menu, QgsMapMouseEvent *event ) signal to QgsMapCanvas to allow plugins
a chance to add entries to the canvas context menu

Fixes #37559
  • Loading branch information
jakimowb committed Jul 8, 2020
1 parent a49cb7c commit fd6dcf3bf6c22acb48b57bae30123314d9a33176
Showing with 25 additions and 3 deletions.
  1. +10 −0 python/gui/auto_generated/qgsmapcanvas.sip.in
  2. +2 −0 src/gui/qgsmapcanvas.cpp
  3. +13 −3 src/gui/qgsmapcanvas.h
@@ -1145,6 +1145,16 @@ Emitted when the map canvas temporal range changes.
.. versionadded:: 3.14
%End


void contextMenuAboutToShow( QMenu *menu, QgsMapMouseEvent *event );
%Docstring
Emitted before the map canvas context menu will be shown.
Can be used to extend the context menu.

.. versionadded:: 3.16
%End


protected:

virtual bool event( QEvent *e );
@@ -906,6 +906,8 @@ void QgsMapCanvas::showContextMenu( QgsMapMouseEvent *event )
if ( mMapTool )
mMapTool->populateContextMenu( mMenu );

emit contextMenuAboutToShow( mMenu, event );

mMenu->exec( event->globalPos() );
}

@@ -1034,11 +1034,21 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView

/**
* Emitted when the map canvas temporal range changes.
*
* \since QGIS 3.14
*/
*
* \since QGIS 3.14
*/
void temporalRangeChanged();


/**
* Emitted before the map canvas context menu will be shown.
* Can be used to extend the context menu.
*
* \since QGIS 3.16
*/
void contextMenuAboutToShow( QMenu *menu, QgsMapMouseEvent *event );


protected:

bool event( QEvent *e ) override;

0 comments on commit fd6dcf3

Please sign in to comment.
You can’t perform that action at this time.