summaryrefslogtreecommitdiffstats
path: root/src/printsupport/kernel/qprinter_p.h
diff options
context:
space:
mode:
authorJohn Layt <jlayt@kde.org>2013-11-23 19:52:34 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-29 15:59:00 +0100
commite8a45152b5e2e99e757e91a5d42a6dce609ff583 (patch)
treead9b801d10b236a4d74caa58b270475b7f25b85b /src/printsupport/kernel/qprinter_p.h
parent7079f1121325cedfb59c753870bd227a897ce6c7 (diff)
QPrinter - Fix OutputFormat when no printers
Currently the QPrinter constructor, setOutputFormat() and setPrinterName() make bad assumptions about the availability of printers when configuring NativeFormat which can lead to inconsistent print engine set-ups leading to crashes in the print dialog, especially on Windows where a valid DEVMODE is needed. This change cleans up the init and methods to ensure NativeFormat can only ever be set if we have both a valid plugin and a valid printer, if not the PdfFormat is used. One side-effect of this is that it is now impossible to set an invalid printer name via QPrinter (but still able to be done via QPrintEngine if really needed). Also if no default printer is set then use the first available one. This also fixes a bug where setting a new printer name on Windows reset all the saved settings. [ChangeLog][Important Behavior Changes] QPrinter no longer allows you to set an invalid printer name. Task-number: QTBUG-34345 Task-number: QTBUG-26008 Task-number: QTBUG-26430 Change-Id: I19737e4209d8c8df5817ea83246b3dd0c483ee85 Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Diffstat (limited to 'src/printsupport/kernel/qprinter_p.h')
-rw-r--r--src/printsupport/kernel/qprinter_p.h28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/printsupport/kernel/qprinter_p.h b/src/printsupport/kernel/qprinter_p.h
index 2bec44aae6..7e5bc12cd0 100644
--- a/src/printsupport/kernel/qprinter_p.h
+++ b/src/printsupport/kernel/qprinter_p.h
@@ -59,6 +59,7 @@
#ifndef QT_NO_PRINTER
#include "QtPrintSupport/qprinter.h"
+#include "QtPrintSupport/qprinterinfo.h"
#include "QtPrintSupport/qprintengine.h"
#include "QtCore/qpointer.h"
@@ -75,14 +76,19 @@ class Q_PRINTSUPPORT_EXPORT QPrinterPrivate
Q_DECLARE_PUBLIC(QPrinter)
public:
QPrinterPrivate(QPrinter *printer)
- : printEngine(0)
- , paintEngine(0)
- , q_ptr(printer)
- , printRange(QPrinter::AllPages)
- , use_default_engine(true)
- , validPrinter(false)
- , hasCustomPageMargins(false)
- , hasUserSetPageSize(false)
+ : printEngine(0),
+ paintEngine(0),
+ realPrintEngine(0),
+ realPaintEngine(0),
+#ifndef QT_NO_PRINTPREVIEWWIDGET
+ previewEngine(0),
+#endif
+ q_ptr(printer),
+ printRange(QPrinter::AllPages),
+ use_default_engine(true),
+ validPrinter(false),
+ hasCustomPageMargins(false),
+ hasUserSetPageSize(false)
{
}
@@ -90,9 +96,11 @@ public:
}
- void init(QPrinter::PrinterMode mode);
+ void init(const QPrinterInfo &printer, QPrinter::PrinterMode mode);
- void createDefaultEngines();
+ QPrinterInfo findValidPrinter(const QPrinterInfo &printer = QPrinterInfo());
+ void initEngines(QPrinter::OutputFormat format, const QPrinterInfo &printer);
+ void changeEngines(QPrinter::OutputFormat format, const QPrinterInfo &printer);
#ifndef QT_NO_PRINTPREVIEWWIDGET
QList<const QPicture *> previewPages() const;
void setPreviewMode(bool);