diff --git a/oscar/reports.cpp b/oscar/reports.cpp index fde8f057..57800f6a 100644 --- a/oscar/reports.cpp +++ b/oscar/reports.cpp @@ -7,12 +7,16 @@ * License. See the file COPYING in the main directory of the source code * for more details. */ +#define TEST_MACROS_ENABLEDoff +#include + #include #include #include #include #include #include +#include #include "reports.h" #include "mainwindow.h" @@ -31,6 +35,7 @@ void Report::PrintReport(gGraphView *gv, QString name, QDate date) { if (!gv) { return; } + Session *journal = nullptr; //QDate d=QDate::currentDate(); @@ -78,10 +83,10 @@ void Report::PrintReport(gGraphView *gv, QString name, QDate date) printer->setOutputFileName(filename); #endif printer->setPrintRange(QPrinter::AllPages); - printer->setOrientation(QPrinter::Portrait); + printer->setPageOrientation(QPageLayout::Portrait); printer->setFullPage(false); // This has nothing to do with scaling - printer->setNumCopies(1); - printer->setPageMargins(10, 10, 10, 10, QPrinter::Millimeter); + printer->setCopyCount(1); + printer->setPageMargins(QMarginsF(10, 10, 10, 10), QPageLayout::Millimeter); QPrintDialog dialog(printer); #ifdef Q_OS_MAC // QTBUG-17913 @@ -104,9 +109,8 @@ void Report::PrintReport(gGraphView *gv, QString name, QDate date) GLint gw; gw = 2048; // Rough guess.. No GL_MAX_RENDERBUFFER_SIZE in mingw.. :( - //QSizeF pxres=printer->paperSize(QPrinter::DevicePixel); - QRect prect = printer->pageRect(); + QRect prect = printer->pageLayout().paintRectPixels( printer->resolution() ) ; float ratio = float(prect.height()) / float(prect.width()); float virt_width = gw; float virt_height = virt_width * ratio; diff --git a/oscar/statistics.cpp b/oscar/statistics.cpp index 7c5daa81..9f7c3e7c 100644 --- a/oscar/statistics.cpp +++ b/oscar/statistics.cpp @@ -1325,12 +1325,13 @@ void Statistics::printReport(QWidget * parent) { #endif printer.setPrintRange(QPrinter::AllPages); - printer.setOrientation(QPrinter::Portrait); + printer.setPageOrientation(QPageLayout::Portrait); printer.setFullPage(false); // Print only on printable area of page and not in non-printable margins - printer.setNumCopies(1); + printer.setCopyCount(1); QMarginsF minMargins = printer.pageLayout().margins(QPageLayout::Millimeter); - printer.setPageMargins(fmax(10,minMargins.left()), fmax(10,minMargins.top()), fmax(10,minMargins.right()), fmax(12,minMargins.bottom()), QPrinter::Millimeter); + + printer.setPageMargins( QMarginsF( fmax(10,minMargins.left()), fmax(10,minMargins.top()), fmax(10,minMargins.right()), fmax(12,minMargins.bottom())), QPageLayout::Millimeter); QMarginsF setMargins = printer.pageLayout().margins(QPageLayout::Millimeter); qDebug () << "Min margins" << minMargins << "Set margins" << setMargins << "millimeters";