Remove deprecated QPrinter methods.

This commit is contained in:
Roman Telezhynskyi 2020-12-21 15:52:34 +02:00
parent c3142b8b07
commit 9793d5e6a2

View File

@ -834,8 +834,9 @@ void MainWindowsNoGUI::PrintPages(QPrinter *printer)
// Get printer rect acording to our dpi. // Get printer rect acording to our dpi.
const QRectF printerPageRect(0, 0, ToPixel(printer->pageRect(QPrinter::Millimeter).width(), Unit::Mm), const QRectF printerPageRect(0, 0, ToPixel(printer->pageRect(QPrinter::Millimeter).width(), Unit::Mm),
ToPixel(printer->pageRect(QPrinter::Millimeter).height(), Unit::Mm)); ToPixel(printer->pageRect(QPrinter::Millimeter).height(), Unit::Mm));
const double xscale = printer->pageRect().width() / printerPageRect.width(); const QRect pageRect = printer->pageLayout().paintRectPixels(printer->resolution());
const double yscale = printer->pageRect().height() / printerPageRect.height(); const double xscale = pageRect.width() / printerPageRect.width();
const double yscale = pageRect.height() / printerPageRect.height();
QPainter painter; QPainter painter;
if (not painter.begin(printer)) if (not painter.begin(printer))
@ -1286,7 +1287,7 @@ void MainWindowsNoGUI::PdfFile(const QString &name, QGraphicsRectItem *paper, QG
printer.setDocName(FileName()); printer.setDocName(FileName());
const QRectF r = paper->rect(); const QRectF r = paper->rect();
printer.setResolution(static_cast<int>(PrintDPI)); printer.setResolution(static_cast<int>(PrintDPI));
printer.setOrientation(QPrinter::Portrait); printer.setPageOrientation(QPageLayout::Portrait);
printer.setFullPage(ignorePrinterFields); printer.setFullPage(ignorePrinterFields);
qreal width = FromPixel(r.width() * m_dialogSaveLayout->GetXScale() + margins.left() + margins.right(), Unit::Mm); qreal width = FromPixel(r.width() * m_dialogSaveLayout->GetXScale() + margins.left() + margins.right(), Unit::Mm);
@ -1707,7 +1708,7 @@ void MainWindowsNoGUI::SetPrinterSettings(QPrinter *printer, const PrintType &pr
printer->setCreator(QGuiApplication::applicationDisplayName()+QChar(QChar::Space)+ printer->setCreator(QGuiApplication::applicationDisplayName()+QChar(QChar::Space)+
QCoreApplication::applicationVersion()); QCoreApplication::applicationVersion());
printer->setOrientation(isLayoutPortrait ? QPrinter::Portrait : QPrinter::Landscape); printer->setPageOrientation(isLayoutPortrait ? QPageLayout::Portrait : QPageLayout::Landscape);
if (not isTiled) if (not isTiled)
{ {