From 5efb9f8a4e204f368e619d42223f659b0968c13a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Mon, 28 Aug 2017 17:48:46 +0200 Subject: [PATCH] Added resolution setting to export dialogue. --- src/exportdialog.cpp | 10 ++++++++++ src/exportdialog.h | 2 ++ src/gui.cpp | 5 +++++ src/settings.h | 2 ++ 4 files changed, 19 insertions(+) diff --git a/src/exportdialog.cpp b/src/exportdialog.cpp index 8e001a86..1d6cfa54 100644 --- a/src/exportdialog.cpp +++ b/src/exportdialog.cpp @@ -35,6 +35,13 @@ ExportDialog::ExportDialog(Export *exp, QWidget *parent) if ((index = _paperSize->findData(_export->paperSize)) >= 0) _paperSize->setCurrentIndex(index); + _resolution = new QComboBox(); + _resolution->addItem("300 DPI", 300); + _resolution->addItem("600 DPI", 600); + _resolution->addItem("1200 DPI", 1200); + if ((index = _resolution->findData(_export->resolution)) >= 0) + _resolution->setCurrentIndex(index); + _portrait = new QRadioButton(tr("Portrait")); _landscape = new QRadioButton(tr("Landscape")); QHBoxLayout *orientationLayout = new QHBoxLayout(); @@ -81,6 +88,7 @@ ExportDialog::ExportDialog(Export *exp, QWidget *parent) #endif // Q_OS_MAC QFormLayout *pageSetupLayout = new QFormLayout; pageSetupLayout->addRow(tr("Page size:"), _paperSize); + pageSetupLayout->addRow(tr("Resolution:"), _resolution); pageSetupLayout->addRow(tr("Orientation:"), orientationLayout); pageSetupLayout->addRow(tr("Margins:"), marginsLayout); #ifdef Q_OS_MAC @@ -161,9 +169,11 @@ void ExportDialog::accept() ? QPrinter::Portrait : QPrinter::Landscape; QPrinter::PaperSize paperSize = static_cast (_paperSize->itemData(_paperSize->currentIndex()).toInt()); + int resolution = _resolution->itemData(_resolution->currentIndex()).toInt(); _export->fileName = _fileSelect->file(); _export->paperSize = paperSize; + _export->resolution = resolution; _export->orientation = orientation; if (_export->units == Imperial) _export->margins = MarginsF(_leftMargin->value() / MM2IN, diff --git a/src/exportdialog.h b/src/exportdialog.h index 5765a836..71e811bf 100644 --- a/src/exportdialog.h +++ b/src/exportdialog.h @@ -16,6 +16,7 @@ struct Export { QPrinter::PaperSize paperSize; QPrinter::Orientation orientation; MarginsF margins; + int resolution; Units units; }; @@ -37,6 +38,7 @@ private: FileSelectWidget *_fileSelect; QComboBox *_paperSize; + QComboBox *_resolution; QRadioButton *_portrait; QRadioButton *_landscape; QDoubleSpinBox *_topMargin; diff --git a/src/gui.cpp b/src/gui.cpp index 2e7515f0..bb06e83e 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -958,6 +958,7 @@ void GUI::exportFile() printer.setOutputFormat(QPrinter::PdfFormat); printer.setCreator(QString(APP_NAME) + QString(" ") + QString(APP_VERSION)); + printer.setResolution(_export.resolution); printer.setOrientation(_export.orientation); printer.setOutputFileName(_export.fileName); printer.setPaperSize(_export.paperSize); @@ -1581,6 +1582,8 @@ void GUI::writeSettings() settings.beginGroup(EXPORT_SETTINGS_GROUP); if (_export.orientation != PAPER_ORIENTATION_DEFAULT) settings.setValue(PAPER_ORIENTATION_SETTING, _export.orientation); + if (_export.resolution != RESOLUTION_DEFAULT) + settings.setValue(RESOLUTION_SETTING, _export.resolution); if (_export.paperSize != PAPER_SIZE_DEFAULT) settings.setValue(PAPER_SIZE_SETTING, _export.paperSize); if (_export.margins.left() != MARGIN_LEFT_DEFAULT) @@ -1779,6 +1782,8 @@ void GUI::readSettings() settings.beginGroup(EXPORT_SETTINGS_GROUP); _export.orientation = (QPrinter::Orientation) settings.value( PAPER_ORIENTATION_SETTING, PAPER_ORIENTATION_DEFAULT).toInt(); + _export.resolution = settings.value(RESOLUTION_SETTING, RESOLUTION_DEFAULT) + .toInt(); _export.paperSize = (QPrinter::PaperSize) settings.value(PAPER_SIZE_SETTING, PAPER_SIZE_DEFAULT).toInt(); qreal ml = settings.value(MARGIN_LEFT_SETTING, MARGIN_LEFT_DEFAULT) diff --git a/src/settings.h b/src/settings.h index a1110ec5..8a7dec82 100644 --- a/src/settings.h +++ b/src/settings.h @@ -70,6 +70,8 @@ #define EXPORT_FILENAME_SETTING "fileName" #define EXPORT_FILENAME_DEFAULT QString("%1/export.pdf"). \ arg(QDir::currentPath()) +#define RESOLUTION_SETTING "resolution" +#define RESOLUTION_DEFAULT 600 #define OPTIONS_SETTINGS_GROUP "Options" #define PALETTE_COLOR_SETTING "paletteColor"