Skip to content

Commit

Permalink
Implement help text under each dialog.
Browse files Browse the repository at this point in the history
Fixes please include link to GitHub User Manual in all set-up windows #697
  • Loading branch information
timlinux committed Dec 11, 2024
1 parent 5e366ed commit baaf2b8
Show file tree
Hide file tree
Showing 5 changed files with 190 additions and 9 deletions.
36 changes: 34 additions & 2 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 @@ -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
39 changes: 34 additions & 5 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 @@ -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
36 changes: 34 additions & 2 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 @@ -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 <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 @@ -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.
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.

0 comments on commit baaf2b8

Please sign in to comment.