From 3d5caabe4acefd08e27167a9c4220dc5fb22d537 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Wed, 24 Jun 2015 03:55:09 +0200 Subject: Printing: fix two dives per page borders and text font As we use a responsive layout, every UI element must be relative to its parent and its size must be a ratio of the view port to prevent them from displaying outside their containing parents. Signed-off-by: Gehad elrobey Signed-off-by: Lubomir I. Ivanov --- printing_templates/two_dives.html | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'printing_templates') diff --git a/printing_templates/two_dives.html b/printing_templates/two_dives.html index 574579f90..9868bfd11 100644 --- a/printing_templates/two_dives.html +++ b/printing_templates/two_dives.html @@ -5,10 +5,11 @@ background-color: white; padding: 0px; margin: 0px; + font-size: 1.2vw; } h1 { - font-size: 0.9cm; + font-size: 1.2vw; float: left; } @@ -20,49 +21,56 @@ margin-top: 0; margin-bottom: 0; overflow: hidden; - border-width: 0px; page-break-inside: avoid; } .innerContainer { height: 85%; - border-style: solid; padding: 0.5%; margin-top: 1%; margin-bottom: 1%; overflow: hidden; + -webkit-box-sizing: border-box; + box-sizing: border-box; + border:max(0.1vw, 1px); + border-style:solid; } .table_class { overflow: hidden; max-width: 25%; min-width: 25%; - box-shadow: 5px 5px 5px #888888; margin: 1.5%; float: left; + -webkit-box-sizing: border-box; + box-sizing: border-box; + border:max(0.1vw, 1px); + border-style:solid; } .notes_table_class { overflow: hidden; max-width: 100%; min-width: 100%; - box-shadow: 5px 5px 5px #888888; margin: 1.5%; float: left; + -webkit-box-sizing: border-box; + box-sizing: border-box; + border:max(0.1vw, 1px); + border-style:solid; } .fieldTitle { background-color: #CfC7C5; overflow: hidden; + padding:0; } .diveProfile { width: 37%; - height: 70%; + height: 95%; margin: 1.5%; float: right; - border-style: solid; - padding: 3mm; } .diveDetails { @@ -80,9 +88,9 @@ } .textArea { - max-height: 43ex; overflow: hidden !important; text-overflow: ellipsis; + max-height: 10.3vw; } #footer { @@ -98,7 +106,7 @@
- +

Dive No.

@@ -139,7 +147,7 @@
- +

Time.

@@ -184,7 +192,7 @@
- +

Notes

-- cgit v1.2.3-70-g09d2 From 6446b75b9e358bf3c7969b7df302410b39249948 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Sat, 4 Jul 2015 16:55:43 +0200 Subject: Printing: edit templates to show template options dynamically Template styles must refere to Grantlee fields to be replaced with user selected settings. Signed-off-by: Gehad elrobey Signed-off-by: Lubomir I. Ivanov --- printing_templates/one_dive.html | 10 ++++++++-- printing_templates/two_dives.html | 7 +++++-- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'printing_templates') diff --git a/printing_templates/one_dive.html b/printing_templates/one_dive.html index 754dc85bc..87b2976e0 100644 --- a/printing_templates/one_dive.html +++ b/printing_templates/one_dive.html @@ -5,12 +5,14 @@ background-color: white; padding: 0; margin: 0; - font-size: 1.2vw; + font-size: {{ template_options.font_size }}vw; + line-height: {{ template_options.line_spacing }}; + font-family: {{ template_options.font }}; } h1 { - font-size: 1.2vw; float: left; + font-size: {{ template_options.font_size }}vw; } table { @@ -84,6 +86,10 @@ margin: 1.5%; float: left; } + + .textArea { + line-height: {{ template_options.line_spacing }}; + } diff --git a/printing_templates/two_dives.html b/printing_templates/two_dives.html index 9868bfd11..b0ad9ba15 100644 --- a/printing_templates/two_dives.html +++ b/printing_templates/two_dives.html @@ -5,11 +5,13 @@ background-color: white; padding: 0px; margin: 0px; - font-size: 1.2vw; + font-size: {{ template_options.font_size }}vw; + line-height: {{ template_options.line_spacing }}; + font-family: {{ template_options.font }}; } h1 { - font-size: 1.2vw; + font-size: {{ template_options.font_size }}vw; float: left; } @@ -91,6 +93,7 @@ overflow: hidden !important; text-overflow: ellipsis; max-height: 10.3vw; + line-height: {{ template_options.line_spacing }}; } #footer { -- cgit v1.2.3-70-g09d2 From 815072d2ae29811271af197e2330cc331d58f9c6 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Sat, 4 Jul 2015 23:54:15 +0200 Subject: Printing: retrieve number of dives per page from the template file Add special data attribute 'data-numberofdives' in the template with the number of dives per page. This is standard HTML5 specification so it won't corrupt the template file. Any template that will be used for printing must contain this attribute to assure correct output. Signed-off-by: Gehad elrobey Signed-off-by: Lubomir I. Ivanov --- printer.cpp | 14 +++++++------- printing_templates/one_dive.html | 2 +- printing_templates/two_dives.html | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'printing_templates') diff --git a/printer.cpp b/printer.cpp index 83cc42d18..f8a90f96d 100644 --- a/printer.cpp +++ b/printer.cpp @@ -34,13 +34,13 @@ void Printer::render() } else { printer->setColorMode(QPrinter::GrayScale); } - switch (printOptions->p_template) { - case print_options::ONE_DIVE: - divesPerPage = 1; - break; - case print_options::TWO_DIVE: - divesPerPage = 2; - break; + + // get number of dives per page from data-numberofdives attribute in the body of the selected template + bool ok; + divesPerPage = webView->page()->mainFrame()->findFirstElement("body").attribute("data-numberofdives").toInt(&ok); + if (!ok) { + divesPerPage = 1; // print each dive in a single page if the attribute is missing or malformed + //TODO: show warning } int Pages = ceil(getTotalWork(printOptions) / (float)divesPerPage); diff --git a/printing_templates/one_dive.html b/printing_templates/one_dive.html index 87b2976e0..d7ae8d477 100644 --- a/printing_templates/one_dive.html +++ b/printing_templates/one_dive.html @@ -92,7 +92,7 @@ } - + {% block main_rows %} {% for dive in dives %}
diff --git a/printing_templates/two_dives.html b/printing_templates/two_dives.html index b0ad9ba15..62502272b 100644 --- a/printing_templates/two_dives.html +++ b/printing_templates/two_dives.html @@ -102,7 +102,7 @@ } - + {% block main_rows %} {% for dive in dives %}
-- cgit v1.2.3-70-g09d2 From c35092f5c9ce30f2b8df4c554302a3e7c8716a07 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Sat, 4 Jul 2015 23:02:17 +0200 Subject: Printing: add custom options to the PrintDialog Add: -custom.html template -custom template to print_options struct -options to the options dialog Signed-off-by: Gehad elrobey Signed-off-by: Lubomir I. Ivanov --- printing_templates/custom.html | 50 ++++++++++++++++++++++++++++++++++++++++++ qt-ui/printoptions.cpp | 6 +++++ qt-ui/printoptions.h | 3 ++- qt-ui/printoptions.ui | 5 +++++ templatelayout.cpp | 2 ++ 5 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 printing_templates/custom.html (limited to 'printing_templates') diff --git a/printing_templates/custom.html b/printing_templates/custom.html new file mode 100644 index 000000000..52fdb4b49 --- /dev/null +++ b/printing_templates/custom.html @@ -0,0 +1,50 @@ + + + + + +{% block main_rows %} + {% for dive in dives %} +
+
+

This template is empty

+ +
+
+ {% endfor %} +{% endblock %} + + diff --git a/qt-ui/printoptions.cpp b/qt-ui/printoptions.cpp index a7c520b21..cd38e3560 100644 --- a/qt-ui/printoptions.cpp +++ b/qt-ui/printoptions.cpp @@ -36,6 +36,9 @@ void PrintOptions::setup(struct print_options *printOpt) case print_options::TWO_DIVE: ui.printTemplate->setCurrentIndex(1); break; + case print_options::CUSTOM: + ui.printTemplate->setCurrentIndex(2); + break; } // general print option checkboxes @@ -97,6 +100,9 @@ void PrintOptions::on_printTemplate_currentIndexChanged(int index) case 1: printOptions->p_template = print_options::TWO_DIVE; break; + case 2: + printOptions->p_template = print_options::CUSTOM; + break; } } diff --git a/qt-ui/printoptions.h b/qt-ui/printoptions.h index 9bacd4e90..1d806b116 100644 --- a/qt-ui/printoptions.h +++ b/qt-ui/printoptions.h @@ -13,7 +13,8 @@ struct print_options { } type; enum print_template { ONE_DIVE, - TWO_DIVE + TWO_DIVE, + CUSTOM } p_template; bool print_selected; bool color_selected; diff --git a/qt-ui/printoptions.ui b/qt-ui/printoptions.ui index 632b9cdaf..7e66d4cb0 100644 --- a/qt-ui/printoptions.ui +++ b/qt-ui/printoptions.ui @@ -140,6 +140,11 @@ Two dives per page + + + Custom template + + diff --git a/templatelayout.cpp b/templatelayout.cpp index 2a5bb8ff7..fcdd22902 100644 --- a/templatelayout.cpp +++ b/templatelayout.cpp @@ -71,6 +71,8 @@ QString TemplateLayout::generate() templateName = "one_dive.html"; } else if (PrintOptions->p_template == print_options::TWO_DIVE) { templateName = "two_dives.html"; + } else if (PrintOptions->p_template == print_options::CUSTOM) { + templateName = "custom.html"; } Grantlee::Template t = m_engine->loadByName(templateName); if (!t || t->error()) { -- cgit v1.2.3-70-g09d2