Skip to content

Commit

Permalink
Remove all QgsSettings for LwcVersions, do not use latest again
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry committed Nov 29, 2023
1 parent b86ab97 commit 84793ca
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 30 deletions.
5 changes: 3 additions & 2 deletions lizmap/forms/atlas_edition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions lizmap/forms/attribute_table_edition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
12 changes: 8 additions & 4 deletions lizmap/forms/base_edition_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
10 changes: 4 additions & 6 deletions lizmap/forms/dataviz_edition.py
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions lizmap/forms/edition_edition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lizmap/forms/filter_by_form_edition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions lizmap/forms/filter_by_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions lizmap/forms/filter_by_polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from qgis.core import QgsMapLayerProxyModel

from lizmap.definitions.definitions import LwcVersions
from lizmap.definitions.filter_by_polygon import (
FilterByPolygonDefinitions,
FilterMode,
Expand All @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions lizmap/forms/layout_edition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down
5 changes: 3 additions & 2 deletions lizmap/forms/locate_layer_edition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions lizmap/forms/tooltip_edition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions lizmap/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 84793ca

Please sign in to comment.