From 2eb627a1a45e64f09511b800c591ebc31653081b Mon Sep 17 00:00:00 2001 From: Tim Sutton Date: Thu, 5 Dec 2024 11:19:47 +0000 Subject: [PATCH] Block layout should not have zero Fixes #675 --- geest/core/workflows/safety_polygon_workflow.py | 5 +++-- .../safety_polygon_configuration_widget.py | 17 ++++++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/geest/core/workflows/safety_polygon_workflow.py b/geest/core/workflows/safety_polygon_workflow.py index e298a14a..16743b14 100644 --- a/geest/core/workflows/safety_polygon_workflow.py +++ b/geest/core/workflows/safety_polygon_workflow.py @@ -122,8 +122,9 @@ def _assign_reclassification_to_safety( for feature in layer.getFeatures(): perceived_safety = feature[self.selected_field] score = self.safety_mapping_table.get(perceived_safety) - # Scale perceived safety values between 0 and 5 - reclass_val = self._scale_value(score, 0, 100, 0, 5) + # Scale perceived safety values between 1 and 5 + # Changed to 1-5 for issue #675 + reclass_val = self._scale_value(score, 0, 100, 1, 5) feature.setAttribute("value", reclass_val) layer.updateFeature(feature) return layer diff --git a/geest/gui/widgets/configuration_widgets/safety_polygon_configuration_widget.py b/geest/gui/widgets/configuration_widgets/safety_polygon_configuration_widget.py index 79e24e39..77a58bff 100644 --- a/geest/gui/widgets/configuration_widgets/safety_polygon_configuration_widget.py +++ b/geest/gui/widgets/configuration_widgets/safety_polygon_configuration_widget.py @@ -8,7 +8,7 @@ from qgis.PyQt.QtWidgets import QSizePolicy from qgis.core import Qgis from .base_configuration_widget import BaseConfigurationWidget -from geest.utilities import log_message +from geest.utilities import log_message, is_qgis_dark_theme_active class SafetyPolygonConfigurationWidget(BaseConfigurationWidget): @@ -95,11 +95,16 @@ def validate_value(value): def on_value_changed(value): # Color handling for current cell + if is_qgis_dark_theme_active(): + font_color = "color: white;" + else: + font_color = "color: black;" + if value is None or not (0 <= value <= 100): value_item.setStyleSheet("color: red;") value_item.setValue(0) else: - value_item.setStyleSheet("color: black;") + value_item.setStyleSheet(font_color) self.update_cell_colors() self.update_data() @@ -117,13 +122,15 @@ def update_cell_colors(self): all_zeros = False break + if is_qgis_dark_theme_active(): + font_color = "color: white;" + else: + font_color = "color: black;" # Color all cells based on all-zeros check for r in range(self.table_widget.rowCount()): spin_widget = self.table_widget.cellWidget(r, 1) if spin_widget: - spin_widget.setStyleSheet( - "color: red;" if all_zeros else "color: black;" - ) + spin_widget.setStyleSheet("color: red;" if all_zeros else font_color) def table_to_dict(self): updated_attributes = {}