From fcde03e84948b0c78c2dd7d8a334cd6def5879af Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Tue, 23 Jun 2015 00:10:32 +0200 Subject: Printing: choose printing color mode 'color/greyscale' We can have color printouts only if the printer supports color prints, the user selected 'print in colors' from the print dialog and the default printer settings (Operating system wise) is to print in colors, Otherwise the prints will be in greyscale. Signed-off-by: Gehad elrobey Signed-off-by: Lubomir I. Ivanov --- printer.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'printer.cpp') diff --git a/printer.cpp b/printer.cpp index 50027c23b..5c93d2fed 100644 --- a/printer.cpp +++ b/printer.cpp @@ -26,9 +26,25 @@ void Printer::putProfileImage(QRect profilePlaceholder, QRect viewPort, QPainter void Printer::render() { - QPointer profile = MainWindow::instance()->graphics(); + // apply user settings + int divesPerPage; + if (printOptions->color_selected && printer->colorMode()) { + printer->setColorMode(QPrinter::Color); + } else { + printer->setColorMode(QPrinter::GrayScale); + } + switch (printOptions->p_template) { + case print_options::ONE_DIVE: + divesPerPage = 1; + break; + case print_options::TWO_DIVE: + divesPerPage = 2; + break; + } + int Pages = ceil(getTotalWork(printOptions) / (float)divesPerPage); // keep original preferences + QPointer profile = MainWindow::instance()->graphics(); int profileFrameStyle = profile->frameStyle(); int animationOriginal = prefs.animation_speed; double fontScale = profile->getFontPrintScale(); @@ -47,17 +63,6 @@ void Printer::render() painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::SmoothPixmapTransform); - int divesPerPage; - switch (printOptions->p_template) { - case print_options::ONE_DIVE: - divesPerPage = 1; - break; - case print_options::TWO_DIVE: - divesPerPage = 2; - break; - } - int Pages = ceil(getTotalWork(printOptions) / (float)divesPerPage); - // get all refereces to diveprofile class in the Html template QWebElementCollection collection = webView->page()->mainFrame()->findAllElements(".diveprofile"); -- cgit v1.2.3-70-g09d2