Skip to content

Commit

Permalink
UX - Disable or enable buttons easily
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry committed Oct 25, 2023
1 parent 638575c commit eb34884
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
16 changes: 12 additions & 4 deletions lizmap/dialogs/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,7 @@ def __init__(self, parent=None):
'These tools can fix your current loaded layers in <b>this project only</b>. '
'You still need to update your connection or default settings in your QGIS global settings, to be be '
'applied automatically for new project or newly added layer.'))
self.enabled_ssl_button(False)
self.enabled_estimated_md_button(False)
self.enabled_trust_project(False)
self.enabled_simplify_geom(False)
self.enable_all_fixer_buttons(False)

self.button_convert_ssl.clicked.connect(self.fix_project_ssl)
self.button_convert_ssl.setIcon(QIcon(":images/themes/default/mIconPostgis.svg"))
Expand Down Expand Up @@ -246,6 +243,13 @@ def enabled_simplify_geom(self, status: bool):
""" Enable or not the button. """
self.button_simplify_geom.setEnabled(status)

def enable_all_fixer_buttons(self, status: bool):
""" Enable or disable all buttons about fixing the project. """
self.enabled_ssl_button(status)
self.enabled_estimated_md_button(status)
self.enabled_trust_project(status)
self.enabled_simplify_geom(status)

def follow_map_theme_toggled(self):
""" If the theme is loaded at startup, the UX is updated about the toggled checkbox and the legend option. """
text = ". " + tr("Overriden by the map theme")
Expand Down Expand Up @@ -737,6 +741,7 @@ def allow_navigation(self, allow_navigation: bool, message: str = ''):

def fix_project_ssl(self):
""" Fix the current project about SSL. """
self.enabled_ssl_button(False)
with OverrideCursor(Qt.WaitCursor):
count = fix_ssl(self.project, force=False)

Expand All @@ -748,6 +753,7 @@ def fix_project_ssl(self):

def fix_project_estimated_md(self):
""" Fix the current project about estimated metadata. """
self.enabled_estimated_md_button(False)
with OverrideCursor(Qt.WaitCursor):
count = len(use_estimated_metadata(self.project, fix=True))

Expand All @@ -759,11 +765,13 @@ def fix_project_estimated_md(self):

def fix_project_trust(self):
""" Fix the current project trust metadata. """
self.enabled_trust_project(False)
project_trust_layer_metadata(self.project, True)
self.display_message_bar(tr("Trust project"), tr('Trust project is enabled'), Qgis.Success)

def fix_simplify_geom_provider(self):
""" Fix the current layers simplify geom. """
self.enabled_simplify_geom(False)
with OverrideCursor(Qt.WaitCursor):
count = len(simplify_provider_side(self.project, fix=True))

Expand Down
2 changes: 1 addition & 1 deletion lizmap/log_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def append(
if time:
now = QDateTime.currentDateTime()
now_str = now.toString(QLocale().timeFormat(QLocale.ShortFormat))
self.widget.append(now_str)
msg = now_str + ' : ' + msg

if level == Qgis.Warning:
# byte_array = QByteArray()
Expand Down
7 changes: 5 additions & 2 deletions lizmap/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2804,6 +2804,9 @@ def project_config_file(
""" Generate the CFG file with all options. """
valid, _ = self.check_project_validity()

if with_gui:
self.dlg.enable_all_fixer_buttons(False)

LOGGER.info("Writing CFG file for LWC version {}".format(lwc_version.value))
current_version = self.global_options['metadata']['lizmap_plugin_version']['default']
if self.is_dev_version:
Expand Down Expand Up @@ -3036,7 +3039,7 @@ def project_config_file(
self.dlg.log_panel.append(tr('Issues which can be fixed automatically'), Html.H2)
self.dlg.log_panel.append(tr(
'You have issue(s) listed above, and there is a wizard to auto fix your project. Saving the '
'configuration file is stopping.'), Html.Strong)
'configuration file is stopping.'), Html.Strong, time=True)
self.dlg.display_message_bar(
"Error", tr('You must fix some issues about this project'), Qgis.Critical)
return None
Expand Down Expand Up @@ -3680,7 +3683,7 @@ def save_cfg_file(
msg = tr('Lizmap configuration file has been updated')
# self.dlg.log_panel.append(tr('All the map parameters are correctly set'), abort=False, time=True)
self.dlg.log_panel.append("<p>")
self.dlg.log_panel.append(msg, style=Html.Strong, abort=False)
self.dlg.log_panel.append(msg, style=Html.Strong, abort=False, time=True)
self.dlg.log_panel.append("</p>")

self.get_min_max_scales()
Expand Down

0 comments on commit eb34884

Please sign in to comment.