Skip to content

Commit

Permalink
Add new panel for autofix buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry committed Dec 7, 2023
1 parent 2edabf1 commit 9570c9c
Show file tree
Hide file tree
Showing 4 changed files with 203 additions and 126 deletions.
55 changes: 39 additions & 16 deletions lizmap/definitions/online_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,46 @@ def online_lwc_help(page: str = '', version=VERSION) -> QUrl:

# When editing this mapping, it must be done in the definition/corresponding.py file

class Panels:
Information = 0
MapOptions = 1
Layers = 2
Basemap = 3
AttributeTable = 4
Editing = 5
Layouts = 6
FormFiltering = 7
Dataviz = 8
FilteredLayers = 9
Actions = 10
TimeManager = 11
Atlas = 12
LocateByLayer = 13
ToolTip = 14
Checks = 15
AutoFix = 16
Settings = 17


MAPPING_INDEX_DOC = {
0: 'publish/lizmap_plugin/information.html',
1: 'publish/lizmap_plugin/map_options.html',
2: 'publish/lizmap_plugin/layers.html',
3: 'publish/lizmap_plugin/basemap.html',
4: 'publish/lizmap_plugin/attribute_table.html',
5: 'publish/lizmap_plugin/editing.html',
6: None, # Layouts
7: 'publish/lizmap_plugin/form_filtering.html',
8: 'publish/lizmap_plugin/dataviz.html',
9: 'publish/lizmap_plugin/filtered_layers_login.html',
10: 'publish/configuration/action_popup.html', # TODO move into the plugin section
11: 'publish/lizmap_plugin/time_manager.html',
12: 'publish/lizmap_plugin/atlas.html',
13: 'publish/lizmap_plugin/locate_by_layer.html',
14: 'publish/lizmap_plugin/tooltip.html',
15: None,
Panels.Information: 'publish/lizmap_plugin/information.html',
Panels.MapOptions: 'publish/lizmap_plugin/map_options.html',
Panels.Layers: 'publish/lizmap_plugin/layers.html',
Panels.Basemap: 'publish/lizmap_plugin/basemap.html',
Panels.AttributeTable: 'publish/lizmap_plugin/attribute_table.html',
Panels.Editing: 'publish/lizmap_plugin/editing.html',
Panels.Layouts: None, # Layouts
Panels.FormFiltering: 'publish/lizmap_plugin/form_filtering.html',
Panels.Dataviz: 'publish/lizmap_plugin/dataviz.html',
Panels.FilteredLayers: 'publish/lizmap_plugin/filtered_layers_login.html',
Panels.Actions: 'publish/configuration/action_popup.html', # TODO move into the plugin section
Panels.TimeManager: 'publish/lizmap_plugin/time_manager.html',
Panels.Atlas: 'publish/lizmap_plugin/atlas.html',
Panels.LocateByLayer: 'publish/lizmap_plugin/locate_by_layer.html',
Panels.ToolTip: 'publish/lizmap_plugin/tooltip.html',
Panels.Checks: None, # Log/checks
Panels.AutoFix: None, # Auto-fix
Panels.Settings: None, # Settings
}


Expand Down
124 changes: 53 additions & 71 deletions lizmap/dialogs/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@
RepositoryComboData,
ServerComboData,
)
from lizmap.definitions.online_help import online_lwc_help, pg_service_help
from lizmap.definitions.online_help import (
Panels,
online_lwc_help,
pg_service_help,
)
from lizmap.qgis_plugin_tools.tools.i18n import tr
from lizmap.qgis_plugin_tools.tools.resources import load_ui, resources_path
from lizmap.qt_style_sheets import COMPLETE_STYLE_SHEET
Expand Down Expand Up @@ -131,13 +135,16 @@ def __init__(self, parent=None, is_dev_version=True):
"<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()
settings_name = self.mOptionsListWidget.item(Panels.Settings).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"))
self.label_check_resume.setVisible(False)
self.label_autofix.setVisible(False)
self.push_visit_settings.setVisible(False)

# Filtering features
self.tab_filtering.setCurrentIndex(0)
Expand Down Expand Up @@ -427,7 +434,7 @@ def check_ign_french_free_key(self):

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

def auto_fix_tooltip(self, lizmap_cloud):
""" Set some tooltips on these auto-fix buttons, according to Lizmap Cloud status. """
Expand Down Expand Up @@ -745,7 +752,6 @@ def display_message_bar(
def setup_icons(self):
""" Setup icons in the left menu. """
self.mOptionsListWidget.setIconSize(QSize(20, 20))
i = 0

# If adding a new panel, all mOptionsListWidget.item(X) must be checked
# definitions/online_help.py about mapping as well
Expand All @@ -755,136 +761,124 @@ def setup_icons(self):
icon = QIcon()
icon.addFile(resources_path('icons', '03-metadata-white'), mode=QIcon.Normal)
icon.addFile(resources_path('icons', '03-metadata-dark'), mode=QIcon.Selected)
self.mOptionsListWidget.item(i).setIcon(icon)
self.mOptionsListWidget.item(i).setData(Qt.UserRole, 'info')
i += 1
self.mOptionsListWidget.item(Panels.Information).setIcon(icon)
self.mOptionsListWidget.item(Panels.Information).setData(Qt.UserRole, 'info')

# Map options
icon = QIcon()
icon.addFile(resources_path('icons', '15-baselayer-white.png'), mode=QIcon.Normal)
icon.addFile(resources_path('icons', '15-baselayer-dark.png'), mode=QIcon.Selected)
self.mOptionsListWidget.item(i).setIcon(icon)
self.mOptionsListWidget.item(i).setData(Qt.UserRole, 'map-options')
i += 1
self.mOptionsListWidget.item(Panels.MapOptions).setIcon(icon)
self.mOptionsListWidget.item(Panels.MapOptions).setData(Qt.UserRole, 'map-options')

# Layers
icon = QIcon()
icon.addFile(resources_path('icons', '02-switcher-white.png'), mode=QIcon.Normal)
icon.addFile(resources_path('icons', '02-switcher-dark.png'), mode=QIcon.Selected)
self.mOptionsListWidget.item(i).setIcon(icon)
self.mOptionsListWidget.item(i).setData(Qt.UserRole, 'layers')
i += 1
self.mOptionsListWidget.item(Panels.Layers).setIcon(icon)
self.mOptionsListWidget.item(Panels.Layers).setData(Qt.UserRole, 'layers')

# Base layer
icon = QIcon()
icon.addFile(resources_path('icons', '02-switcher-white.png'), mode=QIcon.Normal)
icon.addFile(resources_path('icons', '02-switcher-dark.png'), mode=QIcon.Selected)
self.mOptionsListWidget.item(i).setIcon(icon)
self.mOptionsListWidget.item(i).setData(Qt.UserRole, 'base-layers')
i += 1
self.mOptionsListWidget.item(Panels.Basemap).setIcon(icon)
self.mOptionsListWidget.item(Panels.Basemap).setData(Qt.UserRole, 'base-layers')

# Attribute table
icon = QIcon()
icon.addFile(resources_path('icons', '11-attribute-white.png'), mode=QIcon.Normal)
icon.addFile(resources_path('icons', '11-attribute-dark.png'), mode=QIcon.Selected)
self.mOptionsListWidget.item(i).setIcon(icon)
self.mOptionsListWidget.item(i).setData(Qt.UserRole, 'attribute-table')
i += 1
self.mOptionsListWidget.item(Panels.AttributeTable).setIcon(icon)
self.mOptionsListWidget.item(Panels.AttributeTable).setData(Qt.UserRole, 'attribute-table')

# Layer editing
icon = QIcon()
icon.addFile(resources_path('icons', '10-edition-white.png'), mode=QIcon.Normal)
icon.addFile(resources_path('icons', '10-edition-dark.png'), mode=QIcon.Selected)
self.mOptionsListWidget.item(i).setIcon(icon)
self.mOptionsListWidget.item(i).setData(Qt.UserRole, 'layer-editing')
i += 1
self.mOptionsListWidget.item(Panels.Editing).setIcon(icon)
self.mOptionsListWidget.item(Panels.Editing).setData(Qt.UserRole, 'layer-editing')

# Layouts
icon = QIcon()
icon.addFile(resources_path('icons', '08-print-white.png'), mode=QIcon.Normal)
icon.addFile(resources_path('icons', '08-print-dark.png'), mode=QIcon.Selected)
self.mOptionsListWidget.item(i).setIcon(icon)
self.mOptionsListWidget.item(i).setData(Qt.UserRole, 'layouts')
i += 1
self.mOptionsListWidget.item(Panels.Layouts).setIcon(icon)
self.mOptionsListWidget.item(Panels.Layouts).setData(Qt.UserRole, 'layouts')

# Filter data with form
icon = QIcon()
icon.addFile(resources_path('icons', 'filter-icon-white.png'), mode=QIcon.Normal)
icon.addFile(resources_path('icons', 'filter-icon-dark.png'), mode=QIcon.Selected)
self.mOptionsListWidget.item(i).setIcon(icon)
self.mOptionsListWidget.item(i).setData(Qt.UserRole, 'filter-data-form')
i += 1
self.mOptionsListWidget.item(Panels.FormFiltering).setIcon(icon)
self.mOptionsListWidget.item(Panels.FormFiltering).setData(Qt.UserRole, 'filter-data-form')

# Dataviz
icon = QIcon()
icon.addFile(resources_path('icons', 'dataviz-icon-white.png'), mode=QIcon.Normal)
icon.addFile(resources_path('icons', 'dataviz-icon-dark.png'), mode=QIcon.Selected)
self.mOptionsListWidget.item(i).setIcon(icon)
self.mOptionsListWidget.item(i).setData(Qt.UserRole, 'dataviz')
i += 1
self.mOptionsListWidget.item(Panels.Dataviz).setIcon(icon)
self.mOptionsListWidget.item(Panels.Dataviz).setData(Qt.UserRole, 'dataviz')

# Filter layer by user
icon = QIcon()
icon.addFile(resources_path('icons', '12-user-white.png'), mode=QIcon.Normal)
icon.addFile(resources_path('icons', '12-user-dark.png'), mode=QIcon.Selected)
self.mOptionsListWidget.item(i).setIcon(icon)
self.mOptionsListWidget.item(i).setData(Qt.UserRole, 'filter-data-user')
i += 1
self.mOptionsListWidget.item(Panels.FilteredLayers).setIcon(icon)
self.mOptionsListWidget.item(Panels.FilteredLayers).setData(Qt.UserRole, 'filter-data-user')

# Actions
icon = QIcon()
icon.addFile(resources_path('icons', 'actions-white.svg'), mode=QIcon.Normal)
icon.addFile(resources_path('icons', 'actions-dark.svg'), mode=QIcon.Selected)
self.mOptionsListWidget.item(i).setIcon(icon)
self.mOptionsListWidget.item(i).setData(Qt.UserRole, 'actions')
i += 1
self.mOptionsListWidget.item(Panels.Actions).setIcon(icon)
self.mOptionsListWidget.item(Panels.Actions).setData(Qt.UserRole, 'actions')

# Time manager
icon = QIcon()
icon.addFile(resources_path('icons', '13-timemanager-white.png'), mode=QIcon.Normal)
icon.addFile(resources_path('icons', '13-timemanager-dark.png'), mode=QIcon.Selected)
self.mOptionsListWidget.item(i).setIcon(icon)
self.mOptionsListWidget.item(i).setData(Qt.UserRole, 'time-manager')
i += 1
self.mOptionsListWidget.item(Panels.TimeManager).setIcon(icon)
self.mOptionsListWidget.item(Panels.TimeManager).setData(Qt.UserRole, 'time-manager')

# Atlas
icon = QIcon()
icon.addFile(resources_path('icons', 'atlas-icon-white.png'), mode=QIcon.Normal)
icon.addFile(resources_path('icons', 'atlas-icon-dark.png'), mode=QIcon.Selected)
self.mOptionsListWidget.item(i).setIcon(icon)
self.mOptionsListWidget.item(i).setData(Qt.UserRole, 'atlas')
i += 1
self.mOptionsListWidget.item(Panels.Atlas).setIcon(icon)
self.mOptionsListWidget.item(Panels.Atlas).setData(Qt.UserRole, 'atlas')

# Locate by layer
icon = QIcon()
icon.addFile(resources_path('icons', '04-locate-white.png'), mode=QIcon.Normal)
icon.addFile(resources_path('icons', '04-locate-dark.png'), mode=QIcon.Selected)
self.mOptionsListWidget.item(i).setIcon(icon)
self.mOptionsListWidget.item(i).setData(Qt.UserRole, 'locate-by-layer')
i += 1
self.mOptionsListWidget.item(Panels.LocateByLayer).setIcon(icon)
self.mOptionsListWidget.item(Panels.LocateByLayer).setData(Qt.UserRole, 'locate-by-layer')

# Tooltip layer
icon = QIcon()
icon.addFile(resources_path('icons', '16-tooltip-white.png'), mode=QIcon.Normal)
icon.addFile(resources_path('icons', '16-tooltip-dark.png'), mode=QIcon.Selected)
self.mOptionsListWidget.item(i).setIcon(icon)
self.mOptionsListWidget.item(i).setData(Qt.UserRole, 'tooltip-layer')
i += 1
self.mOptionsListWidget.item(Panels.ToolTip).setIcon(icon)
self.mOptionsListWidget.item(Panels.ToolTip).setData(Qt.UserRole, 'tooltip-layer')

# Log
# It must be the before last tab
# Checks
# noinspection PyCallByClass,PyArgumentList
icon = QIcon(QgsApplication.iconPath('mMessageLog.svg'))
self.mOptionsListWidget.item(i).setIcon(icon)
self.mOptionsListWidget.item(i).setData(Qt.UserRole, 'log')
i += 1
icon = QIcon(QIcon(':/geometrychecker/icons/geometrychecker.svg'))
self.mOptionsListWidget.item(Panels.Checks).setIcon(icon)
self.mOptionsListWidget.item(Panels.Checks).setData(Qt.UserRole, 'log')

# Settings
# Auto-fix
# noinspection PyCallByClass,PyArgumentList
icon = QIcon(":images/themes/default/console/iconSettingsConsole.svg")
self.mOptionsListWidget.item(i).setIcon(icon)
self.mOptionsListWidget.item(i).setData(Qt.UserRole, 'settings')
i += 1
self.mOptionsListWidget.item(Panels.AutoFix).setIcon(icon)
self.mOptionsListWidget.item(Panels.AutoFix).setData(Qt.UserRole, 'auto-fix')

# Settings
# noinspection PyCallByClass,PyArgumentList
icon = QIcon(":/images/themes/default/propertyicons/settings.svg")
self.mOptionsListWidget.item(Panels.Settings).setIcon(icon)
self.mOptionsListWidget.item(Panels.Settings).setData(Qt.UserRole, 'settings')

# Set stylesheet for QGroupBox
q_group_box = (
Expand Down Expand Up @@ -990,18 +984,6 @@ 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
11 changes: 6 additions & 5 deletions lizmap/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
from lizmap.definitions.locate_by_layer import LocateByLayerDefinitions
from lizmap.definitions.online_help import (
MAPPING_INDEX_DOC,
Panels,
online_cloud_help,
online_lwc_help,
)
Expand Down Expand Up @@ -848,7 +849,7 @@ def project_saved(self):
).format(
count_qgs=count_qgs,
count_cfg=count_cfg,
layer_tab=self.dlg.mOptionsListWidget.item(2).text()
layer_tab=self.dlg.mOptionsListWidget.item(Panels.Layers).text()
),
Qgis.Warning,
duration=DURATION_WARNING_BAR,
Expand Down Expand Up @@ -1333,7 +1334,7 @@ def initGui(self):
QgsExpression.addVariableHelpText("lizmap_repository", tr("The current repository ID on the server."))

# Let's fix the dialog to the first panel
self.dlg.mOptionsListWidget.setCurrentRow(0)
self.dlg.mOptionsListWidget.setCurrentRow(Panels.Information)

def check_dialog_validity(self) -> bool:
""" Check the global dialog validity if we have :
Expand Down Expand Up @@ -2596,7 +2597,7 @@ def _add_base_layer(self, source: str, name: str, attribution_url: str = None, a
self.dlg.display_message_bar(
tr('New layer'),
tr('Please close and reopen the dialog to display your layer in the tab "{tab_name}".').format(
tab_name=self.dlg.mOptionsListWidget.item(2).text()
tab_name=self.dlg.mOptionsListWidget.item(Panels.Layers).text()
),
Qgis.Warning,
)
Expand Down Expand Up @@ -3128,7 +3129,7 @@ def project_config_file(
self.dlg.check_results.sort()

if with_gui and self.dlg.check_results.has_rows():
self.dlg.mOptionsListWidget.setCurrentRow(self.dlg.mOptionsListWidget.count() - 2)
self.dlg.mOptionsListWidget.setCurrentRow(Panels.Checks)
self.dlg.tab_log.setCurrentIndex(0)
self.dlg.out_log.moveCursor(QTextCursor.Start)
self.dlg.out_log.ensureCursorVisible()
Expand Down Expand Up @@ -4144,7 +4145,7 @@ def run(self) -> bool:
if not self.check_dialog_validity():
# Go back to the first panel because no project loaded.
# Otherwise, the plugin opens the latest valid panel before the previous project has been closed.
self.dlg.mOptionsListWidget.setCurrentRow(0)
self.dlg.mOptionsListWidget.setCurrentRow(Panels.Information)

self.dlg.show()

Expand Down
Loading

0 comments on commit 9570c9c

Please sign in to comment.