From 84793cab1dbe62f0f877a6d1b5aa10fb95da7daa Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Wed, 29 Nov 2023 14:09:58 +0100 Subject: [PATCH] Remove all QgsSettings for LwcVersions, do not use latest again --- lizmap/forms/atlas_edition.py | 5 +++-- lizmap/forms/attribute_table_edition.py | 5 +++-- lizmap/forms/base_edition_dialog.py | 12 ++++++++---- lizmap/forms/dataviz_edition.py | 10 ++++------ lizmap/forms/edition_edition.py | 4 ++-- lizmap/forms/filter_by_form_edition.py | 4 ++-- lizmap/forms/filter_by_login.py | 5 +++-- lizmap/forms/filter_by_polygon.py | 5 +++-- lizmap/forms/layout_edition.py | 5 +++-- lizmap/forms/locate_layer_edition.py | 5 +++-- lizmap/forms/tooltip_edition.py | 5 +++-- lizmap/plugin.py | 3 +-- 12 files changed, 38 insertions(+), 30 deletions(-) diff --git a/lizmap/forms/atlas_edition.py b/lizmap/forms/atlas_edition.py index 1dd9153e..8d9f1797 100755 --- a/lizmap/forms/atlas_edition.py +++ b/lizmap/forms/atlas_edition.py @@ -3,6 +3,7 @@ from qgis.core import QgsMapLayerProxyModel from lizmap.definitions.atlas import AtlasDefinitions +from lizmap.definitions.definitions import LwcVersions from lizmap.forms.base_edition_dialog import BaseEditionDialog from lizmap.qgis_plugin_tools.tools.i18n import tr from lizmap.qgis_plugin_tools.tools.resources import load_ui @@ -17,8 +18,8 @@ class AtlasEditionDialog(BaseEditionDialog, CLASS): - def __init__(self, parent=None, unicity=None): - super().__init__(parent, unicity) + def __init__(self, parent=None, unicity=None, lwc_version: LwcVersions = None): + super().__init__(parent, unicity, lwc_version) self.setupUi(self) self.config = AtlasDefinitions() self.config.add_layer_widget('layer', self.layer) diff --git a/lizmap/forms/attribute_table_edition.py b/lizmap/forms/attribute_table_edition.py index d33dad93..05567a46 100755 --- a/lizmap/forms/attribute_table_edition.py +++ b/lizmap/forms/attribute_table_edition.py @@ -6,6 +6,7 @@ AttributeTableDefinitions, layer_has_custom_attribute_table, ) +from lizmap.definitions.definitions import LwcVersions from lizmap.forms.base_edition_dialog import BaseEditionDialog from lizmap.qgis_plugin_tools.tools.i18n import tr from lizmap.qgis_plugin_tools.tools.resources import load_ui @@ -20,8 +21,8 @@ class AttributeTableEditionDialog(BaseEditionDialog, CLASS): - def __init__(self, parent=None, unicity=None): - super().__init__(parent, unicity) + def __init__(self, parent=None, unicity=None, lwc_version: LwcVersions = None): + super().__init__(parent, unicity, lwc_version) self.setupUi(self) self.config = AttributeTableDefinitions() self.config.add_layer_widget('layerId', self.layer) diff --git a/lizmap/forms/base_edition_dialog.py b/lizmap/forms/base_edition_dialog.py index 0db3aab6..9a15ce3a 100755 --- a/lizmap/forms/base_edition_dialog.py +++ b/lizmap/forms/base_edition_dialog.py @@ -42,6 +42,7 @@ def __init__(self, parent: QDialog = None, unicity=None, lwc_version: LwcVersion self.parent = parent self.config = None self.unicity = unicity + # Should only be used in tests, otherwise, the version is coming from the parent. self._version = lwc_version @@ -154,12 +155,15 @@ def open_help(self): # noinspection PyArgumentList QDesktopServices.openUrl(online_lwc_help(self.config.help_path())) + def current_lwc_version(self) -> LwcVersions: + """ If a parent is defined, by default on production, return the version of the current selected server. """ + if self.parent: + return self.parent.current_lwc_version() + return self._version + def version_lwc(self): """ Make all colors about widgets if it is available or not. """ - if self.parent: - current_version = self.parent.current_lwc_version() - else: - current_version = self._version + current_version = self.current_lwc_version() # For labels in the UI files, which are not part of the definitions. found = False diff --git a/lizmap/forms/dataviz_edition.py b/lizmap/forms/dataviz_edition.py index 368e5526..a24fac97 100755 --- a/lizmap/forms/dataviz_edition.py +++ b/lizmap/forms/dataviz_edition.py @@ -1,6 +1,6 @@ """Dialog for dataviz edition.""" -from qgis.core import QgsApplication, QgsMapLayerProxyModel, QgsSettings +from qgis.core import QgsApplication, QgsMapLayerProxyModel from qgis.PyQt.QtCore import Qt from qgis.PyQt.QtGui import QColor, QIcon from qgis.PyQt.QtWidgets import ( @@ -29,8 +29,8 @@ class DatavizEditionDialog(BaseEditionDialog, CLASS): - def __init__(self, parent=None, unicity=None): - super().__init__(parent, unicity) + def __init__(self, parent=None, unicity=None, lwc_version: LwcVersions = None): + super().__init__(parent, unicity, lwc_version) self.setupUi(self) self.parent = parent self.config = DatavizDefinitions() @@ -275,9 +275,7 @@ def check_trace_action(self): item = self.traces.item(i, 0) self.trace_combo.addItem(item.icon(), item.text(), i + 1) - version = QgsSettings().value( - 'lizmap/lizmap_web_client_version', LwcVersions.latest().value, str) - version = LwcVersions(version) + version = self.current_lwc_version() if version in [LwcVersions.Lizmap_3_1, LwcVersions.Lizmap_3_2, LwcVersions.Lizmap_3_3]: if self.traces.rowCount() >= 2: diff --git a/lizmap/forms/edition_edition.py b/lizmap/forms/edition_edition.py index befb752e..df312b61 100755 --- a/lizmap/forms/edition_edition.py +++ b/lizmap/forms/edition_edition.py @@ -25,8 +25,8 @@ class EditionLayerDialog(BaseEditionDialog, CLASS): - def __init__(self, parent=None, unicity=None): - super().__init__(parent, unicity) + def __init__(self, parent=None, unicity=None, lwc_version: LwcVersions = None): + super().__init__(parent, unicity, lwc_version) self.setupUi(self) self.config = EditionDefinitions() self.config.add_layer_widget('layerId', self.layer) diff --git a/lizmap/forms/filter_by_form_edition.py b/lizmap/forms/filter_by_form_edition.py index 5f9a57a4..9f0eab88 100755 --- a/lizmap/forms/filter_by_form_edition.py +++ b/lizmap/forms/filter_by_form_edition.py @@ -20,8 +20,8 @@ class FilterByFormEditionDialog(BaseEditionDialog, CLASS): - def __init__(self, parent=None, unicity=None): - super().__init__(parent, unicity) + def __init__(self, parent=None, unicity=None, lwc_version: LwcVersions = None): + super().__init__(parent, unicity, lwc_version) self.setupUi(self) self.config = FilterByFormDefinitions() self.config.add_layer_widget('layerId', self.layer) diff --git a/lizmap/forms/filter_by_login.py b/lizmap/forms/filter_by_login.py index f2b57eec..9211dd73 100755 --- a/lizmap/forms/filter_by_login.py +++ b/lizmap/forms/filter_by_login.py @@ -2,6 +2,7 @@ from qgis.core import QgsMapLayerProxyModel +from lizmap.definitions.definitions import LwcVersions from lizmap.definitions.filter_by_login import FilterByLoginDefinitions from lizmap.forms.base_edition_dialog import BaseEditionDialog from lizmap.qgis_plugin_tools.tools.i18n import tr @@ -17,8 +18,8 @@ class FilterByLoginEditionDialog(BaseEditionDialog, CLASS): - def __init__(self, parent=None, unicity=None): - super().__init__(parent, unicity) + def __init__(self, parent=None, unicity=None, lwc_version: LwcVersions = None): + super().__init__(parent, unicity, lwc_version) self.setupUi(self) self.config = FilterByLoginDefinitions() self.config.add_layer_widget('layerId', self.layer) diff --git a/lizmap/forms/filter_by_polygon.py b/lizmap/forms/filter_by_polygon.py index e9f575cb..65bf6d69 100755 --- a/lizmap/forms/filter_by_polygon.py +++ b/lizmap/forms/filter_by_polygon.py @@ -2,6 +2,7 @@ from qgis.core import QgsMapLayerProxyModel +from lizmap.definitions.definitions import LwcVersions from lizmap.definitions.filter_by_polygon import ( FilterByPolygonDefinitions, FilterMode, @@ -20,8 +21,8 @@ class FilterByPolygonEditionDialog(BaseEditionDialog, CLASS): - def __init__(self, parent=None, unicity=None): - super().__init__(parent, unicity) + def __init__(self, parent=None, unicity=None, lwc_version: LwcVersions = None): + super().__init__(parent, unicity, lwc_version) self.setupUi(self) self.config = FilterByPolygonDefinitions() self.config.add_layer_widget('layer', self.layer) diff --git a/lizmap/forms/layout_edition.py b/lizmap/forms/layout_edition.py index 24f5f080..23c55695 100755 --- a/lizmap/forms/layout_edition.py +++ b/lizmap/forms/layout_edition.py @@ -4,6 +4,7 @@ from qgis.PyQt.QtCore import Qt from qgis.PyQt.QtGui import QIcon +from lizmap.definitions.definitions import LwcVersions from lizmap.definitions.layouts import Dpi, FormatType, LayoutsDefinitions from lizmap.forms.base_edition_dialog import BaseEditionDialog from lizmap.qgis_plugin_tools.tools.i18n import tr @@ -19,8 +20,8 @@ class LayoutEditionDialog(BaseEditionDialog, CLASS): - def __init__(self, parent=None, unicity=None): - super().__init__(parent, unicity) + def __init__(self, parent=None, unicity=None, lwc_version: LwcVersions = None): + super().__init__(parent, unicity, lwc_version) self.setupUi(self) self.parent = parent self.config = LayoutsDefinitions() diff --git a/lizmap/forms/locate_layer_edition.py b/lizmap/forms/locate_layer_edition.py index 7b6c4d44..8ad92a32 100755 --- a/lizmap/forms/locate_layer_edition.py +++ b/lizmap/forms/locate_layer_edition.py @@ -2,6 +2,7 @@ from qgis.core import QgsMapLayerProxyModel +from lizmap.definitions.definitions import LwcVersions from lizmap.definitions.locate_by_layer import LocateByLayerDefinitions from lizmap.forms.base_edition_dialog import BaseEditionDialog from lizmap.qgis_plugin_tools.tools.i18n import tr @@ -17,8 +18,8 @@ class LocateLayerEditionDialog(BaseEditionDialog, CLASS): - def __init__(self, parent=None, unicity=None): - super().__init__(parent, unicity) + def __init__(self, parent=None, unicity=None, lwc_version: LwcVersions = None): + super().__init__(parent, unicity, lwc_version) self.setupUi(self) self.config = LocateByLayerDefinitions() self.config.add_layer_widget('layerId', self.layer) diff --git a/lizmap/forms/tooltip_edition.py b/lizmap/forms/tooltip_edition.py index d2d43db0..7e29bd1b 100755 --- a/lizmap/forms/tooltip_edition.py +++ b/lizmap/forms/tooltip_edition.py @@ -3,6 +3,7 @@ from qgis.core import QgsMapLayerProxyModel from qgis.PyQt.QtGui import QColor +from lizmap.definitions.definitions import LwcVersions from lizmap.definitions.tooltip import ToolTipDefinitions from lizmap.forms.base_edition_dialog import BaseEditionDialog from lizmap.qgis_plugin_tools.tools.i18n import tr @@ -18,8 +19,8 @@ class ToolTipEditionDialog(BaseEditionDialog, CLASS): - def __init__(self, parent=None, unicity=None): - super().__init__(parent, unicity) + def __init__(self, parent=None, unicity=None, lwc_version: LwcVersions = None): + super().__init__(parent, unicity, lwc_version) self.setupUi(self) self.config = ToolTipDefinitions() self.config.add_layer_widget('layerId', self.layer) diff --git a/lizmap/plugin.py b/lizmap/plugin.py index 91b56e2a..2344de0c 100755 --- a/lizmap/plugin.py +++ b/lizmap/plugin.py @@ -884,8 +884,7 @@ def target_server_changed(self): self.dlg.refresh_combo_repositories() current_version = self.current_lwc_version() - old_version = QgsSettings().value( - 'lizmap/lizmap_web_client_version', LwcVersions.latest().value, str) + old_version = QgsSettings().value('lizmap/lizmap_web_client_version', type=str) if current_version != old_version: self.lwc_version_changed() self.dlg.check_qgis_version(widget=True)