mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Printing: export border to templates
As there is a problem with sizing the borders in QWebView, "vw" sizing is not working as supposed with border-width, As a workaround we export border-width dynamically, so that border-width is relatively the same for all page sizes. The border-width is equal to the page width / 1000 which gives a nice range for borders for A0 - A5 papers, Also prevent drawing zero pixel borders and use 1 px borders as the minimum border. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
This commit is contained in:
parent
0ced68f15d
commit
59eddc6259
3 changed files with 6 additions and 0 deletions
|
@ -3,6 +3,7 @@
|
|||
#include "statistics.h"
|
||||
#include "helpers.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <QtWebKitWidgets>
|
||||
#include <QPainter>
|
||||
#include <QWebElementCollection>
|
||||
|
@ -150,6 +151,8 @@ void Printer::print()
|
|||
pageSize.setWidth(printerPtr->pageRect(QPrinter::Inch).width() * dpi);
|
||||
webView->page()->setViewportSize(pageSize);
|
||||
webView->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
|
||||
// export border width with at least 1 pixel
|
||||
templateOptions->border_width = std::max(1, pageSize.width() / 1000);
|
||||
webView->setHtml(t.generate());
|
||||
if (printOptions->color_selected && printerPtr->colorMode()) {
|
||||
printerPtr->setColorMode(QPrinter::Color);
|
||||
|
|
|
@ -19,6 +19,7 @@ struct print_options {
|
|||
struct template_options {
|
||||
int font_index;
|
||||
int color_palette_index;
|
||||
int border_width;
|
||||
double font_size;
|
||||
double line_spacing;
|
||||
struct color_palette_struct {
|
||||
|
|
|
@ -151,6 +151,8 @@ if (property == "font") {
|
|||
case 4:
|
||||
return "Verdana, Geneva, sans-serif";
|
||||
}
|
||||
} else if (property == "borderwidth") {
|
||||
return object.border_width;
|
||||
} else if (property == "font_size") {
|
||||
return object.font_size / 9.0;
|
||||
} else if (property == "line_spacing") {
|
||||
|
|
Loading…
Add table
Reference in a new issue