summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/widgets/itemviews/pixelator/mainwindow.cpp8
-rw-r--r--examples/widgets/painting/fontsampler/mainwindow.cpp8
-rw-r--r--src/gui/painting/qpagedpaintdevice.cpp165
-rw-r--r--src/gui/painting/qpagedpaintdevice.h185
-rw-r--r--src/gui/painting/qpagelayout.h1
-rw-r--r--src/gui/painting/qpdfwriter.cpp49
-rw-r--r--src/gui/painting/qpdfwriter.h20
-rw-r--r--src/printsupport/dialogs/qpagesetupdialog_mac.mm2
-rw-r--r--src/printsupport/dialogs/qprintpreviewdialog.cpp4
-rw-r--r--src/printsupport/kernel/qprinter.cpp595
-rw-r--r--src/printsupport/kernel/qprinter.h86
-rw-r--r--src/printsupport/widgets/qprintpreviewwidget.cpp18
-rw-r--r--src/printsupport/widgets/qprintpreviewwidget.h4
-rw-r--r--tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp91
-rw-r--r--tests/auto/gui/text/qtexttable/tst_qtexttable.cpp2
-rw-r--r--tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp696
-rw-r--r--tests/manual/dialogs/printdialogpanel.cpp139
17 files changed, 318 insertions, 1755 deletions
diff --git a/examples/widgets/itemviews/pixelator/mainwindow.cpp b/examples/widgets/itemviews/pixelator/mainwindow.cpp
index e590a1397b..591123b187 100644
--- a/examples/widgets/itemviews/pixelator/mainwindow.cpp
+++ b/examples/widgets/itemviews/pixelator/mainwindow.cpp
@@ -197,12 +197,12 @@ void MainWindow::printImage()
painter.save();
- double xscale = printer.pageRect().width() / double(sourceWidth);
- double yscale = printer.pageRect().height() / double(sourceHeight);
+ double xscale = printer.pageRect(QPrinter::DevicePixel).width() / double(sourceWidth);
+ double yscale = printer.pageRect(QPrinter::DevicePixel).height() / double(sourceHeight);
double scale = qMin(xscale, yscale);
- painter.translate(printer.paperRect().x() + printer.pageRect().width() / 2,
- printer.paperRect().y() + printer.pageRect().height() / 2);
+ painter.translate(printer.paperRect(QPrinter::DevicePixel).x() + printer.pageRect(QPrinter::DevicePixel).width() / 2,
+ printer.paperRect(QPrinter::DevicePixel).y() + printer.pageRect(QPrinter::DevicePixel).height() / 2);
painter.scale(scale, scale);
painter.translate(-sourceWidth / 2, -sourceHeight / 2);
diff --git a/examples/widgets/painting/fontsampler/mainwindow.cpp b/examples/widgets/painting/fontsampler/mainwindow.cpp
index 96258a66d0..65a186099d 100644
--- a/examples/widgets/painting/fontsampler/mainwindow.cpp
+++ b/examples/widgets/painting/fontsampler/mainwindow.cpp
@@ -320,16 +320,16 @@ void MainWindow::printPage(int index, QPainter *painter, QPrinter *printer)
}
}
- qreal xScale = printer->pageRect().width() / width;
- qreal yScale = printer->pageRect().height() / height;
+ qreal xScale = printer->pageRect(QPrinter::DevicePixel).width() / width;
+ qreal yScale = printer->pageRect(QPrinter::DevicePixel).height() / height;
qreal scale = qMin(xScale, yScale);
- qreal remainingHeight = printer->pageRect().height()/scale - height;
+ qreal remainingHeight = printer->pageRect(QPrinter::DevicePixel).height()/scale - height;
qreal spaceHeight = (remainingHeight / 4.0) / (items.count() + 1);
qreal interLineHeight = (remainingHeight / 4.0) / (sampleSizes.count() * items.count());
painter->save();
- painter->translate(printer->pageRect().width() / 2.0, printer->pageRect().height() / 2.0);
+ painter->translate(printer->pageRect(QPrinter::DevicePixel).width() / 2.0, printer->pageRect(QPrinter::DevicePixel).height() / 2.0);
painter->scale(scale, scale);
painter->setBrush(QBrush(Qt::black));
diff --git a/src/gui/painting/qpagedpaintdevice.cpp b/src/gui/painting/qpagedpaintdevice.cpp
index 2149bd8cff..dba143b7e3 100644
--- a/src/gui/painting/qpagedpaintdevice.cpp
+++ b/src/gui/painting/qpagedpaintdevice.cpp
@@ -42,42 +42,6 @@
QT_BEGIN_NAMESPACE
-// ### Qt 6: remove when the deprecated constructor is removed
-class QDummyPagedPaintDevicePrivate : public QPagedPaintDevicePrivate
-{
- bool setPageLayout(const QPageLayout &newPageLayout) override
- {
- m_pageLayout = newPageLayout;
- return m_pageLayout.isEquivalentTo(newPageLayout);
- }
-
- bool setPageSize(const QPageSize &pageSize) override
- {
- m_pageLayout.setPageSize(pageSize);
- return m_pageLayout.pageSize().isEquivalentTo(pageSize);
- }
-
- bool setPageOrientation(QPageLayout::Orientation orientation) override
- {
- m_pageLayout.setOrientation(orientation);
- return m_pageLayout.orientation() == orientation;
- }
-
- bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units) override
- {
- m_pageLayout.setUnits(units);
- m_pageLayout.setMargins(margins);
- return m_pageLayout.margins() == margins && m_pageLayout.units() == units;
- }
-
- QPageLayout pageLayout() const override
- {
- return m_pageLayout;
- }
-
- QPageLayout m_pageLayout;
-};
-
QPagedPaintDevicePrivate::~QPagedPaintDevicePrivate()
{
delete rangeCollection;
@@ -96,15 +60,6 @@ QPagedPaintDevicePrivate::~QPagedPaintDevicePrivate()
QPdfWriter and QPrinter inherit from it.
*/
-/*!
- Constructs a new paged paint device.
-
- \deprecated
- */
-QPagedPaintDevice::QPagedPaintDevice()
- : d(new QDummyPagedPaintDevicePrivate)
-{
-}
/*!
\internal
@@ -298,75 +253,6 @@ QPagedPaintDevicePrivate *QPagedPaintDevice::dd()
*/
/*!
- Sets the size of the a page to \a size.
-
- \sa setPageSizeMM()
- */
-void QPagedPaintDevice::setPageSize(PageSize size)
-{
- d->setPageSize(QPageSize(QPageSize::PageSizeId(size)));
-}
-
-/*!
- Returns the currently used page size.
- */
-QPagedPaintDevice::PageSize QPagedPaintDevice::pageSize() const
-{
- return PageSize(d->pageLayout().pageSize().id());
-}
-
-/*!
- \obsolete Use setPageSize(QPageSize) instead.
- Sets the page size to \a size. \a size is specified in millimeters.
-
- If the size matches a standard QPagedPaintDevice::PageSize then that page
- size will be used, otherwise QPagedPaintDevice::Custom will be set.
-*/
-void QPagedPaintDevice::setPageSizeMM(const QSizeF &size)
-{
- d->setPageSize(QPageSize(size, QPageSize::Millimeter));
-}
-
-/*!
- \obsolete Use pageLayout().pageSize() instead.
-
- Returns the page size in millimeters.
- */
-QSizeF QPagedPaintDevice::pageSizeMM() const
-{
- return d->pageLayout().pageSize().size(QPageSize::Millimeter);
-}
-
-/*!
- \obsolete Use setPageMargins(QMarginsF, QPageLayout::Unit) instead.
- Sets the margins to be used to \a margins.
-
- Margins are specified in millimeters.
-
- The margins are purely a hint to the drawing method. They don't affect the
- coordinate system or clipping.
-
- \sa margins()
- */
-void QPagedPaintDevice::setMargins(const QMarginsF &margins)
-{
- d->setPageMargins(margins, QPageLayout::Millimeter);
-}
-
-/*!
- \obsolete Use pageLayout().margins() instead.
- Returns the current margins of the paint device. The default is 0.
-
- Margins are specified in millimeters.
-
- \sa setMargins()
- */
-QMarginsF QPagedPaintDevice::margins() const
-{
- return d->pageLayout().margins(QPageLayout::Millimeter);
-}
-
-/*!
\since 5.3
Sets the page layout to \a newPageLayout.
@@ -436,28 +322,6 @@ bool QPagedPaintDevice::setPageOrientation(QPageLayout::Orientation orientation)
/*!
\since 5.3
- Set the page \a margins in the current page layout units.
-
- You should call this before calling QPainter::begin(), or immediately
- before calling newPage() to apply the new margins to a new page.
- You should not call any painting methods between a call to setPageMargins()
- and newPage() as the wrong paint metrics may be used.
-
- To get the current page margins use pageLayout().pageMargins().
-
- Returns true if the page margins were successfully set to \a margins.
-
- \sa pageLayout()
-*/
-
-bool QPagedPaintDevice::setPageMargins(const QMarginsF &margins)
-{
- return setPageMargins(margins, pageLayout().units());
-}
-
-/*!
- \since 5.3
-
Set the page \a margins defined in the given \a units.
You should call this before calling QPainter::begin(), or immediately
@@ -494,33 +358,4 @@ QPageLayout QPagedPaintDevice::pageLayout() const
return d->pageLayout();
}
-/*!
- \internal
-
- \deprecated
-
- Returns the internal device page layout.
-*/
-
-QPageLayout QPagedPaintDevice::devicePageLayout() const
-{
- qWarning("QPagedPaintDevice::devicePageLayout() is deprecated, just use QPagedPaintDevice::pageLayout()");
- return d->pageLayout();
-}
-
-/*!
- \internal
-
- \deprecated
-
- Returns the internal device page layout.
-*/
-
-QPageLayout &QPagedPaintDevice::devicePageLayout()
-{
- qWarning("QPagedPaintDevice::devicePageLayout() is deprecated, you shouldn't be using this at all.");
- static QPageLayout dummy;
- return dummy;
-}
-
QT_END_NAMESPACE
diff --git a/src/gui/painting/qpagedpaintdevice.h b/src/gui/painting/qpagedpaintdevice.h
index f4e671f2d2..ab304250c9 100644
--- a/src/gui/painting/qpagedpaintdevice.h
+++ b/src/gui/painting/qpagedpaintdevice.h
@@ -55,199 +55,22 @@ class QPagedPaintDevicePrivate;
class Q_GUI_EXPORT QPagedPaintDevice : public QPaintDevice
{
public:
- QT_DEPRECATED QPagedPaintDevice();
~QPagedPaintDevice();
virtual bool newPage() = 0;
- // ### Qt6 Remove in favor of QPage::PageSize
- // NOTE: Must keep in sync with QPageSize and QPrinter
- enum PageSize {
- // 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
- };
-
// keep in sync with QPdfEngine::PdfVersion!
enum PdfVersion { PdfVersion_1_4, PdfVersion_A1b, PdfVersion_1_6 };
- // ### Qt6 Make these virtual
- bool setPageLayout(const QPageLayout &pageLayout);
- bool setPageSize(const QPageSize &pageSize);
- bool setPageOrientation(QPageLayout::Orientation orientation);
- bool setPageMargins(const QMarginsF &margins);
- bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units);
+ virtual bool setPageLayout(const QPageLayout &pageLayout);
+ virtual bool setPageSize(const QPageSize &pageSize);
+ virtual bool setPageOrientation(QPageLayout::Orientation orientation);
+ virtual bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units = QPageLayout::Millimeter);
QPageLayout pageLayout() const;
-#if QT_DEPRECATED_SINCE(5,15)
- QT_DEPRECATED_VERSION_X_5_15("Use setPageSize(QPageSize) instead.")
- virtual void setPageSize(PageSize size);
- QT_DEPRECATED_VERSION_X_5_15("Use pageLayout().pageSize().id() instead.")
- PageSize pageSize() const;
-
- QT_DEPRECATED_VERSION_X_5_15("Use setPageSize(QPageSize) instead.")
- virtual void setPageSizeMM(const QSizeF &size);
- QT_DEPRECATED_VERSION_X_5_15("Use pageLayout().pageSize() instead.")
- QSizeF pageSizeMM() const;
-#endif
-
-#if QT_DEPRECATED_SINCE(5,15)
- QT_DEPRECATED_VERSION_X_5_15("Use setPageMargins(QMarginsF, QPageLayout::Unit) instead.")
- virtual void setMargins(const QMarginsF &margins);
- QT_DEPRECATED_VERSION_X_5_15("Use pageLayout().margins() instead.")
- QMarginsF margins() const;
-#endif
-
protected:
QPagedPaintDevice(QPagedPaintDevicePrivate *dd);
QPagedPaintDevicePrivate *dd();
- QT_DEPRECATED QPageLayout devicePageLayout() const;
- QT_DEPRECATED QPageLayout &devicePageLayout();
friend class QPagedPaintDevicePrivate;
QPagedPaintDevicePrivate *d;
};
diff --git a/src/gui/painting/qpagelayout.h b/src/gui/painting/qpagelayout.h
index 7ee0ce7a76..6965606252 100644
--- a/src/gui/painting/qpagelayout.h
+++ b/src/gui/painting/qpagelayout.h
@@ -66,7 +66,6 @@ public:
Cicero
};
- // NOTE: Must keep in sync with QPrinter::Orientation
enum Orientation {
Portrait,
Landscape
diff --git a/src/gui/painting/qpdfwriter.cpp b/src/gui/painting/qpdfwriter.cpp
index 1de8ff0bcc..5b2bbc37a5 100644
--- a/src/gui/painting/qpdfwriter.cpp
+++ b/src/gui/painting/qpdfwriter.cpp
@@ -417,37 +417,6 @@ void QPdfWriter::addFileAttachment(const QString &fileName, const QByteArray &da
*/
#endif
-#if QT_DEPRECATED_SINCE(5, 14)
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_DEPRECATED
-/*!
- \reimp
-
- \obsolete Use setPageSize(QPageSize(id)) instead
-
- \sa setPageSize()
-*/
-
-void QPdfWriter::setPageSize(PageSize size)
-{
- setPageSize(QPageSize(QPageSize::PageSizeId(size)));
-}
-
-/*!
- \reimp
-
- \obsolete Use setPageSize(QPageSize(size, QPageSize::Millimeter)) instead
-
- \sa setPageSize()
-*/
-
-void QPdfWriter::setPageSizeMM(const QSizeF &size)
-{
- setPageSize(QPageSize(size, QPageSize::Millimeter));
-}
-QT_WARNING_POP
-#endif
-
/*!
\internal
@@ -469,24 +438,6 @@ bool QPdfWriter::newPage()
return d->engine->newPage();
}
-
-#if QT_DEPRECATED_SINCE(5, 14)
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_DEPRECATED
-/*!
- \reimp
-
- \obsolete Use setPageMargins(QMarginsF(l, t, r, b), QPageLayout::Millimeter) instead
-
- \sa setPageMargins()
- */
-void QPdfWriter::setMargins(const QMarginsF &m)
-{
- setPageMargins(m, QPageLayout::Millimeter);
-}
-QT_WARNING_POP
-#endif
-
QT_END_NAMESPACE
#endif // QT_NO_PDF
diff --git a/src/gui/painting/qpdfwriter.h b/src/gui/painting/qpdfwriter.h
index fa5750dcf0..aa068e20e0 100644
--- a/src/gui/painting/qpdfwriter.h
+++ b/src/gui/painting/qpdfwriter.h
@@ -80,26 +80,6 @@ public:
void addFileAttachment(const QString &fileName, const QByteArray &data, const QString &mimeType = QString());
-#ifdef Q_QDOC
- bool setPageLayout(const QPageLayout &pageLayout);
- bool setPageSize(const QPageSize &pageSize);
- bool setPageOrientation(QPageLayout::Orientation orientation);
- bool setPageMargins(const QMarginsF &margins);
- bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units);
- QPageLayout pageLayout() const;
-#else
- using QPagedPaintDevice::setPageSize;
-#endif
-
-#if QT_DEPRECATED_SINCE(5, 14)
- QT_DEPRECATED_X("Use setPageSize(QPageSize(id)) instead")
- void setPageSize(PageSize size) override;
- QT_DEPRECATED_X("Use setPageSize(QPageSize(size, QPageSize::Millimeter)) instead")
- void setPageSizeMM(const QSizeF &size) override;
- QT_DEPRECATED_X("Use setPageMargins(QMarginsF(l, t, r, b), QPageLayout::Millimeter) instead")
- void setMargins(const QMarginsF &m) override;
-#endif
-
protected:
QPaintEngine *paintEngine() const override;
int metric(PaintDeviceMetric id) const override;
diff --git a/src/printsupport/dialogs/qpagesetupdialog_mac.mm b/src/printsupport/dialogs/qpagesetupdialog_mac.mm
index b88d03696a..16d8bdf74e 100644
--- a/src/printsupport/dialogs/qpagesetupdialog_mac.mm
+++ b/src/printsupport/dialogs/qpagesetupdialog_mac.mm
@@ -84,7 +84,7 @@ QT_USE_NAMESPACE
PMGetOrientation(format, &orientation);
QSizeF paperSize = QSizeF(paperRect.right - paperRect.left, paperRect.bottom - paperRect.top);
printer->printEngine()->setProperty(QPrintEngine::PPK_CustomPaperSize, paperSize);
- printer->printEngine()->setProperty(QPrintEngine::PPK_Orientation, orientation == kPMLandscape ? QPrinter::Landscape : QPrinter::Portrait);
+ printer->printEngine()->setProperty(QPrintEngine::PPK_Orientation, orientation == kPMLandscape ? QPageLayout::Landscape : QPageLayout::Portrait);
}
dialog->done((returnCode == NSModalResponseOK) ? QDialog::Accepted : QDialog::Rejected);
diff --git a/src/printsupport/dialogs/qprintpreviewdialog.cpp b/src/printsupport/dialogs/qprintpreviewdialog.cpp
index e9f2b5e882..ad52dc2b91 100644
--- a/src/printsupport/dialogs/qprintpreviewdialog.cpp
+++ b/src/printsupport/dialogs/qprintpreviewdialog.cpp
@@ -435,7 +435,7 @@ void QPrintPreviewDialogPrivate::setupActions()
// Initial state:
fitPageAction->setChecked(true);
singleModeAction->setChecked(true);
- if (preview->orientation() == QPrinter::Portrait)
+ if (preview->orientation() == QPageLayout::Portrait)
portraitAction->setChecked(true);
else
landscapeAction->setChecked(true);
@@ -609,7 +609,7 @@ void QPrintPreviewDialogPrivate::_q_pageSetup()
if (pageSetupDialog->exec() == QDialog::Accepted) {
// update possible orientation changes
- if (preview->orientation() == QPrinter::Portrait) {
+ if (preview->orientation() == QPageLayout::Portrait) {
portraitAction->setChecked(true);
preview->setPortraitOrientation();
}else {
diff --git a/src/printsupport/kernel/qprinter.cpp b/src/printsupport/kernel/qprinter.cpp
index 227b2af023..8166e816f3 100644
--- a/src/printsupport/kernel/qprinter.cpp
+++ b/src/printsupport/kernel/qprinter.cpp
@@ -77,43 +77,6 @@ QT_BEGIN_NAMESPACE
extern qreal qt_pixelMultiplier(int resolution);
extern QMarginsF qt_convertMargins(const QMarginsF &margins, QPageLayout::Unit fromUnits, QPageLayout::Unit toUnits);
-/// return the multiplier of converting from the unit value to postscript-points.
-Q_PRINTSUPPORT_EXPORT double qt_multiplierForUnit(QPrinter::Unit unit, int resolution)
-{
- switch(unit) {
- case QPrinter::Millimeter:
- return 2.83464566929;
- case QPrinter::Point:
- return 1.0;
- case QPrinter::Inch:
- return 72.0;
- case QPrinter::Pica:
- return 12;
- case QPrinter::Didot:
- return 1.065826771;
- case QPrinter::Cicero:
- return 12.789921252;
- case QPrinter::DevicePixel:
- return 72.0/resolution;
- }
- return 1.0;
-}
-
-// not static: it's needed in qpagesetupdialog_unix.cpp
-Q_PRINTSUPPORT_EXPORT QSizeF qt_printerPaperSize(QPrinter::Orientation orientation,
- QPrinter::PaperSize paperSize,
- QPrinter::Unit unit,
- int resolution)
-{
- QPageSize pageSize = QPageSize(QPageSize::PageSizeId(paperSize));
- QSizeF sizef;
- if (unit == QPrinter::DevicePixel)
- sizef = pageSize.size(QPageSize::Point) * qt_multiplierForUnit(unit, resolution);
- else
- sizef = pageSize.size(QPageSize::Unit(unit));
- return orientation == QPrinter::Landscape ? sizef.transposed() : sizef;
-}
-
QPrinterInfo QPrinterPrivate::findValidPrinter(const QPrinterInfo &printer)
{
// Try find a valid printer to use, either the one given, the default or the first available
@@ -336,9 +299,8 @@ public:
The most important parameters are:
\list
- \li setOrientation() tells QPrinter which page orientation to use.
- \li setPaperSize() tells QPrinter what paper size to expect from the
- printer.
+ \li setPageLayout() tells QPrinter which page orientation to use, and
+ what size to expect from the printer.
\li setResolution() tells QPrinter what resolution you wish the
printer to provide, in dots per inch (DPI).
\li setFullPage() tells QPrinter whether you want to deal with the
@@ -421,22 +383,6 @@ public:
*/
/*!
- \enum QPrinter::Orientation
-
- This enum type (not to be confused with \c Orientation) is used
- to specify each page's orientation.
-
- \value Portrait the page's height is greater than its width.
-
- \value Landscape the page's width is greater than its height.
-
- This type interacts with \l QPrinter::PaperSize and
- QPrinter::setFullPage() to determine the final size of the page
- available to the application.
-*/
-
-
-/*!
\enum QPrinter::PrintRange
Used to specify the print range selection option.
@@ -450,31 +396,6 @@ public:
*/
/*!
- \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 found in QPagedPaintDevice.
-
- With setFullPage(false) (the default), the metrics will be a bit
- smaller; how much depends on the printer in use.
-
- Due to historic reasons QPageSize::Executive is not the same as the standard
- Postscript and Windows Executive size, use QPageSize::ExecutiveStandard instead.
-
- The Postscript standard size QPageSize::Folio is different to the Windows
- DMPAPER_FOLIO size, use the Postscript standard size QPageSize::FanFoldGermanLegal
- if needed.
-*/
-
-
-/*!
\enum QPrinter::PageOrder
This enum type is used by QPrinter to tell the application program
@@ -932,294 +853,6 @@ void QPrinter::setCreator(const QString &creator)
d->setProperty(QPrintEngine::PPK_Creator, creator);
}
-// Defined in QPagedPaintDevice but non-virtual, add QPrinter specific doc here
-#ifdef Q_CLANG_QDOC
-/*!
- \fn bool QPrinter::setPageLayout(const QPageLayout &newLayout)
- \since 5.3
-
- Sets the page layout to \a newLayout.
-
- If the \a newLayout is not valid for the current printer then the page
- layout will not be changed. For example, if the page size is not supported
- by the printer, or if the margins fall outside the printable area.
-
- Returns true if the page layout was successfully set to \a newLayout.
-
- \sa pageLayout(), setPageSize(), setPageOrientation(), setPageMargins()
-*/
-
-/*!
- \fn bool QPrinter::setPageSize(const QPageSize &pageSize)
- \since 5.3
-
- Sets the page size to \a pageSize.
-
- If the \a pageSize is not valid for the current printer then the page
- size will not be changed.
-
- Changing the page size may affect the current page margins if they fall
- outside the printable margins for the new page size on the current printer.
-
- To obtain the current QPageSize use pageLayout().pageSize().
-
- Returns true if the page size was successfully set to \a pageSize.
-
- \sa pageLayout(), setPageLayout()
-*/
-
-/*!
- \fn bool QPrinter::setPageOrientation(QPageLayout::Orientation orientation)
- \since 5.3
-
- Sets the page \a orientation to QPageLayout::Portrait or QPageLayout::Landscape.
-
- The printer driver reads this setting and prints the page using the
- specified orientation.
-
- On Windows and Mac, this option can be changed while printing and will
- take effect from the next call to newPage().
-
- To obtain the current QPageLayout::Orientation use pageLayout().pageOrientation().
-
- Returns true if the page orientation was successfully set to \a orientation.
-
- \sa pageLayout(), setPageLayout()
-*/
-
-/*!
- \fn bool QPrinter::setPageMargins(const QMarginsF &margins, QPageLayout::Unit units)
- \since 5.3
-
- Set the page margins to \a margins in the given \a units. If \a units are
- not provided then the current units are used.
-
- If in Full Page mode then no check is performed on the \a margins set,
- otherwise the \a margins must fall within the printable area for the page
- size on the current printer.
-
- To obtain the current page margins use pageLayout().pageMargins().
-
- Returns \c true if the page margins was successfully set to \a margins.
-
- \sa pageLayout(), setPageLayout()
-*/
-
-/*!
- \fn bool QPrinter::setPageMargins(const QMarginsF &margins)
-
- Set the page margins to \a margins using the current units.
- Returns \c true if the page margins were set successfully.
-
- \sa pageLayout(), setPageLayout()
-*/
-/*!
- \fn QPageLayout QPrinter::pageLayout() const
- \since 5.3
-
- Returns the current page layout. Use this method to access the current
- QPageSize, QPageLayout::Orientation, QMarginsF, fullPageRect() and paintRect().
-
- Note that you cannot use the setters on the returned object, you must either
- call the QPrinter methods or setPageLayout().
-
- \sa setPageLayout(), setPageSize(), setPageOrientation(), setPageMargins()
-*/
-#endif
-
-/*!
- \obsolete Use pageLayout().pageOrientation() instead.
-
- Returns the orientation setting. This is driver-dependent, but is usually
- QPrinter::Portrait.
-
- \sa pageLayout()
-*/
-QPrinter::Orientation QPrinter::orientation() const
-{
- return QPrinter::Orientation(pageLayout().orientation());
-}
-
-
-/*!
- \obsolete Use setPageOrientation() instead.
-
- Sets the print orientation to \a orientation.
-
- The orientation can be either QPrinter::Portrait or
- QPrinter::Landscape.
-
- The printer driver reads this setting and prints using the
- specified orientation.
-
- On Windows and Mac, this option can be changed while printing and will
- take effect from the next call to newPage().
-
- \sa setPageOrientation()
-*/
-
-void QPrinter::setOrientation(Orientation orientation)
-{
- setPageOrientation(QPageLayout::Orientation(orientation));
-}
-
-/*!
- \since 4.4
-
- \obsolete Use pageLayout().pageSize().id() instead.
-
- Returns the printer paper size. The default value is driver-dependent.
-
- \sa pageLayout()
-*/
-
-QPrinter::PaperSize QPrinter::paperSize() const
-{
- return pageSize();
-}
-
-/*!
- \since 4.4
-
- \obsolete Use setPageSize(QPageSize) instead.
-
- Sets the printer paper size to \a newPaperSize if that size is
- supported. The result is undefined if \a newPaperSize is not
- supported.
-
- The default paper size is driver-dependent.
-
- This function is useful mostly for setting a default value that
- the user can override in the print dialog.
-
- \sa setPageSize()
-*/
-void QPrinter::setPaperSize(PaperSize newPaperSize)
-{
- setPageSize(QPageSize(QPageSize::PageSizeId(newPaperSize)));
-}
-
-/*!
- \obsolete Use pageLayout().pageSize().id() instead.
-
- Returns the printer page size. The default value is driver-dependent.
-
- \sa pageLayout()
-*/
-QPrinter::PageSize QPrinter::pageSize() const
-{
- return QPrinter::PaperSize(pageLayout().pageSize().id());
-}
-
-
-/*!
- \obsolete Use setPageSize(QPageSize) instead.
-
- Sets the printer page size based on \a newPageSize.
-
- \sa setPageSize()
-*/
-
-void QPrinter::setPageSize(PageSize newPageSize)
-{
- setPageSize(QPageSize(QPageSize::PageSizeId(newPageSize)));
-}
-
-/*!
- \since 4.4
-
- \obsolete Use setPageSize(QPageSize) instead.
-
- Sets the paper size based on \a paperSize in \a unit.
-
- Note that the paper size is defined in a portrait layout, regardless of
- what the current printer orientation is set to.
-
- \sa setPageSize()
-*/
-
-void QPrinter::setPaperSize(const QSizeF &paperSize, QPrinter::Unit unit)
-{
- if (unit == QPrinter::DevicePixel)
- setPageSize(QPageSize(paperSize * qt_pixelMultiplier(resolution()), QPageSize::Point));
- else
- setPageSize(QPageSize(paperSize, QPageSize::Unit(unit)));
-}
-
-/*!
- \reimp
-
- \obsolete Use setPageSize(QPageSize) instead.
-
- Use setPageSize(QPageSize) instead.
-
- Note that the page size is defined in a portrait layout, regardless of
- what the current printer orientation is set to.
-
- \sa setPageSize()
-*/
-void QPrinter::setPageSizeMM(const QSizeF &size)
-{
- setPageSize(QPageSize(size, QPageSize::Millimeter));
-}
-
-/*!
- \since 4.4
-
- \obsolete Use pageLayout().pageSize().size() or
- pageLayout().fullPageSize() instead.
-
- Returns the paper size in \a unit.
-
- Note that the returned size reflects the current paper orientation.
-
- \sa pageLayout()
-*/
-
-QSizeF QPrinter::paperSize(Unit unit) const
-{
- if (unit == QPrinter::DevicePixel)
- return pageLayout().fullRectPixels(resolution()).size();
- else
- return pageLayout().fullRect(QPageLayout::Unit(unit)).size();
-}
-
-/*!
- \since 5.1
-
- \obsolete Use setPageSize(QPageSize) instead.
-
- Sets the paper used by the printer to \a paperName.
-
- \sa setPageSize()
-*/
-
-void QPrinter::setPaperName(const QString &paperName)
-{
- Q_D(QPrinter);
- if (d->paintEngine->type() != QPaintEngine::Pdf)
- ABORT_IF_ACTIVE("QPrinter::setPaperName");
- d->setProperty(QPrintEngine::PPK_PaperName, paperName);
-}
-
-/*!
- \since 5.1
-
- \obsolete Use pageLayout().pageSize().name() instead.
-
- Returns the paper name of the paper set on the printer.
-
- The default value for this is driver-dependent.
-
- \sa pageLayout()
-*/
-
-QString QPrinter::paperName() const
-{
- Q_D(const QPrinter);
- return d->printEngine->property(QPrintEngine::PPK_PaperName).toString();
-}
-
/*!
Sets the page order to \a pageOrder.
@@ -1282,73 +915,6 @@ QPrinter::ColorMode QPrinter::colorMode() const
return QPrinter::ColorMode(d->printEngine->property(QPrintEngine::PPK_ColorMode).toInt());
}
-
-/*!
- \obsolete
- Returns the number of copies to be printed. The default value is 1.
-
- On Windows, \macos and X11 systems that support CUPS, this will always
- return 1 as these operating systems can internally handle the number
- of copies.
-
- On X11, this value will return the number of times the application is
- required to print in order to match the number specified in the printer setup
- dialog. This has been done since some printer drivers are not capable of
- buffering up the copies and in those cases the application must make an
- explicit call to the print code for each copy.
-
- Use copyCount() in conjunction with supportsMultipleCopies() instead.
-
- \sa setNumCopies(), actualNumCopies()
-*/
-
-int QPrinter::numCopies() const
-{
- Q_D(const QPrinter);
- return d->printEngine->property(QPrintEngine::PPK_NumberOfCopies).toInt();
-}
-
-
-/*!
- \obsolete
- \since 4.6
-
- Returns the number of copies that will be printed. The default
- value is 1.
-
- This function always returns the actual value specified in the print
- dialog or using setNumCopies().
-
- Use copyCount() instead.
-
- \sa setNumCopies(), numCopies()
-*/
-int QPrinter::actualNumCopies() const
-{
- return copyCount();
-}
-
-
-
-/*!
- \obsolete
- Sets the number of copies to be printed to \a numCopies.
-
- The printer driver reads this setting and prints the specified
- number of copies.
-
- Use setCopyCount() instead.
-
- \sa numCopies()
-*/
-
-void QPrinter::setNumCopies(int numCopies)
-{
- Q_D(QPrinter);
- ABORT_IF_ACTIVE("QPrinter::setNumCopies");
- d->setProperty(QPrintEngine::PPK_NumberOfCopies, numCopies);
-}
-
/*!
\since 4.7
@@ -1589,35 +1155,6 @@ bool QPrinter::fontEmbeddingEnabled() const
*/
/*!
- \since 4.2
-
- \obsolete Use setDuplex() instead.
-
- Enables double sided printing if \a doubleSided is true; otherwise disables it.
-
- \sa setDuplex()
-*/
-void QPrinter::setDoubleSidedPrinting(bool doubleSided)
-{
- setDuplex(doubleSided ? DuplexAuto : DuplexNone);
-}
-
-
-/*!
- \since 4.2
-
- \obsolete Use duplex() instead.
-
- Returns \c true if double side printing is enabled.
-
- \sa duplex()
-*/
-bool QPrinter::doubleSidedPrinting() const
-{
- return duplex() != DuplexNone;
-}
-
-/*!
\since 4.4
Enables double sided printing based on the \a duplex mode.
@@ -1678,104 +1215,6 @@ QRectF QPrinter::paperRect(Unit unit) const
}
/*!
- \obsolete Use pageLayout().paintRectPixels(resolution()) instead.
-
- Returns the page's rectangle; this is usually smaller than the
- paperRect() since the page normally has margins between its
- borders and the paper.
-
- The unit of the returned rectangle is DevicePixel.
-
- \sa pageLayout()
-*/
-QRect QPrinter::pageRect() const
-{
- Q_D(const QPrinter);
- return d->printEngine->property(QPrintEngine::PPK_PageRect).toRect();
-}
-
-/*!
- \obsolete Use pageLayout().fullRectPixels(resolution()) instead.
-
- Returns the paper's rectangle; this is usually larger than the
- pageRect().
-
- The unit of the returned rectangle is DevicePixel.
-
- \sa pageLayout()
-*/
-QRect QPrinter::paperRect() const
-{
- Q_D(const QPrinter);
- return d->printEngine->property(QPrintEngine::PPK_PaperRect).toRect();
-}
-
-/*!
- \since 4.4
-
- \obsolete Use setPageMargins(QMarginsF, QPageLayout::Unit) instead.
-
- This function sets the \a left, \a top, \a right and \a bottom
- page margins for this printer. The unit of the margins are
- specified with the \a unit parameter.
-
- \sa setPageMargins()
-*/
-void QPrinter::setPageMargins(qreal left, qreal top, qreal right, qreal bottom, QPrinter::Unit unit)
-{
- if (unit == QPrinter::DevicePixel) {
- QMarginsF margins = QMarginsF(left, top, right, bottom);
- margins *= qt_pixelMultiplier(resolution());
- margins = qt_convertMargins(margins, QPageLayout::Point, pageLayout().units());
- setPageMargins(margins, pageLayout().units());
- } else {
- setPageMargins(QMarginsF(left, top, right, bottom), QPageLayout::Unit(unit));
- }
-}
-
-/*!
- \reimp
-
- \obsolete Use setPageMargins(QMarginsF, QPageLayout::Unit) instead.
-
- \sa setPageMargins()
- */
-void QPrinter::setMargins(const QMarginsF &m)
-{
- setPageMargins(m, QPageLayout::Millimeter);
-}
-
-/*!
- \since 4.4
-
- \obsolete Use pageLayout().pageMargins() instead.
-
- Returns the page margins for this printer in \a left, \a top, \a
- right, \a bottom. The unit of the returned margins are specified
- with the \a unit parameter.
-
- \sa pageLayout(), setPageMargins()
-*/
-void QPrinter::getPageMargins(qreal *left, qreal *top, qreal *right, qreal *bottom, QPrinter::Unit unit) const
-{
- QMarginsF margins;
- if (unit == QPrinter::DevicePixel) {
- QMargins tmp = pageLayout().marginsPixels(resolution());
- margins = QMarginsF(tmp.left(), tmp.top(), tmp.right(), tmp.bottom());
- } else {
- margins = pageLayout().margins(QPageLayout::Unit(unit));
- }
- if (left)
- *left = margins.left();
- if (right)
- *right = margins.right();
- if (top)
- *top = margins.top();
- if (bottom)
- *bottom = margins.bottom();
-}
-
-/*!
\internal
Returns the metric for the given \a id.
@@ -1807,34 +1246,6 @@ QPrintEngine *QPrinter::printEngine() const
}
/*!
- \obsolete Use QPageSize::id(windowsId) and setPageLayout(QPageSize) instead.
-
- Sets the page size to be used by the printer under Windows to \a
- pageSize.
-
- \sa pageLayout()
-*/
-void QPrinter::setWinPageSize(int pageSize)
-{
- Q_D(QPrinter);
- ABORT_IF_ACTIVE("QPrinter::setWinPageSize");
- d->setProperty(QPrintEngine::PPK_WindowsPageSize, pageSize);
-}
-
-/*!
- \obsolete Use pageLayout.pageSize().windowsId() instead.
-
- Returns the page size used by the printer under Windows.
-
- \sa pageLayout()
-*/
-int QPrinter::winPageSize() const
-{
- Q_D(const QPrinter);
- return d->printEngine->property(QPrintEngine::PPK_WindowsPageSize).toInt();
-}
-
-/*!
Returns a list of the resolutions (a list of dots-per-inch
integers) that the printer says it supports.
@@ -2126,7 +1537,7 @@ QPrinter::PrintRange QPrinter::printRange() const
\value PPK_NumberOfCopies Obsolete. An integer specifying the number of
copies. Use PPK_CopyCount instead.
- \value PPK_Orientation Specifies a QPrinter::Orientation value.
+ \value PPK_Orientation Specifies a QPageLayout::Orientation value.
\value PPK_OutputFileName The output file name as a string. An
empty file name indicates that the printer should not print to a file.
diff --git a/src/printsupport/kernel/qprinter.h b/src/printsupport/kernel/qprinter.h
index b912ed8f54..62545f7807 100644
--- a/src/printsupport/kernel/qprinter.h
+++ b/src/printsupport/kernel/qprinter.h
@@ -61,7 +61,6 @@ class QPaintEngine;
class QPrintEngine;
class QPrinterInfo;
class QPageSize;
-class QPageMargins;
class Q_PRINTSUPPORT_EXPORT QPrinter : public QPagedPaintDevice
{
@@ -75,11 +74,6 @@ public:
int devType() const override;
- enum Orientation { Portrait, Landscape };
-
- // ### Qt6 Remove in favor of QPage::PageSize
- typedef PageSize PaperSize;
-
enum PageOrder { FirstPageFirst,
LastPageFirst };
@@ -155,49 +149,6 @@ public:
void setCreator(const QString &);
QString creator() const;
-#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);
- bool setPageMargins(const QMarginsF &margins);
- bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units);
- QPageLayout pageLayout() const;
-#else
- using QPagedPaintDevice::setPageSize;
- using QPagedPaintDevice::setPageMargins;
-#endif
-
-#if QT_DEPRECATED_SINCE(5,15)
- QT_DEPRECATED_VERSION_X_5_15("Use setPageOrientation() instead.")
- void setOrientation(Orientation);
- QT_DEPRECATED_VERSION_X_5_15("Use pageLayout().pageOrientation() instead.")
- Orientation orientation() const;
-
- QT_DEPRECATED_VERSION_X_5_15("Use setPageSize(QPageSize) instead.")
- void setPageSize(PageSize) override;
- QT_DEPRECATED_VERSION_X_5_15("Use pageLayout().pageSize().id() instead.")
- PageSize pageSize() const;
-
- QT_DEPRECATED_VERSION_X_5_15("Use setPageSize(QPageSize) instead.")
- void setPageSizeMM(const QSizeF &size) override;
-
- QT_DEPRECATED_VERSION_X_5_15("Use setPageSize(QPageSize) instead.")
- void setPaperSize(PaperSize);
- QT_DEPRECATED_VERSION_X_5_15("pageLayout().pageSize().id()")
- PaperSize paperSize() const;
-
- QT_DEPRECATED_VERSION_X_5_15("Use setPageSize(QPageSize) instead.")
- void setPaperSize(const QSizeF &paperSize, Unit unit);
- QT_DEPRECATED_VERSION_X_5_15("Use pageLayout().pageSize().size() or pageLayout().fullPageSize() instead.")
- QSizeF paperSize(Unit unit) const;
-
- QT_DEPRECATED_VERSION_X_5_15("Use setPageSize(QPageSize) instead.")
- void setPaperName(const QString &paperName);
- QT_DEPRECATED_VERSION_X_5_15("Use pageLayout().pageSize().name() instead.")
- QString paperName() const;
-#endif
-
void setPageOrder(PageOrder);
PageOrder pageOrder() const;
@@ -213,15 +164,6 @@ public:
void setFullPage(bool);
bool fullPage() const;
-#if QT_DEPRECATED_SINCE(5,15)
- QT_DEPRECATED_VERSION_X_5_15("Use setCopyCount() instead.")
- void setNumCopies(int);
- QT_DEPRECATED_VERSION_X_5_15("Use copyCount() instead.")
- int numCopies() const;
- QT_DEPRECATED_VERSION_X_5_15("Use copyCount() instead.")
- int actualNumCopies() const;
-#endif
-
void setCopyCount(int);
int copyCount() const;
bool supportsMultipleCopies() const;
@@ -241,24 +183,6 @@ public:
void setFontEmbeddingEnabled(bool enable);
bool fontEmbeddingEnabled() const;
-#if QT_DEPRECATED_SINCE(5,15)
- QT_DEPRECATED_VERSION_X_5_15("Use setDuplex() instead.")
- void setDoubleSidedPrinting(bool enable);
- QT_DEPRECATED_VERSION_X_5_15("Use duplex() instead.")
- bool doubleSidedPrinting() const;
-#endif
-
-#if QT_DEPRECATED_SINCE(5,15)
- QT_DEPRECATED_VERSION_X_5_15("Use QPageSize::id(windowsId) and setPageLayout(QPageSize) instead.")
- void setWinPageSize(int winPageSize);
- QT_DEPRECATED_VERSION_X_5_15("Use pageLayout.pageSize().windowsId() instead.")
- int winPageSize() const;
-
- QT_DEPRECATED_VERSION_X_5_15("Use pageLayout().fullRectPixels(resolution()) instead.")
- QRect paperRect() const;
- QT_DEPRECATED_VERSION_X_5_15("Use pageLayout().paintRectPixels(resolution()) instead.")
- QRect pageRect() const;
-#endif
QRectF paperRect(Unit) const;
QRectF pageRect(Unit) const;
@@ -282,16 +206,6 @@ public:
void setPrintRange(PrintRange range);
PrintRange printRange() const;
-#if QT_DEPRECATED_SINCE(5,15)
- QT_DEPRECATED_VERSION_X_5_15("Use setPageMargins(QMarginsF, QPageLayout::Unit) instead.")
- void setMargins(const QMarginsF &m) override;
-
- QT_DEPRECATED_VERSION_X_5_15("Use setPageMargins(QMarginsF, QPageLayout::Unit) instead.")
- void setPageMargins(qreal left, qreal top, qreal right, qreal bottom, Unit unit);
- QT_DEPRECATED_VERSION_X_5_15("Use pageLayout().pageMargins() instead.")
- void getPageMargins(qreal *left, qreal *top, qreal *right, qreal *bottom, Unit unit) const;
-#endif
-
protected:
int metric(PaintDeviceMetric) const override;
void setEngines(QPrintEngine *printEngine, QPaintEngine *paintEngine);
diff --git a/src/printsupport/widgets/qprintpreviewwidget.cpp b/src/printsupport/widgets/qprintpreviewwidget.cpp
index bd22d5a6a5..46d93c315e 100644
--- a/src/printsupport/widgets/qprintpreviewwidget.cpp
+++ b/src/printsupport/widgets/qprintpreviewwidget.cpp
@@ -590,22 +590,20 @@ void QPrintPreviewWidget::setViewMode(ViewMode mode)
Returns the current orientation of the preview. This value is
obtained from the QPrinter object associated with the preview.
*/
-QPrinter::Orientation QPrintPreviewWidget::orientation() const
+QPageLayout::Orientation QPrintPreviewWidget::orientation() const
{
Q_D(const QPrintPreviewWidget);
- return d->printer->pageLayout().orientation() == QPageLayout::Portrait
- ? QPrinter::Portrait : QPrinter::Landscape;
+ return d->printer->pageLayout().orientation();
}
/*!
Sets the current orientation to \a orientation. This value will be
set on the QPrinter object associated with the preview.
*/
-void QPrintPreviewWidget::setOrientation(QPrinter::Orientation orientation)
+void QPrintPreviewWidget::setOrientation(QPageLayout::Orientation orientation)
{
Q_D(QPrintPreviewWidget);
- d->printer->setPageOrientation(orientation == QPrinter::Portrait
- ? QPageLayout::Portrait : QPageLayout::Landscape);
+ d->printer->setPageOrientation(orientation);
d->generatePreview();
}
@@ -744,20 +742,20 @@ QPrintPreviewWidget::ZoomMode QPrintPreviewWidget::zoomMode() const
/*!
This is a convenience function and is the same as calling \c
- {setOrientation(QPrinter::Landscape)}.
+ {setOrientation(QPageLayout::Landscape)}.
*/
void QPrintPreviewWidget::setLandscapeOrientation()
{
- setOrientation(QPrinter::Landscape);
+ setOrientation(QPageLayout::Landscape);
}
/*!
This is a convenience function and is the same as calling \c
- {setOrientation(QPrinter::Portrait)}.
+ {setOrientation(QPageLayout::Portrait)}.
*/
void QPrintPreviewWidget::setPortraitOrientation()
{
- setOrientation(QPrinter::Portrait);
+ setOrientation(QPageLayout::Portrait);
}
/*!
diff --git a/src/printsupport/widgets/qprintpreviewwidget.h b/src/printsupport/widgets/qprintpreviewwidget.h
index f11d686602..fb199db131 100644
--- a/src/printsupport/widgets/qprintpreviewwidget.h
+++ b/src/printsupport/widgets/qprintpreviewwidget.h
@@ -75,7 +75,7 @@ public:
~QPrintPreviewWidget();
qreal zoomFactor() const;
- QPrinter::Orientation orientation() const;
+ QPageLayout::Orientation orientation() const;
ViewMode viewMode() const;
ZoomMode zoomMode() const;
int currentPage() const;
@@ -88,7 +88,7 @@ public Q_SLOTS:
void zoomIn(qreal zoom = 1.1);
void zoomOut(qreal zoom = 1.1);
void setZoomFactor(qreal zoomFactor);
- void setOrientation(QPrinter::Orientation orientation);
+ void setOrientation(QPageLayout::Orientation orientation);
void setViewMode(ViewMode viewMode);
void setZoomMode(ZoomMode zoomMode);
void setCurrentPage(int pageNumber);
diff --git a/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp b/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp
index 36b8a4726b..8c98a8ad98 100644
--- a/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp
+++ b/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp
@@ -65,50 +65,49 @@ void tst_QPdfWriter::basics()
QCOMPARE(writer.resolution(), 600);
QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::A4);
- QCOMPARE(writer.pageSize(), QPdfWriter::A4);
- QCOMPARE(writer.pageSizeMM(), QSizeF(210, 297));
+ QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::A4);
+ QCOMPARE(writer.pageLayout().pageSize().size(QPageSize::Millimeter), QSizeF(210, 297));
writer.setPageSize(QPageSize(QPageSize::A5));
QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::A5);
- QCOMPARE(writer.pageSize(), QPdfWriter::A5);
- QCOMPARE(writer.pageSizeMM(), QSizeF(148, 210));
+ QCOMPARE(writer.pageLayout().pageSize().size(QPageSize::Millimeter), QSizeF(148, 210));
writer.setPageSize(QPageSize(QPageSize::A3));
QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::A3);
- QCOMPARE(writer.pageSize(), QPdfWriter::A3);
- QCOMPARE(writer.pageSizeMM(), QSizeF(297, 420));
+ QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::A3);
+ QCOMPARE(writer.pageLayout().pageSize().size(QPageSize::Millimeter), QSizeF(297, 420));
writer.setPageSize(QPageSize(QSize(210, 297), QPageSize::Millimeter));
QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::A4);
- QCOMPARE(writer.pageSize(), QPdfWriter::A4);
- QCOMPARE(writer.pageSizeMM(), QSizeF(210, 297));
+ QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::A4);
+ QCOMPARE(writer.pageLayout().pageSize().size(QPageSize::Millimeter), QSizeF(210, 297));
QCOMPARE(writer.pageLayout().orientation(), QPageLayout::Portrait);
writer.setPageOrientation(QPageLayout::Landscape);
QCOMPARE(writer.pageLayout().orientation(), QPageLayout::Landscape);
- QCOMPARE(writer.pageSizeMM(), QSizeF(210, 297));
+ QCOMPARE(writer.pageLayout().pageSize().size(QPageSize::Millimeter), QSizeF(210, 297));
QCOMPARE(writer.pageLayout().margins(), QMarginsF(10, 10, 10, 10));
QCOMPARE(writer.pageLayout().units(), QPageLayout::Point);
- QCOMPARE(writer.margins().left(), 3.53); // mm
- QCOMPARE(writer.margins().right(), 3.53);
- QCOMPARE(writer.margins().top(), 3.53);
- QCOMPARE(writer.margins().bottom(), 3.53);
+ QCOMPARE(writer.pageLayout().margins(QPageLayout::Millimeter).left(), 3.53); // mm
+ QCOMPARE(writer.pageLayout().margins(QPageLayout::Millimeter).right(), 3.53);
+ QCOMPARE(writer.pageLayout().margins(QPageLayout::Millimeter).top(), 3.53);
+ QCOMPARE(writer.pageLayout().margins(QPageLayout::Millimeter).bottom(), 3.53);
writer.setPageMargins(QMarginsF(20, 20, 20, 20), QPageLayout::Millimeter);
QCOMPARE(writer.pageLayout().margins(), QMarginsF(20, 20, 20, 20));
QCOMPARE(writer.pageLayout().units(), QPageLayout::Millimeter);
- QCOMPARE(writer.margins().left(), 20.0);
- QCOMPARE(writer.margins().right(), 20.0);
- QCOMPARE(writer.margins().top(), 20.0);
- QCOMPARE(writer.margins().bottom(), 20.0);
+ QCOMPARE(writer.pageLayout().margins().left(), 20.0);
+ QCOMPARE(writer.pageLayout().margins().right(), 20.0);
+ QCOMPARE(writer.pageLayout().margins().top(), 20.0);
+ QCOMPARE(writer.pageLayout().margins().bottom(), 20.0);
const QMarginsF margins = {50, 50, 50, 50};
writer.setPageMargins(margins, QPageLayout::Millimeter);
QCOMPARE(writer.pageLayout().margins(), margins);
QCOMPARE(writer.pageLayout().units(), QPageLayout::Millimeter);
- QCOMPARE(writer.margins().left(), 50.0);
- QCOMPARE(writer.margins().right(), 50.0);
- QCOMPARE(writer.margins().top(), 50.0);
- QCOMPARE(writer.margins().bottom(), 50.0);
+ QCOMPARE(writer.pageLayout().margins().left(), 50.0);
+ QCOMPARE(writer.pageLayout().margins().right(), 50.0);
+ QCOMPARE(writer.pageLayout().margins().top(), 50.0);
+ QCOMPARE(writer.pageLayout().margins().bottom(), 50.0);
QCOMPARE(writer.pageLayout().fullRect(QPageLayout::Millimeter), QRectF(0, 0, 297, 210));
QCOMPARE(writer.pageLayout().paintRect(QPageLayout::Millimeter), QRectF(50, 50, 197, 110));
@@ -185,10 +184,10 @@ void tst_QPdfWriter::testPageMetrics()
if (setMargins) {
// Setup the given margins
writer.setPageMargins({leftMMf, topMMf, rightMMf, bottomMMf}, QPageLayout::Millimeter);
- QCOMPARE(writer.margins().left(), leftMMf);
- QCOMPARE(writer.margins().right(), rightMMf);
- QCOMPARE(writer.margins().top(), topMMf);
- QCOMPARE(writer.margins().bottom(), bottomMMf);
+ QCOMPARE(writer.pageLayout().margins().left(), leftMMf);
+ QCOMPARE(writer.pageLayout().margins().right(), rightMMf);
+ QCOMPARE(writer.pageLayout().margins().top(), topMMf);
+ QCOMPARE(writer.pageLayout().margins().bottom(), bottomMMf);
}
// Set the given size, in Portrait mode
@@ -196,16 +195,16 @@ void tst_QPdfWriter::testPageMetrics()
? QPageSize(sizeMMf, QPageSize::Millimeter) : QPageSize(pageSizeId);
writer.setPageSize(pageSize);
QCOMPARE(writer.pageLayout().pageSize().id(), pageSizeId);
- QCOMPARE(int(writer.pageSize()), int(pageSizeId));
+ QCOMPARE(int(writer.pageLayout().pageSize().id()), int(pageSizeId));
QCOMPARE(writer.pageLayout().orientation(), QPageLayout::Portrait);
- QCOMPARE(writer.margins().left(), leftMMf);
- QCOMPARE(writer.margins().right(), rightMMf);
- QCOMPARE(writer.margins().top(), topMMf);
- QCOMPARE(writer.margins().bottom(), bottomMMf);
+ QCOMPARE(writer.pageLayout().margins(QPageLayout::Millimeter).left(), leftMMf);
+ QCOMPARE(writer.pageLayout().margins(QPageLayout::Millimeter).right(), rightMMf);
+ QCOMPARE(writer.pageLayout().margins(QPageLayout::Millimeter).top(), topMMf);
+ QCOMPARE(writer.pageLayout().margins(QPageLayout::Millimeter).bottom(), bottomMMf);
- // QPagedPaintDevice::pageSizeMM() always returns Portrait
- QCOMPARE(writer.pageSizeMM(), sizeMMf);
+ // QPagedPaintDevice::pageLayout().pageSize().size(QPageSize::Millimeter) always returns Portrait
+ QCOMPARE(writer.pageLayout().pageSize().size(QPageSize::Millimeter), sizeMMf);
// QPagedPaintDevice::widthMM() and heightMM() are paint metrics and always return set orientation
QCOMPARE(writer.widthMM(), qRound(widthMMf - leftMMf - rightMMf));
@@ -214,15 +213,15 @@ void tst_QPdfWriter::testPageMetrics()
// Now switch to Landscape mode, size should be unchanged, but rect and metrics should change
writer.setPageOrientation(QPageLayout::Landscape);
QCOMPARE(writer.pageLayout().pageSize().id(), pageSizeId);
- QCOMPARE(int(writer.pageSize()), int(pageSizeId));
+ QCOMPARE(int(writer.pageLayout().pageSize().id()), int(pageSizeId));
QCOMPARE(writer.pageLayout().orientation(), QPageLayout::Landscape);
- QCOMPARE(writer.margins().left(), leftMMf);
- QCOMPARE(writer.margins().right(), rightMMf);
- QCOMPARE(writer.margins().top(), topMMf);
- QCOMPARE(writer.margins().bottom(), bottomMMf);
+ QCOMPARE(writer.pageLayout().margins(QPageLayout::Millimeter).left(), leftMMf);
+ QCOMPARE(writer.pageLayout().margins(QPageLayout::Millimeter).right(), rightMMf);
+ QCOMPARE(writer.pageLayout().margins(QPageLayout::Millimeter).top(), topMMf);
+ QCOMPARE(writer.pageLayout().margins(QPageLayout::Millimeter).bottom(), bottomMMf);
- // QPagedPaintDevice::pageSizeMM() always returns Portrait
- QCOMPARE(writer.pageSizeMM(), sizeMMf);
+ // QPagedPaintDevice::pageLayout().pageSize().size(QPageSize::Millimeter) always returns Portrait
+ QCOMPARE(writer.pageLayout().pageSize().size(QPageSize::Millimeter), sizeMMf);
// QPagedPaintDevice::widthMM() and heightMM() are paint metrics and always return set orientation
QCOMPARE(writer.widthMM(), qRound(heightMMf - leftMMf - rightMMf));
@@ -238,15 +237,15 @@ void tst_QPdfWriter::testPageMetrics()
// Now while in Landscape mode, set the size again, results should be the same
writer.setPageSize(pageSize);
QCOMPARE(writer.pageLayout().pageSize().id(), pageSizeId);
- QCOMPARE(int(writer.pageSize()), int(pageSizeId));
+ QCOMPARE(int(writer.pageLayout().pageSize().id()), int(pageSizeId));
QCOMPARE(writer.pageLayout().orientation(), QPageLayout::Landscape);
- QCOMPARE(writer.margins().left(), leftMMf);
- QCOMPARE(writer.margins().right(), rightMMf);
- QCOMPARE(writer.margins().top(), topMMf);
- QCOMPARE(writer.margins().bottom(), bottomMMf);
+ QCOMPARE(writer.pageLayout().margins(QPageLayout::Millimeter).left(), leftMMf);
+ QCOMPARE(writer.pageLayout().margins(QPageLayout::Millimeter).right(), rightMMf);
+ QCOMPARE(writer.pageLayout().margins(QPageLayout::Millimeter).top(), topMMf);
+ QCOMPARE(writer.pageLayout().margins(QPageLayout::Millimeter).bottom(), bottomMMf);
- // QPagedPaintDevice::pageSizeMM() always returns Portrait
- QCOMPARE(writer.pageSizeMM(), sizeMMf);
+ // QPagedPaintDevice::pageLayout().pageSize().size(QPageSize::Millimeter) always returns Portrait
+ QCOMPARE(writer.pageLayout().pageSize().size(QPageSize::Millimeter), sizeMMf);
// QPagedPaintDevice::widthMM() and heightMM() are paint metrics and always return set orientation
QCOMPARE(writer.widthMM(), qRound(heightMMf - leftMMf - rightMMf));
diff --git a/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp b/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp
index 474079037b..2b0236339c 100644
--- a/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp
+++ b/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp
@@ -1161,7 +1161,7 @@ void tst_QTextTable::QTBUG31330_renderBackground()
}
QTBUG31330_PaintDevice::PaintEngine engine;
QTBUG31330_PaintDevice paintDevice(&engine);
- paintDevice.setPageSize(QPagedPaintDevice::A4);
+ paintDevice.setPageSize(QPageSize(QPageSize::A4));
doc.print(&paintDevice);
QVERIFY(paintDevice.pages >= 2);
diff --git a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
index f3a6c4c695..d6c236e76e 100644
--- a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
+++ b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
@@ -52,8 +52,6 @@
typedef QSharedPointer<QPrinter> PrinterPtr;
Q_DECLARE_METATYPE(PrinterPtr)
-Q_DECLARE_METATYPE(QPrinter::Orientation)
-Q_DECLARE_METATYPE(QPrinter::PageSize)
#endif // printer
static int fileNumber = 0;
@@ -72,8 +70,8 @@ private slots:
void testMargins();
void testPageSetupDialog();
void testPrintPreviewDialog();
- void testMulitpleSets_data();
- void testMulitpleSets();
+ void testMultipleSets_data();
+ void testMultipleSets();
void testPageMargins_data();
void testPageMargins();
void outputFormatFromSuffix();
@@ -82,7 +80,6 @@ private slots:
void customPaperSizeAndMargins_data();
void customPaperSizeAndMargins();
void customPaperNameSettingBySize();
- void customPaperNameSettingByName();
#if QT_CONFIG(completer) && QT_CONFIG(filedialog)
void printDialogCompleter();
#endif
@@ -97,7 +94,6 @@ private slots:
void copyCount();
void creator();
void docName();
- void doubleSidedPrinting();
void duplex();
void fontEmbedding();
void fullPage();
@@ -105,7 +101,6 @@ private slots:
void outputFileName();
void pageOrder();
void pageSize();
- void paperSize();
void paperSource();
void printerName();
void printerSelectionOption();
@@ -114,7 +109,6 @@ private slots:
void resolution();
void supportedPaperSources();
void supportedResolutions();
- void windowsPageSize();
// Test QPrinter setters/getters for non-QPrintEngine options
void outputFormat();
@@ -198,61 +192,61 @@ void tst_QPrinter::testPrintPreviewDialog()
void tst_QPrinter::testPageRectAndPaperRect_data()
{
QTest::addColumn<PrinterPtr>("printer");
- QTest::addColumn<QPrinter::Orientation>("orientation");
+ QTest::addColumn<QPageLayout::Orientation>("orientation");
QTest::addColumn<bool>("withPainter");
QTest::addColumn<int>("resolution");
QTest::addColumn<bool>("doPaperRect");
const PrinterPtr printer(new QPrinter(QPrinter::HighResolution));
// paperrect
- QTest::newRow("paperRect0") << printer << QPrinter::Portrait << true << 300 << true;
- QTest::newRow("paperRect1") << printer << QPrinter::Portrait << false << 300 << true;
- QTest::newRow("paperRect2") << printer << QPrinter::Landscape << true << 300 << true;
- QTest::newRow("paperRect3") << printer << QPrinter::Landscape << false << 300 << true;
- QTest::newRow("paperRect4") << printer << QPrinter::Portrait << true << 600 << true;
- QTest::newRow("paperRect5") << printer << QPrinter::Portrait << false << 600 << true;
- QTest::newRow("paperRect6") << printer << QPrinter::Landscape << true << 600 << true;
- QTest::newRow("paperRect7") << printer << QPrinter::Landscape << false << 600 << true;
- QTest::newRow("paperRect8") << printer << QPrinter::Portrait << true << 1200 << true;
- QTest::newRow("paperRect9") << printer << QPrinter::Portrait << false << 1200 << true;
- QTest::newRow("paperRect10") << printer << QPrinter::Landscape << true << 1200 << true;
- QTest::newRow("paperRect11") << printer << QPrinter::Landscape << false << 1200 << true;
+ QTest::newRow("paperRect0") << printer << QPageLayout::Portrait << true << 300 << true;
+ QTest::newRow("paperRect1") << printer << QPageLayout::Portrait << false << 300 << true;
+ QTest::newRow("paperRect2") << printer << QPageLayout::Landscape << true << 300 << true;
+ QTest::newRow("paperRect3") << printer << QPageLayout::Landscape << false << 300 << true;
+ QTest::newRow("paperRect4") << printer << QPageLayout::Portrait << true << 600 << true;
+ QTest::newRow("paperRect5") << printer << QPageLayout::Portrait << false << 600 << true;
+ QTest::newRow("paperRect6") << printer << QPageLayout::Landscape << true << 600 << true;
+ QTest::newRow("paperRect7") << printer << QPageLayout::Landscape << false << 600 << true;
+ QTest::newRow("paperRect8") << printer << QPageLayout::Portrait << true << 1200 << true;
+ QTest::newRow("paperRect9") << printer << QPageLayout::Portrait << false << 1200 << true;
+ QTest::newRow("paperRect10") << printer << QPageLayout::Landscape << true << 1200 << true;
+ QTest::newRow("paperRect11") << printer << QPageLayout::Landscape << false << 1200 << true;
// page rect
- QTest::newRow("pageRect0") << printer << QPrinter::Portrait << true << 300 << false;
- QTest::newRow("pageRect1") << printer << QPrinter::Portrait << false << 300 << false;
- QTest::newRow("pageRect2") << printer << QPrinter::Landscape << true << 300 << false;
- QTest::newRow("pageRect3") << printer << QPrinter::Landscape << false << 300 << false;
- QTest::newRow("pageRect4") << printer << QPrinter::Portrait << true << 600 << false;
- QTest::newRow("pageRect5") << printer << QPrinter::Portrait << false << 600 << false;
- QTest::newRow("pageRect6") << printer << QPrinter::Landscape << true << 600 << false;
- QTest::newRow("pageRect7") << printer << QPrinter::Landscape << false << 600 << false;
- QTest::newRow("pageRect8") << printer << QPrinter::Portrait << true << 1200 << false;
- QTest::newRow("pageRect9") << printer << QPrinter::Portrait << false << 1200 << false;
- QTest::newRow("pageRect10") << printer << QPrinter::Landscape << true << 1200 << false;
- QTest::newRow("pageRect11") << printer << QPrinter::Landscape << false << 1200 << false;
+ QTest::newRow("pageRect0") << printer << QPageLayout::Portrait << true << 300 << false;
+ QTest::newRow("pageRect1") << printer << QPageLayout::Portrait << false << 300 << false;
+ QTest::newRow("pageRect2") << printer << QPageLayout::Landscape << true << 300 << false;
+ QTest::newRow("pageRect3") << printer << QPageLayout::Landscape << false << 300 << false;
+ QTest::newRow("pageRect4") << printer << QPageLayout::Portrait << true << 600 << false;
+ QTest::newRow("pageRect5") << printer << QPageLayout::Portrait << false << 600 << false;
+ QTest::newRow("pageRect6") << printer << QPageLayout::Landscape << true << 600 << false;
+ QTest::newRow("pageRect7") << printer << QPageLayout::Landscape << false << 600 << false;
+ QTest::newRow("pageRect8") << printer << QPageLayout::Portrait << true << 1200 << false;
+ QTest::newRow("pageRect9") << printer << QPageLayout::Portrait << false << 1200 << false;
+ QTest::newRow("pageRect10") << printer << QPageLayout::Landscape << true << 1200 << false;
+ QTest::newRow("pageRect11") << printer << QPageLayout::Landscape << false << 1200 << false;
}
void tst_QPrinter::testPageRectAndPaperRect()
{
QFETCH(PrinterPtr, printer);
QFETCH(bool, withPainter);
- QFETCH(QPrinter::Orientation, orientation);
+ QFETCH(QPageLayout::Orientation, orientation);
QFETCH(int, resolution);
QFETCH(bool, doPaperRect);
QPainter *painter = 0;
- printer->setOrientation(orientation);
+ printer->setPageOrientation(orientation);
printer->setOutputFileName(testFileName(QLatin1String("silly"), QString()));
- QRect pageRect = doPaperRect ? printer->paperRect() : printer->pageRect();
+ QRect pageRect = (doPaperRect ? printer->paperRect(QPrinter::DevicePixel) : printer->pageRect(QPrinter::DevicePixel)).toRect();
float inchesX = float(pageRect.width()) / float(printer->resolution());
float inchesY = float(pageRect.height()) / float(printer->resolution());
printer->setResolution(resolution);
if (withPainter)
painter = new QPainter(printer.data());
- QRect otherRect = doPaperRect ? printer->paperRect() : printer->pageRect();
+ QRect otherRect = (doPaperRect ? printer->paperRect(QPrinter::DevicePixel) : printer->pageRect(QPrinter::DevicePixel)).toRect();
float otherInchesX = float(otherRect.width()) / float(printer->resolution());
float otherInchesY = float(otherRect.height()) / float(printer->resolution());
if (painter != 0)
@@ -261,8 +255,8 @@ void tst_QPrinter::testPageRectAndPaperRect()
QVERIFY(qAbs(otherInchesX - inchesX) < 0.01);
QVERIFY(qAbs(otherInchesY - inchesY) < 0.01);
- QVERIFY(printer->orientation() == QPrinter::Portrait || pageRect.width() > pageRect.height());
- QVERIFY(printer->orientation() != QPrinter::Portrait || pageRect.width() < pageRect.height());
+ QVERIFY(printer->pageLayout().orientation() == QPageLayout::Portrait || pageRect.width() > pageRect.height());
+ QVERIFY(printer->pageLayout().orientation() != QPageLayout::Portrait || pageRect.width() < pageRect.height());
}
void tst_QPrinter::testSetOptions()
@@ -295,34 +289,34 @@ void tst_QPrinter::testSetOptions()
void tst_QPrinter::testMargins_data()
{
QTest::addColumn<PrinterPtr>("printer");
- QTest::addColumn<QPrinter::Orientation>("orientation");
+ QTest::addColumn<QPageLayout::Orientation>("orientation");
QTest::addColumn<bool>("fullpage");
- QTest::addColumn<QPrinter::PageSize>("pagesize");
+ QTest::addColumn<QPageSize::PageSizeId>("pagesize");
QTest::addColumn<bool>("withPainter");
const PrinterPtr printer(new QPrinter);
- QTest::newRow("data0") << printer << QPrinter::Portrait << true << QPrinter::A4 << false;
- QTest::newRow("data1") << printer << QPrinter::Landscape << true << QPrinter::A4 << false;
- QTest::newRow("data2") << printer << QPrinter::Landscape << false << QPrinter::A4 << false;
- QTest::newRow("data3") << printer << QPrinter::Portrait << false << QPrinter::A4 << false;
- QTest::newRow("data4") << printer << QPrinter::Portrait << true << QPrinter::A4 << true;
- QTest::newRow("data5") << printer << QPrinter::Landscape << true << QPrinter::A4 << true;
- QTest::newRow("data6") << printer << QPrinter::Landscape << false << QPrinter::A4 << true;
- QTest::newRow("data7") << printer << QPrinter::Portrait << false << QPrinter::A4 << true;
+ QTest::newRow("data0") << printer << QPageLayout::Portrait << true << QPageSize::A4 << false;
+ QTest::newRow("data1") << printer << QPageLayout::Landscape << true << QPageSize::A4 << false;
+ QTest::newRow("data2") << printer << QPageLayout::Landscape << false << QPageSize::A4 << false;
+ QTest::newRow("data3") << printer << QPageLayout::Portrait << false << QPageSize::A4 << false;
+ QTest::newRow("data4") << printer << QPageLayout::Portrait << true << QPageSize::A4 << true;
+ QTest::newRow("data5") << printer << QPageLayout::Landscape << true << QPageSize::A4 << true;
+ QTest::newRow("data6") << printer << QPageLayout::Landscape << false << QPageSize::A4 << true;
+ QTest::newRow("data7") << printer << QPageLayout::Portrait << false << QPageSize::A4 << true;
}
void tst_QPrinter::testMargins()
{
QFETCH(PrinterPtr, printer);
QFETCH(bool, withPainter);
- QFETCH(QPrinter::Orientation, orientation);
- QFETCH(QPrinter::PageSize, pagesize);
+ QFETCH(QPageLayout::Orientation, orientation);
+ QFETCH(QPageSize::PageSizeId, pagesize);
QFETCH(bool, fullpage);
QPainter *painter = 0;
printer->setOutputFileName(testFileName(QLatin1String("silly"), QString()));
- printer->setOrientation(orientation);
+ printer->setPageOrientation(orientation);
printer->setFullPage(fullpage);
- printer->setPageSize(pagesize);
+ printer->setPageSize(QPageSize(pagesize));
if (withPainter)
painter = new QPainter(printer.data());
@@ -330,57 +324,55 @@ void tst_QPrinter::testMargins()
delete painter;
}
-void tst_QPrinter::testMulitpleSets_data()
+void tst_QPrinter::testMultipleSets_data()
{
QTest::addColumn<int>("resolution");
- QTest::addColumn<int>("pageSize");
+ QTest::addColumn<QPageSize::PageSizeId>("pageSize");
QTest::addColumn<int>("widthMMAfter");
QTest::addColumn<int>("heightMMAfter");
- QTest::newRow("lowRes") << int(QPrinter::ScreenResolution) << int(QPrinter::A4) << 210 << 297;
- QTest::newRow("lowResLetter") << int(QPrinter::ScreenResolution) << int(QPrinter::Letter) << 216 << 279;
- QTest::newRow("lowResA5") << int(QPrinter::ScreenResolution) << int(QPrinter::A5) << 148 << 210;
- QTest::newRow("midRes") << int(QPrinter::PrinterResolution) << int(QPrinter::A4) << 210 << 297;
- QTest::newRow("midResLetter") << int(QPrinter::PrinterResolution) << int(QPrinter::Letter) << 216 << 279;
- QTest::newRow("midResA5") << int(QPrinter::PrinterResolution) << int(QPrinter::A5) << 148 << 210;
- QTest::newRow("highRes") << int(QPrinter::HighResolution) << int(QPrinter::A4) << 210 << 297;
- QTest::newRow("highResLetter") << int(QPrinter::HighResolution) << int(QPrinter::Letter) << 216 << 279;
- QTest::newRow("highResA5") << int(QPrinter::HighResolution) << int(QPrinter::A5) << 148 << 210;
+ QTest::newRow("lowRes") << int(QPrinter::ScreenResolution) << QPageSize::A4 << 210 << 297;
+ QTest::newRow("lowResLetter") << int(QPrinter::ScreenResolution) << QPageSize::Letter << 216 << 279;
+ QTest::newRow("lowResA5") << int(QPrinter::ScreenResolution) << QPageSize::A5 << 148 << 210;
+ QTest::newRow("midRes") << int(QPrinter::PrinterResolution) << QPageSize::A4 << 210 << 297;
+ QTest::newRow("midResLetter") << int(QPrinter::PrinterResolution) << QPageSize::Letter << 216 << 279;
+ QTest::newRow("midResA5") << int(QPrinter::PrinterResolution) << QPageSize::A5 << 148 << 210;
+ QTest::newRow("highRes") << int(QPrinter::HighResolution) << QPageSize::A4 << 210 << 297;
+ QTest::newRow("highResLetter") << int(QPrinter::HighResolution) << QPageSize::Letter << 216 << 279;
+ QTest::newRow("highResA5") << int(QPrinter::HighResolution) << QPageSize::A5 << 148 << 210;
}
-static void computePageValue(const QPrinter &printer, int &retWidth, int &retHeight)
-{
- const double Inch2MM = 25.4;
-
- double width = double(printer.paperRect().width()) / printer.logicalDpiX() * Inch2MM;
- double height = double(printer.paperRect().height()) / printer.logicalDpiY() * Inch2MM;
- retWidth = qRound(width);
- retHeight = qRound(height);
-}
-
-void tst_QPrinter::testMulitpleSets()
+void tst_QPrinter::testMultipleSets()
{
// A very simple test, but Mac needs to have its format "validated" if the format is changed
// This takes care of that.
QFETCH(int, resolution);
- QFETCH(int, pageSize);
+ QFETCH(QPageSize::PageSizeId, pageSize);
QFETCH(int, widthMMAfter);
QFETCH(int, heightMMAfter);
QPrinter::PrinterMode mode = QPrinter::PrinterMode(resolution);
- QPrinter::PageSize printerPageSize = QPrinter::PageSize(pageSize);
QPrinter printer(mode);
printer.setFullPage(true);
int paperWidth, paperHeight;
//const int Tolerance = 2;
- computePageValue(printer, paperWidth, paperHeight);
- printer.setPageSize(printerPageSize);
+ const auto computePageValue = [&printer](int &retWidth, int &retHeight)
+ {
+ const double Inch2MM = 25.4;
+ double width = double(printer.paperRect(QPrinter::DevicePixel).width()) / printer.logicalDpiX() * Inch2MM;
+ double height = double(printer.paperRect(QPrinter::DevicePixel).height()) / printer.logicalDpiY() * Inch2MM;
+ retWidth = qRound(width);
+ retHeight = qRound(height);
+ };
+
+ computePageValue(paperWidth, paperHeight);
+ printer.setPageSize(QPageSize(pageSize));
- if (printer.pageSize() != printerPageSize) {
+ if (printer.pageLayout().pageSize().id() != pageSize) {
QSKIP("Current page size is not supported on this printer");
return;
}
@@ -388,18 +380,18 @@ void tst_QPrinter::testMulitpleSets()
QVERIFY(qAbs(printer.widthMM() - widthMMAfter) <= 2);
QVERIFY(qAbs(printer.heightMM() - heightMMAfter) <= 2);
- computePageValue(printer, paperWidth, paperHeight);
+ computePageValue(paperWidth, paperHeight);
QVERIFY(qAbs(paperWidth - widthMMAfter) <= 2);
QVERIFY(qAbs(paperHeight - heightMMAfter) <= 2);
// Set it again and see if it still works.
- printer.setPageSize(printerPageSize);
+ printer.setPageSize(QPageSize(pageSize));
QVERIFY(qAbs(printer.widthMM() - widthMMAfter) <= 2);
QVERIFY(qAbs(printer.heightMM() - heightMMAfter) <= 2);
- printer.setOrientation(QPrinter::Landscape);
- computePageValue(printer, paperWidth, paperHeight);
+ printer.setPageOrientation(QPageLayout::Landscape);
+ computePageValue(paperWidth, paperHeight);
QVERIFY(qAbs(paperWidth - heightMMAfter) <= 2);
QVERIFY(qAbs(paperHeight - widthMMAfter) <= 2);
}
@@ -422,15 +414,15 @@ void tst_QPrinter::testPageMargins_data()
QTest::addColumn<qreal>("top");
QTest::addColumn<qreal>("right");
QTest::addColumn<qreal>("bottom");
- QTest::addColumn<int>("unit");
+ QTest::addColumn<QPageLayout::Unit>("unit");
// Use custom margins that will exceed most printers minimum allowed
- QTest::newRow("data0") << qreal(25.5) << qreal(26.5) << qreal(27.5) << qreal(28.5) << static_cast<int>(QPrinter::Millimeter);
- QTest::newRow("data1") << qreal(55.5) << qreal(56.5) << qreal(57.5) << qreal(58.5) << static_cast<int>(QPrinter::Point);
- QTest::newRow("data2") << qreal(5.5) << qreal(6.5) << qreal(7.5) << qreal(8.5) << static_cast<int>(QPrinter::Inch);
- QTest::newRow("data3") << qreal(5.5) << qreal(6.5) << qreal(7.5) << qreal(8.5) << static_cast<int>(QPrinter::Pica);
- QTest::newRow("data4") << qreal(55.5) << qreal(56.5) << qreal(57.5) << qreal(58.5) << static_cast<int>(QPrinter::Didot);
- QTest::newRow("data5") << qreal(5.5) << qreal(6.5) << qreal(7.5) << qreal(8.5) << static_cast<int>(QPrinter::Cicero);
+ QTest::newRow("data0") << qreal(25.5) << qreal(26.5) << qreal(27.5) << qreal(28.5) << QPageLayout::Millimeter;
+ QTest::newRow("data1") << qreal(55.5) << qreal(56.5) << qreal(57.5) << qreal(58.5) << QPageLayout::Point;
+ QTest::newRow("data2") << qreal(5.5) << qreal(6.5) << qreal(7.5) << qreal(8.5) << QPageLayout::Inch;
+ QTest::newRow("data3") << qreal(5.5) << qreal(6.5) << qreal(7.5) << qreal(8.5) << QPageLayout::Pica;
+ QTest::newRow("data4") << qreal(55.5) << qreal(56.5) << qreal(57.5) << qreal(58.5) << QPageLayout::Didot;
+ QTest::newRow("data5") << qreal(5.5) << qreal(6.5) << qreal(7.5) << qreal(8.5) << QPageLayout::Cicero;
}
void tst_QPrinter::testPageMargins()
@@ -441,50 +433,23 @@ void tst_QPrinter::testPageMargins()
QFETCH(qreal, top);
QFETCH(qreal, right);
QFETCH(qreal, bottom);
- QFETCH(int, unit);
+ QFETCH(QPageLayout::Unit, unit);
QPageLayout layout = QPageLayout(QPageSize(QPageSize::A0), QPageLayout::Portrait,
- QMarginsF(left, top, right, bottom), QPageLayout::Unit(unit));
-
- qreal nLeft, nTop, nRight, nBottom;
-
- obj1.setPageMargins(left, top, right, bottom, QPrinter::Unit(unit));
-
- obj1.getPageMargins(&nLeft, &nTop, &nRight, &nBottom, QPrinter::Millimeter);
- QCOMPARE(nLeft, layout.margins(QPageLayout::Millimeter).left());
- QCOMPARE(nRight, layout.margins(QPageLayout::Millimeter).right());
- QCOMPARE(nTop, layout.margins(QPageLayout::Millimeter).top());
- QCOMPARE(nBottom, layout.margins(QPageLayout::Millimeter).bottom());
-
- obj1.getPageMargins(&nLeft, &nTop, &nRight, &nBottom, QPrinter::Point);
- QCOMPARE(nLeft, layout.margins(QPageLayout::Point).left());
- QCOMPARE(nRight, layout.margins(QPageLayout::Point).right());
- QCOMPARE(nTop, layout.margins(QPageLayout::Point).top());
- QCOMPARE(nBottom, layout.margins(QPageLayout::Point).bottom());
-
- obj1.getPageMargins(&nLeft, &nTop, &nRight, &nBottom, QPrinter::Inch);
- QCOMPARE(nLeft, layout.margins(QPageLayout::Inch).left());
- QCOMPARE(nRight, layout.margins(QPageLayout::Inch).right());
- QCOMPARE(nTop, layout.margins(QPageLayout::Inch).top());
- QCOMPARE(nBottom, layout.margins(QPageLayout::Inch).bottom());
-
- obj1.getPageMargins(&nLeft, &nTop, &nRight, &nBottom, QPrinter::Pica);
- QCOMPARE(nLeft, layout.margins(QPageLayout::Pica).left());
- QCOMPARE(nRight, layout.margins(QPageLayout::Pica).right());
- QCOMPARE(nTop, layout.margins(QPageLayout::Pica).top());
- QCOMPARE(nBottom, layout.margins(QPageLayout::Pica).bottom());
-
- obj1.getPageMargins(&nLeft, &nTop, &nRight, &nBottom, QPrinter::Didot);
- QCOMPARE(nLeft, layout.margins(QPageLayout::Didot).left());
- QCOMPARE(nRight, layout.margins(QPageLayout::Didot).right());
- QCOMPARE(nTop, layout.margins(QPageLayout::Didot).top());
- QCOMPARE(nBottom, layout.margins(QPageLayout::Didot).bottom());
-
- obj1.getPageMargins(&nLeft, &nTop, &nRight, &nBottom, QPrinter::Cicero);
- QCOMPARE(nLeft, layout.margins(QPageLayout::Cicero).left());
- QCOMPARE(nRight, layout.margins(QPageLayout::Cicero).right());
- QCOMPARE(nTop, layout.margins(QPageLayout::Cicero).top());
- QCOMPARE(nBottom, layout.margins(QPageLayout::Cicero).bottom());
+ QMarginsF(left, top, right, bottom), unit);
+
+ const QMarginsF margins(left, top, right, bottom);
+ obj1.setPageMargins(margins, unit);
+
+ for (const auto compareUnit : { QPageLayout::Millimeter,
+ QPageLayout::Point,
+ QPageLayout::Inch,
+ QPageLayout::Pica,
+ QPageLayout::Didot,
+ QPageLayout::Cicero}) {
+ QMarginsF actualMargins = obj1.pageLayout().margins(compareUnit);
+ QCOMPARE(actualMargins, layout.margins(compareUnit));
+ }
}
void tst_QPrinter::errorReporting()
@@ -508,28 +473,29 @@ void tst_QPrinter::testCustomPageSizes()
{
QPrinter p;
- QSizeF customSize(7.0, 11.0);
- p.setPaperSize(customSize, QPrinter::Inch);
+ const QPageSize customSize(QSizeF(7.0, 11.0), QPageSize::Inch);
+ p.setPageSize(customSize);
- QSizeF paperSize = p.paperSize(QPrinter::Inch);
- QCOMPARE(paperSize.width(), customSize.width());
- QCOMPARE(paperSize.height(), customSize.height());
+ QSizeF paperSize = p.pageLayout().pageSize().size(QPageSize::Inch);
+ QCOMPARE(paperSize.width(), customSize.size(QPageSize::Inch).width());
+ QCOMPARE(paperSize.height(), customSize.size(QPageSize::Inch).height());
QPrinter p2(QPrinter::HighResolution);
- p2.setPaperSize(customSize, QPrinter::Inch);
- paperSize = p.paperSize(QPrinter::Inch);
- QCOMPARE(paperSize.width(), customSize.width());
- QCOMPARE(paperSize.height(), customSize.height());
+ p2.setPageSize(customSize);
+ paperSize = p.pageLayout().pageSize().size(QPageSize::Inch);
+ QCOMPARE(paperSize.width(), customSize.size(QPageSize::Inch).width());
+ QCOMPARE(paperSize.height(), customSize.size(QPageSize::Inch).height());
+
+ const QPageSize pageSize = customSize;
+ const QSizeF sizeInPixels = p.paperRect(QPrinter::DevicePixel).size();
- const QSizeF sizeInPixels = p.paperSize(QPrinter::DevicePixel);
QPrinter p3;
- p3.setPaperSize(sizeInPixels, QPrinter::DevicePixel);
- paperSize = p3.paperSize(QPrinter::Inch);
- QCOMPARE(paperSize.width(), customSize.width());
- QCOMPARE(paperSize.height(), customSize.height());
- QPageSize pageSize = p3.pageLayout().pageSize();
- QCOMPARE(pageSize.key(), QString("Custom.504x792"));
- QCOMPARE(pageSize.name(), QString("Custom (504pt x 792pt)"));
+ p3.setPageSize(QPageSize(sizeInPixels / p.resolution(), QPageSize::Inch));
+ paperSize = p3.pageLayout().pageSize().size(QPageSize::Inch);
+ QCOMPARE(paperSize.width(), customSize.size(QPageSize::Inch).width());
+ QCOMPARE(paperSize.height(), customSize.size(QPageSize::Inch).height());
+ QCOMPARE(p3.pageLayout().pageSize().key(), QString("Custom.7x11in"));
+ QCOMPARE(p3.pageLayout().pageSize().name(), QString("Custom (7in x 11in)"));
}
void tst_QPrinter::customPaperSizeAndMargins_data()
@@ -558,34 +524,27 @@ void tst_QPrinter::customPaperSizeAndMargins()
QFETCH(qreal, bottom);
qreal tolerance = 0.05;
- qreal getLeft = 0;
- qreal getRight = 0;
- qreal getTop = 0;
- qreal getBottom = 0;
// Use a custom page size that most printers should support, A4 is 210x297
// TODO Use print device api when available
QSizeF customSize(200.0, 300.0);
+ const QMarginsF margins(left, top, right, bottom);
QPrinter p;
if (pdf)
p.setOutputFormat(QPrinter::PdfFormat);
if (before)
- p.setPageMargins(left, top, right, bottom, QPrinter::Millimeter);
- p.setPaperSize(customSize, QPrinter::Millimeter);
- p.getPageMargins(&getLeft, &getTop, &getRight, &getBottom, QPrinter::Millimeter);
- if (before) {
- QVERIFY(fabs(left - getLeft) < tolerance);
- QVERIFY(fabs(left - getTop) < tolerance);
- QVERIFY(fabs(left - getRight) < tolerance);
- QVERIFY(fabs(left - getBottom) < tolerance);
- } else {
- p.setPageMargins(left, top, right, bottom, QPrinter::Millimeter);
- p.getPageMargins(&getLeft, &getTop, &getRight, &getBottom, QPrinter::Millimeter);
- QVERIFY(fabs(left - getLeft) < tolerance);
- QVERIFY(fabs(left - getTop) < tolerance);
- QVERIFY(fabs(left - getRight) < tolerance);
- QVERIFY(fabs(left - getBottom) < tolerance);
+ p.setPageMargins(margins, QPageLayout::Millimeter);
+ QPageSize customPageSize(customSize, QPageSize::Millimeter);
+ p.setPageSize(customPageSize);
+ QMarginsF actual = p.pageLayout().margins(QPageLayout::Millimeter);
+ if (!before) {
+ p.setPageMargins(margins, QPageLayout::Millimeter);
+ actual = p.pageLayout().margins(QPageLayout::Millimeter);
}
+ QVERIFY(fabs(left - actual.left()) < tolerance);
+ QVERIFY(fabs(top - actual.top()) < tolerance);
+ QVERIFY(fabs(right - actual.right()) < tolerance);
+ QVERIFY(fabs(bottom - actual.bottom()) < tolerance);
}
#if QT_CONFIG(completer) && QT_CONFIG(filedialog)
@@ -707,22 +666,22 @@ void tst_QPrinter::customPaperNameSettingBySize()
{
QPrinter printer(QPrinter::HighResolution);
QPrinterInfo info(printer);
- QList<QPageSize> sizes = info.supportedPageSizes();
+ const QList<QPageSize> sizes = info.supportedPageSizes();
if (sizes.size() == 0)
QSKIP("No printers installed on this machine");
- for (int i=0; i<sizes.size(); i++) {
- printer.setPaperSize(sizes.at(i).size(QPageSize::Millimeter), QPrinter::Millimeter);
- QCOMPARE(sizes.at(i).size(QPageSize::Millimeter), printer.paperSize(QPrinter::Millimeter));
+ for (const auto &pageSize : sizes) {
+ printer.setPageSize(pageSize);
+ QCOMPARE(pageSize.size(QPageSize::Millimeter), printer.pageLayout().pageSize().size(QPageSize::Millimeter));
// Some printers have the same size under different names which can cause a problem for the test
// So we look at all the other sizes to see if one also matches as we don't know which order they are in
- QSizeF paperSize = sizes.at(i).size(QPageSize::Millimeter);
- QString paperName = printer.paperName();
- bool paperNameFound = (sizes.at(i).name() == paperName);
+ const QSizeF paperSize = pageSize.size(QPageSize::Millimeter);
+ const QString paperName = printer.pageLayout().pageSize().name();
+ bool paperNameFound = (pageSize.name() == paperName);
if (!paperNameFound) {
- for (int j = 0; j < sizes.size(); ++j) {
- if (j != i
- && sizes.at(j).size(QPageSize::Millimeter) == paperSize
- && sizes.at(j).name() == paperName) {
+ for (const auto &pageSize2 : sizes) {
+ if (pageSize != pageSize2
+ && pageSize2.size(QPageSize::Millimeter) == paperSize
+ && pageSize2.name() == paperName) {
paperNameFound = true;
break;
}
@@ -732,34 +691,21 @@ void tst_QPrinter::customPaperNameSettingBySize()
if (!paperNameFound) {
qDebug() << "supportedPageSizes() = " << sizes;
QEXPECT_FAIL("", "Paper Name mismatch: please report this failure at bugreports.qt.io", Continue);
- QCOMPARE(sizes.at(i).name(), printer.paperName());
+ QCOMPARE(pageSize.name(), printer.pageLayout().pageSize().name());
}
}
// Check setting a custom size after setting a standard one works
- QSizeF customSize(200, 300);
- printer.setPaperSize(customSize, QPrinter::Millimeter);
- QCOMPARE(printer.paperSize(QPrinter::Millimeter), customSize);
- QCOMPARE(printer.paperSize(), QPrinter::Custom);
+ const QSizeF customSize(200, 300);
+ printer.setPageSize(QPageSize(customSize, QPageSize::Millimeter));
+ QCOMPARE(printer.pageLayout().pageSize().size(QPageSize::Millimeter), customSize);
+ QCOMPARE(printer.pageLayout().pageSize().id(), QPageSize::Custom);
// Finally check setting a standard size after a custom one works
- printer.setPaperSize(sizes.at(0).size(QPageSize::Millimeter), QPrinter::Millimeter);
- QCOMPARE(printer.paperName(), sizes.at(0).name());
- QCOMPARE(printer.paperSize(QPrinter::Millimeter), sizes.at(0).size(QPageSize::Millimeter));
-}
-
-void tst_QPrinter::customPaperNameSettingByName()
-{
- QPrinter printer(QPrinter::HighResolution);
- QPrinterInfo info(printer);
- QList<QPageSize> sizes = info.supportedPageSizes();
- if (sizes.size() == 0)
- QSKIP("No printers installed on this machine");
- for (int i=0; i<sizes.size(); i++) {
- printer.setPaperName(sizes.at(i).name());
- QCOMPARE(sizes.at(i).name(), printer.paperName());
- QCOMPARE(sizes.at(i).size(QPageSize::Millimeter), printer.paperSize(QPrinter::Millimeter));
- }
+ const QPageSize standardPageSize = sizes.first();
+ printer.setPageSize(standardPageSize);
+ QCOMPARE(printer.pageLayout().pageSize().name(), standardPageSize.name());
+ QCOMPARE(printer.pageLayout().pageSize().size(QPageSize::Millimeter), standardPageSize.size(QPageSize::Millimeter));
}
// Test QPrintEngine keys and their QPrinter setters/getters
@@ -772,21 +718,21 @@ void tst_QPrinter::testMultipleKeys()
if (native.outputFormat() == QPrinter::NativeFormat) {
// Check default values
QCOMPARE(native.fullPage(), false);
- QCOMPARE(native.orientation(), QPrinter::Portrait);
+ QCOMPARE(native.pageLayout().orientation(), QPageLayout::Portrait);
QCOMPARE(native.copyCount(), 1);
QCOMPARE(native.collateCopies(), true);
QCOMPARE(native.printRange(), QPrinter::AllPages);
// Change values
native.setFullPage(true);
- native.setOrientation(QPrinter::Landscape);
+ native.setPageOrientation(QPageLayout::Landscape);
native.setCopyCount(9);
native.setCollateCopies(false);
native.setPrintRange(QPrinter::CurrentPage);
// Check changed values
QCOMPARE(native.fullPage(), true);
- QCOMPARE(native.orientation(), QPrinter::Landscape);
+ QCOMPARE(native.pageLayout().orientation(), QPageLayout::Landscape);
QCOMPARE(native.copyCount(), 9);
QCOMPARE(native.collateCopies(), false);
QCOMPARE(native.printRange(), QPrinter::CurrentPage);
@@ -794,21 +740,21 @@ void tst_QPrinter::testMultipleKeys()
// Test value preservation
native.setOutputFormat(QPrinter::PdfFormat);
QCOMPARE(native.fullPage(), true);
- QCOMPARE(native.orientation(), QPrinter::Landscape);
+ QCOMPARE(native.pageLayout().orientation(), QPageLayout::Landscape);
QCOMPARE(native.copyCount(), 9);
QCOMPARE(native.collateCopies(), false);
QCOMPARE(native.printRange(), QPrinter::CurrentPage);
// Change values
native.setFullPage(false);
- native.setOrientation(QPrinter::Portrait);
+ native.setPageOrientation(QPageLayout::Portrait);
native.setCopyCount(5);
native.setCollateCopies(true);
native.setPrintRange(QPrinter::PageRange);
// Check changed values
QCOMPARE(native.fullPage(), false);
- QCOMPARE(native.orientation(), QPrinter::Portrait);
+ QCOMPARE(native.pageLayout().orientation(), QPageLayout::Portrait);
QCOMPARE(native.copyCount(), 5);
QCOMPARE(native.collateCopies(), true);
QCOMPARE(native.printRange(), QPrinter::PageRange);
@@ -891,56 +837,33 @@ void tst_QPrinter::colorMode()
void tst_QPrinter::copyCount()
{
- // copyCount() / setCopyCount() / PPK_CopyCount
- // numCopies() / setNumCopies() / PPK_NumberOfCopies
- // actualNumCopies() / supportsMultipleCopies()
- // PdfFormat: Supported, multiple copies unsupported, default 1
- // NativeFormat, Cups: Supported, multiple copies supported, default 1
- // NativeFormat, Win: Supported, multiple copies supported, default 1
- // NativeFormat, Mac: Supported, multiple copies supported, default 1
-
QPrinter pdf;
pdf.setOutputFormat(QPrinter::PdfFormat);
QCOMPARE(pdf.supportsMultipleCopies(), false);
QCOMPARE(pdf.copyCount(), 1);
- QCOMPARE(pdf.numCopies(), 1);
- QCOMPARE(pdf.actualNumCopies(), 1);
pdf.setCopyCount(9);
QCOMPARE(pdf.copyCount(), 9);
- QCOMPARE(pdf.numCopies(), 9);
- QCOMPARE(pdf.actualNumCopies(), 9);
- pdf.setNumCopies(7);
+ pdf.setCopyCount(7);
QCOMPARE(pdf.copyCount(), 7);
- QCOMPARE(pdf.numCopies(), 7);
- QCOMPARE(pdf.actualNumCopies(), 7);
QPrinter native;
if (native.outputFormat() == QPrinter::NativeFormat) {
// Test default
QCOMPARE(native.supportsMultipleCopies(), true);
QCOMPARE(native.copyCount(), 1);
- QCOMPARE(native.numCopies(), 1);
- QCOMPARE(native.actualNumCopies(), 1);
// Test set/get
native.setCopyCount(9);
QCOMPARE(native.copyCount(), 9);
- QCOMPARE(native.numCopies(), 1);
- QCOMPARE(native.actualNumCopies(), 9);
- native.setNumCopies(7);
+ native.setCopyCount(7);
QCOMPARE(native.copyCount(), 7);
- QCOMPARE(native.numCopies(), 1);
- QCOMPARE(native.actualNumCopies(), 7);
// Test value preservation
native.setOutputFormat(QPrinter::PdfFormat);
QCOMPARE(native.copyCount(), 7);
- QCOMPARE(native.numCopies(), 7);
- QCOMPARE(native.actualNumCopies(), 7);
+
native.setOutputFormat(QPrinter::NativeFormat);
QCOMPARE(native.copyCount(), 7);
- QCOMPARE(native.numCopies(), 1);
- QCOMPARE(native.actualNumCopies(), 7);
} else {
QSKIP("No printers installed, cannot test NativeFormat, please install printers to test");
}
@@ -1060,41 +983,6 @@ void tst_QPrinter::duplex()
}
}
-void tst_QPrinter::doubleSidedPrinting()
-{
- // PdfFormat: Supported, default false
- // NativeFormat, Cups: Supported, default to printer default
- // NativeFormat, Win: Supported, default to printer default
- // NativeFormat, Mac: Supported, default to printer default
-
- QPrinter pdf;
- pdf.setOutputFormat(QPrinter::PdfFormat);
- QCOMPARE(pdf.doubleSidedPrinting(), false);
- pdf.setDoubleSidedPrinting(true);
- QCOMPARE(pdf.doubleSidedPrinting(), false); // pdf doesn't have the concept of duplex
-
- QPrinter native;
- if (native.outputFormat() == QPrinter::NativeFormat) {
- // Test default
- QPrinterInfo printerInfo(native);
- bool expected = (printerInfo.defaultDuplexMode() != QPrinter::DuplexNone);
- QCOMPARE(native.doubleSidedPrinting(), expected);
-
- // Test set/get, changing the expected value if possible
- expected = expected ? false : (printerInfo.supportedDuplexModes().count() > 1);
- native.setDoubleSidedPrinting(expected);
- QCOMPARE(native.doubleSidedPrinting(), expected);
-
- // Test value preservation
- native.setOutputFormat(QPrinter::PdfFormat);
- QCOMPARE(native.doubleSidedPrinting(), expected);
- native.setOutputFormat(QPrinter::NativeFormat);
- QCOMPARE(native.doubleSidedPrinting(), expected);
- } else {
- QSKIP("No printers installed, cannot test NativeFormat, please install printers to test");
- }
-}
-
void tst_QPrinter::fontEmbedding()
{
// fontEmbeddingEnabled() / setFontEmbeddingEnabled() / PPK_FontEmbedding
@@ -1176,44 +1064,44 @@ void tst_QPrinter::fullPage()
void tst_QPrinter::orientation()
{
// orientation() / setOrientation() / PPK_Orientation
- // PdfFormat: Supported, default QPrinter::Portrait
- // NativeFormat, Cups: Supported, default QPrinter::Portrait
- // NativeFormat, Win: Supported, default QPrinter::Portrait
- // NativeFormat, Mac: Supported, default QPrinter::Portrait
+ // PdfFormat: Supported, default QPageLayout::Portrait
+ // NativeFormat, Cups: Supported, default QPageLayout::Portrait
+ // NativeFormat, Win: Supported, default QPageLayout::Portrait
+ // NativeFormat, Mac: Supported, default QPageLayout::Portrait
QPrinter pdf;
pdf.setOutputFormat(QPrinter::PdfFormat);
- QCOMPARE(pdf.orientation(), QPrinter::Portrait);
- pdf.setOrientation(QPrinter::Landscape);
- QCOMPARE(pdf.orientation(), QPrinter::Landscape);
+ QCOMPARE(pdf.pageLayout().orientation(), QPageLayout::Portrait);
+ pdf.setPageOrientation(QPageLayout::Landscape);
+ QCOMPARE(pdf.pageLayout().orientation(), QPageLayout::Landscape);
QPrinter native;
if (native.outputFormat() == QPrinter::NativeFormat) {
// Test default
// TODO Printer specific, need QPrinterInfo::orientation()
- //QCOMPARE(native.orientation(), QPrinter::Portrait);
+ //QCOMPARE(native.orientation(), QPageLayout::Portrait);
// Test set/get
- QPrinter::Orientation expected = QPrinter::Landscape;
- native.setOrientation(expected);
- QCOMPARE(native.orientation(), expected);
+ QPageLayout::Orientation expected = QPageLayout::Landscape;
+ native.setPageOrientation(expected);
+ QCOMPARE(native.pageLayout().orientation(), expected);
// Test value preservation
native.setOutputFormat(QPrinter::PdfFormat);
- QCOMPARE(native.orientation(), expected);
+ QCOMPARE(native.pageLayout().orientation(), expected);
native.setOutputFormat(QPrinter::NativeFormat);
- QCOMPARE(native.orientation(), expected);
+ QCOMPARE(native.pageLayout().orientation(), expected);
// Test set/get
- expected = QPrinter::Portrait;
- native.setOrientation(expected);
- QCOMPARE(native.orientation(), expected);
+ expected = QPageLayout::Portrait;
+ native.setPageOrientation(expected);
+ QCOMPARE(native.pageLayout().orientation(), expected);
// Test value preservation
native.setOutputFormat(QPrinter::PdfFormat);
- QCOMPARE(native.orientation(), expected);
+ QCOMPARE(native.pageLayout().orientation(), expected);
native.setOutputFormat(QPrinter::NativeFormat);
- QCOMPARE(native.orientation(), expected);
+ QCOMPARE(native.pageLayout().orientation(), expected);
} else {
QSKIP("No printers installed, cannot test NativeFormat, please install printers to test");
}
@@ -1295,92 +1183,47 @@ void tst_QPrinter::pageSize()
{
// Note PPK_PaperSize == PPK_PageSize
// pageSize() / setPageSize() / PPK_PageSize
- // PdfFormat: Supported, defaults to QPrinter::A4
+ // PdfFormat: Supported, defaults to QPageSize::A4
// NativeFormat, Cups: Supported, defaults to printer default
// NativeFormat, Win: Supported, defaults to printer default
// NativeFormat, Mac: Supported, must be supported size, defaults to printer default
QPrinter pdf;
pdf.setOutputFormat(QPrinter::PdfFormat);
- QCOMPARE(pdf.pageSize(), QPrinter::A4);
- pdf.setPageSize(QPrinter::A1);
- QCOMPARE(pdf.pageSize(), QPrinter::A1);
+ QCOMPARE(pdf.pageLayout().pageSize().id(), QPageSize::A4);
+ pdf.setPageSize(QPageSize(QPageSize::A1));
+ QCOMPARE(pdf.pageLayout().pageSize().id(), QPageSize::A1);
QPrinter native;
if (native.outputFormat() == QPrinter::NativeFormat) {
// Test default
// TODO Printer specific, need QPrinterInfo::paperSize()
- //QCOMPARE(native.pageSize(), QPrinter::A4);
+ //QCOMPARE(native.pageSize(), QPageSize::A4);
// Test set/get
- QPrinter::PaperSize expected = QPrinter::A4;
+ QPageSize expected(QPageSize::A4);
QPrinterInfo info = QPrinterInfo::printerInfo(native.printerName());
const auto &pageSizes = info.supportedPageSizes();
for (const auto &pageSize : pageSizes) {
- const QPrinter::PaperSize supported = QPrinter::PaperSize(pageSize.id());
- if (supported != QPrinter::Custom && supported != native.paperSize()) {
- expected = supported;
+ const auto supported = pageSize.id();
+ if (supported != QPageSize::Custom && supported != native.pageLayout().pageSize().id()) {
+ expected = QPageSize(supported);
break;
}
}
native.setPageSize(expected);
- QCOMPARE(native.pageSize(), expected);
+ QCOMPARE(native.pageLayout().pageSize().id(), expected.id());
// Test value preservation
native.setOutputFormat(QPrinter::PdfFormat);
- QCOMPARE(native.pageSize(), expected);
+ QCOMPARE(native.pageLayout().pageSize().id(), expected.id());
native.setOutputFormat(QPrinter::NativeFormat);
- QCOMPARE(native.pageSize(), expected);
+ QCOMPARE(native.pageLayout().pageSize().id(), expected.id());
} else {
QSKIP("No printers installed, cannot test NativeFormat, please install printers to test");
}
}
-void tst_QPrinter::paperSize()
-{
- // PPK_PaperSize == PPK_PageSize
- // paperSize() / setPaperSize() / PPK_PaperSize
- // pageSize() / setPageSize() / PPK_PageSize
- // PdfFormat: Supported, defaults to QPrinter::A4
- // NativeFormat, Cups: Supported, defaults to printer default
- // NativeFormat, Win: Supported, defaults to printer default
- // NativeFormat, Mac: Supported, must be supported size, defaults to printer default
-
- QPrinter pdf;
- pdf.setOutputFormat(QPrinter::PdfFormat);
- QCOMPARE(pdf.paperSize(), QPrinter::A4);
- pdf.setPaperSize(QPrinter::A1);
- QCOMPARE(pdf.paperSize(), QPrinter::A1);
-
- QPrinter native;
- if (native.outputFormat() == QPrinter::NativeFormat) {
- // Test default
- // TODO Printer specific, need QPrinterInfo::paperSize()
- //QCOMPARE(native.paperSize(), QPrinter::A4);
-
- // Test set/get
- QPrinter::PaperSize expected = QPrinter::A4;
- QPrinterInfo info = QPrinterInfo::printerInfo(native.printerName());
- const auto &pageSizes = info.supportedPageSizes();
- for (const auto &pageSize : pageSizes) {
- const QPrinter::PaperSize supported = QPrinter::PaperSize(pageSize.id());
- if (supported != QPrinter::Custom && supported != native.paperSize()) {
- expected = supported;
- break;
- }
- }
- native.setPaperSize(expected);
- QCOMPARE(native.paperSize(), expected);
-
- // Test value preservation
- native.setOutputFormat(QPrinter::PdfFormat);
- QCOMPARE(native.paperSize(), expected);
- native.setOutputFormat(QPrinter::NativeFormat);
- QCOMPARE(native.paperSize(), expected);
- } else {
- QSKIP("No printers installed, cannot test NativeFormat, please install printers to test");
- }
-}
void tst_QPrinter::paperSource()
{
@@ -1693,51 +1536,6 @@ void tst_QPrinter::supportedResolutions()
}
}
-void tst_QPrinter::windowsPageSize()
-{
- // winPageSize() / setWinPageSize() / PPK_WindowsPageSize
- // PdfFormat: Supported, defaults to printer default
- // NativeFormat, Cups: Supported, defaults to printer default
- // NativeFormat, Win: Supported, defaults to printer default
- // NativeFormat, Mac: Supported, defaults to printer default
-
- QPrinter pdf;
- pdf.setOutputFormat(QPrinter::PdfFormat);
- QCOMPARE(pdf.winPageSize(), 9); // DMPAPER_A4
- pdf.setWinPageSize(1); // DMPAPER_LETTER
- QCOMPARE(pdf.winPageSize(), 1);
-
- QPrinter native;
- if (native.outputFormat() == QPrinter::NativeFormat) {
- // Test set/get
- native.setPaperSize(QPrinter::A4);
- QCOMPARE(native.pageSize(), QPrinter::A4);
- QCOMPARE(native.winPageSize(), 9); // DMPAPER_A4
-
- native.setPaperSize(QPrinter::Letter);
- QCOMPARE(native.pageSize(), QPrinter::Letter);
- QCOMPARE(native.winPageSize(), 1); // DMPAPER_LETTER
-
- native.setWinPageSize(9); // DMPAPER_A4
- QCOMPARE(native.pageSize(), QPrinter::A4);
- QCOMPARE(native.winPageSize(), 9); // DMPAPER_A4
-
- native.setWinPageSize(1); // DMPAPER_LETTER
- QCOMPARE(native.pageSize(), QPrinter::Letter);
- QCOMPARE(native.winPageSize(), 1); // DMPAPER_LETTER
-
- // Test value preservation
- native.setOutputFormat(QPrinter::PdfFormat);
- QCOMPARE(native.pageSize(), QPrinter::Letter);
- QCOMPARE(native.winPageSize(), 1); // DMPAPER_LETTER
- native.setOutputFormat(QPrinter::NativeFormat);
- QCOMPARE(native.pageSize(), QPrinter::Letter);
- QCOMPARE(native.winPageSize(), 1); // DMPAPER_LETTER
- } else {
- QSKIP("No printers installed, cannot test NativeFormat, please install printers to test");
- }
-}
-
// Test QPrinter setters/getters for non-QPrintEngine options
void tst_QPrinter::outputFormat()
@@ -1778,10 +1576,10 @@ void tst_QPrinter::testPageMetrics_data()
QTest::addColumn<qreal>("topMMf");
QTest::addColumn<qreal>("bottomMMf");
- QTest::newRow("PDF A4") << int(QPrinter::PdfFormat) << int(QPrinter::A4) << 210.0 << 297.0 << false << 0.0 << 0.0 << 0.0 << 0.0;
- QTest::newRow("PDF A4 Margins") << int(QPrinter::PdfFormat) << int(QPrinter::A4) << 210.0 << 297.0 << true << 20.0 << 30.0 << 40.0 << 50.0;
- QTest::newRow("Native A4") << int(QPrinter::NativeFormat) << int(QPrinter::A4) << 210.0 << 297.0 << false << 0.0 << 0.0 << 0.0 << 0.0;
- QTest::newRow("Native A4 Margins") << int(QPrinter::NativeFormat) << int(QPrinter::A4) << 210.0 << 297.0 << true << 20.0 << 30.0 << 40.0 << 50.0;
+ QTest::newRow("PDF A4") << int(QPrinter::PdfFormat) << int(QPageSize::A4) << 210.0 << 297.0 << false << 0.0 << 0.0 << 0.0 << 0.0;
+ QTest::newRow("PDF A4 Margins") << int(QPrinter::PdfFormat) << int(QPageSize::A4) << 210.0 << 297.0 << true << 20.0 << 30.0 << 40.0 << 50.0;
+ QTest::newRow("Native A4") << int(QPrinter::NativeFormat) << int(QPageSize::A4) << 210.0 << 297.0 << false << 0.0 << 0.0 << 0.0 << 0.0;
+ QTest::newRow("Native A4 Margins") << int(QPrinter::NativeFormat) << int(QPageSize::A4) << 210.0 << 297.0 << true << 20.0 << 30.0 << 40.0 << 50.0;
QTest::newRow("PDF Portrait") << int(QPrinter::PdfFormat) << -1 << 200.0 << 300.0 << false << 0.0 << 0.0 << 0.0 << 0.0;
QTest::newRow("PDF Portrait Margins") << int(QPrinter::PdfFormat) << -1 << 200.0 << 300.0 << true << 20.0 << 30.0 << 40.0 << 50.0;
@@ -1805,57 +1603,52 @@ void tst_QPrinter::testPageMetrics()
QFETCH(qreal, topMMf);
QFETCH(qreal, bottomMMf);
- QSizeF sizeMMf = QSizeF(widthMMf, heightMMf);
+ const QSizeF sizeMMf = QSizeF(widthMMf, heightMMf);
QPrinter printer;
printer.setOutputFormat(QPrinter::OutputFormat(outputFormat));
if (printer.outputFormat() != QPrinter::OutputFormat(outputFormat))
QSKIP("Please install a native printer to run this test");
QCOMPARE(printer.outputFormat(), QPrinter::OutputFormat(outputFormat));
- QCOMPARE(printer.orientation(), QPrinter::Portrait);
+ QCOMPARE(printer.pageLayout().orientation(), QPageLayout::Portrait);
if (setMargins) {
// Setup the given margins
QMarginsF margins(leftMMf, topMMf, rightMMf, bottomMMf);
- printer.setMargins(margins);
- QCOMPARE(printer.margins().left(), leftMMf);
- QCOMPARE(printer.margins().right(), rightMMf);
- QCOMPARE(printer.margins().top(), topMMf);
- QCOMPARE(printer.margins().bottom(), bottomMMf);
+ printer.setPageMargins(margins);
+ QCOMPARE(printer.pageLayout().margins(), margins);
}
-
// Set the given size, in Portrait mode
if (pageSize < 0) {
- printer.setPageSizeMM(sizeMMf);
- QCOMPARE(printer.pageSize(), QPrinter::Custom);
+ printer.setPageSize(QPageSize(sizeMMf, QPageSize::Millimeter));
+ QCOMPARE(printer.pageLayout().pageSize().id(), QPageSize::Custom);
} else {
- printer.setPageSize(QPrinter::PageSize(pageSize));
- QCOMPARE(printer.pageSize(), QPrinter::PageSize(pageSize));
+ printer.setPageSize(QPageSize(QPageSize::PageSizeId(pageSize)));
+ QCOMPARE(printer.pageLayout().pageSize().id(), QPageSize::PageSizeId(pageSize));
}
- QCOMPARE(printer.orientation(), QPrinter::Portrait);
+ QCOMPARE(printer.pageLayout().orientation(), QPageLayout::Portrait);
if (setMargins) {
// Check margins unchanged from page size change
- QCOMPARE(printer.margins().left(), leftMMf);
- QCOMPARE(printer.margins().right(), rightMMf);
- QCOMPARE(printer.margins().top(), topMMf);
- QCOMPARE(printer.margins().bottom(), bottomMMf);
+ QMarginsF margins(leftMMf, topMMf, rightMMf, bottomMMf);
+ QCOMPARE(printer.pageLayout().margins(), margins);
} else {
// Fetch the default margins for the printer and page size
// TODO Check against margins from print device when api added
- leftMMf = printer.margins().left();
- rightMMf = printer.margins().right();
- topMMf = printer.margins().top();
- bottomMMf = printer.margins().bottom();
+ leftMMf = printer.pageLayout().margins(QPageLayout::Millimeter).left();
+ rightMMf = printer.pageLayout().margins(QPageLayout::Millimeter).right();
+ topMMf = printer.pageLayout().margins(QPageLayout::Millimeter).top();
+ bottomMMf = printer.pageLayout().margins(QPageLayout::Millimeter).bottom();
}
- // QPagedPaintDevice::pageSizeMM() always returns Portrait
- QCOMPARE(printer.pageSizeMM(), sizeMMf);
+ // QPageLayout::pageSize() always returns Portrait
+ QCOMPARE(printer.pageLayout().pageSize().size(QPageSize::Millimeter), sizeMMf);
- // QPrinter::paperSize() always returns set orientation
- QCOMPARE(printer.paperSize(QPrinter::Millimeter), sizeMMf);
+ // QPrinter::paperRect() always returns set orientation
+ QCOMPARE(printer.paperRect(QPrinter::Millimeter).size(), sizeMMf);
- // QPagedPaintDevice::widthMM() and heightMM() are paint metrics and always return set orientation
+
+ // QPaintDevice::widthMM() and heightMM() are paint metrics and always return set orientation
QCOMPARE(printer.widthMM(), qRound(widthMMf - leftMMf - rightMMf));
QCOMPARE(printer.heightMM(), qRound(heightMMf - topMMf - bottomMMf));
@@ -1867,35 +1660,33 @@ void tst_QPrinter::testPageMetrics()
// Now switch to Landscape mode, size should be unchanged, but rect and metrics should change
- printer.setOrientation(QPrinter::Landscape);
+ printer.setPageOrientation(QPageLayout::Landscape);
if (pageSize < 0) {
- QCOMPARE(printer.pageSize(), QPrinter::Custom);
+ QCOMPARE(printer.pageLayout().pageSize().id(), QPageSize::Custom);
} else {
- QCOMPARE(printer.pageSize(), QPrinter::PageSize(pageSize));
+ QCOMPARE(printer.pageLayout().pageSize().id(), QPageSize::PageSizeId(pageSize));
}
- QCOMPARE(printer.orientation(), QPrinter::Landscape);
+ QCOMPARE(printer.pageLayout().orientation(), QPageLayout::Landscape);
if (setMargins) {
// Check margins unchanged from page size change
- QCOMPARE(printer.margins().left(), leftMMf);
- QCOMPARE(printer.margins().right(), rightMMf);
- QCOMPARE(printer.margins().top(), topMMf);
- QCOMPARE(printer.margins().bottom(), bottomMMf);
+ QMarginsF margins(leftMMf, topMMf, rightMMf, bottomMMf);
+ QCOMPARE(printer.pageLayout().margins(), margins);
} else {
// Fetch the default margins for the printer and page size
// TODO Check against margins from print device when api added
- leftMMf = printer.margins().left();
- rightMMf = printer.margins().right();
- topMMf = printer.margins().top();
- bottomMMf = printer.margins().bottom();
+ leftMMf = printer.pageLayout().margins(QPageLayout::Millimeter).left();
+ rightMMf = printer.pageLayout().margins(QPageLayout::Millimeter).right();
+ topMMf = printer.pageLayout().margins(QPageLayout::Millimeter).top();
+ bottomMMf = printer.pageLayout().margins(QPageLayout::Millimeter).bottom();
}
- // QPagedPaintDevice::pageSizeMM() always returns Portrait
- QCOMPARE(printer.pageSizeMM(), sizeMMf);
+ // QPageLayout::pageSize() always returns Portrait
+ QCOMPARE(printer.pageLayout().pageSize().size(QPageSize::Millimeter), sizeMMf);
- // QPrinter::paperSize() always returns set orientation
- QCOMPARE(printer.paperSize(QPrinter::Millimeter), sizeMMf.transposed());
+ // QPrinter::paperRect() always returns set orientation
+ QCOMPARE(printer.paperRect(QPrinter::Millimeter).size(), sizeMMf.transposed());
- // QPagedPaintDevice::widthMM() and heightMM() are paint metrics and always return set orientation
+ // QPaintDevice::widthMM() and heightMM() are paint metrics and always return set orientation
QCOMPARE(printer.widthMM(), qRound(heightMMf - leftMMf - rightMMf));
QCOMPARE(printer.heightMM(), qRound(widthMMf - topMMf - bottomMMf));
@@ -1905,36 +1696,33 @@ void tst_QPrinter::testPageMetrics()
// QPrinter::pageRect() always returns set orientation
QCOMPARE(printer.pageRect(QPrinter::Millimeter), QRectF(leftMMf, topMMf, heightMMf - leftMMf - rightMMf, widthMMf - topMMf - bottomMMf));
-
// Now while in Landscape mode, set the size again, results should be the same
if (pageSize < 0) {
- printer.setPageSizeMM(sizeMMf);
- QCOMPARE(printer.pageSize(), QPrinter::Custom);
+ printer.setPageSize(QPageSize(sizeMMf, QPageSize::Millimeter));
+ QCOMPARE(printer.pageLayout().pageSize().id(), QPageSize::Custom);
} else {
- printer.setPageSize(QPrinter::PageSize(pageSize));
- QCOMPARE(printer.pageSize(), QPrinter::PageSize(pageSize));
+ printer.setPageSize(QPageSize(QPageSize::PageSizeId(pageSize)));
+ QCOMPARE(printer.pageLayout().pageSize().id(), QPageSize::PageSizeId(pageSize));
}
- QCOMPARE(printer.orientation(), QPrinter::Landscape);
+ QCOMPARE(printer.pageLayout().orientation(), QPageLayout::Landscape);
if (setMargins) {
// Check margins unchanged from page size change
- QCOMPARE(printer.margins().left(), leftMMf);
- QCOMPARE(printer.margins().right(), rightMMf);
- QCOMPARE(printer.margins().top(), topMMf);
- QCOMPARE(printer.margins().bottom(), bottomMMf);
+ QMarginsF margins(leftMMf, topMMf, rightMMf, bottomMMf);
+ QCOMPARE(printer.pageLayout().margins(), margins);
} else {
// Fetch the default margins for the printer and page size
// TODO Check against margins from print device when api added
- leftMMf = printer.margins().left();
- rightMMf = printer.margins().right();
- topMMf = printer.margins().top();
- bottomMMf = printer.margins().bottom();
+ leftMMf = printer.pageLayout().margins(QPageLayout::Millimeter).left();
+ rightMMf = printer.pageLayout().margins(QPageLayout::Millimeter).right();
+ topMMf = printer.pageLayout().margins(QPageLayout::Millimeter).top();
+ bottomMMf = printer.pageLayout().margins(QPageLayout::Millimeter).bottom();
}
- // QPagedPaintDevice::pageSizeMM() always returns Portrait
- QCOMPARE(printer.pageSizeMM(), sizeMMf);
+ // QPageLayout::pageSize() always returns Portrait
+ QCOMPARE(printer.pageLayout().pageSize().size(QPageSize::Millimeter), sizeMMf);
- // QPrinter::paperSize() always returns set orientation
- QCOMPARE(printer.paperSize(QPrinter::Millimeter), sizeMMf.transposed());
+ // QPrinter::paperRect() always returns set orientation
+ QCOMPARE(printer.paperRect(QPrinter::Millimeter).size(), sizeMMf.transposed());
// QPagedPaintDevice::widthMM() and heightMM() are paint metrics and always return set orientation
QCOMPARE(printer.widthMM(), qRound(heightMMf - leftMMf - rightMMf));
diff --git a/tests/manual/dialogs/printdialogpanel.cpp b/tests/manual/dialogs/printdialogpanel.cpp
index 7f834399e4..29dc33285b 100644
--- a/tests/manual/dialogs/printdialogpanel.cpp
+++ b/tests/manual/dialogs/printdialogpanel.cpp
@@ -53,10 +53,7 @@
#include <QDebug>
#include <QTextStream>
#include <QDir>
-
-#if QT_VERSION >= 0x050000
-# include <QScreen>
-#endif
+#include <QScreen>
const FlagData printerModeComboData[] =
{
@@ -65,42 +62,6 @@ const FlagData printerModeComboData[] =
{"HighResolution", QPrinter::HighResolution}
};
-#if QT_VERSION < 0x050300
-const FlagData pageSizeComboData[] =
-{
- {"A4", QPrinter::A4},
- {"B5", QPrinter::B5},
- {"Letter", QPrinter::Letter},
- {"Legal", QPrinter::Legal},
- {"Executive", QPrinter::Executive},
- {"A0", QPrinter::A0},
- {"A1", QPrinter::A1},
- {"A2", QPrinter::A2},
- {"A3", QPrinter::A3},
- {"A5", QPrinter::A5},
- {"A6", QPrinter::A6},
- {"A7", QPrinter::A7},
- {"A8", QPrinter::A8},
- {"A9", QPrinter::A9},
- {"B0", QPrinter::B0},
- {"B1", QPrinter::B1},
- {"B10", QPrinter::B10},
- {"B2", QPrinter::B2},
- {"B3", QPrinter::B3},
- {"B4", QPrinter::B4},
- {"B6", QPrinter::B6},
- {"B7", QPrinter::B7},
- {"B8", QPrinter::B8},
- {"B9", QPrinter::B9},
- {"C5E", QPrinter::C5E},
- {"Comm10E", QPrinter::Comm10E},
- {"DLE", QPrinter::DLE},
- {"Folio", QPrinter::Folio},
- {"Ledger", QPrinter::Ledger},
- {"Tabloid", QPrinter::Tabloid},
- {"Custom", QPrinter::Custom}
-};
-#endif
const FlagData printRangeComboData[] =
{
@@ -197,9 +158,7 @@ QTextStream &operator<<(QTextStream &s, const QRectF &rect)
QTextStream &operator<<(QTextStream &s, const QPrinter &printer)
{
s << '"' << printer.printerName() << "\"\nPaper #" <<printer.paperSize()
-#if QT_VERSION >= 0x050000
<< " \"" << printer.paperName() << '"'
-#endif
<< (printer.orientation() == QPrinter::Portrait ? ", Portrait" : ", Landscape");
if (printer.fullPage())
s << ", full page";
@@ -208,9 +167,7 @@ QTextStream &operator<<(QTextStream &s, const QPrinter &printer)
<< printer.paperSize(QPrinter::Millimeter) << "mm "
<< "\n " << printer.paperSize(QPrinter::DevicePixel) << "device pt "
<< printer.paperSize(QPrinter::Inch) << "inch "
-#if QT_VERSION >= 0x050000
<< "\nPagedPaintDevSize: " << printer.pageSizeMM() << "mm"
-#endif
<< "\nLogical resolution : " << printer.logicalDpiX() << ',' << printer.logicalDpiY() << "DPI"
<< "\nPhysical resolution: " << printer.physicalDpiX() << ',' << printer.physicalDpiY() << "DPI"
<< "\nPaperRect: " << printer.paperRect(QPrinter::Point) << "pt "
@@ -290,9 +247,7 @@ static bool print(QPrinter *printer, QString *errorMessage)
QString msg;
QTextStream str(&msg);
str << "Qt "<< QT_VERSION_STR;
-#if QT_VERSION >= 0x050000
str << ' ' << QGuiApplication::platformName();
-#endif
str << ' ' << QDateTime::currentDateTime().toString()
<< "\nFont: " << font.family() << ' ' << font.pointSize() << '\n'
<< *printer;
@@ -346,10 +301,6 @@ public slots:
PrintDialogPanel::PrintDialogPanel(QWidget *parent)
: QWidget(parent), m_blockSignals(true)
{
-#if QT_VERSION < 0x050300
- m_printerLayout.setOutputFormat(QPrinter::PdfFormat);
-#endif
-
m_panel.setupUi(this);
// Setup the Create box
@@ -360,14 +311,10 @@ PrintDialogPanel::PrintDialogPanel(QWidget *parent)
// Setup the Page Layout box
populateCombo(m_panel.m_unitsCombo, unitsComboData, sizeof(unitsComboData)/sizeof(FlagData));
connect(m_panel.m_unitsCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(unitsChanged()));
-#if QT_VERSION >= 0x050300
for (int i = QPageSize::A4; i < QPageSize::LastPageSize; ++i) {
QPageSize::PageSizeId id = QPageSize::PageSizeId(i);
m_panel.m_pageSizeCombo->addItem(QPageSize::name(id), QVariant(id));
}
-#else
- populateCombo(m_panel.m_pageSizeCombo, pageSizeComboData, sizeof(pageSizeComboData)/sizeof(FlagData));
-#endif
connect(m_panel.m_pageSizeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(pageSizeChanged()));
connect(m_panel.m_pageWidth, SIGNAL(valueChanged(double)), this, SLOT(pageDimensionsChanged()));
connect(m_panel.m_pageHeight, SIGNAL(valueChanged(double)), this, SLOT(pageDimensionsChanged()));
@@ -382,13 +329,8 @@ PrintDialogPanel::PrintDialogPanel(QWidget *parent)
// Setup the Print Job box
m_panel.m_printerCombo->addItem(tr("Print to PDF"), QVariant("PdfFormat"));
-#if QT_VERSION >= 0x050300
foreach (const QString &name, QPrinterInfo::availablePrinterNames())
m_panel.m_printerCombo->addItem(name, QVariant(name));
-#else
- foreach (const QPrinterInfo &printer, QPrinterInfo::availablePrinters())
- m_panel.m_printerCombo->addItem(printer.printerName(), QVariant(printer.printerName()));
-#endif
connect(m_panel.m_printerCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(printerChanged()));
populateCombo(m_panel.m_printRangeCombo, printRangeComboData, sizeof(printRangeComboData)/sizeof(FlagData));
populateCombo(m_panel.m_pageOrderCombo, pageOrderComboData, sizeof(pageOrderComboData)/sizeof(FlagData));
@@ -462,19 +404,7 @@ void PrintDialogPanel::applySettings(QPrinter *printer) const
printer->setColorMode(comboBoxValue<QPrinter::ColorMode>(m_panel.m_colorModeCombo));
printer->setResolution(m_panel.m_resolution->value());
-#if QT_VERSION >= 0x050300
printer->setPageLayout(m_pageLayout);
-#else
- if (m_printerLayout.pageSize() == QPrinter::Custom)
- printer->setPaperSize(customPageSize(), m_units);
- else
- printer->setPageSize(m_printerLayout.pageSize());
- printer->setOrientation(m_printerLayout.orientation());
- printer->setFullPage(m_printerLayout.fullPage());
- double left, top, right, bottom;
- m_printerLayout.getPageMargins(&left, &top, &right, &bottom, m_units);
- printer->setPageMargins(left, top, right, bottom, m_units);
-#endif
}
// Retrieve the settings from the QPrinter
@@ -508,26 +438,13 @@ void PrintDialogPanel::retrieveSettings(const QPrinter *printer)
m_panel.availPaperSourceLabel->setText(QLatin1String("N/A"));
#endif
-#if QT_VERSION >= 0x050300
m_pageLayout = printer->pageLayout();
-#else
- if (printer->pageSize() == QPrinter::Custom)
- m_printerLayout.setPaperSize(customPageSize(), m_units);
- else
- m_printerLayout.setPageSize(printer->pageSize());
- m_printerLayout.setOrientation(printer->orientation());
- m_printerLayout.setFullPage(printer->fullPage());
- double left, top, right, bottom;
- printer->getPageMargins(&left, &top, &right, &bottom, m_units);
- m_printerLayout.setPageMargins(left, top, right, bottom, m_units);
-#endif
updatePageLayoutWidgets();
}
void PrintDialogPanel::updatePageLayoutWidgets()
{
m_blockSignals = true;
-#if QT_VERSION >= 0x050300
setComboBoxValue(m_panel.m_unitsCombo, m_pageLayout.units());
setComboBoxValue(m_panel.m_pageSizeCombo, m_pageLayout.pageSize().id());
QSizeF sizef = m_pageLayout.pageSize().size(QPageSize::Unit(m_pageLayout.units()));
@@ -539,24 +456,7 @@ void PrintDialogPanel::updatePageLayoutWidgets()
m_panel.m_bottomMargin->setValue(m_pageLayout.margins().bottom());
setComboBoxValue(m_panel.m_layoutModeCombo, m_pageLayout.mode());
QRectF rectf = m_pageLayout.paintRect();
-#else
- setComboBoxValue(m_panel.m_unitsCombo, m_units);
- setComboBoxValue(m_panel.m_pageSizeCombo, m_printerLayout.pageSize());
- QSizeF sizef = m_printerLayout.paperSize(m_units);
- bool custom = (m_printerLayout.pageSize() == QPrinter::Custom);
- setComboBoxValue(m_panel.m_orientationCombo, m_printerLayout.orientation());
- double left, top, right, bottom;
- m_printerLayout.getPageMargins(&left, &top, &right, &bottom, m_units);
- m_panel.m_leftMargin->setValue(left);
- m_panel.m_topMargin->setValue(top);
- m_panel.m_rightMargin->setValue(right);
- m_panel.m_bottomMargin->setValue(bottom);
- if (m_printerLayout.fullPage())
- setComboBoxValue(m_panel.m_layoutModeCombo, QPageLayout::FullPageMode);
- else
- setComboBoxValue(m_panel.m_layoutModeCombo, QPageLayout::StandardMode);
- QRectF rectf = m_printerLayout.pageRect(m_units);
-#endif
+
m_panel.m_pageWidth->setValue(sizef.width());
m_panel.m_pageHeight->setValue(sizef.height());
m_panel.m_pageWidth->setEnabled(custom);
@@ -603,11 +503,7 @@ void PrintDialogPanel::unitsChanged()
{
if (m_blockSignals)
return;
-#if QT_VERSION >= 0x050300
m_pageLayout.setUnits(comboBoxValue<QPageLayout::Unit>(m_panel.m_unitsCombo));
-#else
- m_units = comboBoxValue<QPrinter::Unit>(m_panel.m_unitsCombo);
-#endif
updatePageLayoutWidgets();
}
@@ -615,7 +511,6 @@ void PrintDialogPanel::pageSizeChanged()
{
if (m_blockSignals)
return;
-#if QT_VERSION >= 0x050300
const QPageSize::PageSizeId pageSizeId = comboBoxValue<QPageSize::PageSizeId>(m_panel.m_pageSizeCombo);
QPageSize pageSize;
if (pageSizeId == QPageSize::Custom)
@@ -623,13 +518,6 @@ void PrintDialogPanel::pageSizeChanged()
else
pageSize = QPageSize(pageSizeId);
m_pageLayout.setPageSize(pageSize);
-#else
- const QPrinter::PageSize pageSize = comboBoxValue<QPrinter::PageSize>(m_panel.m_pageSizeCombo);
- if (pageSize == QPrinter::Custom)
- m_printerLayout.setPaperSize(QSizeF(200, 200), m_units);
- else
- m_printerLayout.setPageSize(pageSize);
-#endif
updatePageLayoutWidgets();
}
@@ -637,11 +525,7 @@ void PrintDialogPanel::pageDimensionsChanged()
{
if (m_blockSignals)
return;
-#if QT_VERSION >= 0x050300
m_pageLayout.setPageSize(QPageSize(customPageSize(), QPageSize::Unit(m_pageLayout.units())));
-#else
- m_printerLayout.setPaperSize(customPageSize(), m_units);
-#endif
updatePageLayoutWidgets();
}
@@ -649,11 +533,7 @@ void PrintDialogPanel::orientationChanged()
{
if (m_blockSignals)
return;
-#if QT_VERSION >= 0x050300
m_pageLayout.setOrientation(comboBoxValue<QPageLayout::Orientation>(m_panel.m_orientationCombo));
-#else
- m_printerLayout.setOrientation(comboBoxValue<QPrinter::Orientation>(m_panel.m_orientationCombo));
-#endif
updatePageLayoutWidgets();
}
@@ -661,14 +541,8 @@ void PrintDialogPanel::marginsChanged()
{
if (m_blockSignals)
return;
-#if QT_VERSION >= 0x050300
m_pageLayout.setMargins(QMarginsF(m_panel.m_leftMargin->value(), m_panel.m_topMargin->value(),
m_panel.m_rightMargin->value(), m_panel.m_bottomMargin->value()));
-#else
- m_printerLayout.setPageMargins(m_panel.m_leftMargin->value(), m_panel.m_topMargin->value(),
- m_panel.m_rightMargin->value(), m_panel.m_bottomMargin->value(),
- m_units);
-#endif
updatePageLayoutWidgets();
}
@@ -676,12 +550,7 @@ void PrintDialogPanel::layoutModeChanged()
{
if (m_blockSignals)
return;
-#if QT_VERSION >= 0x050300
m_pageLayout.setMode(comboBoxValue<QPageLayout::Mode>(m_panel.m_layoutModeCombo));
-#else
- bool fullPage = (comboBoxValue<QPageLayout::Mode>(m_panel.m_layoutModeCombo) == QPageLayout::FullPageMode);
- m_printerLayout.setFullPage(fullPage);
-#endif
updatePageLayoutWidgets();
}
@@ -709,11 +578,7 @@ void PrintDialogPanel::showPreviewDialog()
{
applySettings(m_printer.data());
PrintPreviewDialog dialog(m_printer.data(), this);
-#if QT_VERSION >= 0x050000
const QSize availableSize = screen()->availableSize();
-#else
- const QSize availableSize = QApplication::desktop()->availableGeometry().size();
-#endif
dialog.resize(availableSize * 4/ 5);
if (dialog.exec() == QDialog::Accepted)
retrieveSettings(m_printer.data());