summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-08-13 20:30:22 (GMT)
committerMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-08-13 20:30:22 (GMT)
commitdecd4849a80ddd77addfd35013ac2ca0e6b00e7a (patch)
tree33df0792bf138596f036fa6d3c8125ef4a672405
parent2639b1e8ed45d1c21099debe5ab6cbdf37a279ef (diff)
Use Okular's own print preview dialog for all documents
-rw-r--r--part.cpp43
1 files changed, 22 insertions, 21 deletions
diff --git a/part.cpp b/part.cpp
index e23ac6e..2db9387 100644
--- a/part.cpp
+++ b/part.cpp
@@ -68,8 +68,6 @@
#include <KXMLGUIClient>
#include <KXMLGUIFactory>
-#include <KPrintPreview>
-
#if 0
#include <knewstuff2/engine.h>
#endif
@@ -2453,30 +2451,33 @@ void Part::slotPrintPreview()
if (m_document->pages() == 0) return;
QPrinter printer;
+ QString tempFilePattern;
- // Native printing supports KPrintPreview, Postscript needs to use FilePrinterPreview
- if ( m_document->printingSupport() == Okular::Document::NativePrinting )
+ if ( m_document->printingSupport() == Okular::Document::PostscriptPrinting )
{
- KPrintPreview previewdlg( &printer, widget() );
- setupPrint( printer );
- doPrint( printer );
- previewdlg.exec();
+ tempFilePattern = (QDir::tempPath() + QLatin1String("/okular_XXXXXX.ps"));
+ }
+ else if ( m_document->printingSupport() == Okular::Document::NativePrinting )
+ {
+ tempFilePattern = (QDir::tempPath() + QLatin1String("/okular_XXXXXX.pdf"));
}
else
{
- // Generate a temp filename for Print to File, then release the file so generator can write to it
- QTemporaryFile tf(QDir::tempPath() + QLatin1String("/okular_XXXXXX.ps"));
- tf.setAutoRemove( true );
- tf.open();
- printer.setOutputFileName( tf.fileName() );
- tf.close();
- setupPrint( printer );
- doPrint( printer );
- if ( QFile::exists( printer.outputFileName() ) )
- {
- Okular::FilePrinterPreview previewdlg( printer.outputFileName(), widget() );
- previewdlg.exec();
- }
+ return;
+ }
+
+ // Generate a temp filename for Print to File, then release the file so generator can write to it
+ QTemporaryFile tf(tempFilePattern);
+ tf.setAutoRemove( true );
+ tf.open();
+ printer.setOutputFileName( tf.fileName() );
+ tf.close();
+ setupPrint( printer );
+ doPrint( printer );
+ if ( QFile::exists( printer.outputFileName() ) )
+ {
+ Okular::FilePrinterPreview previewdlg( printer.outputFileName(), widget() );
+ previewdlg.exec();
}
}