From 5b326e2464622eb87812f76ec936c412c6c7735a Mon Sep 17 00:00:00 2001 From: Tim Sutton Date: Thu, 16 Jan 2025 23:53:23 +0000 Subject: [PATCH 1/3] Scale text size according to panel size Fixes #781 --- geest/gui/panels/intro_panel.py | 30 +++++++++++++--- geest/gui/panels/open_project_panel.py | 22 ++++++++++-- geest/gui/panels/ors_panel.py | 28 +++++++++++++-- geest/gui/widgets/custom_banner_label.py | 10 +++++- geest/ui/intro_panel_base.ui | 46 ++++++++++++++---------- geest/ui/open_project_panel_base.ui | 7 ++-- geest/ui/ors_panel_base.ui | 4 +-- geest/utilities.py | 35 ++++++++++++++++++ 8 files changed, 151 insertions(+), 31 deletions(-) diff --git a/geest/gui/panels/intro_panel.py b/geest/gui/panels/intro_panel.py index 83d8a26f..7804d34a 100644 --- a/geest/gui/panels/intro_panel.py +++ b/geest/gui/panels/intro_panel.py @@ -4,10 +4,14 @@ from qgis.core import Qgis from qgis.PyQt.QtCore import pyqtSignal -from qgis.PyQt.QtGui import QPixmap +from qgis.PyQt.QtGui import QFont from geest.core.tasks import OrsCheckerTask -from geest.utilities import get_ui_class, resources_path -from geest.utilities import log_message +from geest.utilities import ( + get_ui_class, + resources_path, + log_message, + linear_interpolation, +) from geest.gui.widgets import CustomBannerLabel FORM_CLASS = get_ui_class("intro_panel_base.ui") @@ -34,8 +38,26 @@ def initUI(self): parent_layout.replaceWidget(self.banner_label, self.custom_label) self.banner_label.deleteLater() parent_layout.update() - self.next_button.clicked.connect(self.on_next_button_clicked) + self.set_font_size() def on_next_button_clicked(self): self.switch_to_next_tab.emit() + + def resizeEvent(self, event): + self.set_font_size() + super().resizeEvent(event) + + def set_font_size(self): + # Scale the font size to fit the text in the available space + font_size = 16 + threshold = 300 + log_message(f"Intro Label Width: {self.intro_label.rect().width()}") + # scale the font size linearly from 16 pt to 8 ps as the width of the label decreases + # interpolate 16, 8, 300, 200 + font_size = int( + linear_interpolation(self.intro_label.rect().width(), 8, 16, 200, 400) + ) + + log_message(f"Intro Label Font Size: {font_size}") + self.intro_label.setFont(QFont("Arial", font_size)) diff --git a/geest/gui/panels/open_project_panel.py b/geest/gui/panels/open_project_panel.py index 97d940a6..69cba39d 100644 --- a/geest/gui/panels/open_project_panel.py +++ b/geest/gui/panels/open_project_panel.py @@ -6,8 +6,8 @@ Qgis, ) from qgis.PyQt.QtCore import QSettings, pyqtSignal -from qgis.PyQt.QtGui import QPixmap -from geest.utilities import get_ui_class, resources_path +from qgis.PyQt.QtGui import QFont +from geest.utilities import get_ui_class, resources_path, linear_interpolation from geest.core import WorkflowQueueManager from geest.utilities import log_message from geest.gui.widgets import CustomBannerLabel @@ -158,3 +158,21 @@ def load_project(self, working_directory=None): # QMessageBox.critical( # self, "Error", "Selected project does not contain a model.json file." # ) + + def resizeEvent(self, event): + self.set_font_size() + super().resizeEvent(event) + + def set_font_size(self): + # Scale the font size to fit the text in the available space + font_size = 16 + threshold = 300 + log_message(f"Label Width: {self.label.rect().width()}") + # scale the font size linearly from 16 pt to 8 ps as the width of the label decreases + # interpolate 16, 8, 300, 200 + font_size = int( + linear_interpolation(self.label.rect().width(), 8, 16, 200, 400) + ) + + log_message(f"Label Font Size: {font_size}") + self.label.setFont(QFont("Arial", font_size)) diff --git a/geest/gui/panels/ors_panel.py b/geest/gui/panels/ors_panel.py index 3e818564..d1bbee83 100644 --- a/geest/gui/panels/ors_panel.py +++ b/geest/gui/panels/ors_panel.py @@ -2,10 +2,15 @@ QWidget, ) from qgis.PyQt.QtCore import QUrl, pyqtSignal -from qgis.PyQt.QtGui import QPixmap, QDesktopServices +from qgis.PyQt.QtGui import QPixmap, QDesktopServices, QFont from qgis.PyQt.QtWidgets import QMessageBox from geest.core.tasks import OrsCheckerTask -from geest.utilities import get_ui_class, resources_path, log_message +from geest.utilities import ( + get_ui_class, + resources_path, + log_message, + linear_interpolation, +) from geest.core import setting, set_setting from geest.core import WorkflowQueueManager from geest.gui.widgets import CustomBannerLabel @@ -25,6 +30,7 @@ def __init__(self): log_message(f"Loading ORS panel") self.initUI() self.queue_manager = WorkflowQueueManager(pool_size=1) + self.set_font_size() def initUI(self): self.custom_label = CustomBannerLabel( @@ -83,3 +89,21 @@ def on_next_button_clicked(self): def on_previous_button_clicked(self): self.switch_to_previous_tab.emit() + + def resizeEvent(self, event): + self.set_font_size() + super().resizeEvent(event) + + def set_font_size(self): + # Scale the font size to fit the text in the available space + font_size = 16 + threshold = 300 + log_message(f"Label Width: {self.description.rect().width()}") + # scale the font size linearly from 16 pt to 8 ps as the width of the label decreases + # interpolate 16, 8, 300, 200 + font_size = int( + linear_interpolation(self.description.rect().width(), 8, 16, 200, 400) + ) + + log_message(f"Label Font Size: {font_size}") + self.description.setFont(QFont("Arial", font_size)) diff --git a/geest/gui/widgets/custom_banner_label.py b/geest/gui/widgets/custom_banner_label.py index 55e631ee..dc5b8025 100644 --- a/geest/gui/widgets/custom_banner_label.py +++ b/geest/gui/widgets/custom_banner_label.py @@ -4,6 +4,7 @@ ) from qgis.PyQt.QtGui import QPixmap, QPainter, QColor, QFont from qgis.PyQt.QtCore import Qt +from geest.utilities import log_message class CustomBannerLabel(QLabel): @@ -22,8 +23,15 @@ def paintEvent(self, event): # Draw the title text painter.setPen(QColor("white")) - painter.setFont(QFont("Arial", 16)) text_rect = self.rect().adjusted(10, 0, -10, -5) + # Scale the font size to fit the text in the available space + font_size = 16 + threshold = 430 + log_message(f"Banner Label Width: {self.rect().width()}") + if self.rect().width() < threshold: + font_size = int(14 * (self.rect().width() / threshold)) + log_message(f"Font Size: {font_size}") + painter.setFont(QFont("Arial", font_size)) painter.drawText(text_rect, Qt.AlignCenter | Qt.AlignBottom, self.text) painter.end() diff --git a/geest/ui/intro_panel_base.ui b/geest/ui/intro_panel_base.ui index 902f6fbd..4549db4b 100644 --- a/geest/ui/intro_panel_base.ui +++ b/geest/ui/intro_panel_base.ui @@ -93,6 +93,9 @@ + + QFrame::NoFrame + true @@ -101,18 +104,38 @@ 0 0 - 540 - 699 + 556 + 655 + + 0 + + + 0 + + + 0 + + + 0 + - + - <html><head/><body><p align="justify"><span style=" font-size:16pt;">The Gender Enabling Environments Spatial Tool (</span><span style=" font-size:16pt; font-weight:600;">GEEST</span><span style=" font-size:16pt;">), developed by the </span><span style=" font-size:16pt; font-weight:600;">World Bank</span><span style=" font-size:16pt;">, evaluates locations based on how supportive they are of women’s employment and business opportunities.</span></p><p align="justify"><span style=" font-size:16pt;">By incorporating </span><span style=" font-size:16pt; font-weight:600;">15 spatial factors</span><span style=" font-size:16pt;"> across three dimensions:</span></p><p align="center"><span style=" font-size:16pt; font-weight:600;">Contextual</span><span style=" font-size:16pt;"> ,<br/></span><span style=" font-size:16pt; font-weight:600;">Accessibility</span><span style=" font-size:16pt;">, <br/>and </span><span style=" font-size:16pt; font-weight:600;">Place Characterization</span><span style=" font-size:16pt;">,</span></p><p align="justify"><span style=" font-size:16pt;">GEEST offers a comprehensive analysis of how the environment impacts women's job prospects, indicating whether it is highly enabling or not enabling at all. </span></p></body></html> + The Gender Enabling Environments Spatial Tool (GEEST), developed by the **World Bank**, evaluates locations based on how supportive they are of women’s employment and business opportunities. + +By incorporating 15 spatial factors across three dimensions: + +1. **Contextual** , +1. **Accessibility**, and +1. **Place Characterization**, + +GEEST offers a comprehensive analysis of how the environment impacts women's job prospects, indicating whether it is highly enabling or not enabling at all. - Qt::RichText + Qt::MarkdownText Qt::AlignJustify|Qt::AlignTop @@ -122,19 +145,6 @@ - - - - Qt::Vertical - - - - 20 - 258 - - - - diff --git a/geest/ui/open_project_panel_base.ui b/geest/ui/open_project_panel_base.ui index bcf2f6bb..16e3c7f3 100644 --- a/geest/ui/open_project_panel_base.ui +++ b/geest/ui/open_project_panel_base.ui @@ -57,14 +57,17 @@ - + 16 - <html><head/><body><p>Choose from one of the recent project folders you used, or click the ... button to browse to a specific GEEST project folder.</p></body></html> + Choose from one of the recent project folders you used, or click the ... button to browse to a specific GEEST project folder. + + + Qt::MarkdownText Qt::AlignJustify|Qt::AlignTop diff --git a/geest/ui/ors_panel_base.ui b/geest/ui/ors_panel_base.ui index f400dedc..9dfcb494 100644 --- a/geest/ui/ors_panel_base.ui +++ b/geest/ui/ors_panel_base.ui @@ -139,10 +139,10 @@ - <html><head/><body><p><span style=" font-size:16pt;">This plugin makes use of the </span><span style=" font-size:16pt; font-weight:600;">Open Route Service</span><span style=" font-size:16pt;"> (ORS) platform for elements of the spatial analysis workflows. In order to use ORS, you need to obtain an </span><span style=" font-size:16pt; font-weight:600;">API key</span><span style=" font-size:16pt;">. There is no charge to get your key. Click on </span><a href="https://openrouteservice.org/dev/#/signup"><span style=" font-size:16pt; text-decoration: underline; color:#0000ff;">this link</span></a><span style=" font-size:16pt;"> for the API Key sign up page. Once you have your API key, </span><span style=" font-size:16pt; font-weight:600;">paste</span><span style=" font-size:16pt;"> it into the box below.</span></p></body></html> + This plugin makes use of the Open Route Service (ORS) platform for elements of the spatial analysis workflows. In order to use ORS, you need to obtain an API key. There is no charge to get your key. Click on [this link](https://openrouteservice.org/dev/#/signup) for the API Key sign up page. Once you have your API key, paste it into the box below. - Qt::RichText + Qt::MarkdownText Qt::AlignJustify|Qt::AlignTop diff --git a/geest/utilities.py b/geest/utilities.py index 5c93ef71..7a2b8c94 100644 --- a/geest/utilities.py +++ b/geest/utilities.py @@ -196,3 +196,38 @@ def is_qgis_dark_theme_active() -> bool: # Default to False if none of the conditions are met return False + + +def linear_interpolation( + value: float, + output_min: float, + output_max: float, + domain_min: float, + domain_max: float, +) -> float: + """ + Scales a value using linear interpolation. + + Parameters: + value (float): The value to scale. + output_min (float): The minimum of the output range. + output_max (float): The maximum of the output range. + domain_min (float): The minimum of the input range. + domain_max (float): The maximum of the input range. + + Returns: + float: The scaled value. + """ + if domain_min == domain_max: + raise ValueError("domain_min and domain_max cannot be the same value.") + if value > domain_max: + return output_max + # Compute the scaled value + scale = (value - domain_min) / (domain_max - domain_min) + result = output_min + scale * (output_max - output_min) + # Clamp the value to the output range + if result < output_min: + return output_min + if result > output_max: + return output_max + return result From 93f0ddaec1278e3c4f9f99d06743cf6ce9fb2d07 Mon Sep 17 00:00:00 2001 From: Tim Sutton Date: Fri, 17 Jan 2025 15:39:38 +0000 Subject: [PATCH 2/3] WIP to resize elements based on panel width --- geest/gui/geest_dock.py | 22 +- geest/gui/panels/create_project_panel.py | 31 +- geest/gui/panels/credits_panel.py | 34 +- geest/gui/panels/ors_panel.py | 2 - geest/ui/analysis_dialog_base.ui | 351 ++++++++--------- geest/ui/create_project_panel_base.ui | 470 +++++++++++------------ geest/ui/credits_panel_base.ui | 43 ++- geest/ui/ors_panel_base.ui | 7 +- 8 files changed, 484 insertions(+), 476 deletions(-) diff --git a/geest/gui/geest_dock.py b/geest/gui/geest_dock.py index 37838e0b..fddf69bf 100644 --- a/geest/gui/geest_dock.py +++ b/geest/gui/geest_dock.py @@ -285,14 +285,24 @@ def on_panel_changed(self, index: int) -> None: :param index: The index of the newly selected panel. """ - if index == 0: + if index == INTRO_PANEL: log_message("Switched to Intro panel") - if index == 1: + self.intro_widget.set_font_size() + elif index == CREDITS_PANEL: + log_message("Switched to Credits panel") + self.credits_widget.set_font_size() + elif index == SETUP_PANEL: + log_message("Switched to Setup panel") + elif index == ORS_PANEL: + self.ors_widget.set_font_size() log_message("Switched to ORS panel") - elif index == 2: - log_message("Switched to Project panel") - elif index == 3: + elif index == OPEN_PROJECT_PANEL: + log_message("Switched to Open Project panel") + elif index == CREATE_PROJECT_PANEL: + self.create_project_widget.set_font_size() + log_message("Switched to Create Project panel") + elif index == TREE_PANEL: log_message("Switched to Tree panel") # self.tree_widget.set_working_directory(self.setup_widget.working_dir) - elif index == 4: + elif index == HELP_PANEL: log_message("Switched to Help panel") diff --git a/geest/gui/panels/create_project_panel.py b/geest/gui/panels/create_project_panel.py index 6e590cc8..d782f23a 100644 --- a/geest/gui/panels/create_project_panel.py +++ b/geest/gui/panels/create_project_panel.py @@ -18,9 +18,9 @@ ) from qgis.PyQt.QtCore import QSettings, pyqtSignal -from qgis.PyQt.QtGui import QPixmap -from geest.core.tasks import StudyAreaProcessingTask, OrsCheckerTask -from geest.utilities import get_ui_class, resources_path +from qgis.PyQt.QtGui import QPixmap, QFont +from geest.core.tasks import StudyAreaProcessingTask +from geest.utilities import get_ui_class, resources_path, linear_interpolation from geest.core import WorkflowQueueManager from geest.utilities import log_message from geest.gui.widgets import CustomBannerLabel @@ -234,3 +234,28 @@ def update_recent_projects(self, directory): # Save back to QSettings self.settings.setValue("recent_projects", recent_projects) + + def resizeEvent(self, event): + self.set_font_size() + super().resizeEvent(event) + + def set_font_size(self): + # Scale the font size to fit the text in the available space + font_size = 16 + threshold = 300 + log_message(f"Description Label Width: {self.description.rect().width()}") + # scale the font size linearly from 16 pt to 8 ps as the width of the label decreases + # interpolate 16, 8, 300, 200 + font_size = int( + linear_interpolation(self.description.rect().width(), 8, 16, 200, 400) + ) + + log_message(f"Description Label Font Size: {font_size}") + self.description.setFont(QFont("Arial", font_size)) + self.description2.setFont(QFont("Arial", font_size)) + self.description3.setFont(QFont("Arial", font_size)) + self.create_project_directory_button.setFont(QFont("Arial", font_size)) + self.load_boundary_button.setFont(QFont("Arial", font_size)) + self.cell_size_spinbox.setFont(QFont("Arial", font_size)) + self.layer_combo.setFont(QFont("Arial", font_size)) + self.field_combo.setFont(QFont("Arial", font_size)) diff --git a/geest/gui/panels/credits_panel.py b/geest/gui/panels/credits_panel.py index 6dd39a73..18aab26f 100644 --- a/geest/gui/panels/credits_panel.py +++ b/geest/gui/panels/credits_panel.py @@ -4,9 +4,13 @@ from qgis.core import Qgis from qgis.PyQt.QtCore import QUrl, pyqtSignal -from qgis.PyQt.QtGui import QPixmap, QDesktopServices -from geest.core.tasks import OrsCheckerTask -from geest.utilities import get_ui_class, resources_path, log_message +from qgis.PyQt.QtGui import QFont, QDesktopServices +from geest.utilities import ( + get_ui_class, + resources_path, + log_message, + linear_interpolation, +) from geest.gui.widgets import CustomBannerLabel FORM_CLASS = get_ui_class("credits_panel_base.ui") @@ -21,7 +25,7 @@ def __init__(self): self.setWindowTitle("GEEST") # Dynamically load the .ui file self.setupUi(self) - log_message(f"Loading intro panel") + log_message(f"Loading Credits panel") self.initUI() def initUI(self): @@ -37,6 +41,7 @@ def initUI(self): self.next_button.clicked.connect(self.on_next_button_clicked) self.previous_button.clicked.connect(self.on_previous_button_clicked) self.description.linkActivated.connect(self.open_link_in_browser) + self.set_font_size() def on_next_button_clicked(self): self.switch_to_next_tab.emit() @@ -47,3 +52,24 @@ def on_previous_button_clicked(self): 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 repaint(self): + self.set_font_size() + super().repaint() + + def resizeEvent(self, event): + self.set_font_size() + super().resizeEvent(event) + + def set_font_size(self): + # Scale the font size to fit the text in the available space + font_size = 16 + log_message(f"Label Width: {self.description.rect().width()}") + # scale the font size linearly from 16 pt to 8 ps as the width of the label decreases + # interpolate 16, 8, 300, 200 + font_size = int( + linear_interpolation(self.description.rect().width(), 8, 16, 200, 400) + ) + log_message(f"Label Font Size: {font_size}") + self.description.setFont(QFont("Arial", font_size)) + self.description.repaint() diff --git a/geest/gui/panels/ors_panel.py b/geest/gui/panels/ors_panel.py index d1bbee83..b86de38e 100644 --- a/geest/gui/panels/ors_panel.py +++ b/geest/gui/panels/ors_panel.py @@ -97,13 +97,11 @@ def resizeEvent(self, event): def set_font_size(self): # Scale the font size to fit the text in the available space font_size = 16 - threshold = 300 log_message(f"Label Width: {self.description.rect().width()}") # scale the font size linearly from 16 pt to 8 ps as the width of the label decreases # interpolate 16, 8, 300, 200 font_size = int( linear_interpolation(self.description.rect().width(), 8, 16, 200, 400) ) - log_message(f"Label Font Size: {font_size}") self.description.setFont(QFont("Arial", font_size)) diff --git a/geest/ui/analysis_dialog_base.ui b/geest/ui/analysis_dialog_base.ui index 6e2ef1c8..5ba2c9b9 100644 --- a/geest/ui/analysis_dialog_base.ui +++ b/geest/ui/analysis_dialog_base.ui @@ -40,12 +40,12 @@ 0 0 - 1072 - 671 + 1066 + 673 - + @@ -98,7 +98,7 @@ padding: 4px; - + <html><head/><body><p><span style=" font-size:8pt; font-weight:600;">Aggregation boundaries (optional):</span><span style=" font-size:8pt;"> You can generate insights from the WEE analysis by providing subnational boundaries. For each boundary, we will calculate the majority WEE score, majority WEE by Population score (if population data is set below) and majority WEE by Job Distribution score (if configured below).</span></p></body></html> @@ -108,7 +108,7 @@ padding: 4px; - + @@ -125,7 +125,7 @@ padding: 4px; - + @@ -183,7 +183,7 @@ padding: 4px; - + @@ -223,223 +223,174 @@ padding: 4px; - + - - - - - - 0 - 0 - - - - - - - - - - - ... - - - - + + + + 0 + 0 + + + - - - - - Input - - - - - - - WEE - - - true - - - - - - - WEE x Population - - - - + - - - - - - - Qt::Vertical - - - - 20 - 40 - + + + ... - + - - - - Mask Source - - - - + + + + + + Mask Source + + + + + + Buffer Point Layer + + + + + + + + + + + + + - Buffer Point Layer + ... + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + m + + + 100000 + + + 100 - - - - - - - - - - - - ... - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - m - - - 100000 - - - 100 - - - - + + + + + + Polygon Layer + + + + + + + + + + - - + + - Polygon Layer + ... - - - - - - - - - - - - ... - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 100 - 20 - - - - - + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 100 + 20 + + + + + + + + + + Raster Layer + + + + + + + + + + - - + + - Raster Layer + ... - - - - - - - - - - - - ... - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 100 - 20 - - - - - + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 100 + 20 + + + - - - + + + - + diff --git a/geest/ui/create_project_panel_base.ui b/geest/ui/create_project_panel_base.ui index aec1d4bf..8f66f3b3 100644 --- a/geest/ui/create_project_panel_base.ui +++ b/geest/ui/create_project_panel_base.ui @@ -13,11 +13,106 @@ Form - + + + + + + + + ../resources/geest-banner.png + + + true + + + + + + + <html><head/><body><p align="center"><span style=" font-size:16pt; font-weight:600;">GEEST Project Creation</span></p></body></html> + + + Qt::RichText + + + Qt::AlignCenter + + + true + + + + + + + Qt::Horizontal + + + + + + + + 16 + + + + A GEEST project is a folder with files that are managed by the GEEST plugin. Analysis outputs and working files will be stored in this folder. It needs to be an empty folder that contains no other files. + + + Qt::MarkdownText + + + Qt::AlignJustify|Qt::AlignTop + + + true + + + + + + + + + + 32 + 32 + + + + TextLabel + + + true + + + + + + + + 0 + 0 + + + + + 16 + + + + 📂 Create or select a project directory + + + + + - + 0 0 @@ -27,41 +122,132 @@ - - - - Qt::Horizontal + + + + + 16 + + + + Set the analysis cell size (m). Smaller sizes require longer processing times, but produce more detailed analysis results. We suggest a value between 100m and 1000m. + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true - - - - + + + + true + + + + 0 + 0 + + + + + 16 + + + + 1 + + + 100000 + + + 100 + + + 100 + + + + + + + + 16 + + + + Select a layer containing your Admin0 areas and the column containing the names of your areas. + + + Qt::MarkdownText + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + + 0 + 0 + + + + + 16 + + + + + + + + - + 0 0 - - - 0 - 0 - + + + 16 + + + + + 16 - ◀️ + ... - - + + + + + + Use CRS of your boundary layer (disabled if map units are in degrees) + + + + + + + 0 @@ -80,241 +266,49 @@ - ▶️ + ◀️ - + + + + 0 + 0 + + 0 - - - - Qt::Horizontal + + + + + 0 + 0 + - + - 88 - 20 + 0 + 0 - + + + 16 + + + + ▶️ + + - - - - - - - ../resources/geest-banner.png - - - true - - - - - - - true - - - - - 0 - 0 - 584 - 653 - - - - - - - - 16 - - - - - - - - true - - - - 16 - - - - 1 - - - 100000 - - - 100 - - - 100 - - - - - - - - 16 - - - - ... - - - - - - - - 16 - - - - <html><head/><body><p>A GEEST project is a folder with files that are managed by the GEEST plugin. Analysis outputs and working files will be stored in this folder. <span style=" font-weight:600;">It needs to be an empty folder that contains no other files.</span></p></body></html> - - - Qt::AlignJustify|Qt::AlignTop - - - true - - - - - - - - 16 - - - - <html><head/><body><p align="justify">Select a layer containing your <span style=" font-weight:600;">Admin0</span> areas and the column containing the names of your areas.</p></body></html> - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - - - - - Use Coordinate System of your boundary layer (disabled if map units are in degrees) - - - - - - - - - - 32 - 32 - - - - TextLabel - - - true - - - - - - - - 16 - - - - 📂 Create or select a project directory - - - - - - - - - true - - - <html><head/><body><p align="justify"><span style=" font-size:16pt;">Set the analysis cell size (m). Smaller sizes require longer processing times, but produce more detailed analysis results. We suggest a value between </span><span style=" font-size:16pt; font-weight:600;">100m</span><span style=" font-size:16pt;"> and </span><span style=" font-size:16pt; font-weight:600;">1000m.</span></p></body></html> - - - Qt::RichText - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - - - - - - 16 - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - <html><head/><body><p align="center"><span style=" font-size:16pt; font-weight:600;">GEEST Project Creation</span></p></body></html> - - - Qt::RichText - - - Qt::AlignCenter - - - true - - - diff --git a/geest/ui/credits_panel_base.ui b/geest/ui/credits_panel_base.ui index e6339827..a44ed7fe 100644 --- a/geest/ui/credits_panel_base.ui +++ b/geest/ui/credits_panel_base.ui @@ -154,6 +154,9 @@ + + QFrame::NoFrame + true @@ -162,11 +165,23 @@ 0 0 - 526 - 670 + 542 + 629 + + 0 + + + 0 + + + 0 + + + 0 + @@ -176,35 +191,21 @@ - <html><head/><body><p><span style=" font-size:16pt;">This plugin is built with support from the </span><span style=" font-size:16pt; font-weight:600;">Canada Clean Energy and Forest Climate Facility</span><span style=" font-size:16pt;"> (CCEFCFy), the </span><span style=" font-size:16pt; font-weight:600;">Geospatial Operational Support Team</span><span style=" font-size:16pt;"> (GOST, DECSC) for the project Geospatial Assessment of Women Employment and Business Opportunities in the Renewable Energy Sector. <br/></span></p><p><span style=" font-size:16pt;">This project is open source, you can download the code at </span><a href="https://github.com/worldbank/GEEST"><span style=" font-size:16pt; text-decoration: underline; color:#0000ff;">https://github.com/worldbank/GEEST.</span></a><span style=" font-size:16pt;"><br/></span></p><p><br/></p></body></html> + This plugin is built with support from the **Canada Clean Energy and Forest Climate Facility (CCEFCFy)**, the **Geospatial Operational Support Team (GOST, DECSC)** for the project Geospatial Assessment of Women Employment and Business Opportunities in the Renewable Energy Sector. + +This project is open source, you can download the code at [https://github.com/worldbank/GEEST](https://github.com/worldbank/GEEST). - Qt::RichText + Qt::MarkdownText - Qt::AlignJustify|Qt::AlignVCenter + Qt::AlignJustify|Qt::AlignTop true - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 20 - 318 - - - - diff --git a/geest/ui/ors_panel_base.ui b/geest/ui/ors_panel_base.ui index 9dfcb494..9a5fa360 100644 --- a/geest/ui/ors_panel_base.ui +++ b/geest/ui/ors_panel_base.ui @@ -117,6 +117,9 @@ + + QFrame::NoFrame + true @@ -125,8 +128,8 @@ 0 0 - 610 - 653 + 612 + 655 From a367dac12785b82260702fe90bb6fe9dc5e6e918 Mon Sep 17 00:00:00 2001 From: Tim Sutton Date: Fri, 17 Jan 2025 20:43:01 +0000 Subject: [PATCH 3/3] Fix Scale text size according to panel size #781 --- geest/gui/panels/create_project_panel.py | 7 ++---- geest/gui/panels/credits_panel.py | 6 ++--- geest/gui/panels/intro_panel.py | 7 ++---- geest/gui/panels/open_project_panel.py | 8 ++----- geest/gui/panels/ors_panel.py | 6 ++--- geest/gui/panels/setup_panel.py | 22 ++++++++++++++++- geest/ui/create_project_panel_base.ui | 30 +++++++++++++++++++----- geest/ui/setup_panel_base.ui | 7 ++++-- 8 files changed, 60 insertions(+), 33 deletions(-) diff --git a/geest/gui/panels/create_project_panel.py b/geest/gui/panels/create_project_panel.py index d782f23a..ffe164be 100644 --- a/geest/gui/panels/create_project_panel.py +++ b/geest/gui/panels/create_project_panel.py @@ -241,13 +241,10 @@ def resizeEvent(self, event): def set_font_size(self): # Scale the font size to fit the text in the available space - font_size = 16 - threshold = 300 log_message(f"Description Label Width: {self.description.rect().width()}") - # scale the font size linearly from 16 pt to 8 ps as the width of the label decreases - # interpolate 16, 8, 300, 200 + # scale the font size linearly from 16 pt to 8 ps as the width of the panel decreases font_size = int( - linear_interpolation(self.description.rect().width(), 8, 16, 200, 400) + linear_interpolation(self.description.rect().width(), 12, 16, 400, 600) ) log_message(f"Description Label Font Size: {font_size}") diff --git a/geest/gui/panels/credits_panel.py b/geest/gui/panels/credits_panel.py index 18aab26f..5b188027 100644 --- a/geest/gui/panels/credits_panel.py +++ b/geest/gui/panels/credits_panel.py @@ -63,12 +63,10 @@ def resizeEvent(self, event): def set_font_size(self): # Scale the font size to fit the text in the available space - font_size = 16 log_message(f"Label Width: {self.description.rect().width()}") - # scale the font size linearly from 16 pt to 8 ps as the width of the label decreases - # interpolate 16, 8, 300, 200 + # scale the font size linearly from 16 pt to 8 ps as the width of the panel decreases font_size = int( - linear_interpolation(self.description.rect().width(), 8, 16, 200, 400) + linear_interpolation(self.description.rect().width(), 12, 16, 400, 600) ) log_message(f"Label Font Size: {font_size}") self.description.setFont(QFont("Arial", font_size)) diff --git a/geest/gui/panels/intro_panel.py b/geest/gui/panels/intro_panel.py index 7804d34a..fa03bf01 100644 --- a/geest/gui/panels/intro_panel.py +++ b/geest/gui/panels/intro_panel.py @@ -50,13 +50,10 @@ def resizeEvent(self, event): def set_font_size(self): # Scale the font size to fit the text in the available space - font_size = 16 - threshold = 300 log_message(f"Intro Label Width: {self.intro_label.rect().width()}") - # scale the font size linearly from 16 pt to 8 ps as the width of the label decreases - # interpolate 16, 8, 300, 200 + # scale the font size linearly from 16 pt to 8 ps as the width of the panel decreases font_size = int( - linear_interpolation(self.intro_label.rect().width(), 8, 16, 200, 400) + linear_interpolation(self.intro_label.rect().width(), 12, 16, 400, 600) ) log_message(f"Intro Label Font Size: {font_size}") diff --git a/geest/gui/panels/open_project_panel.py b/geest/gui/panels/open_project_panel.py index 69cba39d..d530a730 100644 --- a/geest/gui/panels/open_project_panel.py +++ b/geest/gui/panels/open_project_panel.py @@ -165,14 +165,10 @@ def resizeEvent(self, event): def set_font_size(self): # Scale the font size to fit the text in the available space - font_size = 16 - threshold = 300 log_message(f"Label Width: {self.label.rect().width()}") - # scale the font size linearly from 16 pt to 8 ps as the width of the label decreases - # interpolate 16, 8, 300, 200 + # scale the font size linearly from 16 pt to 8 ps as the width of the panel decreases font_size = int( - linear_interpolation(self.label.rect().width(), 8, 16, 200, 400) + linear_interpolation(self.label.rect().width(), 12, 16, 400, 600) ) - log_message(f"Label Font Size: {font_size}") self.label.setFont(QFont("Arial", font_size)) diff --git a/geest/gui/panels/ors_panel.py b/geest/gui/panels/ors_panel.py index b86de38e..3a20a709 100644 --- a/geest/gui/panels/ors_panel.py +++ b/geest/gui/panels/ors_panel.py @@ -96,12 +96,10 @@ def resizeEvent(self, event): def set_font_size(self): # Scale the font size to fit the text in the available space - font_size = 16 log_message(f"Label Width: {self.description.rect().width()}") - # scale the font size linearly from 16 pt to 8 ps as the width of the label decreases - # interpolate 16, 8, 300, 200 + # scale the font size linearly from 16 pt to 8 ps as the width of the panel decreases font_size = int( - linear_interpolation(self.description.rect().width(), 8, 16, 200, 400) + linear_interpolation(self.description.rect().width(), 12, 16, 400, 600) ) log_message(f"Label Font Size: {font_size}") self.description.setFont(QFont("Arial", font_size)) diff --git a/geest/gui/panels/setup_panel.py b/geest/gui/panels/setup_panel.py index ba2bbb25..108c14bc 100644 --- a/geest/gui/panels/setup_panel.py +++ b/geest/gui/panels/setup_panel.py @@ -2,7 +2,13 @@ QWidget, ) from qgis.PyQt.QtCore import pyqtSignal -from geest.utilities import get_ui_class, resources_path, log_message +from PyQt5.QtGui import QFont +from geest.utilities import ( + get_ui_class, + resources_path, + log_message, + linear_interpolation, +) from geest.gui.widgets import CustomBannerLabel FORM_CLASS = get_ui_class("setup_panel_base.ui") @@ -47,3 +53,17 @@ def create_project(self): def on_previous_button_clicked(self): self.switch_to_previous_tab.emit() + + def resizeEvent(self, event): + self.set_font_size() + super().resizeEvent(event) + + def set_font_size(self): + # Scale the font size to fit the text in the available space + log_message(f"Label Width: {self.description.rect().width()}") + # scale the font size linearly from 16 pt to 8 ps as the width of the panel decreases + font_size = int( + linear_interpolation(self.description.rect().width(), 12, 16, 400, 600) + ) + log_message(f"Label Font Size: {font_size}") + self.description.setFont(QFont("Arial", font_size)) diff --git a/geest/ui/create_project_panel_base.ui b/geest/ui/create_project_panel_base.ui index 8f66f3b3..c591b223 100644 --- a/geest/ui/create_project_panel_base.ui +++ b/geest/ui/create_project_panel_base.ui @@ -7,7 +7,7 @@ 0 0 604 - 884 + 938 @@ -120,6 +120,9 @@ + + true + @@ -239,8 +242,11 @@ + + Disabled if map units are in degrees + - Use CRS of your boundary layer (disabled if map units are in degrees) + Use boundary layer CRS @@ -256,8 +262,14 @@ - 0 - 0 + 80 + 40 + + + + + 80 + 40 @@ -293,8 +305,14 @@ - 0 - 0 + 80 + 40 + + + + + 80 + 40 diff --git a/geest/ui/setup_panel_base.ui b/geest/ui/setup_panel_base.ui index 8bd5c352..7cb0fdbb 100644 --- a/geest/ui/setup_panel_base.ui +++ b/geest/ui/setup_panel_base.ui @@ -51,14 +51,17 @@ - + 16 - <html><head/><body><p>To get started, we need a project folder. You can either select a <span style=" font-weight:600;">previously created</span> project folder, or <span style=" font-weight:600;">create a new one</span>. The contents of this folder will be managed by GEEST. It will store the GEEST project file and the working analysis results.</p></body></html> + To get started, we need a project folder. You can either select a **previously created** project folder, or **create a new one**. The contents of this folder will be managed by GEEST. It will store the GEEST project file and the working analysis results. + + + Qt::MarkdownText Qt::AlignJustify|Qt::AlignTop