summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2020-09-02 16:23:06 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-09-03 10:30:31 +0200
commit8f2d63febcc8c243ab86049755cf1b963d57f9f8 (patch)
tree26b75958778403811da586fe722e629291034108 /src/gui
parent22cc8e0d6fd8ac680927bc47965cff02b41688a9 (diff)
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>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/painting/qpagedpaintdevice.cpp8
-rw-r--r--src/gui/painting/qpagedpaintdevice.h10
-rw-r--r--src/gui/text/qtextdocument.cpp11
3 files changed, 24 insertions, 5 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