Skip to content

Commit

Permalink
UX - Add the new actions panel, for now only the filename used #515
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry committed Sep 18, 2023
1 parent 593887e commit 59b8d2e
Show file tree
Hide file tree
Showing 5 changed files with 158 additions and 2 deletions.
45 changes: 44 additions & 1 deletion lizmap/dialogs/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from typing import Optional

from qgis.core import Qgis, QgsApplication, QgsProject, QgsSettings
from qgis.PyQt.QtCore import Qt
from qgis.PyQt.QtCore import QSize, Qt
from qgis.PyQt.QtGui import QIcon, QImageReader, QPixmap
from qgis.PyQt.QtWidgets import (
QDialog,
Expand Down Expand Up @@ -121,6 +121,26 @@ def __init__(self, parent=None):
"HTML maptip which is the more powerful. This popup will be removed later for vector layer."
))

text = tr(
"Actions in Lizmap Web Client are similar to <a href=\"{}\">Actions in QGIS</a> but it's using it's own "
"format. For now, creating a action requires manual editing of the action configuration file named below. "
"Please check the <a href=\"{}\">Lizmap documentation</a>. There is the 'Feature' scope."
).format(
"https://docs.qgis.org/latest/en/docs/user_manual/working_with_vector/vector_properties.html#"
"actions-properties",
online_lwc_help('publish/configuration/action_popup.html').url()
)
self.label_help_action.setText(text)
self.label_demo_action.setText(tr(
"See the <a href=\"{}\">online demo</a> for an example, using actions in the 'Feature' scope."
).format(
"https://demo.lizmap.com/lizmap/index.php/view/map?repository=features&project=fire_hydrant_actions"))
self.label_file_action.setText(
tr("Configuration file") + " : <a href=\"file://{}\">".format(self.action_file().parent)
+ self.action_file().name + "</a>"
)
self.label_file_action.setOpenExternalLinks(True)

def check_api_key_address(self):
""" Check the API key is provided for the address search bar. """
provider = self.liExternalSearch.currentData()
Expand Down Expand Up @@ -421,6 +441,7 @@ def display_message_bar(

def setup_icons(self):
""" Setup icons in the left menu. """
self.mOptionsListWidget.setIconSize(QSize(20, 20))
i = 0

# Information
Expand Down Expand Up @@ -494,6 +515,14 @@ def setup_icons(self):
self.mOptionsListWidget.item(i).setIcon(icon)
i += 1

# 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)

i += 1

# Time manager
icon = QIcon()
icon.addFile(resources_path('icons', '13-timemanager-white.png'), mode=QIcon.Normal)
Expand Down Expand Up @@ -594,6 +623,19 @@ def check_cfg_file_exists(self) -> bool:
""" Return boolean if a CFG file exists for the given project. """
return self.cfg_file().exists()

def action_file(self) -> Path:
""" Return the path to the current action file. """
return Path(self.project.fileName() + '.action')

def check_action_file_exists(self) -> bool:
""" Return boolean if an action file exists for the given project. """
if self.action_file().is_file():
self.label_file_action_found.setText('✔')
return True

self.label_file_action_found.setText("<strong>" + tr('Not found') + "</strong>")
return False

def allow_navigation(self, allow_navigation: bool, message: str = ''):
""" Allow the navigation or not in the UI. """
for i in range(1, self.mOptionsListWidget.count()):
Expand All @@ -613,5 +655,6 @@ def allow_navigation(self, allow_navigation: bool, message: str = ''):
def activateWindow(self):
""" When the dialog displayed, to trigger functions in the plugin when the dialog is opening. """
self.check_project_thumbnail()
self.check_action_file_exists()
LOGGER.info("Opening the Lizmap dialog.")
super().activateWindow()
9 changes: 8 additions & 1 deletion lizmap/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ def write_log_message(message, tag, level):
self.dlg.list_group_visibility,
self.dlg.activate_first_map_theme,
self.dlg.activate_drawing_tools,
# Actions
self.dlg.label_help_action,
]
self.lwc_versions[LwcVersions.Lizmap_3_5] = [
self.dlg.liPopupSource.model().item(
Expand Down Expand Up @@ -333,10 +335,12 @@ def write_log_message(message, tag, level):
self.dlg.button_edit_dd_dataviz,
self.dlg.button_add_plot,
self.dlg.combo_plots,
# Baselayers
# Base-layers
self.dlg.add_group_empty,
self.dlg.add_group_baselayers,
self.dlg.predefined_baselayers,
# New scopes in actions
self.dlg.label_action_scope_layer_project,
]

self.lizmap_dot_com = [
Expand Down Expand Up @@ -3828,6 +3832,9 @@ def on_project_read(self):

def run(self) -> bool:
"""Plugin run method : launch the GUI."""
self.dlg.check_action_file_exists()
self.dlg.check_project_thumbnail()

if self.dlg.isVisible():
# show dialog in front of QGIS
self.dlg.raise_()
Expand Down
1 change: 1 addition & 0 deletions lizmap/resources/icons/actions-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions lizmap/resources/icons/actions-white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 67 additions & 0 deletions lizmap/resources/ui/ui_lizmap.ui
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ QListWidget::item::selected {
<string>Filter by user</string>
</property>
</item>
<item>
<property name="text">
<string>Actions</string>
</property>
</item>
<item>
<property name="text">
<string>Time manager</string>
Expand Down Expand Up @@ -3872,6 +3877,68 @@ This is different to the map maximum extent (defined in QGIS project properties,
</item>
</layout>
</widget>
<widget class="QWidget" name="page_actions">
<layout class="QVBoxLayout" name="verticalLayout_62">
<item>
<widget class="QLabel" name="label_help_action">
<property name="text">
<string notr="true">Help, set in Python</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_demo_action">
<property name="text">
<string notr="true">Help demo action</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_action_scope_layer_project">
<property name="text">
<string>Actions can have different scopes : 'Feature', 'Layer' or 'Project'.</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_49">
<item>
<widget class="QLabel" name="label_file_action">
<property name="text">
<string notr="true">PROJECT NAME, set in Python</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_file_action_found">
<property name="text">
<string notr="true">Action found, set in Python</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_time_manager">
<layout class="QVBoxLayout" name="verticalLayout_30">
<property name="leftMargin">
Expand Down

0 comments on commit 59b8d2e

Please sign in to comment.