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.
upstream-master
Michael J Gruber 5 years ago committed by Roland Lötscher
parent b11161566e
commit 20c4c012c8
  1. 6
      src/control/jobs/BaseExportJob.h
  2. 18
      src/control/jobs/CustomExportJob.cpp
  3. 5
      src/control/jobs/CustomExportJob.h
  4. 4
      src/gui/dialog/ExportDialog.cpp
  5. 1
      src/gui/dialog/ExportDialog.h
  6. 95
      ui/exportSettings.glade

@ -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) {}
};
};

@ -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();

@ -67,6 +67,11 @@ private:
*/
bool exportTypeXoj = false;
/**
* Background export type
*/
ExportBackgroundType exportBackground = EXPORT_BACKGROUND_ALL;
/**
* Export all Layers progressively
*/

@ -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");

@ -28,6 +28,7 @@ public:
bool isConfirmed() const;
PageRangeVector getRange();
bool progressiveMode();
ExportBackgroundType getBackgroundType();
/**
* @brief Reads the quality parameter from the dialog

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.1 -->
<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="3.16"/>
<object class="GtkAdjustment" id="adjustmentDpi">
@ -33,6 +33,23 @@
</row>
</data>
</object>
<object class="GtkListStore" id="listBackgroundType">
<columns>
<!-- column-name Text -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">None</col>
</row>
<row>
<col id="0" translatable="yes">No ruling</col>
</row>
<row>
<col id="0" translatable="yes">All</col>
</row>
</data>
</object>
<object class="GtkDialog" id="exportDialog">
<property name="name">exportDialog</property>
<property name="can-focus">False</property>
@ -114,7 +131,7 @@ Set export parameters</property>
</packing>
</child>
<child>
<!-- n-columns=3 n-rows=5 -->
<!-- n-columns=3 n-rows=6 -->
<object class="GtkGrid" id="grid1">
<property name="visible">True</property>
<property name="can-focus">False</property>
@ -149,7 +166,7 @@ Set export parameters</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
@ -165,7 +182,7 @@ Set export parameters</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
@ -181,7 +198,7 @@ Set export parameters</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">2</property>
<property name="top-attach">3</property>
</packing>
</child>
<child>
@ -197,7 +214,7 @@ Set export parameters</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">3</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
@ -213,7 +230,7 @@ Set export parameters</property>
</object>
<packing>
<property name="left-attach">2</property>
<property name="top-attach">3</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
@ -226,7 +243,7 @@ Set export parameters</property>
</object>
<packing>
<property name="left-attach">2</property>
<property name="top-attach">4</property>
<property name="top-attach">5</property>
</packing>
</child>
<child>
@ -242,7 +259,7 @@ Set export parameters</property>
</object>
<packing>
<property name="left-attach">2</property>
<property name="top-attach">1</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
@ -258,7 +275,7 @@ Set export parameters</property>
</object>
<packing>
<property name="left-attach">2</property>
<property name="top-attach">2</property>
<property name="top-attach">3</property>
</packing>
</child>
<child>
@ -328,24 +345,62 @@ Set export parameters</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="tooltip-text" translatable="yes" comments="Keep the order the same as in listBackgroundType and use the translation of these types in parentheses.">Export the document without any background (None) or with PDF and image backgrounds only (No ruling) or with all background types (All).</property>
<property name="label" translatable="yes">Background</property>
<property name="ellipsize">middle</property>
<property name="xalign">0</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="cbProgressiveMode">
<property name="label" translatable="yes">Export layers progressively</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">If enabled, the layers of each page will be added one by one. The resulting PDF file can be used for a presentation.</property>
<property name="draw_indicator">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="tooltip-text" translatable="yes">If enabled, the layers of each page will be added one by one. The resulting PDF file can be used for a presentation.</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<!-- Same place as "Image quality"; only one of them is shown -->
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
<property name="width">3</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="cbBackgroundType">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="model">listBackgroundType</property>
<property name="active">2</property>
<property name="id-column">0</property>
<property name="active-id">0</property>
<child>
<object class="GtkCellRendererText" id="cbBackgroundTypeCell"/>
<attributes>
<attribute name="markup">0</attribute>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>

Loading…
Cancel
Save