Changeset View
Changeset View
Standalone View
Standalone View
part.cpp
Show First 20 Lines • Show All 111 Lines • ▼ Show 20 Line(s) | |||||
112 | #include "core/action.h" | 112 | #include "core/action.h" | ||
113 | #include "core/annotations.h" | 113 | #include "core/annotations.h" | ||
114 | #include "core/bookmarkmanager.h" | 114 | #include "core/bookmarkmanager.h" | ||
115 | #include "core/document.h" | 115 | #include "core/document.h" | ||
116 | #include "core/document_p.h" | 116 | #include "core/document_p.h" | ||
117 | #include "core/generator.h" | 117 | #include "core/generator.h" | ||
118 | #include "core/page.h" | 118 | #include "core/page.h" | ||
119 | #include "core/fileprinter.h" | 119 | #include "core/fileprinter.h" | ||
120 | #include "core/printoptionswidget.h" | ||||
120 | #include <memory> | 121 | #include <memory> | ||
121 | 122 | | |||
122 | #ifdef OKULAR_KEEP_FILE_OPEN | 123 | #ifdef OKULAR_KEEP_FILE_OPEN | ||
123 | class FileKeeper | 124 | class FileKeeper | ||
124 | { | 125 | { | ||
125 | public: | 126 | public: | ||
126 | FileKeeper() | 127 | FileKeeper() | ||
127 | : m_handle( nullptr ) | 128 | : m_handle( nullptr ) | ||
▲ Show 20 Lines • Show All 3169 Lines • ▼ Show 20 Line(s) | 3294 | #endif | |||
3297 | // Must do certain QPrinter setup before creating QPrintDialog | 3298 | // Must do certain QPrinter setup before creating QPrintDialog | ||
3298 | setupPrint( printer ); | 3299 | setupPrint( printer ); | ||
3299 | 3300 | | |||
3300 | // Create the Print Dialog with extra config widgets if required | 3301 | // Create the Print Dialog with extra config widgets if required | ||
3301 | if ( m_document->canConfigurePrinter() ) | 3302 | if ( m_document->canConfigurePrinter() ) | ||
3302 | { | 3303 | { | ||
3303 | printConfigWidget = m_document->printConfigurationWidget(); | 3304 | printConfigWidget = m_document->printConfigurationWidget(); | ||
3304 | } | 3305 | } | ||
3306 | else | ||||
3307 | { | ||||
3308 | printConfigWidget = new DefaultPrintOptionsWidget(); | ||||
3309 | } | ||||
3305 | 3310 | | |||
3306 | printDialog = new QPrintDialog(&printer, widget()); | 3311 | printDialog = new QPrintDialog(&printer, widget()); | ||
3307 | printDialog->setWindowTitle(i18nc("@title:window", "Print")); | 3312 | printDialog->setWindowTitle(i18nc("@title:window", "Print")); | ||
3308 | QList<QWidget*> options; | 3313 | QList<QWidget*> options; | ||
3309 | if (printConfigWidget) { | 3314 | if (printConfigWidget) { | ||
3310 | options << printConfigWidget; | 3315 | options << printConfigWidget; | ||
3311 | } | 3316 | } | ||
3312 | printDialog->setOptionTabs(options); | 3317 | printDialog->setOptionTabs(options); | ||
Show All 21 Lines | 3320 | { | |||
3334 | // Enable the Current Page option in the dialog. | 3339 | // Enable the Current Page option in the dialog. | ||
3335 | if ( m_document->pages() > 1 && currentPage() > 0 ) | 3340 | if ( m_document->pages() > 1 && currentPage() > 0 ) | ||
3336 | { | 3341 | { | ||
3337 | printDialog->setOption( QAbstractPrintDialog::PrintCurrentPage ); | 3342 | printDialog->setOption( QAbstractPrintDialog::PrintCurrentPage ); | ||
3338 | } | 3343 | } | ||
3339 | 3344 | | |||
3340 | bool success = true; | 3345 | bool success = true; | ||
3341 | if ( printDialog->exec() ) | 3346 | if ( printDialog->exec() ) | ||
3347 | { | ||||
3348 | // set option for margins if widget is of corresponding type that holds this information | ||||
3349 | PrintOptionsWidget *optionWidget = dynamic_cast<PrintOptionsWidget *>(printConfigWidget); | ||||
3350 | if (optionWidget != nullptr) | ||||
3351 | printer.setFullPage( optionWidget->ignorePrintMargins() ); | ||||
3352 | else | ||||
3353 | { | ||||
3354 | // printConfigurationWidget() method should always return an object of type Okular::PrintOptionsWidget, | ||||
3355 | // (signature does not (yet) require it for ABI stability reasons), so emit a warning if the object is of another type | ||||
3356 | qWarning() << "printConfigurationWidget() method did not return an Okular::PrintOptionsWidget. This is strongly discouraged!"; | ||||
3357 | } | ||||
3358 | | ||||
3342 | success = doPrint( printer ); | 3359 | success = doPrint( printer ); | ||
3360 | } | ||||
3343 | delete printDialog; | 3361 | delete printDialog; | ||
3344 | if ( m_cliPrintAndExit ) | 3362 | if ( m_cliPrintAndExit ) | ||
3345 | exit ( success ? EXIT_SUCCESS : EXIT_FAILURE ); | 3363 | exit ( success ? EXIT_SUCCESS : EXIT_FAILURE ); | ||
3346 | } | 3364 | } | ||
3347 | } | 3365 | } | ||
3348 | 3366 | | |||
3349 | 3367 | | |||
3350 | void Part::setupPrint( QPrinter &printer ) | 3368 | void Part::setupPrint( QPrinter &printer ) | ||
▲ Show 20 Lines • Show All 328 Lines • Show Last 20 Lines |