Replace obsolete setPaperSize with setPageSize.
--HG-- branch : develop
This commit is contained in:
parent
ec5b28fe0b
commit
a795642cf0
|
@ -62,6 +62,7 @@
|
||||||
#include <QPrinterInfo>
|
#include <QPrinterInfo>
|
||||||
#include <QtConcurrent>
|
#include <QtConcurrent>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <QPageSize>
|
||||||
|
|
||||||
#if defined(Q_OS_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
|
#if defined(Q_OS_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
|
||||||
#include <QWinTaskbarButton>
|
#include <QWinTaskbarButton>
|
||||||
|
@ -1174,9 +1175,12 @@ void MainWindowsNoGUI::PdfFile(const QString &name, QGraphicsRectItem *paper, QG
|
||||||
printer.setResolution(static_cast<int>(PrintDPI));
|
printer.setResolution(static_cast<int>(PrintDPI));
|
||||||
printer.setOrientation(QPrinter::Portrait);
|
printer.setOrientation(QPrinter::Portrait);
|
||||||
printer.setFullPage(ignorePrinterFields);
|
printer.setFullPage(ignorePrinterFields);
|
||||||
printer.setPaperSize ( QSizeF(FromPixel(r.width() + margins.left() + margins.right(), Unit::Mm),
|
if (not printer.setPageSize(QPageSize(QSizeF(FromPixel(r.width() + margins.left() + margins.right(), Unit::Mm),
|
||||||
FromPixel(r.height() + margins.top() + margins.bottom(), Unit::Mm)),
|
FromPixel(r.height() + margins.top() + margins.bottom(), Unit::Mm)),
|
||||||
QPrinter::Millimeter );
|
QPageSize::Millimeter)))
|
||||||
|
{
|
||||||
|
qWarning() << tr("Cannot set printer page size");
|
||||||
|
}
|
||||||
|
|
||||||
const qreal left = FromPixel(margins.left(), Unit::Mm);
|
const qreal left = FromPixel(margins.left(), Unit::Mm);
|
||||||
const qreal top = FromPixel(margins.top(), Unit::Mm);
|
const qreal top = FromPixel(margins.top(), Unit::Mm);
|
||||||
|
@ -1533,14 +1537,20 @@ void MainWindowsNoGUI::SetPrinterSettings(QPrinter *printer, const PrintType &pr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const QPrinter::PageSize pSZ = FindQPrinterPageSize(size);
|
const QPageSize::PageSizeId pSZ = FindPageSizeId(size);
|
||||||
if (pSZ == QPrinter::Custom)
|
if (pSZ == QPageSize::Custom)
|
||||||
{
|
{
|
||||||
printer->setPaperSize (size, QPrinter::Millimeter );
|
if (not printer->setPageSize(QPageSize(size, QPageSize::Millimeter)))
|
||||||
|
{
|
||||||
|
qWarning() << tr("Cannot set custom printer page size");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printer->setPaperSize (pSZ);
|
if (not printer->setPageSize(QPageSize(pSZ)))
|
||||||
|
{
|
||||||
|
qWarning() << tr("Cannot set printer page size");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1548,7 +1558,11 @@ void MainWindowsNoGUI::SetPrinterSettings(QPrinter *printer, const PrintType &pr
|
||||||
if (not m_dialogSaveLayout.isNull())
|
if (not m_dialogSaveLayout.isNull())
|
||||||
{
|
{
|
||||||
VAbstractLayoutDialog::PaperSizeTemplate tiledFormat = m_dialogSaveLayout->GetTiledPageFormat();
|
VAbstractLayoutDialog::PaperSizeTemplate tiledFormat = m_dialogSaveLayout->GetTiledPageFormat();
|
||||||
printer->setPaperSize (m_dialogSaveLayout->GetTemplateSize(tiledFormat, Unit::Mm), QPrinter::Millimeter);
|
if (not printer->setPageSize(QPageSize(m_dialogSaveLayout->GetTemplateSize(tiledFormat, Unit::Mm),
|
||||||
|
QPageSize::Millimeter)))
|
||||||
|
{
|
||||||
|
qWarning() << tr("Cannot set printer page size");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1672,44 +1686,44 @@ bool MainWindowsNoGUI::IsLayoutGrayscale() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QPrinter::PaperSize MainWindowsNoGUI::FindQPrinterPageSize(const QSizeF &size) const
|
QPageSize::PageSizeId MainWindowsNoGUI::FindPageSizeId(const QSizeF &size) const
|
||||||
{
|
{
|
||||||
if (size == QSizeF(841, 1189) || size == QSizeF(1189, 841))
|
if (size == QSizeF(841, 1189) || size == QSizeF(1189, 841))
|
||||||
{
|
{
|
||||||
return QPrinter::A0;
|
return QPageSize::A0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size == QSizeF(594, 841) || size == QSizeF(841, 594))
|
if (size == QSizeF(594, 841) || size == QSizeF(841, 594))
|
||||||
{
|
{
|
||||||
return QPrinter::A1;
|
return QPageSize::A1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size == QSizeF(420, 594) || size == QSizeF(594, 420))
|
if (size == QSizeF(420, 594) || size == QSizeF(594, 420))
|
||||||
{
|
{
|
||||||
return QPrinter::A2;
|
return QPageSize::A2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size == QSizeF(297, 420) || size == QSizeF(420, 297))
|
if (size == QSizeF(297, 420) || size == QSizeF(420, 297))
|
||||||
{
|
{
|
||||||
return QPrinter::A3;
|
return QPageSize::A3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size == QSizeF(210, 297) || size == QSizeF(297, 210))
|
if (size == QSizeF(210, 297) || size == QSizeF(297, 210))
|
||||||
{
|
{
|
||||||
return QPrinter::A4;
|
return QPageSize::A4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size == QSizeF(215.9, 355.6) || size == QSizeF(355.6, 215.9))
|
if (size == QSizeF(215.9, 355.6) || size == QSizeF(355.6, 215.9))
|
||||||
{
|
{
|
||||||
return QPrinter::Legal;
|
return QPageSize::Legal;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size == QSizeF(215.9, 279.4) || size == QSizeF(279.4, 215.9))
|
if (size == QSizeF(215.9, 279.4) || size == QSizeF(279.4, 215.9))
|
||||||
{
|
{
|
||||||
return QPrinter::Letter;
|
return QPageSize::Letter;
|
||||||
}
|
}
|
||||||
|
|
||||||
return QPrinter::Custom;
|
return QPageSize::Custom;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -191,7 +191,7 @@ private:
|
||||||
|
|
||||||
void SetPrinterSettings(QPrinter *printer, const PrintType &printType);
|
void SetPrinterSettings(QPrinter *printer, const PrintType &printType);
|
||||||
bool IsLayoutGrayscale() const;
|
bool IsLayoutGrayscale() const;
|
||||||
QPrinter::PaperSize FindQPrinterPageSize(const QSizeF &size) const;
|
QPageSize::PageSizeId FindPageSizeId(const QSizeF &size) const;
|
||||||
|
|
||||||
bool isPagesUniform() const;
|
bool isPagesUniform() const;
|
||||||
bool IsPagesFit(const QSizeF &printPaper) const;
|
bool IsPagesFit(const QSizeF &printPaper) const;
|
||||||
|
|
|
@ -46,7 +46,7 @@ void TST_VPoster::BigPoster()
|
||||||
{
|
{
|
||||||
QPrinter printer;
|
QPrinter printer;
|
||||||
printer.setResolution(96);// By default
|
printer.setResolution(96);// By default
|
||||||
printer.setPaperSize(QPrinter::A4);
|
printer.setPageSize(QPageSize(QPageSize::A4));
|
||||||
printer.setFullPage(true);
|
printer.setFullPage(true);
|
||||||
// We need to set full page because otherwise QPrinter->pageRect returns different values in Windows and Linux
|
// We need to set full page because otherwise QPrinter->pageRect returns different values in Windows and Linux
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ void TST_VPoster::SmallPoster()
|
||||||
{
|
{
|
||||||
QPrinter printer;
|
QPrinter printer;
|
||||||
printer.setResolution(96);// By default
|
printer.setResolution(96);// By default
|
||||||
printer.setPaperSize(QPrinter::A4);
|
printer.setPageSize(QPageSize(QPageSize::A4));
|
||||||
|
|
||||||
const QRect image(0, 0, 700, 1000); // Little bit less than A4
|
const QRect image(0, 0, 700, 1000); // Little bit less than A4
|
||||||
VPoster posterazor(&printer);
|
VPoster posterazor(&printer);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user