mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Printing: use selected print preferences while printing
Having a pointer to the printing_options struct, it should be used to privide the selected options while printing. Print options used ATM: - number of dives per page - template file name - print in colors Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
parent
60c5e3cf25
commit
6c54781e17
2 changed files with 19 additions and 4 deletions
15
printer.cpp
15
printer.cpp
|
@ -44,7 +44,7 @@ void Printer::render()
|
||||||
|
|
||||||
// apply printing settings to profile
|
// apply printing settings to profile
|
||||||
profile->setFrameStyle(QFrame::NoFrame);
|
profile->setFrameStyle(QFrame::NoFrame);
|
||||||
profile->setPrintMode(true);
|
profile->setPrintMode(true, !printOptions->color_selected);
|
||||||
profile->setFontPrintScale(0.6);
|
profile->setFontPrintScale(0.6);
|
||||||
profile->setToolTipVisibile(false);
|
profile->setToolTipVisibile(false);
|
||||||
prefs.animation_speed = 0;
|
prefs.animation_speed = 0;
|
||||||
|
@ -56,9 +56,18 @@ void Printer::render()
|
||||||
painter.begin(printer);
|
painter.begin(printer);
|
||||||
painter.setRenderHint(QPainter::Antialiasing);
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||||
|
|
||||||
webView->page()->setViewportSize(size);
|
webView->page()->setViewportSize(size);
|
||||||
int Pages = ceil(getTotalWork() / 2.0);
|
|
||||||
|
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() / (float)divesPerPage);
|
||||||
|
|
||||||
// get all refereces to diveprofile class in the Html template
|
// get all refereces to diveprofile class in the Html template
|
||||||
QWebElementCollection collection = webView->page()->mainFrame()->findAllElements(".diveprofile");
|
QWebElementCollection collection = webView->page()->mainFrame()->findAllElements(".diveprofile");
|
||||||
|
|
|
@ -30,6 +30,7 @@ QString TemplateLayout::generate()
|
||||||
{
|
{
|
||||||
int progress = 0;
|
int progress = 0;
|
||||||
int totalWork = getTotalWork();
|
int totalWork = getTotalWork();
|
||||||
|
QString templateName;
|
||||||
|
|
||||||
QString htmlContent;
|
QString htmlContent;
|
||||||
m_engine = new Grantlee::Engine(this);
|
m_engine = new Grantlee::Engine(this);
|
||||||
|
@ -59,7 +60,12 @@ QString TemplateLayout::generate()
|
||||||
|
|
||||||
Grantlee::Context c(mapping);
|
Grantlee::Context c(mapping);
|
||||||
|
|
||||||
Grantlee::Template t = m_engine->loadByName("base.html");
|
if (PrintOptions->p_template == print_options::ONE_DIVE) {
|
||||||
|
templateName = "one_dive.html";
|
||||||
|
} else if (PrintOptions->p_template == print_options::TWO_DIVE) {
|
||||||
|
templateName = "base.html";
|
||||||
|
}
|
||||||
|
Grantlee::Template t = m_engine->loadByName(templateName);
|
||||||
if (!t || t->error()) {
|
if (!t || t->error()) {
|
||||||
qDebug() << "Can't load template";
|
qDebug() << "Can't load template";
|
||||||
return htmlContent;
|
return htmlContent;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue