11"""Dialog for tooltip edition."""
22from typing import Dict , Optional
33
4- from qgis .core import QgsMapLayerProxyModel
4+ from qgis .core import QgsMapLayerProxyModel , QgsWkbTypes
55from qgis .PyQt .QtGui import QColor , QIcon
66from qgis .PyQt .QtWidgets import QMessageBox , QWidget
77
@@ -30,14 +30,14 @@ def __init__(self,
3030 self .config .add_layer_widget ('template' , self .html_template )
3131 self .config .add_layer_widget ('displayGeom' , self .display_geometry )
3232 self .config .add_layer_widget ('colorGeom' , self .color )
33+ self .config .add_layer_widget ('displayLayerStyle' , self .display_layer_style )
3334
3435 self .config .add_layer_label ('layerId' , self .label_layer )
3536 self .config .add_layer_label ('fields' , self .label_fields )
3637 self .config .add_layer_label ('template' , self .label_html_template )
3738 self .config .add_layer_label ('displayGeom' , self .label_display_geometry )
3839 self .config .add_layer_label ('colorGeom' , self .label_color )
39-
40- # TODO when 3.8 will be the default, change the default tab according to the LWC version
40+ self .config .add_layer_label ('displayLayerStyle' , self .label_display_layer_style )
4141
4242 self .layer .setFilters (QgsMapLayerProxyModel .Filter .VectorLayer )
4343 self .layer .layerChanged .connect (self .check_layer_wfs )
@@ -51,9 +51,18 @@ def __init__(self,
5151
5252 self .generate_table .clicked .connect (self .generate_table_clicked )
5353
54+ # Make "display" checkbox mutually exclusive
55+ # We cannot use QButtonGroup because it forces at least one button to be checked,
56+ # which is not the case here, so we manage the exclusivity manually in the slot.
57+ self .display_layer_style .toggled .connect (self .toggleDisplayCheckbox )
58+
5459 self .lwc_versions [LwcVersions .Lizmap_3_8 ] = [
5560 self .label_html_template ,
5661 ]
62+ self .lwc_versions [LwcVersions .Lizmap_3_10 ] = [
63+ self .label_display_layer_style ,
64+ self .display_layer_style ,
65+ ]
5766
5867 self .setup_ui ()
5968 self .check_layer_wfs ()
@@ -104,10 +113,17 @@ def enable_color(self):
104113 if self .display_geometry .isChecked ():
105114 self .color .setEnabled (True )
106115 self .color .setColor (QColor ('blue' ))
116+ if self .display_layer_style .isChecked ():
117+ self .display_layer_style .setChecked (False )
107118 else :
108119 self .color .setEnabled (False )
109120 self .color .setToNull ()
110121
122+ def toggleDisplayCheckbox (self ):
123+ if self .display_layer_style .isChecked ():
124+ if self .display_geometry .isChecked ():
125+ self .display_geometry .setChecked (False )
126+
111127 def validate (self ) -> Optional [str ]:
112128 upstream = super ().validate ()
113129 if upstream :
@@ -124,4 +140,13 @@ def validate(self) -> Optional[str]:
124140 if not self .fields .selection () and not self .html_template .html_content ():
125141 return tr ('Either an HTML template or a field must be set.' )
126142
143+ # Allow display layer style only for point
144+ # LWC 3.10
145+ # Could be changed in future version
146+ if layer .geometryType () != QgsWkbTypes .PointGeometry :
147+ return tr (
148+ "At present, the option 'Display layer feature'"
149+ " is only available for point layers."
150+ )
151+
127152 return None
0 commit comments