From 0016946d2b33cbdb761591e5e7b0cfe3d0fe10e6 Mon Sep 17 00:00:00 2001 From: Trey Stafford Date: Thu, 17 Aug 2023 09:59:18 -0600 Subject: [PATCH 1/3] WIP: add buffer to copyright text --- qgreenland/util/qgis/project.py | 100 ++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/qgreenland/util/qgis/project.py b/qgreenland/util/qgis/project.py index a788f7a1..386f4ad4 100644 --- a/qgreenland/util/qgis/project.py +++ b/qgreenland/util/qgis/project.py @@ -275,6 +275,106 @@ def _add_decorations(project: qgc.QgsProject) -> None: project.writeEntry("CopyrightLabel", "/MarginH", 0) project.writeEntry("CopyrightLabel", "/MarginV", 0) + # TODO: can we figure out a way to export `text_format` to xml so that it + # can be written to the project file without hard-coding everything? The + # `text_format` (`QgsTextFormat`) object has a `writeXml` method but it is + # unclear how to apply it to the project file. + + # text_format = qgc.QgsTextFormat() + # buffer_settings = text_format.buffer() + # buffer_settings.setEnabled(True) + # text_format.setBuffer(buffer_settings) + + project.writeEntry( + "CopyrightLabel", + "/Font", + """ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +""", + ) + # Add Image (QGreenland logo): project.writeEntry("Image", "/Enabled", True) project.writeEntry("Image", "/Placement", 0) From 34d559b7b2a7f6d3ed09c8f7f127f9929a29bdbc Mon Sep 17 00:00:00 2001 From: Trey Stafford Date: Thu, 17 Aug 2023 10:22:20 -0600 Subject: [PATCH 2/3] Simplify setting buffer on copyright text --- qgreenland/util/qgis/project.py | 87 +-------------------------------- 1 file changed, 1 insertion(+), 86 deletions(-) diff --git a/qgreenland/util/qgis/project.py b/qgreenland/util/qgis/project.py index 386f4ad4..727c202c 100644 --- a/qgreenland/util/qgis/project.py +++ b/qgreenland/util/qgis/project.py @@ -284,95 +284,10 @@ def _add_decorations(project: qgc.QgsProject) -> None: # buffer_settings = text_format.buffer() # buffer_settings.setEnabled(True) # text_format.setBuffer(buffer_settings) - project.writeEntry( "CopyrightLabel", "/Font", - """ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -""", + '', ) # Add Image (QGreenland logo): From ab2c8cd55e2631fd53134e17b33a78168b45296b Mon Sep 17 00:00:00 2001 From: Trey Stafford Date: Thu, 17 Aug 2023 10:28:44 -0600 Subject: [PATCH 3/3] Reformat TODO and line that is too long --- qgreenland/util/qgis/project.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/qgreenland/util/qgis/project.py b/qgreenland/util/qgis/project.py index 727c202c..724f73b0 100644 --- a/qgreenland/util/qgis/project.py +++ b/qgreenland/util/qgis/project.py @@ -275,19 +275,27 @@ def _add_decorations(project: qgc.QgsProject) -> None: project.writeEntry("CopyrightLabel", "/MarginH", 0) project.writeEntry("CopyrightLabel", "/MarginV", 0) + # Add buffer around copyright text # TODO: can we figure out a way to export `text_format` to xml so that it # can be written to the project file without hard-coding everything? The # `text_format` (`QgsTextFormat`) object has a `writeXml` method but it is - # unclear how to apply it to the project file. - + # unclear how to apply it to the project file: + # ``` # text_format = qgc.QgsTextFormat() # buffer_settings = text_format.buffer() # buffer_settings.setEnabled(True) # text_format.setBuffer(buffer_settings) + # text_format.write_xml(...) + # ``` project.writeEntry( "CopyrightLabel", "/Font", - '', + ( + '' + ), ) # Add Image (QGreenland logo):