Skip to content

Commit

Permalink
Review about tooltips and help about autofix
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry committed Dec 7, 2023
1 parent 80d2264 commit 2edabf1
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 15 deletions.
61 changes: 55 additions & 6 deletions lizmap/dialogs/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
use_estimated_metadata,
)
from lizmap.saas import fix_ssl, is_lizmap_cloud
from lizmap.widgets.check_project import Checks, TableCheck
from lizmap.widgets.check_project import Checks, Headers, TableCheck

try:
from qgis.PyQt.QtWebKitWidgets import QWebView
Expand Down Expand Up @@ -123,11 +123,21 @@ def __init__(self, parent=None, is_dev_version=True):
self.lwc_version_latest_changelog.setVisible(False)
self.lwc_version_oldest_changelog.setVisible(False)

self.label_explanations.setText(tr(
"Some checks might be blocking the Lizmap configuration file generation. To fix, either use the tooltip "
"(by hovering your mouse pointer on the table row) in the last column, or check the documentation in "
"the next tab '{tab_name}' for all errors which can be reported."
).format(tab_name=self.tab_log.tabText(1)))
self.label_general_help.setText(
tr("The plugin is doing some checks on your project.") + " "
+ tr(
"To know how to fix these checks, either use the tooltip (by hovering your mouse pointer on the table "
"row) in the last column <strong>'{column_name}'</strong>, or check the documentation in the next tab "
"<strong>'{tab_name}'</strong> for all errors which can be reported."
).format(column_name=Headers.Error.label, tab_name=self.tab_log.tabText(1))
)
settings_name = self.mOptionsListWidget.item(16).text()
self.label_autofix.setText(tr(
"An auto-fix is available in the '{tab_name}' panel"
).format(tab_name=settings_name))
self.push_visit_settings.setText(tr("Visit the '{tab_name}' panel").format(tab_name=settings_name))
self.push_visit_settings.clicked.connect(self.visit_settings_panel)
self.push_visit_settings.setIcon(QIcon(":/images/themes/default/console/iconSettingsConsole.svg"))

# Filtering features
self.tab_filtering.setCurrentIndex(0)
Expand Down Expand Up @@ -415,6 +425,33 @@ def check_ign_french_free_key(self):
else:
self.cbIgnTerrain.setEnabled(True)

def visit_settings_panel(self):
""" Go to settings panel. """
self.mOptionsListWidget.setCurrentRow(self.mOptionsListWidget.count() - 1)

def auto_fix_tooltip(self, lizmap_cloud):
""" Set some tooltips on these auto-fix buttons, according to Lizmap Cloud status. """
self.label_pg_ssl.setToolTip(Checks.SSLConnection.html_tooltip(lizmap_cloud))
self.button_convert_ssl.setToolTip(Checks.SSLConnection.html_tooltip(lizmap_cloud))

self.label_pg_estimated.setToolTip(Checks.EstimatedMetadata.html_tooltip(lizmap_cloud))
self.button_use_estimated_md.setToolTip(Checks.EstimatedMetadata.html_tooltip(lizmap_cloud))

self.label_trust_project.setToolTip(Checks.TrustProject.html_tooltip(lizmap_cloud))
self.button_trust_project.setToolTip(Checks.TrustProject.html_tooltip(lizmap_cloud))

self.label_simplify.setToolTip(Checks.SimplifyGeometry.html_tooltip(lizmap_cloud))
self.button_simplify_geom.setToolTip(Checks.SimplifyGeometry.html_tooltip(lizmap_cloud))

def has_auto_fix(self) -> bool:
""" Return if an auto-fix is enabled. """
return any([
self.button_convert_ssl.isEnabled(),
self.button_use_estimated_md.isEnabled(),
self.button_trust_project.isEnabled(),
self.button_simplify_geom.isEnabled(),
])

def enabled_ssl_button(self, status: bool):
""" Enable or not the button. """
if Qgis.QGIS_VERSION_INT <= 32200:
Expand Down Expand Up @@ -953,6 +990,18 @@ def only_lizmap_cloud(self):
if not is_lizmap_cloud(metadata):
only_cloud = False

self.label_pg_ssl.setToolTip(Checks.SSLConnection.html_tooltip(False))
self.button_convert_ssl.setToolTip(Checks.SSLConnection.html_tooltip(False))

self.label_pg_estimated.setToolTip(Checks.EstimatedMetadata.html_tooltip(False))
self.button_use_estimated_md.setToolTip(Checks.EstimatedMetadata.html_tooltip(False))

self.label_trust_project.setToolTip(Checks.TrustProject.html_tooltip(False))
self.button_trust_project.setToolTip(Checks.TrustProject.html_tooltip(False))

self.label_simplify.setToolTip(Checks.SimplifyGeometry.html_tooltip(False))
self.button_simplify_geom.setToolTip(Checks.SimplifyGeometry.html_tooltip(False))

# These rules are hard coded
# Other rules depends on the user.
widgets = (
Expand Down
14 changes: 14 additions & 0 deletions lizmap/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3133,12 +3133,26 @@ def project_config_file(
self.dlg.out_log.moveCursor(QTextCursor.Start)
self.dlg.out_log.ensureCursorVisible()

beginner_mode = QgsSettings().value(Settings.key(Settings.BeginnerMode), True, bool)
mode = tr('beginner') if beginner_mode else tr('normal')
if self.dlg.check_results.has_blocking():
msg = tr(
'You are using "{mode}" mode and you have some <strong>blocking</strong> checks.').format(mode=mode)
else:
msg = tr('You are using "{mode}"').format(mode=mode)
self.dlg.label_check_resume.setText(msg)

self.dlg.auto_fix_tooltip(is_lizmap_cloud(server_metadata))
self.dlg.label_autofix.setVisible(self.dlg.has_auto_fix())
self.dlg.push_visit_settings.setVisible(self.dlg.has_auto_fix())

if self.dlg.check_results.has_blocking() and not ignore_error:
self.dlg.display_message_bar(
tr("Blocking issue"),
tr("The project has at least one blocking issue. The file is not saved."),
Qgis.Critical,
)

return None

# No more blocking issues, we can continue
Expand Down
47 changes: 39 additions & 8 deletions lizmap/resources/ui/ui_lizmap.ui
Original file line number Diff line number Diff line change
Expand Up @@ -4627,25 +4627,56 @@ This is different to the map maximum extent (defined in QGIS project properties,
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_70">
<item>
<widget class="QLabel" name="label_explanations">
<widget class="QLabel" name="label_general_help">
<property name="text">
<string notr="true">SET IN PYTHON</string>
<string notr="true">SET IN PYTHON, GENERAL HELP</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="TableCheck" name="table_checks"/>
<widget class="QLabel" name="label_check_resume">
<property name="text">
<string notr="true">PYTHON, RESUME</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_20">
<item>
<widget class="QLabel" name="label_autofix">
<property name="text">
<string notr="true">SET IN PYTHON ABOUT AUTO FIX</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="push_visit_settings">
<property name="text">
<string notr="true">SET IN PYTHON</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="export_summary_table">
<property name="text">
<string>Copy in clipboard</string>
<string>Copy results in clipboard</string>
</property>
</widget>
</item>
<item>
<widget class="TableCheck" name="table_checks"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="table_help">
Expand Down Expand Up @@ -4745,7 +4776,7 @@ This is different to the map maximum extent (defined in QGIS project properties,
<item>
<layout class="QFormLayout" name="formLayout_5">
<item row="0" column="0">
<widget class="QLabel" name="label_57">
<widget class="QLabel" name="label_pg_ssl">
<property name="text">
<string>Convert all PostgreSQL layers used in this project to use SSL</string>
</property>
Expand All @@ -4768,7 +4799,7 @@ This is different to the map maximum extent (defined in QGIS project properties,
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_66">
<widget class="QLabel" name="label_pg_estimated">
<property name="text">
<string>Convert all PostgreSQL layers used in this project to 'estimated metadata'</string>
</property>
Expand All @@ -4791,7 +4822,7 @@ This is different to the map maximum extent (defined in QGIS project properties,
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_79">
<widget class="QLabel" name="label_trust_project">
<property name="text">
<string>Enable the trust project option in the project properties dialog</string>
</property>
Expand All @@ -4808,7 +4839,7 @@ This is different to the map maximum extent (defined in QGIS project properties,
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_82">
<widget class="QLabel" name="label_simplify">
<property name="text">
<string>Enable provider geometry simplification when possible in the layer properties dialog</string>
</property>
Expand Down
2 changes: 1 addition & 1 deletion lizmap/test/test_table_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test(self):
self.assertDictEqual(expected, table.to_json_summarized())

expected = (
'Validator summarized :\n\n'
'Validation summarized :\n\n'
'* Duplicated layer name or group → 2\n'
'* Missing a proper primary key in the database. → 1\n'
'\n')
Expand Down

0 comments on commit 2edabf1

Please sign in to comment.