Remove deprecated QPrinter and QPagedPaintDevice APIs
Adjusting the QPrinter test case - some use cases no longer exist, or are already tested in QPageSize and QPageLayout tests. Adjust examples and manual tests. Change-Id: I01cbc65f3d8031aea2dac86dd942126ba708b111 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>bb10
parent
6b171dc6c0
commit
00a5629d8d
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -297,75 +252,6 @@ QPagedPaintDevicePrivate *QPagedPaintDevice::dd()
|
|||
This value was added in Qt 5.12.
|
||||
*/
|
||||
|
||||
/*!
|
||||
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
|
||||
|
||||
|
|
@ -433,28 +319,6 @@ bool QPagedPaintDevice::setPageOrientation(QPageLayout::Orientation orientation)
|
|||
return d->setPageOrientation(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
|
||||
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -66,7 +66,6 @@ public:
|
|||
Cicero
|
||||
};
|
||||
|
||||
// NOTE: Must keep in sync with QPrinter::Orientation
|
||||
enum Orientation {
|
||||
Portrait,
|
||||
Landscape
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -420,22 +382,6 @@ public:
|
|||
sizes are what you expect.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\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
|
||||
|
||||
|
|
@ -449,31 +395,6 @@ public:
|
|||
\sa setPrintRange(), printRange(), QAbstractPrintDialog::PrintRange
|
||||
*/
|
||||
|
||||
/*!
|
||||
\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
|
||||
|
||||
|
|
@ -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
|
||||
|
||||
|
|
@ -1588,35 +1154,6 @@ bool QPrinter::fontEmbeddingEnabled() const
|
|||
side is printed
|
||||
*/
|
||||
|
||||
/*!
|
||||
\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
|
||||
|
||||
|
|
@ -1677,104 +1214,6 @@ QRectF QPrinter::paperRect(Unit unit) const
|
|||
return pageLayout().fullRect(QPageLayout::Unit(unit));
|
||||
}
|
||||
|
||||
/*!
|
||||
\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
|
||||
|
||||
|
|
@ -1806,34 +1245,6 @@ QPrintEngine *QPrinter::printEngine() const
|
|||
return d->printEngine;
|
||||
}
|
||||
|
||||
/*!
|
||||
\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.
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -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());
|
||||
|
|
|
|||
Loading…
Reference in New Issue