Skip to content

Commit

Permalink
Merge pull request #709 from kartoza/carolina-fixes
Browse files Browse the repository at this point in the history
Carolina fixes
  • Loading branch information
timlinux authored Dec 11, 2024
2 parents 0de5c6f + 067108c commit 82c77e9
Show file tree
Hide file tree
Showing 12 changed files with 541 additions and 23 deletions.
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
38 changes: 35 additions & 3 deletions geest/gui/dialogs/analysis_aggregation_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -47,7 +48,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)
Expand Down Expand Up @@ -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 <a href='https://worldbank.github.io/GEEST/docs/user_guide.html'>GEEST User Guide</a>."
)
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
Expand Down Expand Up @@ -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")
Expand Down
41 changes: 35 additions & 6 deletions geest/gui/dialogs/dimension_aggregation_dialog.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -51,7 +49,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)
Expand Down Expand Up @@ -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 <a href='https://worldbank.github.io/GEEST/docs/user_guide.html'>GEEST User Guide</a>."
)
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
Expand All @@ -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")
Expand Down
40 changes: 35 additions & 5 deletions geest/gui/dialogs/factor_aggregation_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -51,9 +52,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)

Expand Down Expand Up @@ -116,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 <a href='https://worldbank.github.io/GEEST/docs/user_guide.html'>GEEST User Guide</a>."
)
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
Expand Down Expand Up @@ -143,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.
Expand Down
6 changes: 3 additions & 3 deletions geest/gui/panels/tree_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
5 changes: 3 additions & 2 deletions geest/gui/widgets/datasource_widgets/csv_datasource_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
QLineEdit,
QToolButton,
QFileDialog,
QMessageBox,
)
from qgis.core import Qgis
from .base_datasource_widget import BaseDataSourceWidget
Expand All @@ -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"

Expand Down Expand Up @@ -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.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
88 changes: 88 additions & 0 deletions geest/resources/icons/help.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added geest/resources/images/help.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 82c77e9

Please sign in to comment.