Changeset View
Changeset View
Standalone View
Standalone View
generators/poppler/generator_pdf.cpp
Show First 20 Lines • Show All 74 Lines • ▼ Show 20 Line(s) | |||||
75 | #endif | 75 | #endif | ||
76 | 76 | | |||
77 | static const int defaultPageWidth = 595; | 77 | static const int defaultPageWidth = 595; | ||
78 | static const int defaultPageHeight = 842; | 78 | static const int defaultPageHeight = 842; | ||
79 | 79 | | |||
80 | class PDFOptionsPage : public Okular::PrintOptionsWidget | 80 | class PDFOptionsPage : public Okular::PrintOptionsWidget | ||
81 | { | 81 | { | ||
82 | Q_OBJECT | 82 | Q_OBJECT | ||
83 | public slots: | | |||
84 | void enableOrDisableScaleMode() | | |||
85 | { | | |||
86 | m_scaleMode->setEnabled ( m_forceRaster->isChecked() ); | | |||
87 | | ||||
88 | if ( m_forceRaster->isChecked() ) { | | |||
89 | m_scaleMode->setToolTip( i18n( "Scaling mode for the printed pages" ) ); | | |||
90 | } else { | | |||
91 | m_scaleMode->setToolTip( i18n( "Select rasterization to enable this!" ) ); | | |||
92 | } | | |||
93 | } | | |||
94 | 83 | | |||
95 | public: | 84 | public: | ||
96 | enum ScaleMode { | 85 | enum ScaleMode { | ||
97 | FitToPrintableArea, | 86 | FitToPrintableArea, | ||
98 | FitToPage, | 87 | FitToPage, | ||
99 | None | 88 | None | ||
100 | }; | 89 | }; | ||
101 | Q_ENUM(ScaleMode) | 90 | Q_ENUM(ScaleMode) | ||
Show All 13 Lines | 93 | { | |||
115 | 104 | | |||
116 | QWidget* formWidget = new QWidget(this); | 105 | QWidget* formWidget = new QWidget(this); | ||
117 | QFormLayout* printBackendLayout = new QFormLayout(formWidget); | 106 | QFormLayout* printBackendLayout = new QFormLayout(formWidget); | ||
118 | 107 | | |||
119 | m_scaleMode = new QComboBox; | 108 | m_scaleMode = new QComboBox; | ||
120 | m_scaleMode->insertItem(FitToPrintableArea, i18n("Fit to printable area"), FitToPrintableArea); | 109 | m_scaleMode->insertItem(FitToPrintableArea, i18n("Fit to printable area"), FitToPrintableArea); | ||
121 | m_scaleMode->insertItem(FitToPage, i18n("Fit to full page"), FitToPage); | 110 | m_scaleMode->insertItem(FitToPage, i18n("Fit to full page"), FitToPage); | ||
122 | m_scaleMode->insertItem(None, i18n("None; print original size"), None); | 111 | m_scaleMode->insertItem(None, i18n("None; print original size"), None); | ||
123 | m_scaleMode->setToolTip(i18n("Select rasterization to enable this!")); | 112 | m_scaleMode->setToolTip(i18n( "Scaling mode for the printed pages" ) ); | ||
124 | printBackendLayout->addRow(i18n("Scale mode:"), m_scaleMode); | 113 | printBackendLayout->addRow(i18n("Scale mode:"), m_scaleMode); | ||
125 | 114 | | |||
126 | layout->addWidget(formWidget); | 115 | layout->addWidget(formWidget); | ||
127 | 116 | | |||
128 | layout->addStretch(1); | 117 | layout->addStretch(1); | ||
129 | 118 | | |||
130 | // Enable scaleMode only if the file is to be rasterized before printing | | |||
131 | m_scaleMode->setEnabled( false ); | | |||
132 | | ||||
133 | connect( m_forceRaster, &QCheckBox::stateChanged, this, &PDFOptionsPage::enableOrDisableScaleMode ); | | |||
134 | | ||||
135 | #if defined(Q_OS_WIN) && !defined HAVE_POPPLER_0_60 | 119 | #if defined(Q_OS_WIN) && !defined HAVE_POPPLER_0_60 | ||
136 | m_printAnnots->setVisible( false ); | 120 | m_printAnnots->setVisible( false ); | ||
137 | #endif | 121 | #endif | ||
138 | setPrintAnnots( true ); // Default value | 122 | setPrintAnnots( true ); // Default value | ||
139 | } | 123 | } | ||
140 | 124 | | |||
141 | bool ignorePrintMargins() const override { | 125 | bool ignorePrintMargins() const override { | ||
142 | return scaleMode() == FitToPage; | 126 | return scaleMode() == FitToPage; | ||
▲ Show 20 Lines • Show All 1340 Lines • ▼ Show 20 Line(s) | 1466 | if (!printAnnots) | |||
1483 | psConverter->setPSOptions(psConverter->psOptions() | Poppler::PSConverter::HideAnnotations ); | 1467 | psConverter->setPSOptions(psConverter->psOptions() | Poppler::PSConverter::HideAnnotations ); | ||
1484 | 1468 | | |||
1485 | userMutex()->lock(); | 1469 | userMutex()->lock(); | ||
1486 | if (psConverter->convert()) | 1470 | if (psConverter->convert()) | ||
1487 | { | 1471 | { | ||
1488 | userMutex()->unlock(); | 1472 | userMutex()->unlock(); | ||
1489 | delete psConverter; | 1473 | delete psConverter; | ||
1490 | tf.close(); | 1474 | tf.close(); | ||
1475 | | ||||
1476 | const Okular::FilePrinter::ScaleMode filePrinterScaleMode = | ||||
1477 | (scaleMode == PDFOptionsPage::None) ? Okular::FilePrinter::ScaleMode::None : Okular::FilePrinter::ScaleMode::FitToPrintArea; | ||||
1478 | | ||||
1491 | int ret = Okular::FilePrinter::printFile( printer, tempfilename, | 1479 | int ret = Okular::FilePrinter::printFile( printer, tempfilename, | ||
1492 | document()->orientation(), | 1480 | document()->orientation(), | ||
1493 | Okular::FilePrinter::SystemDeletesFiles, | 1481 | Okular::FilePrinter::SystemDeletesFiles, | ||
1494 | Okular::FilePrinter::ApplicationSelectsPages, | 1482 | Okular::FilePrinter::ApplicationSelectsPages, | ||
1495 | document()->bookmarkedPageRange() ); | 1483 | document()->bookmarkedPageRange(), | ||
1484 | filePrinterScaleMode | ||||
1485 | ); | ||||
1496 | 1486 | | |||
1497 | lastPrintError = Okular::FilePrinter::printError( ret ); | 1487 | lastPrintError = Okular::FilePrinter::printError( ret ); | ||
1498 | 1488 | | |||
1499 | return (lastPrintError == NoPrintError); | 1489 | return (lastPrintError == NoPrintError); | ||
1500 | } | 1490 | } | ||
1501 | else | 1491 | else | ||
1502 | { | 1492 | { | ||
1503 | lastPrintError = FileConversionPrintError; | 1493 | lastPrintError = FileConversionPrintError; | ||
▲ Show 20 Lines • Show All 573 Lines • Show Last 20 Lines |