From eb348843106a217b6603014906765495bbf184ee Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Wed, 25 Oct 2023 14:44:21 +0200 Subject: [PATCH] UX - Disable or enable buttons easily --- lizmap/dialogs/main.py | 16 ++++++++++++---- lizmap/log_panel.py | 2 +- lizmap/plugin.py | 7 +++++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lizmap/dialogs/main.py b/lizmap/dialogs/main.py index f74fa55f..e0e291a1 100755 --- a/lizmap/dialogs/main.py +++ b/lizmap/dialogs/main.py @@ -108,10 +108,7 @@ def __init__(self, parent=None): 'These tools can fix your current loaded layers in this project only. ' '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")) @@ -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") @@ -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) @@ -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)) @@ -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)) diff --git a/lizmap/log_panel.py b/lizmap/log_panel.py index 524736e6..67cdb14c 100644 --- a/lizmap/log_panel.py +++ b/lizmap/log_panel.py @@ -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() diff --git a/lizmap/plugin.py b/lizmap/plugin.py index 595e3720..10e55904 100755 --- a/lizmap/plugin.py +++ b/lizmap/plugin.py @@ -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: @@ -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 @@ -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("

") - 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("

") self.get_min_max_scales()