From 20c4c012c810e12e25ac8d8aec50fbfe940a38b2 Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Sun, 10 Jan 2021 21:56:01 +0100 Subject: [PATCH] configure background export types in dialog So far, the type of background export determined extra export types. Originally this increased the number of export types by a factor of 2, now (with the addition of "no ruling") by a factor of 3. This is a lot already and does not scale. Instead, reduce the export types to those determined by the file type and configure the background export types in the export dialog, along with progressive mode and quality parameters (depending on file type). In addition to a cleaner UI this makes it easier to remember the last choice or make the default configurable (to be implemented by a future series) rather than forcing the user to make the same choice over and over again. --- src/control/jobs/BaseExportJob.h | 6 +- src/control/jobs/CustomExportJob.cpp | 18 ++---- src/control/jobs/CustomExportJob.h | 5 ++ src/gui/dialog/ExportDialog.cpp | 4 ++ src/gui/dialog/ExportDialog.h | 1 + ui/exportSettings.glade | 95 ++++++++++++++++++++++------ 6 files changed, 94 insertions(+), 35 deletions(-) diff --git a/src/control/jobs/BaseExportJob.h b/src/control/jobs/BaseExportJob.h index 04829aeb..8a58da45 100644 --- a/src/control/jobs/BaseExportJob.h +++ b/src/control/jobs/BaseExportJob.h @@ -21,7 +21,8 @@ /** * @brief List of types for the export of background components. - * Keep the order so that one can check for intermediate types using comparsion. + * The order must agree with the corresponding listBackgroundType in ui/exportSettings.glade. + * It is constructed so that one can check for intermediate types using comparison. */ enum ExportBackgroundType { EXPORT_BACKGROUND_NONE, EXPORT_BACKGROUND_UNRULED, EXPORT_BACKGROUND_ALL }; @@ -62,8 +63,7 @@ protected: class ExportType { public: string extension; - ExportBackgroundType exportBackground; - ExportType(string ext, ExportBackgroundType exportBg): extension(ext), exportBackground(exportBg) {} + ExportType(string ext): extension(ext) {} }; }; diff --git a/src/control/jobs/CustomExportJob.cpp b/src/control/jobs/CustomExportJob.cpp index b04c1c47..770d6665 100644 --- a/src/control/jobs/CustomExportJob.cpp +++ b/src/control/jobs/CustomExportJob.cpp @@ -18,16 +18,10 @@ CustomExportJob::CustomExportJob(Control* control): BaseExportJob(control, _("Custom Export")) { // Supported filters - filters[_("PDF files")] = new ExportType(".pdf", EXPORT_BACKGROUND_ALL); - filters[_("PDF without ruling")] = new ExportType(".pdf", EXPORT_BACKGROUND_UNRULED); - filters[_("PDF with plain background")] = new ExportType(".pdf", EXPORT_BACKGROUND_NONE); - filters[_("PNG graphics")] = new ExportType(".png", EXPORT_BACKGROUND_ALL); - filters[_("PNG without ruling")] = new ExportType(".png", EXPORT_BACKGROUND_UNRULED); - filters[_("PNG with transparent background")] = new ExportType(".png", EXPORT_BACKGROUND_NONE); - filters[_("SVG graphics")] = new ExportType(".svg", EXPORT_BACKGROUND_ALL); - filters[_("SVG without ruling")] = new ExportType(".svg", EXPORT_BACKGROUND_UNRULED); - filters[_("SVG with transparent background")] = new ExportType(".svg", EXPORT_BACKGROUND_NONE); - filters[_("Xournal (Compatibility)")] = new ExportType(".xoj", EXPORT_BACKGROUND_ALL); + filters[_("PDF files")] = new ExportType(".pdf"); + filters[_("PNG graphics")] = new ExportType(".png"); + filters[_("SVG graphics")] = new ExportType(".svg"); + filters[_("Xournal (Compatibility)")] = new ExportType(".xoj"); } CustomExportJob::~CustomExportJob() { @@ -98,6 +92,7 @@ auto CustomExportJob::showFilechooser() -> bool { exportRange = dlg->getRange(); progressiveMode = dlg->progressiveMode(); + exportBackground = dlg->getBackgroundType(); if (format == EXPORT_GRAPHICS_PNG) { pngQualityParameter = dlg->getPngQualityParameter(); @@ -112,7 +107,6 @@ auto CustomExportJob::showFilechooser() -> bool { * Create one Graphics file per page */ void CustomExportJob::exportGraphics() { - ExportBackgroundType exportBackground = filters.at(this->chosenFilterName)->exportBackground; ImageExport imgExport(control->getDocument(), filepath, format, exportBackground, exportRange); if (format == EXPORT_GRAPHICS_PNG) { imgExport.setQualityParameter(pngQualityParameter); @@ -144,7 +138,7 @@ void CustomExportJob::run() { XojPdfExport* pdfe = XojPdfExportFactory::createExport(doc, control); - pdfe->setExportBackground(filters[this->chosenFilterName]->exportBackground); + pdfe->setExportBackground(exportBackground); if (!pdfe->createPdf(this->filepath, exportRange, progressiveMode)) { this->errorMsg = pdfe->getLastError(); diff --git a/src/control/jobs/CustomExportJob.h b/src/control/jobs/CustomExportJob.h index b13dda24..e1b143fd 100644 --- a/src/control/jobs/CustomExportJob.h +++ b/src/control/jobs/CustomExportJob.h @@ -67,6 +67,11 @@ private: */ bool exportTypeXoj = false; + /** + * Background export type + */ + ExportBackgroundType exportBackground = EXPORT_BACKGROUND_ALL; + /** * Export all Layers progressively */ diff --git a/src/gui/dialog/ExportDialog.cpp b/src/gui/dialog/ExportDialog.cpp index ec3ebcb8..f63a4541 100644 --- a/src/gui/dialog/ExportDialog.cpp +++ b/src/gui/dialog/ExportDialog.cpp @@ -80,6 +80,10 @@ auto ExportDialog::progressiveMode() -> bool { return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(get("cbProgressiveMode"))); } +auto ExportDialog::getBackgroundType() -> ExportBackgroundType { + return (ExportBackgroundType)gtk_combo_box_get_active(GTK_COMBO_BOX(get("cbBackgroundType"))); +} + auto ExportDialog::getRange() -> PageRangeVector { GtkWidget* rdRangeCurrent = get("rdRangeCurrent"); GtkWidget* rdRangePages = get("rdRangePages"); diff --git a/src/gui/dialog/ExportDialog.h b/src/gui/dialog/ExportDialog.h index 4f429690..3d534749 100644 --- a/src/gui/dialog/ExportDialog.h +++ b/src/gui/dialog/ExportDialog.h @@ -28,6 +28,7 @@ public: bool isConfirmed() const; PageRangeVector getRange(); bool progressiveMode(); + ExportBackgroundType getBackgroundType(); /** * @brief Reads the quality parameter from the dialog diff --git a/ui/exportSettings.glade b/ui/exportSettings.glade index f32eb4de..876e5ae1 100644 --- a/ui/exportSettings.glade +++ b/ui/exportSettings.glade @@ -1,5 +1,5 @@ - + @@ -33,6 +33,23 @@ + + + + + + + + None + + + No ruling + + + All + + + exportDialog False @@ -114,7 +131,7 @@ Set export parameters - + True False @@ -149,7 +166,7 @@ Set export parameters 0 - 1 + 2 @@ -165,7 +182,7 @@ Set export parameters 1 - 1 + 2 @@ -181,7 +198,7 @@ Set export parameters 1 - 2 + 3 @@ -197,7 +214,7 @@ Set export parameters 1 - 3 + 4 @@ -213,7 +230,7 @@ Set export parameters 2 - 3 + 4 @@ -226,7 +243,7 @@ Set export parameters 2 - 4 + 5 @@ -242,7 +259,7 @@ Set export parameters 2 - 1 + 2 @@ -258,7 +275,7 @@ Set export parameters 2 - 2 + 3 @@ -328,24 +345,62 @@ Set export parameters 0 - - + + + True + False + Export the document without any background (None) or with PDF and image backgrounds only (No ruling) or with all background types (All). + Background + middle + 0 + + + + + + 0 + 1 + + + Export layers progressively True - True - False - If enabled, the layers of each page will be added one by one. The resulting PDF file can be used for a presentation. - True + True + False + If enabled, the layers of each page will be added one by one. The resulting PDF file can be used for a presentation. + True - - 0 - 0 + 0 + 0 3 - + + + True + False + listBackgroundType + 2 + 0 + 0 + + + + 0 + 0 + + + + + 1 + 1 + + + + +