Skip to content

Commit

Permalink
do not "Make available offline" context menu entry to local MBTiles
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Sep 7, 2023
1 parent 52f4a8e commit a51f65a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Mergin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,11 @@ def initGui(self):
# add layer context menu action for downloading vector tiles
self.action_export_mbtiles = QAction("Make available offline…", self.iface.mainWindow())
self.action_export_mbtiles.setIcon(QIcon(icon_path("file-export.svg")))
self.iface.addCustomActionForLayerType(self.action_export_mbtiles, "", QgsMapLayer.VectorTileLayer, True)
self.iface.addCustomActionForLayerType(self.action_export_mbtiles, "", QgsMapLayer.VectorTileLayer, False)
self.action_export_mbtiles.triggered.connect(self.export_vector_tiles)

QgsProject.instance().layersAdded.connect(self.add_context_menu_actions)

def add_action(
self,
icon_name,
Expand Down Expand Up @@ -475,6 +477,11 @@ def on_qgis_project_changed(self):
if self.mergin_proj_dir is not None:
self.enable_toolbar_actions()

def add_context_menu_actions(self, layers):
for l in layers:
if l.dataProvider().name() == "xyzvectortiles":
self.iface.addCustomActionForLayer(self.action_export_mbtiles, l)

def unload(self):
if self.iface is not None:
# Disconnect Mergin related signals
Expand Down

0 comments on commit a51f65a

Please sign in to comment.