From 5892fb576272214410764ea542189799d896e4bf Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Fri, 14 Aug 2015 21:37:12 +0200 Subject: [PATCH] Printing: fill the QPainter background color before rendering While rendering a dynamically sized view port, it may not fit the full page size, But the background color should be the same for the whole page, So fill the page background color with the template background color before rendering. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- printer.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/printer.cpp b/printer.cpp index 5d7adcacc..b9f9b3363 100644 --- a/printer.cpp +++ b/printer.cpp @@ -75,6 +75,10 @@ void Printer::flowRender() // One more element can be placed end = dontbreakElement.geometry().y() + dontbreakElement.geometry().height(); } else { + // fill the page with background color + QRect fullPage(0, 0, pageSize.width(), pageSize.height()); + QBrush fillBrush(templateOptions->color_palette.color1); + painter.fillRect(fullPage, fillBrush); QRegion reigon(0, 0, pageSize.width(), end - start); viewPort.setRect(0, start, pageSize.width(), end - start); @@ -91,6 +95,9 @@ void Printer::flowRender() } } // render the remianing page + QRect fullPage(0, 0, pageSize.width(), pageSize.height()); + QBrush fillBrush(templateOptions->color_palette.color1); + painter.fillRect(fullPage, fillBrush); QRegion reigon(0, 0, pageSize.width(), end - start); webView->page()->mainFrame()->render(&painter, QWebFrame::ContentsLayer, reigon);