summaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2017-03-06 18:41:54 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-03-06 20:08:39 -0800
commite8c918622fbd7072b3ff53e1d97148fbfd4274ff (patch)
treebbe410224be7a9e536fef684166344523a41f7e9 /desktop-widgets
parent831fe3d7f9e339edb3ac19205514022ab2b00551 (diff)
downloadsubsurface-e8c918622fbd7072b3ff53e1d97148fbfd4274ff.tar.gz
Printing: support the "Border width" setting for templates
Going to "Template -> Edit" now has a field to enter the border width (in pixels as only that makes sense in CSS as a flexible unit, TMK). This field modifies the template_options.borderwidth Grantlee property which is part of the bundled templates already and allows the users to modify the borders of tables. The C++ implementation was missing, while the HTML (template) implementation was already in place. Overlooked during GSoC. Reported-by: Willem Ferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/printdialog.cpp2
-rw-r--r--desktop-widgets/printer.cpp4
-rw-r--r--desktop-widgets/printoptions.h1
-rw-r--r--desktop-widgets/templateedit.cpp7
-rw-r--r--desktop-widgets/templateedit.h2
-rw-r--r--desktop-widgets/templateedit.ui30
6 files changed, 44 insertions, 2 deletions
diff --git a/desktop-widgets/printdialog.cpp b/desktop-widgets/printdialog.cpp
index 5fdc78198..e9f11ca53 100644
--- a/desktop-widgets/printdialog.cpp
+++ b/desktop-widgets/printdialog.cpp
@@ -51,6 +51,7 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) :
templateOptions.font_size = s.value("font_size", 9).toDouble();
templateOptions.color_palette_index = s.value("color_palette", SSRF_COLORS).toInt();
templateOptions.line_spacing = s.value("line_spacing", 1).toDouble();
+ templateOptions.border_width = s.value("border_width", 1).toInt();
custom_colors.color1 = QColor(s.value("custom_color_1", ssrf_colors.color1).toString());
custom_colors.color2 = QColor(s.value("custom_color_2", ssrf_colors.color2).toString());
custom_colors.color3 = QColor(s.value("custom_color_3", ssrf_colors.color3).toString());
@@ -148,6 +149,7 @@ void PrintDialog::onFinished()
s.setValue("font_size", templateOptions.font_size);
s.setValue("color_palette", templateOptions.color_palette_index);
s.setValue("line_spacing", templateOptions.line_spacing);
+ s.setValue("border_width", templateOptions.border_width);
// save custom colors
s.setValue("custom_color_1", custom_colors.color1.name());
diff --git a/desktop-widgets/printer.cpp b/desktop-widgets/printer.cpp
index bad1c2760..49a9a18b1 100644
--- a/desktop-widgets/printer.cpp
+++ b/desktop-widgets/printer.cpp
@@ -237,7 +237,7 @@ void Printer::print()
webView->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
#endif
// export border width with at least 1 pixel
- templateOptions->border_width = std::max(1, pageSize.width() / 1000);
+ // templateOptions->borderwidth = std::max(1, pageSize.width() / 1000);
if (printOptions->type == print_options::DIVELIST) {
webView->setHtml(t.generate());
} else if (printOptions->type == print_options::STATISTICS ) {
@@ -284,7 +284,7 @@ void Printer::previewOnePage()
webView->page()->setViewportSize(pageSize);
#endif
// initialize the border settings
- templateOptions->border_width = std::max(1, pageSize.width() / 1000);
+ // templateOptions->border_width = std::max(1, pageSize.width() / 1000);
if (printOptions->type == print_options::DIVELIST) {
webView->setHtml(t.generate());
} else if (printOptions->type == print_options::STATISTICS ) {
diff --git a/desktop-widgets/printoptions.h b/desktop-widgets/printoptions.h
index 9c50b10f3..b8248b7e5 100644
--- a/desktop-widgets/printoptions.h
+++ b/desktop-widgets/printoptions.h
@@ -43,6 +43,7 @@ struct template_options {
|| other.color_palette_index != color_palette_index
|| other.font_size != font_size
|| other.line_spacing != line_spacing
+ || other.border_width != border_width
|| other.color_palette != color_palette;
}
};
diff --git a/desktop-widgets/templateedit.cpp b/desktop-widgets/templateedit.cpp
index 4964016b9..ea6314075 100644
--- a/desktop-widgets/templateedit.cpp
+++ b/desktop-widgets/templateedit.cpp
@@ -20,6 +20,7 @@ TemplateEdit::TemplateEdit(QWidget *parent, struct print_options *printOptions,
ui->fontsize->setValue(templateOptions->font_size);
ui->colorpalette->setCurrentIndex(templateOptions->color_palette_index);
ui->linespacing->setValue(templateOptions->line_spacing);
+ ui->borderwidth->setValue(templateOptions->border_width);
grantlee_template = TemplateLayout::readTemplate(printOptions->p_template);
if (printOptions->type == print_options::DIVELIST)
@@ -97,6 +98,12 @@ void TemplateEdit::on_linespacing_valueChanged(double line_spacing)
updatePreview();
}
+void TemplateEdit::on_borderwidth_valueChanged(double border_width)
+{
+ newTemplateOptions.border_width = (int)border_width;
+ updatePreview();
+}
+
void TemplateEdit::on_fontSelection_currentIndexChanged(int index)
{
newTemplateOptions.font_index = index;
diff --git a/desktop-widgets/templateedit.h b/desktop-widgets/templateedit.h
index 5e548ae19..abbe8e20b 100644
--- a/desktop-widgets/templateedit.h
+++ b/desktop-widgets/templateedit.h
@@ -20,6 +20,8 @@ private slots:
void on_linespacing_valueChanged(double line_spacing);
+ void on_borderwidth_valueChanged(double border_width);
+
void on_fontSelection_currentIndexChanged(int index);
void on_colorpalette_currentIndexChanged(int index);
diff --git a/desktop-widgets/templateedit.ui b/desktop-widgets/templateedit.ui
index 60a0fc7e6..616d13536 100644
--- a/desktop-widgets/templateedit.ui
+++ b/desktop-widgets/templateedit.ui
@@ -220,6 +220,36 @@
</layout>
</item>
<item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QLabel" name="borderwidth_label">
+ <property name="text">
+ <string>Border width</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDoubleSpinBox" name="borderwidth">
+ <property name="decimals">
+ <number>0</number>
+ </property>
+ <property name="minimum">
+ <double>0.000000000000000</double>
+ </property>
+ <property name="maximum">
+ <double>100.000000000000000</double>
+ </property>
+ <property name="singleStep">
+ <double>1.000000000000000</double>
+ </property>
+ <property name="value">
+ <double>1.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>