From ed65810a4e093450e3998e8f76ea2299f26e5ca8 Mon Sep 17 00:00:00 2001 From: Tim Sutton Date: Wed, 11 Dec 2024 21:26:32 +0000 Subject: [PATCH 1/4] Fix more places where log_message is not passed correct params --- geest/gui/panels/tree_panel.py | 6 +- .../index_score_configuration_widget.py | 2 +- .../acled_csv_datasource_widget.py | 2 +- .../csv_datasource_widget.py | 5 +- .../vector_and_field_datasource_widget.py | 2 +- geest/resources/models/insights.model3 | 338 ++++++++++++++++++ 6 files changed, 347 insertions(+), 8 deletions(-) create mode 100644 geest/resources/models/insights.model3 diff --git a/geest/gui/panels/tree_panel.py b/geest/gui/panels/tree_panel.py index 1f299085..b4ab979f 100644 --- a/geest/gui/panels/tree_panel.py +++ b/geest/gui/panels/tree_panel.py @@ -331,7 +331,7 @@ def working_directory_changed(self, new_directory): else: log_message( f"No model.json found in {new_directory}, using default.", - "Geest", + tag="Geest", level=Qgis.Warning, ) # copy the default model.json to the working directory @@ -343,7 +343,7 @@ def working_directory_changed(self, new_directory): except Exception as e: log_message( f"Error copying master model.json: {str(e)}", - "Geest", + tag="Geest", level=Qgis.Critical, ) self.load_json() @@ -364,7 +364,7 @@ def save_json_to_working_directory(self): if not self.working_directory: log_message( "No working directory set, cannot save JSON.", - "Geest", + tag="Geest", level=Qgis.Warning, ) try: diff --git a/geest/gui/widgets/configuration_widgets/index_score_configuration_widget.py b/geest/gui/widgets/configuration_widgets/index_score_configuration_widget.py index e058fcbd..e0997d1a 100644 --- a/geest/gui/widgets/configuration_widgets/index_score_configuration_widget.py +++ b/geest/gui/widgets/configuration_widgets/index_score_configuration_widget.py @@ -36,7 +36,7 @@ def set_internal_widgets_enabled(self, enabled: bool) -> None: except Exception as e: log_message( f"Error in set_internal_widgets_enabled: {e}", - "Geest", + tag="Geest", level=Qgis.Critical, ) diff --git a/geest/gui/widgets/datasource_widgets/acled_csv_datasource_widget.py b/geest/gui/widgets/datasource_widgets/acled_csv_datasource_widget.py index f0a014a0..9ab96ca1 100644 --- a/geest/gui/widgets/datasource_widgets/acled_csv_datasource_widget.py +++ b/geest/gui/widgets/datasource_widgets/acled_csv_datasource_widget.py @@ -101,7 +101,7 @@ def validate_csv_file(self, file_path: str) -> None: if missing_columns: error_message = f"Missing columns: {', '.join(missing_columns)}" - log_message(error_message, "Geest", Qgis.Critical) + log_message(error_message, tag="Geest", level=Qgis.Critical) QMessageBox.critical(self, "Invalid CSV", error_message) else: log_message("CSV file validation successful.") diff --git a/geest/gui/widgets/datasource_widgets/csv_datasource_widget.py b/geest/gui/widgets/datasource_widgets/csv_datasource_widget.py index 724a0217..1e8e7961 100644 --- a/geest/gui/widgets/datasource_widgets/csv_datasource_widget.py +++ b/geest/gui/widgets/datasource_widgets/csv_datasource_widget.py @@ -3,6 +3,7 @@ QLineEdit, QToolButton, QFileDialog, + QMessageBox, ) from qgis.core import Qgis from .base_datasource_widget import BaseDataSourceWidget @@ -27,7 +28,7 @@ def add_internal_widgets(self) -> None: Adds the internal widgets required for selecting the CSV firadiole and validating its format. This method is called during the widget initialization and sets up the layout for the UI components. """ - log_message("Adding internal widgets for ACLED CSV Layer Widget", "Geest") + log_message("Adding internal widgets for ACLED CSV Layer Widget") try: self.widget_key = "use_csv_to_point_layer" @@ -100,7 +101,7 @@ def validate_csv_file(self, file_path: str) -> None: if missing_columns: error_message = f"Missing columns: {', '.join(missing_columns)}" - log_message(error_message, "Geest", Qgis.Critical) + log_message(error_message, tag="Geest", level=Qgis.Critical) QMessageBox.critical(self, "Invalid CSV", error_message) else: log_message("CSV file validation successful.") diff --git a/geest/gui/widgets/datasource_widgets/vector_and_field_datasource_widget.py b/geest/gui/widgets/datasource_widgets/vector_and_field_datasource_widget.py index de70c260..3ab63921 100644 --- a/geest/gui/widgets/datasource_widgets/vector_and_field_datasource_widget.py +++ b/geest/gui/widgets/datasource_widgets/vector_and_field_datasource_widget.py @@ -156,7 +156,7 @@ def _populate_field_combo(self, shapefile_path: str) -> None: vector_layer = QgsVectorLayer(shapefile_path, "layer", "ogr") if not vector_layer.isValid(): - log_message(f"Failed to load shapefile: {shapefile_path}", "Geest") + log_message(f"Failed to load shapefile: {shapefile_path}") return # Set the vector layer on the field selection combo box, which will automatically populate it diff --git a/geest/resources/models/insights.model3 b/geest/resources/models/insights.model3 new file mode 100644 index 00000000..a3d1c35a --- /dev/null +++ b/geest/resources/models/insights.model3 @@ -0,0 +1,338 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 5e366edf0685437de8f23e76a589a01f074fc40a Mon Sep 17 00:00:00 2001 From: Tim Sutton Date: Wed, 11 Dec 2024 21:33:49 +0000 Subject: [PATCH 2/4] Fix please rename Tab description #696 --- geest/gui/dialogs/analysis_aggregation_dialog.py | 2 +- geest/gui/dialogs/dimension_aggregation_dialog.py | 2 +- geest/gui/dialogs/factor_aggregation_dialog.py | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/geest/gui/dialogs/analysis_aggregation_dialog.py b/geest/gui/dialogs/analysis_aggregation_dialog.py index 0e5d7a6b..7f41c8ff 100644 --- a/geest/gui/dialogs/analysis_aggregation_dialog.py +++ b/geest/gui/dialogs/analysis_aggregation_dialog.py @@ -47,7 +47,7 @@ def __init__(self, analysis_item, parent=None): # Title label self.title_label = QLabel( - "Geospatial Assessment of Women Employment and Business Opportunities in the Renewable Energy Sector", + "The Gender Enabling Environments Spatial Tool", self, ) self.title_label.setWordWrap(True) diff --git a/geest/gui/dialogs/dimension_aggregation_dialog.py b/geest/gui/dialogs/dimension_aggregation_dialog.py index 21d63a48..6b90639b 100644 --- a/geest/gui/dialogs/dimension_aggregation_dialog.py +++ b/geest/gui/dialogs/dimension_aggregation_dialog.py @@ -51,7 +51,7 @@ def __init__(self, dimension_name, dimension_data, dimension_item, parent=None): # Title label self.title_label = QLabel( - "Geospatial Assessment of Women Employment and Business Opportunities in the Renewable Energy Sector", + "The Gender Enabling Environments Spatial Tool", self, ) self.title_label.setWordWrap(True) diff --git a/geest/gui/dialogs/factor_aggregation_dialog.py b/geest/gui/dialogs/factor_aggregation_dialog.py index ca19c77f..0a14956b 100644 --- a/geest/gui/dialogs/factor_aggregation_dialog.py +++ b/geest/gui/dialogs/factor_aggregation_dialog.py @@ -51,9 +51,7 @@ def __init__(self, factor_name, factor_data, factor_item, parent=None): layout.setContentsMargins(20, 20, 20, 20) # Add padding around the layout # Title label - self.title_label = QLabel( - "Geospatial Assessment of Women Employment and Business Opportunities in the Renewable Energy Sector" - ) + self.title_label = QLabel("The Gender Enabling Environments Spatial Tool") self.title_label.setWordWrap(True) layout.addWidget(self.title_label) From baaf2b8d703e23b867d76c2ce3d1764c586a1304 Mon Sep 17 00:00:00 2001 From: Tim Sutton Date: Wed, 11 Dec 2024 23:15:44 +0000 Subject: [PATCH 3/4] Implement help text under each dialog. Fixes please include link to GitHub User Manual in all set-up windows #697 --- .../dialogs/analysis_aggregation_dialog.py | 36 ++++++- .../dialogs/dimension_aggregation_dialog.py | 39 +++++++- .../gui/dialogs/factor_aggregation_dialog.py | 36 ++++++- geest/resources/icons/help.svg | 88 ++++++++++++++++++ geest/resources/images/help.png | Bin 0 -> 904 bytes 5 files changed, 190 insertions(+), 9 deletions(-) create mode 100644 geest/resources/icons/help.svg create mode 100644 geest/resources/images/help.png diff --git a/geest/gui/dialogs/analysis_aggregation_dialog.py b/geest/gui/dialogs/analysis_aggregation_dialog.py index 7f41c8ff..3db1d491 100644 --- a/geest/gui/dialogs/analysis_aggregation_dialog.py +++ b/geest/gui/dialogs/analysis_aggregation_dialog.py @@ -16,9 +16,10 @@ QCheckBox, QWidget, QHBoxLayout, + QSpacerItem, ) -from qgis.PyQt.QtGui import QPixmap -from qgis.PyQt.QtCore import Qt +from qgis.PyQt.QtGui import QPixmap, QDesktopServices +from qgis.PyQt.QtCore import Qt, QUrl from qgis.core import Qgis from geest.utilities import ( resources_path, @@ -179,6 +180,33 @@ def __init__(self, analysis_item, parent=None): layout.addWidget(self.table) + help_layout = QHBoxLayout() + help_layout.addItem( + QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) + ) + self.help_icon = QPixmap(resources_path("resources", "images", "help.png")) + self.help_icon = self.help_icon.scaledToWidth(20) + self.help_label_icon = QLabel() + self.help_label_icon.setPixmap(self.help_icon) + self.help_label_icon.setScaledContents(True) + self.help_label_icon.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) + self.help_label_icon.setMaximumWidth(20) + self.help_label_icon.setAlignment(Qt.AlignRight) + help_layout.addWidget(self.help_label_icon) + + self.help_label = QLabel( + "For detailed instructions on how to use this tool, please refer to the GEEST User Guide." + ) + self.help_label.setOpenExternalLinks(True) + self.help_label.setAlignment(Qt.AlignCenter) + layout.addWidget(self.help_label) + self.help_label.linkActivated.connect(self.open_link_in_browser) + help_layout.addWidget(self.help_label) + help_layout.addItem( + QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) + ) + layout.addLayout(help_layout) + # QDialogButtonBox for OK and Cancel self.button_box = QDialogButtonBox( QDialogButtonBox.Ok | QDialogButtonBox.Cancel @@ -207,6 +235,10 @@ def __init__(self, analysis_item, parent=None): # Initial validation check self.validate_weightings() + def open_link_in_browser(self, url: str): + """Open the given URL in the user's default web browser using QDesktopServices.""" + QDesktopServices.openUrl(QUrl(url)) + def toggle_guid_column(self): """Toggle the visibility of the GUID column.""" log_message("Toggling GUID column visibility") diff --git a/geest/gui/dialogs/dimension_aggregation_dialog.py b/geest/gui/dialogs/dimension_aggregation_dialog.py index 6b90639b..424572a8 100644 --- a/geest/gui/dialogs/dimension_aggregation_dialog.py +++ b/geest/gui/dialogs/dimension_aggregation_dialog.py @@ -1,24 +1,22 @@ from qgis.PyQt.QtWidgets import ( QDialog, QDialogButtonBox, - QFrame, QHeaderView, QLabel, QDoubleSpinBox, QPushButton, QSizePolicy, QSpacerItem, - QSplitter, QTableWidget, QTableWidgetItem, - QTextEdit, QVBoxLayout, QCheckBox, QWidget, QHBoxLayout, + QSpacerItem, ) -from qgis.PyQt.QtGui import QPixmap -from qgis.PyQt.QtCore import Qt +from qgis.PyQt.QtGui import QPixmap, QDesktopServices +from qgis.PyQt.QtCore import Qt, QUrl from qgis.core import Qgis from geest.utilities import ( resources_path, @@ -173,6 +171,33 @@ def __init__(self, dimension_name, dimension_data, dimension_item, parent=None): layout.addWidget(self.table) + help_layout = QHBoxLayout() + help_layout.addItem( + QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) + ) + self.help_icon = QPixmap(resources_path("resources", "images", "help.png")) + self.help_icon = self.help_icon.scaledToWidth(20) + self.help_label_icon = QLabel() + self.help_label_icon.setPixmap(self.help_icon) + self.help_label_icon.setScaledContents(True) + self.help_label_icon.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) + self.help_label_icon.setMaximumWidth(20) + self.help_label_icon.setAlignment(Qt.AlignRight) + help_layout.addWidget(self.help_label_icon) + + self.help_label = QLabel( + "For detailed instructions on how to use this tool, please refer to the GEEST User Guide." + ) + self.help_label.setOpenExternalLinks(True) + self.help_label.setAlignment(Qt.AlignCenter) + layout.addWidget(self.help_label) + self.help_label.linkActivated.connect(self.open_link_in_browser) + help_layout.addWidget(self.help_label) + help_layout.addItem( + QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) + ) + layout.addLayout(help_layout) + # QDialogButtonBox for OK and Cancel self.button_box = QDialogButtonBox( QDialogButtonBox.Ok | QDialogButtonBox.Cancel @@ -199,6 +224,10 @@ def __init__(self, dimension_name, dimension_data, dimension_item, parent=None): # Initial validation check self.validate_weightings() + def open_link_in_browser(self, url: str): + """Open the given URL in the user's default web browser using QDesktopServices.""" + QDesktopServices.openUrl(QUrl(url)) + def toggle_guid_column(self): """Toggle the visibility of the GUID column.""" log_message("Toggling GUID column visibility") diff --git a/geest/gui/dialogs/factor_aggregation_dialog.py b/geest/gui/dialogs/factor_aggregation_dialog.py index 0a14956b..1e830aa2 100644 --- a/geest/gui/dialogs/factor_aggregation_dialog.py +++ b/geest/gui/dialogs/factor_aggregation_dialog.py @@ -12,9 +12,10 @@ QWidget, QCheckBox, QHBoxLayout, + QSpacerItem, ) -from qgis.PyQt.QtGui import QPixmap -from qgis.PyQt.QtCore import Qt +from qgis.PyQt.QtGui import QPixmap, QDesktopServices +from qgis.PyQt.QtCore import Qt, QUrl from qgis.core import Qgis from geest.utilities import resources_path, setting from ..datasource_widget_factory import DataSourceWidgetFactory @@ -114,6 +115,33 @@ def __init__(self, factor_name, factor_data, factor_item, parent=None): layout.addWidget(self.table) + help_layout = QHBoxLayout() + help_layout.addItem( + QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) + ) + self.help_icon = QPixmap(resources_path("resources", "images", "help.png")) + self.help_icon = self.help_icon.scaledToWidth(20) + self.help_label_icon = QLabel() + self.help_label_icon.setPixmap(self.help_icon) + self.help_label_icon.setScaledContents(True) + self.help_label_icon.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) + self.help_label_icon.setMaximumWidth(20) + self.help_label_icon.setAlignment(Qt.AlignRight) + help_layout.addWidget(self.help_label_icon) + + self.help_label = QLabel( + "For detailed instructions on how to use this tool, please refer to the GEEST User Guide." + ) + self.help_label.setOpenExternalLinks(True) + self.help_label.setAlignment(Qt.AlignCenter) + layout.addWidget(self.help_label) + self.help_label.linkActivated.connect(self.open_link_in_browser) + help_layout.addWidget(self.help_label) + help_layout.addItem( + QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) + ) + layout.addLayout(help_layout) + # Buttons self.button_box = QDialogButtonBox( QDialogButtonBox.Ok | QDialogButtonBox.Cancel @@ -141,6 +169,10 @@ def __init__(self, factor_name, factor_data, factor_item, parent=None): self.setLayout(layout) self.populate_table() # Populate the table after initializing data_sources and weightings + def open_link_in_browser(self, url: str): + """Open the given URL in the user's default web browser using QDesktopServices.""" + QDesktopServices.openUrl(QUrl(url)) + def refresh_configuration(self, attributes: dict): """Refresh the configuration widget and table. diff --git a/geest/resources/icons/help.svg b/geest/resources/icons/help.svg new file mode 100644 index 00000000..58bdf37d --- /dev/null +++ b/geest/resources/icons/help.svg @@ -0,0 +1,88 @@ + + + + + + + + + + + + + diff --git a/geest/resources/images/help.png b/geest/resources/images/help.png new file mode 100644 index 0000000000000000000000000000000000000000..ba29fd52d1daf8983cc3ac209bbac4bf3e866d05 GIT binary patch literal 904 zcmV;319$w1P)pF8FWQhbW?9;ba!ELWdL_~cP?peYja~^aAhuUa%Y?FJQ@H10~JX` zK~!jg?b=O<97Pz$@!vbUD<)tRM2#Bp12i61LGdJu;umHG!7qdaJWGJ3KBecFc(FHJp~OY7_!-m8&ou6me)h|klxMeW_Ekh_An0=)m2?RJpX>{ zqnWD6Osgp(ZpSlt6gT47Gs;_7#2!qojO_m{RiHa@ zy7GPsH)N)IS6rxW9>?~!O|JuTx(4`Z9qvFaVx0r40q%5e4BiX3;cQj0yKRFTgbU17 zEc<%ObU&d?7;iT)*jrN;!b4T@fgW~Lg~OTocRRKk)v+qy*27Iz;oEk+G_KQCenk&k ztHMG{W`?F7rmE{v=#tCSYumsuHHPb|#&BKL7_O@t!*x|-xUOmp*Hw+-x~ef;S2c#~ zszwoRbCv%wig4Fe`N>g)o2l~eM+z4aL;67(XYa0z zR$l|dMZ^~6K+CkUm%a;M)S7HjwxOHQYQOah<}>rmS`QBd7ZICq822b$;`z)xxT4wO zAip_GUGPK@5traY+^>M`&CGX(WvmHZ5L`q|D1-K~s_Lc8d~;~78q%6@5fOMxnRelo z%zS;Qt{T*TE(Lg_)@Fa(2WbXeuKpcP`Hbn`KY(7_h8uyy%e8wSVX|$rgQiu-Ttw`} zt5xv`c4g+-28Y5$(RpwY@f`M5#iMvCGyl4%t{PG(-414zkJ5w6;{G)r&dlFh^0r~s zBR7i=6tFqWb{UN2k?ZR??#s;i7W_1-m1FK_JTeMk6u5rmPT`@<{HZ-V&1wR7W0SJZ e9b2P)r}Ph*Od=3QWy4bd0000 Date: Wed, 11 Dec 2024 23:20:20 +0000 Subject: [PATCH 4/4] bump version --- config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.json b/config.json index a168a51d..53b40ade 100644 --- a/config.json +++ b/config.json @@ -16,7 +16,7 @@ "author": "Kartoza", "email": "info@kartoza.com", "description": "Gender Enabling Environments Spatial Tool", - "version": "0.4.1", + "version": "0.4.2", "changelog": "", "server": false }