From 490b9dee3e78bb45486cb92f75887296ac5fd5f3 Mon Sep 17 00:00:00 2001 From: letsfindaway Date: Sat, 20 Mar 2021 14:11:23 +0100 Subject: [PATCH 1/2] add option to export background grid to pdf --- resources/etc/OpenBoard.config | 1 + src/adaptors/UBExportPDF.cpp | 10 +++++++++- src/core/UBSettings.cpp | 1 + src/core/UBSettings.h | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/resources/etc/OpenBoard.config b/resources/etc/OpenBoard.config index 463ece5b..b94e808b 100644 --- a/resources/etc/OpenBoard.config +++ b/resources/etc/OpenBoard.config @@ -128,6 +128,7 @@ Margin=20 PageFormat=A4 Resolution=300 ZoomBehavior=4 +ExportBackgroundGrid=false [Podcast] AudioRecordingDevice=Default diff --git a/src/adaptors/UBExportPDF.cpp b/src/adaptors/UBExportPDF.cpp index 177f716d..3f97f273 100644 --- a/src/adaptors/UBExportPDF.cpp +++ b/src/adaptors/UBExportPDF.cpp @@ -106,7 +106,15 @@ bool UBExportPDF::persistsDocument(UBDocumentProxy* pDocumentProxy, const QStrin // set background to white, no crossing for PDF output bool isDark = scene->isDarkBackground(); UBPageBackground pageBackground = scene->pageBackground(); - scene->setBackground(false, UBPageBackground::plain); + + if (UBSettings::settings()->exportBackgroundGrid->get().toBool()) + { + scene->setBackground(false, pageBackground); + } + else + { + scene->setBackground(false, UBPageBackground::plain); + } // pageSize is the output PDF page size; it is set to equal the scene's boundary size; if the contents // of the scene overflow from the boundaries, they will be scaled down. diff --git a/src/core/UBSettings.cpp b/src/core/UBSettings.cpp index f659452f..d5b5ed6a 100644 --- a/src/core/UBSettings.cpp +++ b/src/core/UBSettings.cpp @@ -409,6 +409,7 @@ void UBSettings::init() pdfZoomBehavior = new UBSetting(this, "PDF", "ZoomBehavior", "4"); enableQualityLossToIncreaseZoomPerfs = new UBSetting(this, "PDF", "enableQualityLossToIncreaseZoomPerfs", true); + exportBackgroundGrid = new UBSetting(this, "PDF", "ExportBackgroundGrid", false); podcastFramesPerSecond = new UBSetting(this, "Podcast", "FramesPerSecond", 10); podcastVideoSize = new UBSetting(this, "Podcast", "VideoSize", "Medium"); diff --git a/src/core/UBSettings.h b/src/core/UBSettings.h index 17d4ae79..90e77eef 100644 --- a/src/core/UBSettings.h +++ b/src/core/UBSettings.h @@ -361,6 +361,7 @@ class UBSettings : public QObject UBSetting* pdfZoomBehavior; UBSetting* enableQualityLossToIncreaseZoomPerfs; + UBSetting* exportBackgroundGrid; UBSetting* podcastFramesPerSecond; UBSetting* podcastVideoSize; From 421a407202d2bf6acb5eaafd64534f7674292449 Mon Sep 17 00:00:00 2001 From: letsfindaway Date: Sat, 20 Mar 2021 14:31:37 +0100 Subject: [PATCH 2/2] add option to keep background color in PDF export --- resources/etc/OpenBoard.config | 3 ++- src/adaptors/UBExportPDF.cpp | 6 ++++-- src/core/UBSettings.cpp | 1 + src/core/UBSettings.h | 1 + 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/resources/etc/OpenBoard.config b/resources/etc/OpenBoard.config index b94e808b..77eea8d1 100644 --- a/resources/etc/OpenBoard.config +++ b/resources/etc/OpenBoard.config @@ -124,11 +124,12 @@ RefreshRateInFramePerSecond=2 [PDF] enableQualityLossToIncreaseZoomPerfs=true +ExportBackgroundGrid=false +ExportBackgroundColor=false Margin=20 PageFormat=A4 Resolution=300 ZoomBehavior=4 -ExportBackgroundGrid=false [Podcast] AudioRecordingDevice=Default diff --git a/src/adaptors/UBExportPDF.cpp b/src/adaptors/UBExportPDF.cpp index 3f97f273..683716bb 100644 --- a/src/adaptors/UBExportPDF.cpp +++ b/src/adaptors/UBExportPDF.cpp @@ -107,13 +107,15 @@ bool UBExportPDF::persistsDocument(UBDocumentProxy* pDocumentProxy, const QStrin bool isDark = scene->isDarkBackground(); UBPageBackground pageBackground = scene->pageBackground(); + bool exportDark = isDark && UBSettings::settings()->exportBackgroundColor->get().toBool(); + if (UBSettings::settings()->exportBackgroundGrid->get().toBool()) { - scene->setBackground(false, pageBackground); + scene->setBackground(exportDark, pageBackground); } else { - scene->setBackground(false, UBPageBackground::plain); + scene->setBackground(exportDark, UBPageBackground::plain); } // pageSize is the output PDF page size; it is set to equal the scene's boundary size; if the contents diff --git a/src/core/UBSettings.cpp b/src/core/UBSettings.cpp index d5b5ed6a..c98f1d70 100644 --- a/src/core/UBSettings.cpp +++ b/src/core/UBSettings.cpp @@ -410,6 +410,7 @@ void UBSettings::init() pdfZoomBehavior = new UBSetting(this, "PDF", "ZoomBehavior", "4"); enableQualityLossToIncreaseZoomPerfs = new UBSetting(this, "PDF", "enableQualityLossToIncreaseZoomPerfs", true); exportBackgroundGrid = new UBSetting(this, "PDF", "ExportBackgroundGrid", false); + exportBackgroundColor = new UBSetting(this, "PDF", "ExportBackgroundColor", false); podcastFramesPerSecond = new UBSetting(this, "Podcast", "FramesPerSecond", 10); podcastVideoSize = new UBSetting(this, "Podcast", "VideoSize", "Medium"); diff --git a/src/core/UBSettings.h b/src/core/UBSettings.h index 90e77eef..6067db5b 100644 --- a/src/core/UBSettings.h +++ b/src/core/UBSettings.h @@ -362,6 +362,7 @@ class UBSettings : public QObject UBSetting* pdfZoomBehavior; UBSetting* enableQualityLossToIncreaseZoomPerfs; UBSetting* exportBackgroundGrid; + UBSetting* exportBackgroundColor; UBSetting* podcastFramesPerSecond; UBSetting* podcastVideoSize;