From d8ec0b225b0dd0d009b4d820af2867f8507203f7 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Wed, 5 Jun 2024 12:36:18 +1000 Subject: [PATCH] Disable popups for layers even without labels (#75) --- felt/core/fsl_converter.py | 9 ++++++--- felt/core/layer_exporter.py | 3 ++- felt/test/test_fsl_conversion.py | 15 +++++++++------ 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/felt/core/fsl_converter.py b/felt/core/fsl_converter.py index 881df2d..13e1de8 100644 --- a/felt/core/fsl_converter.py +++ b/felt/core/fsl_converter.py @@ -1860,7 +1860,9 @@ def label_settings_to_fsl(settings: QgsPalLayerSettings, Converts label settings to FSL """ if not settings.drawLabels or not settings.fieldName: - return None + return { + 'label': {"isClickable": False, "isHoverable": False} + } if settings.isExpression: context.push_warning('Expression based labels are not supported', @@ -1870,8 +1872,9 @@ def label_settings_to_fsl(settings: QgsPalLayerSettings, 'cause': 'expression_based_label', 'summary': 'expression based label' }) - - return None + return { + 'label': {"isClickable": False, "isHoverable": False} + } converted_format = FslConverter.text_format_to_fsl( settings.format(), context diff --git a/felt/core/layer_exporter.py b/felt/core/layer_exporter.py index e92d63f..5d5f685 100644 --- a/felt/core/layer_exporter.py +++ b/felt/core/layer_exporter.py @@ -230,7 +230,8 @@ def representative_layer_style( LayerExporter.merge_dicts(fsl, label_def) else: fsl = label_def - + elif fsl: + fsl['label'] = {"isClickable": False, "isHoverable": False} elif isinstance(layer, QgsRasterLayer): fsl = FslConverter.raster_layer_to_fsl( layer, conversion_context diff --git a/felt/test/test_fsl_conversion.py b/felt/test/test_fsl_conversion.py index 3858047..934d161 100644 --- a/felt/test/test_fsl_conversion.py +++ b/felt/test/test_fsl_conversion.py @@ -2241,20 +2241,23 @@ def test_label_settings(self): # no labels label_settings.drawLabels = False - self.assertIsNone( - FslConverter.label_settings_to_fsl(label_settings, context) + self.assertEqual( + FslConverter.label_settings_to_fsl(label_settings, context), + {'label': {'isClickable': False, 'isHoverable': False}} ) label_settings.drawLabels = True label_settings.fieldName = '' - self.assertIsNone( - FslConverter.label_settings_to_fsl(label_settings, context) + self.assertEqual( + FslConverter.label_settings_to_fsl(label_settings, context), + {'label': {'isClickable': False, 'isHoverable': False}} ) # expression labels, unsupported label_settings.fieldName = '1 + 2' label_settings.isExpression = True - self.assertIsNone( - FslConverter.label_settings_to_fsl(label_settings, context) + self.assertEqual( + FslConverter.label_settings_to_fsl(label_settings, context), + {'label': {'isClickable': False, 'isHoverable': False}} ) # simple field