mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Printing: refactor printing code
This section of the code is called only while rendering a flow layout template, so move it to the flow layout function. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
This commit is contained in:
parent
4a988aa868
commit
afc697e797
1 changed files with 6 additions and 4 deletions
10
printer.cpp
10
printer.cpp
|
@ -59,6 +59,11 @@ void Printer::putProfileImage(QRect profilePlaceholder, QRect viewPort, QPainter
|
||||||
|
|
||||||
void Printer::flowRender()
|
void Printer::flowRender()
|
||||||
{
|
{
|
||||||
|
// add extra padding at the bottom to pages with height not divisible by view port
|
||||||
|
int paddingBottom = pageSize.height() - (webView->page()->mainFrame()->contentsSize().height() % pageSize.height());
|
||||||
|
QString styleString = QString::fromUtf8("padding-bottom: ") + QString::number(paddingBottom) + "px;";
|
||||||
|
webView->page()->mainFrame()->findFirstElement("body").setAttribute("style", styleString);
|
||||||
|
|
||||||
// render the Qwebview
|
// render the Qwebview
|
||||||
QPainter painter;
|
QPainter painter;
|
||||||
QRect viewPort(0, 0, 0, 0);
|
QRect viewPort(0, 0, 0, 0);
|
||||||
|
@ -187,6 +192,7 @@ void Printer::print()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QPrinter *printerPtr;
|
QPrinter *printerPtr;
|
||||||
printerPtr = static_cast<QPrinter*>(paintDevice);
|
printerPtr = static_cast<QPrinter*>(paintDevice);
|
||||||
|
|
||||||
|
@ -218,10 +224,6 @@ void Printer::print()
|
||||||
}
|
}
|
||||||
int Pages;
|
int Pages;
|
||||||
if (divesPerPage == 0) {
|
if (divesPerPage == 0) {
|
||||||
// add extra padding at the bottom to pages with height not divisible by view port
|
|
||||||
int paddingBottom = pageSize.height() - (webView->page()->mainFrame()->contentsSize().height() % pageSize.height());
|
|
||||||
QString styleString = QString::fromUtf8("padding-bottom: ") + QString::number(paddingBottom) + "px;";
|
|
||||||
webView->page()->mainFrame()->findFirstElement("body").setAttribute("style", styleString);
|
|
||||||
flowRender();
|
flowRender();
|
||||||
} else {
|
} else {
|
||||||
Pages = ceil(getTotalWork(printOptions) / (float)divesPerPage);
|
Pages = ceil(getTotalWork(printOptions) / (float)divesPerPage);
|
||||||
|
|
Loading…
Add table
Reference in a new issue