summaryrefslogtreecommitdiffstats
path: root/src/printsupport
diff options
context:
space:
mode:
Diffstat (limited to 'src/printsupport')
-rw-r--r--src/printsupport/dialogs/qabstractprintdialog.h2
-rw-r--r--src/printsupport/dialogs/qpagesetupdialog_mac.mm4
-rw-r--r--src/printsupport/dialogs/qprintdialog.h1
-rw-r--r--src/printsupport/dialogs/qprintdialog_mac.mm4
-rw-r--r--src/printsupport/kernel/qplatformprintplugin.cpp14
-rw-r--r--src/printsupport/kernel/qprintengine_win.cpp41
-rw-r--r--src/printsupport/kernel/qprinter.cpp138
-rw-r--r--src/printsupport/kernel/qprinter.h159
8 files changed, 64 insertions, 299 deletions
diff --git a/src/printsupport/dialogs/qabstractprintdialog.h b/src/printsupport/dialogs/qabstractprintdialog.h
index f18406af4b..6c57a301a6 100644
--- a/src/printsupport/dialogs/qabstractprintdialog.h
+++ b/src/printsupport/dialogs/qabstractprintdialog.h
@@ -76,8 +76,10 @@ public:
DontUseSheet = 0x0020,
PrintCurrentPage = 0x0040
};
+ Q_ENUM(PrintDialogOption)
Q_DECLARE_FLAGS(PrintDialogOptions, PrintDialogOption)
+ Q_FLAG(PrintDialogOptions)
#ifndef QT_NO_PRINTDIALOG
explicit QAbstractPrintDialog(QPrinter *printer, QWidget *parent = Q_NULLPTR);
diff --git a/src/printsupport/dialogs/qpagesetupdialog_mac.mm b/src/printsupport/dialogs/qpagesetupdialog_mac.mm
index c29b911e35..581c0271f1 100644
--- a/src/printsupport/dialogs/qpagesetupdialog_mac.mm
+++ b/src/printsupport/dialogs/qpagesetupdialog_mac.mm
@@ -78,7 +78,7 @@ QT_USE_NAMESPACE
QPageSetupDialog *dialog = static_cast<QPageSetupDialog *>(contextInfo);
QPrinter *printer = dialog->printer();
- if (returnCode == NSOKButton) {
+ if (returnCode == NSModalResponseOK) {
PMPageFormat format = static_cast<PMPageFormat>([printInfo PMPageFormat]);
PMRect paperRect;
PMGetUnadjustedPaperRect(format, &paperRect);
@@ -89,7 +89,7 @@ QT_USE_NAMESPACE
printer->printEngine()->setProperty(QPrintEngine::PPK_Orientation, orientation == kPMLandscape ? QPrinter::Landscape : QPrinter::Portrait);
}
- dialog->done((returnCode == NSOKButton) ? QDialog::Accepted : QDialog::Rejected);
+ dialog->done((returnCode == NSModalResponseOK) ? QDialog::Accepted : QDialog::Rejected);
}
@end
diff --git a/src/printsupport/dialogs/qprintdialog.h b/src/printsupport/dialogs/qprintdialog.h
index a1d79b2310..f01e515af4 100644
--- a/src/printsupport/dialogs/qprintdialog.h
+++ b/src/printsupport/dialogs/qprintdialog.h
@@ -56,7 +56,6 @@ class Q_PRINTSUPPORT_EXPORT QPrintDialog : public QAbstractPrintDialog
{
Q_OBJECT
Q_DECLARE_PRIVATE(QPrintDialog)
- Q_ENUMS(PrintDialogOption)
Q_PROPERTY(PrintDialogOptions options READ options WRITE setOptions)
public:
diff --git a/src/printsupport/dialogs/qprintdialog_mac.mm b/src/printsupport/dialogs/qprintdialog_mac.mm
index c630ab634a..4595ed71ff 100644
--- a/src/printsupport/dialogs/qprintdialog_mac.mm
+++ b/src/printsupport/dialogs/qprintdialog_mac.mm
@@ -103,7 +103,7 @@ QT_USE_NAMESPACE
QPrintDialog *dialog = static_cast<QPrintDialog *>(contextInfo);
QPrinter *printer = dialog->printer();
- if (returnCode == NSOKButton) {
+ if (returnCode == NSModalResponseOK) {
PMPrintSession session = static_cast<PMPrintSession>([printInfo PMPrintSession]);
PMPrintSettings settings = static_cast<PMPrintSettings>([printInfo PMPrintSettings]);
@@ -192,7 +192,7 @@ QT_USE_NAMESPACE
printer->setPageSize(pageSize);
printer->setOrientation(orientation == kPMLandscape ? QPrinter::Landscape : QPrinter::Portrait);
- dialog->done((returnCode == NSOKButton) ? QDialog::Accepted : QDialog::Rejected);
+ dialog->done((returnCode == NSModalResponseOK) ? QDialog::Accepted : QDialog::Rejected);
}
@end
diff --git a/src/printsupport/kernel/qplatformprintplugin.cpp b/src/printsupport/kernel/qplatformprintplugin.cpp
index 9bc4b61829..a80f369040 100644
--- a/src/printsupport/kernel/qplatformprintplugin.cpp
+++ b/src/printsupport/kernel/qplatformprintplugin.cpp
@@ -42,6 +42,7 @@
#include "qprinterinfo.h"
#include "private/qfactoryloader_p.h"
#include <qcoreapplication.h>
+#include <qdebug.h>
#ifndef QT_NO_PRINTER
@@ -79,8 +80,17 @@ QPlatformPrinterSupport *QPlatformPrinterSupportPlugin::get()
{
if (!printerSupport) {
const QMultiMap<int, QString> keyMap = loader()->keyMap();
- if (!keyMap.isEmpty())
- printerSupport = qLoadPlugin<QPlatformPrinterSupport, QPlatformPrinterSupportPlugin>(loader(), keyMap.constBegin().value());
+ QMultiMap<int, QString>::const_iterator it = keyMap.cbegin();
+ if (!qEnvironmentVariableIsEmpty("QT_PRINTER_MODULE")) {
+ QString module = QString::fromLocal8Bit(qgetenv("QT_PRINTER_MODULE"));
+ QMultiMap<int, QString>::const_iterator it2 = std::find_if(keyMap.cbegin(), keyMap.cend(), [module](const QString &value){ return value == module; });
+ if (it2 == keyMap.cend())
+ qWarning() << "Unable to load printer plugin" << module;
+ else
+ it = it2;
+ }
+ if (it != keyMap.cend())
+ printerSupport = qLoadPlugin<QPlatformPrinterSupport, QPlatformPrinterSupportPlugin>(loader(), it.value());
if (printerSupport)
qAddPostRoutine(cleanupPrinterSupport);
}
diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp
index 706a7c4b02..f1ccbaa90a 100644
--- a/src/printsupport/kernel/qprintengine_win.cpp
+++ b/src/printsupport/kernel/qprintengine_win.cpp
@@ -1224,11 +1224,20 @@ void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &
QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();
if (!ps)
return;
+
+ QVariant pageSize = QVariant::fromValue(d->m_pageLayout.pageSize());
+ const bool isFullPage = (d->m_pageLayout.mode() == QPageLayout::FullPageMode);
+ QVariant orientation = QVariant::fromValue(d->m_pageLayout.orientation());
+ QVariant margins = QVariant::fromValue(
+ QPair<QMarginsF, QPageLayout::Unit>(d->m_pageLayout.margins(), d->m_pageLayout.units()));
QPrintDevice printDevice = ps->createPrintDevice(id.isEmpty() ? ps->defaultPrintDeviceId() : id);
if (printDevice.isValid()) {
d->m_printDevice = printDevice;
- // TODO Do we need to check if the page size is valid on new printer?
d->initialize();
+ setProperty(PPK_QPageSize, pageSize);
+ setProperty(PPK_FullPage, QVariant(isFullPage));
+ setProperty(PPK_Orientation, orientation);
+ setProperty(PPK_QPageMargins, margins);
}
break;
}
@@ -1650,9 +1659,33 @@ void QWin32PrintEnginePrivate::updatePageLayout()
m_pageLayout.setOrientation(devMode->dmOrientation == DMORIENT_LANDSCAPE ? QPageLayout::Landscape : QPageLayout::Portrait);
if (devMode->dmPaperSize >= DMPAPER_LAST) {
// Is a custom size
- QPageSize pageSize = QPageSize(QSizeF(devMode->dmPaperWidth / 10.0f, devMode->dmPaperLength / 10.0f),
- QPageSize::Millimeter);
- setPageSize(pageSize);
+ // Check if it is using the Postscript Custom Size first
+ bool hasCustom = false;
+ int feature = PSIDENT_GDICENTRIC;
+ if (ExtEscape(hdc, POSTSCRIPT_IDENTIFY,
+ sizeof(DWORD), reinterpret_cast<LPCSTR>(&feature), 0, 0) >= 0) {
+ PSFEATURE_CUSTPAPER custPaper;
+ feature = FEATURESETTING_CUSTPAPER;
+ if (ExtEscape(hdc, GET_PS_FEATURESETTING, sizeof(INT), reinterpret_cast<LPCSTR>(&feature),
+ sizeof(custPaper), reinterpret_cast<LPSTR>(&custPaper)) > 0) {
+ // If orientation is 1 and width/height is 0 then it's not really custom
+ if (!(custPaper.lOrientation == 1 && custPaper.lWidth == 0 && custPaper.lHeight == 0)) {
+ if (custPaper.lOrientation == 0 || custPaper.lOrientation == 2)
+ m_pageLayout.setOrientation(QPageLayout::Portrait);
+ else
+ m_pageLayout.setOrientation(QPageLayout::Landscape);
+ QPageSize pageSize = QPageSize(QSizeF(custPaper.lWidth, custPaper.lHeight),
+ QPageSize::Point);
+ setPageSize(pageSize);
+ hasCustom = true;
+ }
+ }
+ }
+ if (!hasCustom) {
+ QPageSize pageSize = QPageSize(QSizeF(devMode->dmPaperWidth / 10.0f, devMode->dmPaperLength / 10.0f),
+ QPageSize::Millimeter);
+ setPageSize(pageSize);
+ }
} else {
// Is a supported size
setPageSize(QPageSize(QPageSize::id(devMode->dmPaperSize)));
diff --git a/src/printsupport/kernel/qprinter.cpp b/src/printsupport/kernel/qprinter.cpp
index 7824d28ac5..53bed87dfc 100644
--- a/src/printsupport/kernel/qprinter.cpp
+++ b/src/printsupport/kernel/qprinter.cpp
@@ -449,143 +449,17 @@ public:
*/
/*!
- \enum QPrinter::PaperSize
+ \typedef QPrinter::PaperSize
\since 4.4
+ typdef for the enum QPagedPaintDevice::PageSize.
+
This enum type specifies what paper size QPrinter should use.
QPrinter does not check that the paper size is available; it just
uses this information, together with QPrinter::Orientation and
QPrinter::setFullPage(), to determine the printable area.
- The defined sizes (with setFullPage(true)) are:
-
- \value A0 841 x 1189 mm
- \value A1 594 x 841 mm
- \value A2 420 x 594 mm
- \value A3 297 x 420 mm
- \value A4 210 x 297 mm, 8.26 x 11.69 inches
- \value A5 148 x 210 mm
- \value A6 105 x 148 mm
- \value A7 74 x 105 mm
- \value A8 52 x 74 mm
- \value A9 37 x 52 mm
- \value B0 1000 x 1414 mm
- \value B1 707 x 1000 mm
- \value B2 500 x 707 mm
- \value B3 353 x 500 mm
- \value B4 250 x 353 mm
- \value B5 176 x 250 mm, 6.93 x 9.84 inches
- \value B6 125 x 176 mm
- \value B7 88 x 125 mm
- \value B8 62 x 88 mm
- \value B9 33 x 62 mm
- \value B10 31 x 44 mm
- \value C5E 163 x 229 mm
- \value Comm10E 105 x 241 mm, U.S. Common 10 Envelope
- \value DLE 110 x 220 mm
- \value Executive 7.5 x 10 inches, 190.5 x 254 mm
- \value Folio 210 x 330 mm
- \value Ledger 431.8 x 279.4 mm
- \value Legal 8.5 x 14 inches, 215.9 x 355.6 mm
- \value Letter 8.5 x 11 inches, 215.9 x 279.4 mm
- \value Tabloid 279.4 x 431.8 mm
- \value Custom Unknown, or a user defined size.
- \value A10
- \value A3Extra
- \value A4Extra
- \value A4Plus
- \value A4Small
- \value A5Extra
- \value B5Extra
- \value JisB0
- \value JisB1
- \value JisB2
- \value JisB3
- \value JisB4
- \value JisB5
- \value JisB6,
- \value JisB7
- \value JisB8
- \value JisB9
- \value JisB10
- \value AnsiA = Letter
- \value AnsiB = Ledger
- \value AnsiC
- \value AnsiD
- \value AnsiE
- \value LegalExtra
- \value LetterExtra
- \value LetterPlus
- \value LetterSmall
- \value TabloidExtra
- \value ArchA
- \value ArchB
- \value ArchC
- \value ArchD
- \value ArchE
- \value Imperial7x9
- \value Imperial8x10
- \value Imperial9x11
- \value Imperial9x12
- \value Imperial10x11
- \value Imperial10x13
- \value Imperial10x14
- \value Imperial12x11
- \value Imperial15x11
- \value ExecutiveStandard
- \value Note
- \value Quarto
- \value Statement
- \value SuperA
- \value SuperB
- \value Postcard
- \value DoublePostcard
- \value Prc16K
- \value Prc32K
- \value Prc32KBig
- \value FanFoldUS
- \value FanFoldGerman
- \value FanFoldGermanLegal
- \value EnvelopeB4
- \value EnvelopeB5
- \value EnvelopeB6
- \value EnvelopeC0
- \value EnvelopeC1
- \value EnvelopeC2
- \value EnvelopeC3
- \value EnvelopeC4
- \value EnvelopeC5 = C5E
- \value EnvelopeC6
- \value EnvelopeC65
- \value EnvelopeC7
- \value EnvelopeDL = DLE
- \value Envelope9
- \value Envelope10 = Comm10E
- \value Envelope11
- \value Envelope12
- \value Envelope14
- \value EnvelopeMonarch
- \value EnvelopePersonal
- \value EnvelopeChou3
- \value EnvelopeChou4
- \value EnvelopeInvite
- \value EnvelopeItalian
- \value EnvelopeKaku2
- \value EnvelopeKaku3
- \value EnvelopePrc1
- \value EnvelopePrc2
- \value EnvelopePrc3
- \value EnvelopePrc4
- \value EnvelopePrc5
- \value EnvelopePrc6
- \value EnvelopePrc7
- \value EnvelopePrc8
- \value EnvelopePrc9
- \value EnvelopePrc10
- \value EnvelopeYou4
- \value LastPageSize = EnvelopeYou4
- \omitvalue NPageSize
- \omitvalue NPaperSize
+ The defined sizes (with setFullPage(true)) are found in QPagedPaintDevice.
With setFullPage(false) (the default), the metrics will be a bit
smaller; how much depends on the printer in use.
@@ -1032,7 +906,7 @@ void QPrinter::setCreator(const QString &creator)
}
// Defined in QPagedPaintDevice but non-virtual, add QPrinter specific doc here
-#ifdef Q_QDOC
+#ifdef Q_CLANG_QDOC
/*!
\fn bool QPrinter::setPageLayout(const QPageLayout &newLayout)
\since 5.3
@@ -1997,7 +1871,7 @@ QPrinter::PrinterState QPrinter::printerState() const
return d->printEngine->printerState();
}
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC)
/*!
Returns the supported paper sizes for this printer.
diff --git a/src/printsupport/kernel/qprinter.h b/src/printsupport/kernel/qprinter.h
index 4650d5432a..33a2d4dbc8 100644
--- a/src/printsupport/kernel/qprinter.h
+++ b/src/printsupport/kernel/qprinter.h
@@ -77,161 +77,7 @@ public:
enum Orientation { Portrait, Landscape };
// ### Qt6 Remove in favor of QPage::PageSize
- // NOTE: Must keep in sync with QPageSize and QPagedPaintDevice
-#ifndef Q_QDOC
typedef PageSize PaperSize;
-#else
- enum PaperSize {
- // Existing Qt sizes
- A4,
- B5,
- Letter,
- Legal,
- Executive,
- A0,
- A1,
- A2,
- A3,
- A5,
- A6,
- A7,
- A8,
- A9,
- B0,
- B1,
- B10,
- B2,
- B3,
- B4,
- B6,
- B7,
- B8,
- B9,
- C5E,
- Comm10E,
- DLE,
- Folio,
- Ledger,
- Tabloid,
- Custom,
-
- // New values derived from PPD standard
- A10,
- A3Extra,
- A4Extra,
- A4Plus,
- A4Small,
- A5Extra,
- B5Extra,
-
- JisB0,
- JisB1,
- JisB2,
- JisB3,
- JisB4,
- JisB5,
- JisB6,
- JisB7,
- JisB8,
- JisB9,
- JisB10,
-
- // AnsiA = Letter,
- // AnsiB = Ledger,
- AnsiC,
- AnsiD,
- AnsiE,
- LegalExtra,
- LetterExtra,
- LetterPlus,
- LetterSmall,
- TabloidExtra,
-
- ArchA,
- ArchB,
- ArchC,
- ArchD,
- ArchE,
-
- Imperial7x9,
- Imperial8x10,
- Imperial9x11,
- Imperial9x12,
- Imperial10x11,
- Imperial10x13,
- Imperial10x14,
- Imperial12x11,
- Imperial15x11,
-
- ExecutiveStandard,
- Note,
- Quarto,
- Statement,
- SuperA,
- SuperB,
- Postcard,
- DoublePostcard,
- Prc16K,
- Prc32K,
- Prc32KBig,
-
- FanFoldUS,
- FanFoldGerman,
- FanFoldGermanLegal,
-
- EnvelopeB4,
- EnvelopeB5,
- EnvelopeB6,
- EnvelopeC0,
- EnvelopeC1,
- EnvelopeC2,
- EnvelopeC3,
- EnvelopeC4,
- // EnvelopeC5 = C5E,
- EnvelopeC6,
- EnvelopeC65,
- EnvelopeC7,
- // EnvelopeDL = DLE,
-
- Envelope9,
- // Envelope10 = Comm10E,
- Envelope11,
- Envelope12,
- Envelope14,
- EnvelopeMonarch,
- EnvelopePersonal,
-
- EnvelopeChou3,
- EnvelopeChou4,
- EnvelopeInvite,
- EnvelopeItalian,
- EnvelopeKaku2,
- EnvelopeKaku3,
- EnvelopePrc1,
- EnvelopePrc2,
- EnvelopePrc3,
- EnvelopePrc4,
- EnvelopePrc5,
- EnvelopePrc6,
- EnvelopePrc7,
- EnvelopePrc8,
- EnvelopePrc9,
- EnvelopePrc10,
- EnvelopeYou4,
-
- // Last item, with commonly used synynoms from QPagedPrintEngine / QPrinter
- LastPageSize = EnvelopeYou4,
- NPageSize = LastPageSize,
- NPaperSize = LastPageSize,
-
- // Convenience overloads for naming consistency
- AnsiA = Letter,
- AnsiB = Ledger,
- EnvelopeC5 = C5E,
- EnvelopeDL = DLE,
- Envelope10 = Comm10E
- };
-#endif
enum PageOrder { FirstPageFirst,
LastPageFirst };
@@ -305,7 +151,8 @@ public:
void setCreator(const QString &);
QString creator() const;
-#ifdef Q_QDOC
+#ifdef Q_CLANG_QDOC
+ // ### Qt6 Remove when these are made virtual in QPagedPaintDevice
bool setPageLayout(const QPageLayout &pageLayout);
bool setPageSize(const QPageSize &pageSize);
bool setPageOrientation(QPageLayout::Orientation orientation);
@@ -366,7 +213,7 @@ public:
QList<int> supportedResolutions() const;
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC)
QList<PaperSource> supportedPaperSources() const;
#endif