I have a plugin which I want to add options to either the context menu when right clicking a layer at the Layers
panel or the properties menu for that layer.
How can I call them from PyQGIS?
Can I add the options every time the plugin loads?
It feels like the properties menu should be qgis.gui.QgsLayerPropertiesWidget but it seems to be mapped by symbol layers and not map layers.
I can't find any class that seems to fit the right click context menu in the layer panel.
How can I do this?
EDIT 1
Luis Perez's answer was what i wanted.
I meanwhile found the way to add actions to the right click context menu, so posting this here for anyone else looking
def printSomething():
print('Yay a new action!')
customAction = QAction('Print Something Nice')
customAction.triggered.connect(printSomething)
iface.addCustomActionForLayerType(customAction,'',qgis.core.QgsMapLayerType(0),True)
This will add the action Print Something Nice
to all the Vector layers in your project.
This can be further customized by connecting the action to other signals instead of triggered
, like hovered
for instance.