Skip to content

Commit

Permalink
Disable popups for layers even without labels (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson authored Jun 5, 2024
1 parent e8e3ce5 commit d8ec0b2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
9 changes: 6 additions & 3 deletions felt/core/fsl_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion felt/core/layer_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 9 additions & 6 deletions felt/test/test_fsl_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d8ec0b2

Please sign in to comment.