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 3161 Lines • ▼ Show 20 Line(s) | 3286 | #endif | |||
3289 | // Must do certain QPrinter setup before creating QPrintDialog | 3290 | // Must do certain QPrinter setup before creating QPrintDialog | ||
3290 | setupPrint( printer ); | 3291 | setupPrint( printer ); | ||
3291 | 3292 | | |||
3292 | // Create the Print Dialog with extra config widgets if required | 3293 | // Create the Print Dialog with extra config widgets if required | ||
3293 | if ( m_document->canConfigurePrinter() ) | 3294 | if ( m_document->canConfigurePrinter() ) | ||
3294 | { | 3295 | { | ||
3295 | printConfigWidget = m_document->printConfigurationWidget(); | 3296 | printConfigWidget = m_document->printConfigurationWidget(); | ||
3296 | } | 3297 | } | ||
3298 | else | ||||
3299 | { | ||||
3300 | printConfigWidget = new DefaultPrintOptionsWidget(); | ||||
3301 | } | ||||
3297 | 3302 | | |||
3298 | printDialog = new QPrintDialog(&printer, widget()); | 3303 | printDialog = new QPrintDialog(&printer, widget()); | ||
3299 | printDialog->setWindowTitle(i18nc("@title:window", "Print")); | 3304 | printDialog->setWindowTitle(i18nc("@title:window", "Print")); | ||
3300 | QList<QWidget*> options; | 3305 | QList<QWidget*> options; | ||
3301 | if (printConfigWidget) { | 3306 | if (printConfigWidget) { | ||
3302 | options << printConfigWidget; | 3307 | options << printConfigWidget; | ||
3303 | } | 3308 | } | ||
3304 | printDialog->setOptionTabs(options); | 3309 | printDialog->setOptionTabs(options); | ||
Show All 21 Lines | 3312 | { | |||
3326 | // Enable the Current Page option in the dialog. | 3331 | // Enable the Current Page option in the dialog. | ||
3327 | if ( m_document->pages() > 1 && currentPage() > 0 ) | 3332 | if ( m_document->pages() > 1 && currentPage() > 0 ) | ||
3328 | { | 3333 | { | ||
3329 | printDialog->setOption( QAbstractPrintDialog::PrintCurrentPage ); | 3334 | printDialog->setOption( QAbstractPrintDialog::PrintCurrentPage ); | ||
3330 | } | 3335 | } | ||
3331 | 3336 | | |||
3332 | bool success = true; | 3337 | bool success = true; | ||
3333 | if ( printDialog->exec() ) | 3338 | if ( printDialog->exec() ) | ||
3339 | { | ||||
3340 | // set option for margins if widget is of corresponding type that holds this information | ||||
3341 | PrintOptionsWidget *optionWidget = dynamic_cast<PrintOptionsWidget *>(printConfigWidget); | ||||
3342 | if (optionWidget != nullptr) | ||||
3343 | printer.setFullPage( optionWidget->ignorePrintMargins() ); | ||||
3344 | else | ||||
3345 | { | ||||
3346 | // printConfigurationWidget() method should always return an object of type Okular::PrintOptionsWidget, | ||||
3347 | // (signature does not (yet) require it for ABI stability reasons), so emit a warning if the object is of another type | ||||
3348 | qWarning() << "printConfigurationWidget() method did not return an Okular::PrintOptionsWidget. This is strongly discouraged!"; | ||||
3349 | } | ||||
3350 | | ||||
3334 | success = doPrint( printer ); | 3351 | success = doPrint( printer ); | ||
3352 | } | ||||
3335 | delete printDialog; | 3353 | delete printDialog; | ||
3336 | if ( m_cliPrintAndExit ) | 3354 | if ( m_cliPrintAndExit ) | ||
3337 | exit ( success ? EXIT_SUCCESS : EXIT_FAILURE ); | 3355 | exit ( success ? EXIT_SUCCESS : EXIT_FAILURE ); | ||
3338 | } | 3356 | } | ||
3339 | } | 3357 | } | ||
3340 | 3358 | | |||
3341 | 3359 | | |||
3342 | void Part::setupPrint( QPrinter &printer ) | 3360 | void Part::setupPrint( QPrinter &printer ) | ||
▲ Show 20 Lines • Show All 323 Lines • Show Last 20 Lines |