diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-09-02 16:23:06 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-09-03 10:30:31 +0200 |
commit | 8f2d63febcc8c243ab86049755cf1b963d57f9f8 (patch) | |
tree | 26b75958778403811da586fe722e629291034108 | |
parent | 22cc8e0d6fd8ac680927bc47965cff02b41688a9 (diff) | |
download | qtbase-8f2d63febcc8c243ab86049755cf1b963d57f9f8.tar.gz |
Mark obsolete QPrinter functions as deprecated from 5.15 on
Some of the methods are overrides of virtuals in QPagedPaintDevice, so document
and mark those as obsolete as well.
Adjust code that calls those APIs to use the recommended replacement.
Change-Id: I3cd1980609ea20808d17379a5f97ca595e869875
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 6bbf3f0257603eb39d5511910e8bee1ed862b6cf)
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r-- | src/gui/painting/qpagedpaintdevice.cpp | 8 | ||||
-rw-r--r-- | src/gui/painting/qpagedpaintdevice.h | 10 | ||||
-rw-r--r-- | src/gui/text/qtextdocument.cpp | 11 | ||||
-rw-r--r-- | src/printsupport/dialogs/qprintdialog_mac.mm | 2 | ||||
-rw-r--r-- | src/printsupport/kernel/qprinter.h | 34 | ||||
-rw-r--r-- | src/printsupport/widgets/qprintpreviewwidget.cpp | 8 |
6 files changed, 63 insertions, 10 deletions
diff --git a/src/gui/painting/qpagedpaintdevice.cpp b/src/gui/painting/qpagedpaintdevice.cpp index 3fdd0206b7..ea86a08f9e 100644 --- a/src/gui/painting/qpagedpaintdevice.cpp +++ b/src/gui/painting/qpagedpaintdevice.cpp @@ -135,7 +135,8 @@ QPagedPaintDevicePrivate *QPagedPaintDevice::dd() \enum QPagedPaintDevice::PageSize This enum type lists the available page sizes as defined in the Postscript - PPD standard. These values are duplicated in QPageSize and QPrinter. + PPD standard. These values are duplicated in QPageSize and QPrinter and + those types and enum will be merged in Qt 6. The defined sizes are: @@ -314,6 +315,7 @@ QPagedPaintDevice::PageSize QPagedPaintDevice::pageSize() const } /*! + \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 @@ -325,6 +327,8 @@ void QPagedPaintDevice::setPageSizeMM(const QSizeF &size) } /*! + \obsolete Use pageLayout().pageSize() instead. + Returns the page size in millimeters. */ QSizeF QPagedPaintDevice::pageSizeMM() const @@ -333,6 +337,7 @@ QSizeF QPagedPaintDevice::pageSizeMM() const } /*! + \obsolete Use setPageMargins(QMarginsF, QPageLayout::Unit) instead. Sets the margins to be used to \a margins. Margins are specified in millimeters. @@ -348,6 +353,7 @@ void QPagedPaintDevice::setMargins(const Margins &margins) } /*! + \obsolete Use pageLayout().margins() instead. Returns the current margins of the paint device. The default is 0. Margins are specified in millimeters. diff --git a/src/gui/painting/qpagedpaintdevice.h b/src/gui/painting/qpagedpaintdevice.h index 21e23e0eb4..143393cfba 100644 --- a/src/gui/painting/qpagedpaintdevice.h +++ b/src/gui/painting/qpagedpaintdevice.h @@ -224,11 +224,17 @@ public: bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units); 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 // ### Qt6 Remove in favor of QMarginsF struct Margins { @@ -238,8 +244,12 @@ public: qreal bottom; }; +#if QT_DEPRECATED_SINCE(5,15) + QT_DEPRECATED_VERSION_X_5_15("Use setPageMargins(QMarginsF, QPageLayout::Unit) instead.") virtual void setMargins(const Margins &margins); + QT_DEPRECATED_VERSION_X_5_15("Use pageLayout().margins() instead.") Margins margins() const; +#endif protected: QPagedPaintDevice(QPagedPaintDevicePrivate *dd); diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index a633e5da11..7ee9898537 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -1965,10 +1965,13 @@ void QTextDocument::print(QPagedPaintDevice *printer) const QPagedPaintDevicePrivate *pd = QPagedPaintDevicePrivate::get(printer); // ### set page size to paginated size? - QPagedPaintDevice::Margins m = printer->margins(); - if (!documentPaginated && m.left == 0. && m.right == 0. && m.top == 0. && m.bottom == 0.) { - m.left = m.right = m.top = m.bottom = 2.; - printer->setMargins(m); + QMarginsF m = printer->pageLayout().margins(QPageLayout::Millimeter); + if (!documentPaginated && m.left() == 0 && m.right() == 0 && m.top() == 0 && m.bottom() == 0) { + m.setLeft(2.); + m.setRight(2.); + m.setTop(2.); + m.setBottom(2.); + printer->setPageMargins(m, QPageLayout::Millimeter); } // ### use the margins correctly diff --git a/src/printsupport/dialogs/qprintdialog_mac.mm b/src/printsupport/dialogs/qprintdialog_mac.mm index a4101f7ec0..43ad7d22ae 100644 --- a/src/printsupport/dialogs/qprintdialog_mac.mm +++ b/src/printsupport/dialogs/qprintdialog_mac.mm @@ -202,7 +202,7 @@ QT_USE_NAMESPACE } if (pageSize.isValid() && !pageSize.isEquivalentTo(printer->pageLayout().pageSize())) printer->setPageSize(pageSize); - printer->setOrientation(orientation == kPMLandscape ? QPrinter::Landscape : QPrinter::Portrait); + printer->setPageOrientation(orientation == kPMLandscape ? QPageLayout::Landscape : QPageLayout::Portrait); dialog->done((returnCode == NSModalResponseOK) ? QDialog::Accepted : QDialog::Rejected); } diff --git a/src/printsupport/kernel/qprinter.h b/src/printsupport/kernel/qprinter.h index 28dca78a63..ee881f9b03 100644 --- a/src/printsupport/kernel/qprinter.h +++ b/src/printsupport/kernel/qprinter.h @@ -167,22 +167,35 @@ public: 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; @@ -199,10 +212,14 @@ 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; @@ -223,14 +240,24 @@ 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; @@ -252,10 +279,15 @@ 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 Margins &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; diff --git a/src/printsupport/widgets/qprintpreviewwidget.cpp b/src/printsupport/widgets/qprintpreviewwidget.cpp index 16b84e328d..bd22d5a6a5 100644 --- a/src/printsupport/widgets/qprintpreviewwidget.cpp +++ b/src/printsupport/widgets/qprintpreviewwidget.cpp @@ -357,7 +357,7 @@ void QPrintPreviewWidgetPrivate::layoutPages() int numPagePlaces = numPages; int cols = 1; // singleMode and default if (viewMode == QPrintPreviewWidget::AllPagesView) { - if (printer->orientation() == QPrinter::Portrait) + if (printer->pageLayout().orientation() == QPageLayout::Portrait) cols = qCeil(qSqrt((float) numPages)); else cols = qFloor(qSqrt((float) numPages)); @@ -593,7 +593,8 @@ void QPrintPreviewWidget::setViewMode(ViewMode mode) QPrinter::Orientation QPrintPreviewWidget::orientation() const { Q_D(const QPrintPreviewWidget); - return d->printer->orientation(); + return d->printer->pageLayout().orientation() == QPageLayout::Portrait + ? QPrinter::Portrait : QPrinter::Landscape; } /*! @@ -603,7 +604,8 @@ QPrinter::Orientation QPrintPreviewWidget::orientation() const void QPrintPreviewWidget::setOrientation(QPrinter::Orientation orientation) { Q_D(QPrintPreviewWidget); - d->printer->setOrientation(orientation); + d->printer->setPageOrientation(orientation == QPrinter::Portrait + ? QPageLayout::Portrait : QPageLayout::Landscape); d->generatePreview(); } |