Skip to content

Commit

Permalink
UX - Disable panel when the layer is excluded from WMS
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry committed Oct 31, 2023
1 parent 8524bb6 commit b28b056
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lizmap/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
from lizmap.table_manager.base import TableManager
from lizmap.table_manager.dataviz import TableManagerDataviz
from lizmap.table_manager.layouts import TableManagerLayouts
from lizmap.widgets.project_tools import is_layer_wms_excluded

try:
from lizmap.plugin_manager import QgisPluginManager
Expand Down Expand Up @@ -2196,6 +2197,12 @@ def process_node(self, node, parent_node, json_layers):
if predefined_group != PredefinedGroup.No.value:
text = tr('Special group for Lizmap Web Client')
item.setToolTip(0, self.myDic[child_id]['name'] + ' - ' + text)
elif is_layer_wms_excluded(self.project, self.myDic[child_id]['name']):
text = tr(
'The layer is excluded from WMS service, in the '
'"Project Properties" → "QGIS Server" → "WMS" → "Excluded Layers"'
)
item.setToolTip(0, self.myDic[child_id]['name'] + ' - ' + text)
else:
item.setToolTip(0, self.myDic[child_id]['name'])
item.setIcon(0, child_icon)
Expand Down Expand Up @@ -2417,6 +2424,11 @@ def from_data_to_ui_for_layer_group(self):
if self._current_item_predefined_group() != PredefinedGroup.No.value:
self.dlg.gb_layerSettings.setEnabled(False)

layer = self._current_selected_layer()
if isinstance(layer, QgsMapLayer):
if is_layer_wms_excluded(self.project, layer.name()):
self.dlg.gb_layerSettings.setEnabled(False)

# def enable_or_not_toggle_checkbox(self):
# """ Only for groups, to determine the state of the "toggled" option. """
# if self.layer_options_list['groupAsLayer']['widget'].isChecked():
Expand Down
14 changes: 14 additions & 0 deletions lizmap/widgets/project_tools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
__copyright__ = 'Copyright 2023, 3Liz'
__license__ = 'GPL version 3'
__email__ = '[email protected]'

from qgis.core import QgsProject


def is_layer_wms_excluded(project: QgsProject, name: str) -> bool:
""" Is the layer excluded from WMS.
Project properties → QGIS server → WMS → Exclude layers
"""
server_wms_excluded_list, server_exclude = project.readListEntry('WMSRestrictedLayers', '')
return server_exclude and name in server_wms_excluded_list

0 comments on commit b28b056

Please sign in to comment.