Skip to content

Commit 11a9307

Browse files
authored
Merge pull request #738 from mind84/short_link_permalink
[Feature] Option to enable short link permalink management
2 parents 65a397b + ae82785 commit 11a9307

5 files changed

Lines changed: 89 additions & 42 deletions

File tree

lizmap/config/global_options.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class GlobalOptionsDefinitions(TypedDict):
6666
wms_single_request_for_all_layers: ModelItem
6767
exclude_basemaps_from_single_wms: ModelItem
6868
group_popup_by_layer: ModelItem
69+
short_link_permalink: ModelItem
6970
tmTimeFrameSize: ModelItem
7071
tmTimeFrameType: ModelItem
7172
tmAnimationFrameLength: ModelItem
@@ -238,6 +239,16 @@ class GlobalOptionsDefinitions(TypedDict):
238239
"When enabled, results will be displayed grouped by layer, and can be viewed individually."
239240
),
240241
},
242+
'short_link_permalink': {
243+
'wType': 'checkbox',
244+
'type': 'boolean',
245+
'default': False,
246+
'use_proper_boolean': True,
247+
'tooltip': tr(
248+
"Handle the permalink with an encoded short hash rather "
249+
"than a full hash containing all the information in plain text"
250+
),
251+
},
241252
"tmTimeFrameSize": {"wType": "spinbox", "type": "integer", "default": 10},
242253
"tmTimeFrameType": {
243254
"wType": "list",

lizmap/plugin/lwc_versions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ def configure_lwc_versions(dlg: LizmapDialog) -> OrderedDict:
222222
dlg.text_dxf_allowed_groups,
223223
dlg.button_dxf_wizard_group,
224224
dlg.label_dxf_layers_info,
225-
dlg.checkbox_group_popup_by_layer
225+
dlg.checkbox_group_popup_by_layer,
226+
dlg.checkbox_short_link_permalink
226227
]
227228
lwc_versions[LwcVersions.Lizmap_3_11] = []
228229

lizmap/plugin/options.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ def global_options(dlg: "LizmapDialog", lizmap_config: LizmapConfig) -> GlobalOp
8080
global_options["group_popup_by_layer"]["widget"] = (
8181
dlg.checkbox_group_popup_by_layer
8282
)
83+
global_options["short_link_permalink"]["widget"] = (
84+
dlg.checkbox_short_link_permalink
85+
)
8386

8487
global_options["tmTimeFrameSize"]["widget"] = dlg.inTimeFrameSize
8588
global_options["tmTimeFrameType"]["widget"] = dlg.liTimeFrameType

lizmap/resources/ui/ui_lizmap.ui

Lines changed: 51 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ QListWidget::item::selected {
331331
</sizepolicy>
332332
</property>
333333
<property name="currentIndex">
334-
<number>7</number>
334+
<number>1</number>
335335
</property>
336336
<widget class="QWidget" name="page_information">
337337
<layout class="QVBoxLayout" name="verticalLayout_7">
@@ -773,8 +773,8 @@ QListWidget::item::selected {
773773
<rect>
774774
<x>0</x>
775775
<y>0</y>
776-
<width>797</width>
777-
<height>1433</height>
776+
<width>835</width>
777+
<height>1542</height>
778778
</rect>
779779
</property>
780780
<layout class="QVBoxLayout" name="verticalLayout_26">
@@ -793,7 +793,7 @@ QListWidget::item::selected {
793793
</property>
794794
</widget>
795795
</item>
796-
<item row="1" column="0">
796+
<item row="2" column="0">
797797
<widget class="QCheckBox" name="checkbox_wms_single_request_all_layers">
798798
<property name="toolTip">
799799
<string>All the map layers will be loaded as a single WMS image</string>
@@ -803,20 +803,30 @@ QListWidget::item::selected {
803803
</property>
804804
</widget>
805805
</item>
806-
<item row="0" column="1">
806+
<item row="2" column="1">
807+
<widget class="QCheckBox" name="checkbox_exclude_basemaps_from_single_wms">
808+
<property name="toolTip">
809+
<string>When single WMS is enabled, exclude basemaps from the single WMS request. This improves performance for Cloud-Optimized GeoTIFF (COG) basemaps by preserving their native format instead of converting to PNG.</string>
810+
</property>
811+
<property name="text">
812+
<string>Exclude basemaps from single WMS</string>
813+
</property>
814+
</widget>
815+
</item>
816+
<item row="1" column="0">
807817
<widget class="QCheckBox" name="automatic_permalink">
808818
<property name="text">
809819
<string>Enable automatic permalink</string>
810820
</property>
811821
</widget>
812822
</item>
813823
<item row="1" column="1">
814-
<widget class="QCheckBox" name="checkbox_exclude_basemaps_from_single_wms">
824+
<widget class="QCheckBox" name="checkbox_short_link_permalink">
815825
<property name="toolTip">
816-
<string>When single WMS is enabled, exclude basemaps from the single WMS request. This improves performance for Cloud-Optimized GeoTIFF (COG) basemaps by preserving their native format instead of converting to PNG.</string>
826+
<string>Handle the permalink with an encoded short hash rather than a full hash containing all the information in plain text</string>
817827
</property>
818828
<property name="text">
819-
<string>Exclude basemaps from single WMS</string>
829+
<string>Enable short link permalink</string>
820830
</property>
821831
</widget>
822832
</item>
@@ -1518,8 +1528,8 @@ This is different to the map maximum extent (defined in QGIS project properties,
15181528
<rect>
15191529
<x>0</x>
15201530
<y>0</y>
1521-
<width>585</width>
1522-
<height>209</height>
1531+
<width>856</width>
1532+
<height>820</height>
15231533
</rect>
15241534
</property>
15251535
<layout class="QHBoxLayout" name="horizontalLayout_28">
@@ -1649,8 +1659,8 @@ This is different to the map maximum extent (defined in QGIS project properties,
16491659
<rect>
16501660
<x>0</x>
16511661
<y>0</y>
1652-
<width>478</width>
1653-
<height>1194</height>
1662+
<width>448</width>
1663+
<height>1248</height>
16541664
</rect>
16551665
</property>
16561666
<layout class="QVBoxLayout" name="verticalLayout_9">
@@ -2393,8 +2403,8 @@ This is different to the map maximum extent (defined in QGIS project properties,
23932403
<rect>
23942404
<x>0</x>
23952405
<y>0</y>
2396-
<width>780</width>
2397-
<height>726</height>
2406+
<width>856</width>
2407+
<height>820</height>
23982408
</rect>
23992409
</property>
24002410
<layout class="QVBoxLayout" name="verticalLayout_28">
@@ -2808,8 +2818,8 @@ This is different to the map maximum extent (defined in QGIS project properties,
28082818
<rect>
28092819
<x>0</x>
28102820
<y>0</y>
2811-
<width>497</width>
2812-
<height>396</height>
2821+
<width>856</width>
2822+
<height>820</height>
28132823
</rect>
28142824
</property>
28152825
<layout class="QVBoxLayout" name="verticalLayout_31">
@@ -2940,8 +2950,8 @@ This is different to the map maximum extent (defined in QGIS project properties,
29402950
<rect>
29412951
<x>0</x>
29422952
<y>0</y>
2943-
<width>450</width>
2944-
<height>283</height>
2953+
<width>856</width>
2954+
<height>820</height>
29452955
</rect>
29462956
</property>
29472957
<layout class="QVBoxLayout" name="verticalLayout_4">
@@ -3296,8 +3306,8 @@ This is different to the map maximum extent (defined in QGIS project properties,
32963306
<rect>
32973307
<x>0</x>
32983308
<y>0</y>
3299-
<width>450</width>
3300-
<height>300</height>
3309+
<width>464</width>
3310+
<height>306</height>
33013311
</rect>
33023312
</property>
33033313
<layout class="QVBoxLayout" name="verticalLayout_46">
@@ -3397,8 +3407,8 @@ This is different to the map maximum extent (defined in QGIS project properties,
33973407
<rect>
33983408
<x>0</x>
33993409
<y>0</y>
3400-
<width>618</width>
3401-
<height>546</height>
3410+
<width>559</width>
3411+
<height>558</height>
34023412
</rect>
34033413
</property>
34043414
<layout class="QVBoxLayout" name="verticalLayout_19">
@@ -3775,8 +3785,8 @@ This is different to the map maximum extent (defined in QGIS project properties,
37753785
<rect>
37763786
<x>0</x>
37773787
<y>0</y>
3778-
<width>386</width>
3779-
<height>867</height>
3788+
<width>392</width>
3789+
<height>876</height>
37803790
</rect>
37813791
</property>
37823792
<layout class="QVBoxLayout" name="verticalLayout_29">
@@ -4160,8 +4170,8 @@ This is different to the map maximum extent (defined in QGIS project properties,
41604170
<rect>
41614171
<x>0</x>
41624172
<y>0</y>
4163-
<width>450</width>
4164-
<height>439</height>
4173+
<width>464</width>
4174+
<height>444</height>
41654175
</rect>
41664176
</property>
41674177
<layout class="QVBoxLayout" name="verticalLayout_43">
@@ -4343,8 +4353,8 @@ This is different to the map maximum extent (defined in QGIS project properties,
43434353
<rect>
43444354
<x>0</x>
43454355
<y>0</y>
4346-
<width>601</width>
4347-
<height>488</height>
4356+
<width>534</width>
4357+
<height>494</height>
43484358
</rect>
43494359
</property>
43504360
<layout class="QVBoxLayout" name="verticalLayout_41">
@@ -4499,8 +4509,8 @@ This is different to the map maximum extent (defined in QGIS project properties,
44994509
<rect>
45004510
<x>0</x>
45014511
<y>0</y>
4502-
<width>450</width>
4503-
<height>340</height>
4512+
<width>464</width>
4513+
<height>330</height>
45044514
</rect>
45054515
</property>
45064516
<layout class="QVBoxLayout" name="verticalLayout_12">
@@ -4615,8 +4625,8 @@ This is different to the map maximum extent (defined in QGIS project properties,
46154625
<rect>
46164626
<x>0</x>
46174627
<y>0</y>
4618-
<width>450</width>
4619-
<height>317</height>
4628+
<width>464</width>
4629+
<height>324</height>
46204630
</rect>
46214631
</property>
46224632
<layout class="QVBoxLayout" name="verticalLayout_27">
@@ -4837,8 +4847,8 @@ This is different to the map maximum extent (defined in QGIS project properties,
48374847
<rect>
48384848
<x>0</x>
48394849
<y>0</y>
4840-
<width>415</width>
4841-
<height>882</height>
4850+
<width>372</width>
4851+
<height>918</height>
48424852
</rect>
48434853
</property>
48444854
<layout class="QVBoxLayout" name="verticalLayout_73">
@@ -4976,8 +4986,8 @@ This is different to the map maximum extent (defined in QGIS project properties,
49764986
<rect>
49774987
<x>0</x>
49784988
<y>0</y>
4979-
<width>434</width>
4980-
<height>611</height>
4989+
<width>389</width>
4990+
<height>612</height>
49814991
</rect>
49824992
</property>
49834993
<layout class="QVBoxLayout" name="verticalLayout_72">
@@ -5200,8 +5210,8 @@ This is different to the map maximum extent (defined in QGIS project properties,
52005210
<rect>
52015211
<x>0</x>
52025212
<y>0</y>
5203-
<width>584</width>
5204-
<height>592</height>
5213+
<width>542</width>
5214+
<height>677</height>
52055215
</rect>
52065216
</property>
52075217
<layout class="QVBoxLayout" name="verticalLayout_80">
@@ -5504,8 +5514,8 @@ This is different to the map maximum extent (defined in QGIS project properties,
55045514
<rect>
55055515
<x>0</x>
55065516
<y>0</y>
5507-
<width>749</width>
5508-
<height>453</height>
5517+
<width>670</width>
5518+
<height>504</height>
55095519
</rect>
55105520
</property>
55115521
<layout class="QVBoxLayout" name="verticalLayout_83">
@@ -5928,6 +5938,7 @@ This is different to the map maximum extent (defined in QGIS project properties,
59285938
<tabstop>scrollArea</tabstop>
59295939
<tabstop>cbHideProject</tabstop>
59305940
<tabstop>automatic_permalink</tabstop>
5941+
<tabstop>checkbox_short_link_permalink</tabstop>
59315942
<tabstop>checkbox_wms_single_request_all_layers</tabstop>
59325943
<tabstop>checkbox_exclude_basemaps_from_single_wms</tabstop>
59335944
<tabstop>inAcl</tabstop>

tests/test_ui.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,4 +850,25 @@ def test_group_popup_by_layer(self, data: Path):
850850
lizmap.dlg.checkbox_group_popup_by_layer.setChecked(False)
851851
output = lizmap.project_config_file(LwcVersions.latest(), check_server=False, ignore_error=True)
852852
# Group popup by layers option should be unchecked in output config file
853-
self.assertFalse(output["options"].get("group_popup_by_layer"))
853+
self.assertFalse(output["options"].get("group_popup_by_layer"))
854+
855+
def test_short_link_permalink(self, data: Path):
856+
"""Test short link permalink UI settings."""
857+
lizmap = self._setup_empty_project(data)
858+
859+
# Default checkbox states
860+
self.assertFalse(lizmap.dlg.checkbox_short_link_permalink.isChecked())
861+
862+
# Enable short link permalink
863+
lizmap.dlg.checkbox_short_link_permalink.setChecked(True)
864+
self.assertTrue(lizmap.dlg.checkbox_short_link_permalink.isEnabled())
865+
866+
output = lizmap.project_config_file(LwcVersions.latest(), check_server=False, ignore_error=True)
867+
# Short link permalink option should be checked in output config file
868+
self.assertTrue(output["options"].get("short_link_permalink"))
869+
870+
# Disable short link permalink
871+
lizmap.dlg.checkbox_short_link_permalink.setChecked(False)
872+
output = lizmap.project_config_file(LwcVersions.latest(), check_server=False, ignore_error=True)
873+
# Short link permalink option should be unchecked in output config file
874+
self.assertFalse(output["options"].get("short_link_permalink"))

0 commit comments

Comments
 (0)