From 55f09f01069cdfbb4b366824916409b66ddc11f5 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Tue, 28 Jul 2015 21:55:23 +0200 Subject: [PATCH 01/35] Printing: don't save invalid colors When QColorDialog is closed with 'Cancel' button, it returns invalid color that must be discarded. So check if color is valid to prevent replacing the current color with black. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- qt-ui/templateedit.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/qt-ui/templateedit.cpp b/qt-ui/templateedit.cpp index 94ed276b5..95e7ebac7 100644 --- a/qt-ui/templateedit.cpp +++ b/qt-ui/templateedit.cpp @@ -168,24 +168,30 @@ void TemplateEdit::colorSelect(QAbstractButton *button) switch (btnGroup->id(button)) { case 1: color = QColorDialog::getColor(newTemplateOptions.color_palette.color1, this); - newTemplateOptions.color_palette.color1 = color; + if (color.isValid()) { + newTemplateOptions.color_palette.color1 = color; + } break; case 2: color = QColorDialog::getColor(newTemplateOptions.color_palette.color2, this); - newTemplateOptions.color_palette.color2 = color; - break; + if (color.isValid()) { + newTemplateOptions.color_palette.color2 = color; + } break; case 3: color = QColorDialog::getColor(newTemplateOptions.color_palette.color3, this); - newTemplateOptions.color_palette.color3 = color; - break; + if (color.isValid()) { + newTemplateOptions.color_palette.color3 = color; + } break; case 4: color = QColorDialog::getColor(newTemplateOptions.color_palette.color4, this); - newTemplateOptions.color_palette.color4 = color; - break; + if (color.isValid()) { + newTemplateOptions.color_palette.color4 = color; + } break; case 5: color = QColorDialog::getColor(newTemplateOptions.color_palette.color5, this); - newTemplateOptions.color_palette.color5 = color; - break; + if (color.isValid()) { + newTemplateOptions.color_palette.color5 = color; + } break; } newTemplateOptions.color_palette_index = CUSTOM; updatePreview(); From dd7bae378e6463f5a4125f7b51a41ab6c0407578 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Wed, 29 Jul 2015 19:35:08 +0200 Subject: [PATCH 02/35] Printing: fix wrong custom palette index The custom palette index is defined by the CUSTOM directive, and it should be used. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- qt-ui/templateedit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qt-ui/templateedit.cpp b/qt-ui/templateedit.cpp index 95e7ebac7..97627749d 100644 --- a/qt-ui/templateedit.cpp +++ b/qt-ui/templateedit.cpp @@ -121,7 +121,7 @@ void TemplateEdit::saveSettings() printOptions->p_template = "custom.html"; TemplateLayout::writeTemplate("custom.html", ui->plainTextEdit->toPlainText()); } - if (templateOptions->color_palette_index == 2) { + if (templateOptions->color_palette_index == CUSTOM) { custom_colors = templateOptions->color_palette; } } From 1d22bdc08c04d3726154a5975ff5314c4f290c9d Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Wed, 29 Jul 2015 19:49:50 +0200 Subject: [PATCH 03/35] Printing: fix TemplateEdit color selection bug When choosing a color from the QColorDialog, the TemplateEdit trigger to change the current selected template to be custom, and then changes the selected color. When the selected template is changed old template values are copied to the current template which results in incorrect behaviour. This is fixed by checking for the current editting state before setting the saved palettes as the current used palette. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- qt-ui/templateedit.cpp | 11 ++++++++--- qt-ui/templateedit.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/qt-ui/templateedit.cpp b/qt-ui/templateedit.cpp index 97627749d..90ef7e750 100644 --- a/qt-ui/templateedit.cpp +++ b/qt-ui/templateedit.cpp @@ -33,6 +33,7 @@ TemplateEdit::TemplateEdit(QWidget *parent, struct print_options *printOptions, connect(btnGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(colorSelect(QAbstractButton*))); ui->plainTextEdit->setPlainText(grantlee_template); + editingCustomColors = false; updatePreview(); } @@ -102,7 +103,10 @@ void TemplateEdit::on_colorpalette_currentIndexChanged(int index) newTemplateOptions.color_palette = blueshades_colors; break; case CUSTOM: // custom - newTemplateOptions.color_palette = custom_colors; + if (!editingCustomColors) + newTemplateOptions.color_palette = custom_colors; + else + editingCustomColors = false; break; } updatePreview(); @@ -148,6 +152,7 @@ void TemplateEdit::on_buttonBox_clicked(QAbstractButton *button) void TemplateEdit::colorSelect(QAbstractButton *button) { + editingCustomColors = true; // reset custom colors palette switch (newTemplateOptions.color_palette_index) { case SSRF_COLORS: // subsurface derived default colors @@ -155,11 +160,11 @@ void TemplateEdit::colorSelect(QAbstractButton *button) break; case ALMOND: // almond newTemplateOptions.color_palette = almond_colors; - custom_colors = newTemplateOptions.color_palette; break; case BLUESHADES: // blueshades newTemplateOptions.color_palette = blueshades_colors; - custom_colors = newTemplateOptions.color_palette; + break; + default: break; } diff --git a/qt-ui/templateedit.h b/qt-ui/templateedit.h index 15b717f78..5e548ae19 100644 --- a/qt-ui/templateedit.h +++ b/qt-ui/templateedit.h @@ -31,6 +31,7 @@ private slots: private: Ui::TemplateEdit *ui; QButtonGroup *btnGroup; + bool editingCustomColors; struct template_options *templateOptions; struct template_options newTemplateOptions; struct print_options *printOptions; From 8d0101bf3d94d393615f19396bc2ff2d930f531c Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Mon, 3 Aug 2015 18:21:16 +0200 Subject: [PATCH 04/35] Printing: templates should use colors defined in the color palette Use the colors defined in the color palettes for all font, borders, table sections and backgrounds of all templates. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- printing_templates/Flowlayout.html | 30 ++++++++++++++++++---------- printing_templates/One Dive.html | 30 ++++++++++++++++++---------- printing_templates/Table.html | 2 +- printing_templates/Two Dives.html | 32 ++++++++++++++++++++---------- 4 files changed, 62 insertions(+), 32 deletions(-) diff --git a/printing_templates/Flowlayout.html b/printing_templates/Flowlayout.html index a3f7951d9..98867d259 100644 --- a/printing_templates/Flowlayout.html +++ b/printing_templates/Flowlayout.html @@ -20,6 +20,7 @@ box-sizing: border-box; border:max(1px, 0.1vw); border-style:solid; + border-color: {{ template_options.color5 }}; } td { @@ -54,6 +55,7 @@ box-sizing: border-box; border:max(1px, 0.1vw); border-style:solid; + border-color: {{ template_options.color5 }}; float: left; } @@ -65,6 +67,11 @@ .fieldTitle { background-color: {{ template_options.color2 }}; overflow: hidden; + color: {{ template_options.color3 }}; + } + + .fieldData { + color: {{ template_options.color4 }}; } .table_class { @@ -83,6 +90,7 @@ line-height: {{ template_options.line_spacing }}; max-height: 19vh; overflow: hidden; + color: {{ template_options.color4 }}; } @@ -99,7 +107,7 @@

Dive No.

- +

{{ dive.number }}

@@ -107,14 +115,15 @@

Date

-

{{ dive.date }}

+ +

{{ dive.date }}

Location

- +

{{ dive.location }}

@@ -122,7 +131,7 @@

Max depth

- +

{{ dive.depth }}

@@ -130,7 +139,7 @@

Duration

- +

{{ dive.duration }}

@@ -140,7 +149,7 @@

Time.

- +

{{ dive.time }}

@@ -148,14 +157,15 @@

Air Temp.

-

{{ dive.airTemp }}

+ +

{{ dive.airTemp }}

Water Temp.

- +

{{ dive.waterTemp }}

@@ -163,7 +173,7 @@

Buddy

- +

{{ dive.buddy }}

@@ -171,7 +181,7 @@

Dive Master

- +

{{ dive.divemaster }}

diff --git a/printing_templates/One Dive.html b/printing_templates/One Dive.html index 40c02b395..ff0d8cd40 100644 --- a/printing_templates/One Dive.html +++ b/printing_templates/One Dive.html @@ -20,6 +20,7 @@ box-sizing: border-box; border:max(1px, 0.1vw); border-style:solid; + border-color: {{ template_options.color5 }}; } td { @@ -57,6 +58,7 @@ box-sizing: border-box; border:max(1px, 0.1vw); border-style:solid; + border-color: {{ template_options.color5 }}; float: left; } @@ -75,6 +77,11 @@ .fieldTitle { background-color: {{ template_options.color2 }}; overflow: hidden; + color: {{ template_options.color3 }}; + } + + .fieldData { + color: {{ template_options.color4 }}; } .table_class { @@ -91,6 +98,7 @@ .textArea { line-height: {{ template_options.line_spacing }}; + color: {{ template_options.color4 }}; max-height: 19vh; overflow: hidden; } @@ -111,7 +119,7 @@

Dive No.

- +

{{ dive.number }}

@@ -119,14 +127,15 @@

Date

-

{{ dive.date }}

+ +

{{ dive.date }}

Location

- +

{{ dive.location }}

@@ -134,7 +143,7 @@

Max depth

- +

{{ dive.depth }}

@@ -142,7 +151,7 @@

Duration

- +

{{ dive.duration }}

@@ -152,7 +161,7 @@

Time.

- +

{{ dive.time }}

@@ -160,14 +169,15 @@

Air Temp.

-

{{ dive.airTemp }}

+ +

{{ dive.airTemp }}

Water Temp.

- +

{{ dive.waterTemp }}

@@ -175,7 +185,7 @@

Buddy

- +

{{ dive.buddy }}

@@ -183,7 +193,7 @@

Dive Master

- +

{{ dive.divemaster }}

diff --git a/printing_templates/Table.html b/printing_templates/Table.html index c97267405..2668ccb62 100644 --- a/printing_templates/Table.html +++ b/printing_templates/Table.html @@ -47,7 +47,7 @@ box-sizing: border-box; border:max(0.1vw, 1px); border-style:solid; - border-color: color: {{ template_options.color5 }}; + border-color: {{ template_options.color5 }}; } diff --git a/printing_templates/Two Dives.html b/printing_templates/Two Dives.html index 5dba74303..463942ab5 100644 --- a/printing_templates/Two Dives.html +++ b/printing_templates/Two Dives.html @@ -40,6 +40,7 @@ box-sizing: border-box; border:max(0.1vw, 1px); border-style:solid; + border-color: {{ template_options.color5 }}; } .table_class { @@ -52,6 +53,7 @@ box-sizing: border-box; border:max(0.1vw, 1px); border-style:solid; + border-color: {{ template_options.color5 }}; } .notes_table_class { @@ -64,14 +66,20 @@ box-sizing: border-box; border:max(0.1vw, 1px); border-style:solid; + border-color: {{ template_options.color5 }}; } .fieldTitle { background-color: {{ template_options.color2 }}; + color: {{ template_options.color3 }}; overflow: hidden; padding:0; } + .fieldData { + color: {{ template_options.color4 }}; + } + .diveProfile { width: 48%; height: 95%; @@ -122,7 +130,7 @@

Dive No.

- +

{{ dive.number }}

@@ -130,14 +138,15 @@

Date

-

{{ dive.date }}

+ +

{{ dive.date }}

Location

- +

{{ dive.location }}

@@ -145,7 +154,7 @@

Max depth

- +

{{ dive.depth }}

@@ -153,7 +162,7 @@

Duration

- +

{{ dive.duration }}

@@ -163,7 +172,7 @@

Time.

- +

{{ dive.time }}

@@ -171,14 +180,15 @@

Air Temp.

-

{{ dive.airTemp }}

+ +

{{ dive.airTemp }}

Water Temp.

- +

{{ dive.waterTemp }}

@@ -186,7 +196,7 @@

Buddy

- +

{{ dive.buddy }}

@@ -194,7 +204,7 @@

Dive Master

- +

{{ dive.divemaster }}

@@ -210,7 +220,7 @@ - +

{{ dive.notes }}

From 88c19adc7880d21aed4fa0e498d0291c5fd9f9d4 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Mon, 3 Aug 2015 22:55:46 +0200 Subject: [PATCH 05/35] Printing: hide warnings in dive profile while printing While printing only draw headings, SP changes, gas events or bookmark events, otherwise don't show anything. Many warning logos can hide the useful information especially in templates with small dive profile area. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- qt-ui/profile/profilewidget2.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 400401655..c776f9fea 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -627,6 +627,17 @@ void ProfileWidget2::plotDive(struct dive *d, bool force) eventItems.clear(); struct event *event = currentdc->events; while (event) { + // if print mode is selected only draw headings, SP change, gas events or bookmark event + if (printMode) { + if (same_string(event->name, "") || + !(strcmp(event->name, "heading") == 0 || + (same_string(event->name, "SP change") && event->time.seconds == 0) || + event_is_gaschange(event) || + event->type == SAMPLE_EVENT_BOOKMARK)) { + event = event->next; + continue; + } + } DiveEventItem *item = new DiveEventItem(); item->setHorizontalAxis(timeAxis); item->setVerticalAxis(profileYAxis); From 9c13e7a071e85de5bf71924ebf280a052ea1b64a Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Tue, 4 Aug 2015 08:01:53 +0200 Subject: [PATCH 06/35] Printing: enhance templates layout Make better use of extra spaces, and decrease the margin sizes. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- printing_templates/Flowlayout.html | 13 ++++++------- printing_templates/One Dive.html | 8 ++++---- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/printing_templates/Flowlayout.html b/printing_templates/Flowlayout.html index 98867d259..f035e2172 100644 --- a/printing_templates/Flowlayout.html +++ b/printing_templates/Flowlayout.html @@ -37,7 +37,7 @@ margin-left: 2%; margin-right: 2%; margin-top: 0%; - margin-bottom: 0%; + margin-bottom: 2%; overflow: hidden; border-width: 0; page-break-inside: avoid; @@ -60,8 +60,7 @@ } .dataSection { - width: 98%; - margin: 1%; + width: 100%; } .fieldTitle { @@ -76,14 +75,14 @@ .table_class { float: left; - margin: 1%; - width: 48%; + margin: 0.5%; + width: 49%; } .notes_table_class { overflow: hidden; - width: 98%; - margin: 1%; + width: 99%; + margin: 0.5%; } .textArea { diff --git a/printing_templates/One Dive.html b/printing_templates/One Dive.html index ff0d8cd40..24108c69f 100644 --- a/printing_templates/One Dive.html +++ b/printing_templates/One Dive.html @@ -86,14 +86,14 @@ .table_class { float: left; - margin: 1%; - width: 48%; + margin: 0.5%; + width: 49%; } .notes_table_class { overflow: hidden; - width: 98%; - margin: 1%; + width: 99%; + margin: 0.5%; } .textArea { From 11841563d25a18bee5fc5e52139ca3d89d601818 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Wed, 5 Aug 2015 19:18:13 +0200 Subject: [PATCH 07/35] Printing: add six dives per page template Six dives per page templates makes good use of the page area, it can be mainly used to produce a lightweight print outs. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- printing_templates/Six Dives.html | 175 ++++++++++++++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 printing_templates/Six Dives.html diff --git a/printing_templates/Six Dives.html b/printing_templates/Six Dives.html new file mode 100644 index 000000000..3c64d5ec3 --- /dev/null +++ b/printing_templates/Six Dives.html @@ -0,0 +1,175 @@ + + + + + +
+{% block main_rows %} + {% for dive in dives %} +
+
+
+
+
+
+
+ + + + + + + +
+

Dive # {{ dive.number }} - {{ dive.date }} {{ dive.time }}

+

Max depth: {{ dive.depth }}

+
+

{{ dive.location }}

+

Duration: {{ dive.duration }}

+
+ + + + + + + + + + + +
Gas used: {{ dive.gas }} Tags: {{ dive.tags }} SAC: {{ dive.sac }}
Divemaster: {{ dive.divemaster }} Buddy: {{ dive.buddy }} Rating: {{ dive.rating }}/5
+
+
+
+ + + + + + + + + +
+

Notes:

+
+
+

{{ dive.notes }}

+
+
+
+
+
+
+ {% endfor %} +{% endblock %} +
+ + + From e2dcee55a38b86e48daad8a890ca2b4e6b122e37 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Wed, 5 Aug 2015 19:35:34 +0200 Subject: [PATCH 08/35] Printing: use pageRect() to support old QT versions While calculating the page size use QPrinter::pageRect instead of QPrinter::pageLayout which is added in QT 5.3 and is not supported in earlier versions. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- printer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/printer.cpp b/printer.cpp index fc18c9afe..2c1dcdc2f 100644 --- a/printer.cpp +++ b/printer.cpp @@ -144,8 +144,8 @@ void Printer::print() connect(&t, SIGNAL(progressUpdated(int)), this, SLOT(templateProgessUpdated(int))); dpi = printerPtr->resolution(); //rendering resolution = selected paper size in inchs * printer dpi - pageSize.setHeight(printerPtr->pageLayout().paintRect(QPageLayout::Inch).height() * dpi); - pageSize.setWidth(printerPtr->pageLayout().paintRect(QPageLayout::Inch).width() * dpi); + pageSize.setHeight(printerPtr->pageRect(QPrinter::Inch).height() * dpi); + pageSize.setWidth(printerPtr->pageRect(QPrinter::Inch).width() * dpi); webView->page()->setViewportSize(pageSize); webView->setHtml(t.generate()); if (printOptions->color_selected && printerPtr->colorMode()) { From f05e9c5c79aa6be153759837cc67fdf3c9980021 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Wed, 5 Aug 2015 22:31:27 +0200 Subject: [PATCH 09/35] Printing: export more dive details with Grantlee backend Add SAC, tags, used gas and dive rating to dive data fields exported with Grantlee backend. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- templatelayout.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++++++ templatelayout.h | 23 +++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/templatelayout.cpp b/templatelayout.cpp index 1da88249b..437a6aea6 100644 --- a/templatelayout.cpp +++ b/templatelayout.cpp @@ -188,6 +188,26 @@ QString Dive::notes() const return m_notes; } +QString Dive::tags() const +{ + return m_tags; +} + +QString Dive::gas() const +{ + return m_gas; +} + +QString Dive::sac() const +{ + return m_sac; +} + +int Dive::rating() const +{ + return m_rating; +} + void Dive::put_divemaster() { if (!dive->divemaster) @@ -237,3 +257,40 @@ void Dive::put_notes() { m_notes = QString::fromUtf8(dive->notes); } + +void Dive::put_tags() +{ + char buffer[256]; + taglist_get_tagstring(dive->tag_list, buffer, 256); + m_tags = QString(buffer); +} + +void Dive::put_gas() +{ + int added = 0; + QString gas, gases; + for (int i = 0; i < MAX_CYLINDERS; i++) { + if (!is_cylinder_used(dive, i)) + continue; + gas = dive->cylinder[i].type.description; + gas += QString(!gas.isEmpty() ? " " : "") + gasname(&dive->cylinder[i].gasmix); + // if has a description and if such gas is not already present + if (!gas.isEmpty() && gases.indexOf(gas) == -1) { + if (added > 0) + gases += QString(" / "); + gases += gas; + added++; + } + } + m_gas = gases; +} + +void Dive::put_sac() +{ + if (dive->sac) { + const char *unit; + int decimal; + double value = get_volume_units(dive->sac, &decimal, &unit); + m_sac = QString::number(value, 'f', decimal).append(unit); + } +} diff --git a/templatelayout.h b/templatelayout.h index c545f5a05..1bb08d25d 100644 --- a/templatelayout.h +++ b/templatelayout.h @@ -32,6 +32,7 @@ class Dive { private: int m_number; int m_id; + int m_rating; QString m_date; QString m_time; QString m_location; @@ -42,6 +43,9 @@ private: QString m_airTemp; QString m_waterTemp; QString m_notes; + QString m_tags; + QString m_gas; + QString m_sac; struct dive *dive; void put_date_time(); void put_location(); @@ -51,6 +55,9 @@ private: void put_buddy(); void put_temp(); void put_notes(); + void put_tags(); + void put_gas(); + void put_sac(); public: Dive(struct dive *dive) @@ -58,6 +65,7 @@ public: { m_number = dive->number; m_id = dive->id; + m_rating = dive->rating; put_date_time(); put_location(); put_duration(); @@ -66,11 +74,15 @@ public: put_buddy(); put_temp(); put_notes(); + put_tags(); + put_gas(); + put_sac(); } Dive(); ~Dive(); int number() const; int id() const; + int rating() const; QString date() const; QString time() const; QString location() const; @@ -81,6 +93,9 @@ public: QString airTemp() const; QString waterTemp() const; QString notes() const; + QString tags() const; + QString gas() const; + QString sac() const; }; Q_DECLARE_METATYPE(Dive) @@ -112,6 +127,14 @@ else if (property == "waterTemp") return object.waterTemp(); else if (property == "notes") return object.notes(); +else if (property == "rating") + return object.rating(); +else if (property == "sac") + return object.sac(); +else if (property == "tags") + return object.tags(); +else if (property == "gas") + return object.gas(); GRANTLEE_END_LOOKUP GRANTLEE_BEGIN_LOOKUP(template_options) From 1a2f154cf49041a223e5801328beb68cb8b42442 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Thu, 6 Aug 2015 20:39:38 +0200 Subject: [PATCH 10/35] Printing: add statistics print Add statistics table print option. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- printer.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++ printer.h | 1 + qt-ui/printdialog.cpp | 24 +++++++------------ 3 files changed, 66 insertions(+), 15 deletions(-) diff --git a/printer.cpp b/printer.cpp index 2c1dcdc2f..eee0fdbd6 100644 --- a/printer.cpp +++ b/printer.cpp @@ -1,5 +1,7 @@ #include "printer.h" #include "templatelayout.h" +#include "statistics.h" +#include "helpers.h" #include #include @@ -172,6 +174,60 @@ void Printer::print() render(Pages); } +void Printer::print_statistics() +{ + QPrinter *printerPtr; + printerPtr = static_cast(paintDevice); + stats_t total_stats; + + total_stats.selection_size = 0; + total_stats.total_time.seconds = 0; + + QString html; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + int i = 0; + while (stats_yearly != NULL && stats_yearly[i].period) { + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + total_stats.selection_size += stats_yearly[i].selection_size; + total_stats.total_time.seconds += stats_yearly[i].total_time.seconds; + i++; + } + html += "
YearDivesTotal TimeAvg TimeShortest TimeLongest TimeAvg DepthMin DepthMax DepthAvg SACMin SACMax SACMin TempMax Temp
" + QString::number(stats_yearly[i].period) + "" + QString::number(stats_yearly[i].selection_size) + "" + QString::fromUtf8(get_time_string(stats_yearly[i].total_time.seconds, 0)) + "" + QString::fromUtf8(get_minutes(stats_yearly[i].total_time.seconds / stats_yearly[i].selection_size)) + "" + QString::fromUtf8(get_minutes(stats_yearly[i].shortest_time.seconds)) + "" + QString::fromUtf8(get_minutes(stats_yearly[i].longest_time.seconds)) + "" + get_depth_string(stats_yearly[i].avg_depth) + "" + get_depth_string(stats_yearly[i].min_depth) + "" + get_depth_string(stats_yearly[i].max_depth) + "" + get_volume_string(stats_yearly[i].avg_sac) + "" + get_volume_string(stats_yearly[i].min_sac) + "" + get_volume_string(stats_yearly[i].max_sac) + "" + QString::number(stats_yearly[i].min_temp == 0 ? 0 : get_temp_units(stats_yearly[i].min_temp, NULL)) + "" + QString::number(stats_yearly[i].max_temp == 0 ? 0 : get_temp_units(stats_yearly[i].max_temp, NULL)) + "
"; + webView->setHtml(html); + webView->print(printerPtr); +} + void Printer::previewOnePage() { if (printMode == PREVIEW) { diff --git a/printer.h b/printer.h index b4cf3ac2a..c0775fa4b 100644 --- a/printer.h +++ b/printer.h @@ -38,6 +38,7 @@ public: Printer(QPaintDevice *paintDevice, print_options *printOptions, template_options *templateOptions, PrintMode printMode); ~Printer(); void print(); + void print_statistics(); void previewOnePage(); signals: diff --git a/qt-ui/printdialog.cpp b/qt-ui/printdialog.cpp index 6c50ae99b..08fdf7064 100644 --- a/qt-ui/printdialog.cpp +++ b/qt-ui/printdialog.cpp @@ -164,13 +164,6 @@ void PrintDialog::onFinished() void PrintDialog::previewClicked(void) { - if (printOptions.type == print_options::STATISTICS) { - QMessageBox msgBox; - msgBox.setText("This feature is not implemented yet"); - msgBox.exec(); - return; - } - QPrintPreviewDialog previewDialog(&qprinter, this, Qt::Window | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint | Qt::WindowTitleHint); @@ -180,13 +173,6 @@ void PrintDialog::previewClicked(void) void PrintDialog::printClicked(void) { - if (printOptions.type == print_options::STATISTICS) { - QMessageBox msgBox; - msgBox.setText("This feature is not implemented yet"); - msgBox.exec(); - return; - } - QPrintDialog printDialog(&qprinter, this); if (printDialog.exec() == QDialog::Accepted) { switch (printOptions.type) { @@ -195,6 +181,7 @@ void PrintDialog::printClicked(void) printer->print(); break; case print_options::STATISTICS: + printer->print_statistics(); break; } close(); @@ -204,7 +191,14 @@ void PrintDialog::printClicked(void) void PrintDialog::onPaintRequested(QPrinter *printerPtr) { connect(printer, SIGNAL(progessUpdated(int)), progressBar, SLOT(setValue(int))); - printer->print(); + switch (printOptions.type) { + case print_options::DIVELIST: + printer->print(); + break; + case print_options::STATISTICS: + printer->print_statistics(); + break; + } progressBar->setValue(0); disconnect(printer, SIGNAL(progessUpdated(int)), progressBar, SLOT(setValue(int))); } From 1dbe10fe278650430beca638976ea7df3b5c76fd Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Fri, 7 Aug 2015 09:54:09 +0200 Subject: [PATCH 11/35] Printing: add another color in color palettes Add another color 'Table cells 2' to the color palette, make all the backgrounds solid white by default. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- qt-ui/printdialog.cpp | 33 +++++++++++++----------- qt-ui/printoptions.h | 4 ++- qt-ui/templateedit.cpp | 8 ++++++ qt-ui/templateedit.ui | 58 +++++++++++++++++++++++++++++++++++------- templatelayout.h | 2 ++ 5 files changed, 80 insertions(+), 25 deletions(-) diff --git a/qt-ui/printdialog.cpp b/qt-ui/printdialog.cpp index 08fdf7064..0095597fd 100644 --- a/qt-ui/printdialog.cpp +++ b/qt-ui/printdialog.cpp @@ -17,21 +17,24 @@ template_options::color_palette_struct ssrf_colors, almond_colors, blueshades_co PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f) { // initialize const colors - ssrf_colors.color1 = QColor::fromRgb(0xef, 0xf7, 0xff); - ssrf_colors.color2 = QColor::fromRgb(0xa6, 0xbc, 0xd7); - ssrf_colors.color3 = QColor::fromRgb(0x34, 0x65, 0xa4); - ssrf_colors.color4 = QColor::fromRgb(0x20, 0x4a, 0x87); - ssrf_colors.color5 = QColor::fromRgb(0x17, 0x37, 0x64); - almond_colors.color1 = QColor::fromRgb(243, 234, 207); - almond_colors.color2 = QColor::fromRgb(253, 204, 156); - almond_colors.color3 = QColor::fromRgb(136, 160, 150); - almond_colors.color4 = QColor::fromRgb(187, 171, 139); - almond_colors.color5 = QColor::fromRgb(239, 130, 117); - blueshades_colors.color1 = QColor::fromRgb(182, 192, 206); - blueshades_colors.color2 = QColor::fromRgb(142, 152, 166); - blueshades_colors.color3 = QColor::fromRgb(31, 49, 75); - blueshades_colors.color4 = QColor::fromRgb(21, 45, 84); - blueshades_colors.color5 = QColor::fromRgb(5, 25, 56); + ssrf_colors.color1 = QColor::fromRgb(0xff, 0xff, 0xff); + ssrf_colors.color2 = QColor::fromRgb(0xef, 0xf7, 0xff); + ssrf_colors.color3 = QColor::fromRgb(0xa6, 0xbc, 0xd7); + ssrf_colors.color4 = QColor::fromRgb(0x34, 0x65, 0xa4); + ssrf_colors.color5 = QColor::fromRgb(0x20, 0x4a, 0x87); + ssrf_colors.color6 = QColor::fromRgb(0x17, 0x37, 0x64); + almond_colors.color1 = QColor::fromRgb(255, 255, 255); + almond_colors.color2 = QColor::fromRgb(243, 234, 207); + almond_colors.color3 = QColor::fromRgb(253, 204, 156); + almond_colors.color4 = QColor::fromRgb(136, 160, 150); + almond_colors.color5 = QColor::fromRgb(187, 171, 139); + almond_colors.color6 = QColor::fromRgb(239, 130, 117); + blueshades_colors.color1 = QColor::fromRgb(255, 255, 255); + blueshades_colors.color2 = QColor::fromRgb(182, 192, 206); + blueshades_colors.color3 = QColor::fromRgb(142, 152, 166); + blueshades_colors.color4 = QColor::fromRgb(31, 49, 75); + blueshades_colors.color5 = QColor::fromRgb(21, 45, 84); + blueshades_colors.color6 = QColor::fromRgb(5, 25, 56); // check if the options were previously stored in the settings; if not use some defaults. QSettings s; diff --git a/qt-ui/printoptions.h b/qt-ui/printoptions.h index 4903da09f..aff8ed1d9 100644 --- a/qt-ui/printoptions.h +++ b/qt-ui/printoptions.h @@ -27,12 +27,14 @@ struct template_options { QColor color3; QColor color4; QColor color5; + QColor color6; bool operator!=(const color_palette_struct &other) const { return other.color1 != color1 || other.color2 != color2 || other.color3 != color3 || other.color4 != color4 - || other.color5 != color5; + || other.color5 != color5 + || other.color6 != color6; } } color_palette; bool operator!=(const template_options &other) const { diff --git a/qt-ui/templateedit.cpp b/qt-ui/templateedit.cpp index 90ef7e750..e4e6453ac 100644 --- a/qt-ui/templateedit.cpp +++ b/qt-ui/templateedit.cpp @@ -30,6 +30,7 @@ TemplateEdit::TemplateEdit(QWidget *parent, struct print_options *printOptions, btnGroup->addButton(ui->editButton3, 3); btnGroup->addButton(ui->editButton4, 4); btnGroup->addButton(ui->editButton5, 5); + btnGroup->addButton(ui->editButton6, 6); connect(btnGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(colorSelect(QAbstractButton*))); ui->plainTextEdit->setPlainText(grantlee_template); @@ -60,12 +61,14 @@ void TemplateEdit::updatePreview() ui->colorLable3->setStyleSheet("QLabel { background-color : \"" + newTemplateOptions.color_palette.color3.name() + "\";}"); ui->colorLable4->setStyleSheet("QLabel { background-color : \"" + newTemplateOptions.color_palette.color4.name() + "\";}"); ui->colorLable5->setStyleSheet("QLabel { background-color : \"" + newTemplateOptions.color_palette.color5.name() + "\";}"); + ui->colorLable6->setStyleSheet("QLabel { background-color : \"" + newTemplateOptions.color_palette.color6.name() + "\";}"); ui->colorLable1->setText(newTemplateOptions.color_palette.color1.name()); ui->colorLable2->setText(newTemplateOptions.color_palette.color2.name()); ui->colorLable3->setText(newTemplateOptions.color_palette.color3.name()); ui->colorLable4->setText(newTemplateOptions.color_palette.color4.name()); ui->colorLable5->setText(newTemplateOptions.color_palette.color5.name()); + ui->colorLable6->setText(newTemplateOptions.color_palette.color6.name()); // update critical UI elements ui->colorpalette->setCurrentIndex(newTemplateOptions.color_palette_index); @@ -197,6 +200,11 @@ void TemplateEdit::colorSelect(QAbstractButton *button) if (color.isValid()) { newTemplateOptions.color_palette.color5 = color; } break; + case 6: + color = QColorDialog::getColor(newTemplateOptions.color_palette.color6, this); + if (color.isValid()) { + newTemplateOptions.color_palette.color6 = color; + } break; } newTemplateOptions.color_palette_index = CUSTOM; updatePreview(); diff --git a/qt-ui/templateedit.ui b/qt-ui/templateedit.ui index 238e69290..0a1b18c54 100644 --- a/qt-ui/templateedit.ui +++ b/qt-ui/templateedit.ui @@ -347,9 +347,9 @@ - + - + 0 @@ -357,7 +357,7 @@ - Text 1 + Table cells 2 @@ -387,9 +387,9 @@ - + - + 0 @@ -397,7 +397,7 @@ - Text 2 + Text 1 @@ -427,9 +427,9 @@ - + - + 0 @@ -437,7 +437,7 @@ - Borders + Text 2 @@ -466,6 +466,46 @@ + + + + + + + 0 + 0 + + + + Borders + + + + + + + + 0 + 0 + + + + color6 + + + Qt::AlignCenter + + + + + + + Edit + + + + + diff --git a/templatelayout.h b/templatelayout.h index 1bb08d25d..07e3ae060 100644 --- a/templatelayout.h +++ b/templatelayout.h @@ -165,6 +165,8 @@ if (property == "font") { return object.color_palette.color4.name(); } else if (property == "color5") { return object.color_palette.color5.name(); +} else if (property == "color6") { + return object.color_palette.color6.name(); } GRANTLEE_END_LOOKUP From e0ecccfa7bebaebb532d532f9a40b8d85facdecc Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Fri, 7 Aug 2015 09:53:34 +0200 Subject: [PATCH 12/35] Printing: fix color numbers in printing templates After adding the additional 'Table Cells 2' color to the color palette fix the colors assigned to each field. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- printing_templates/Flowlayout.html | 8 ++++---- printing_templates/One Dive.html | 10 +++++----- printing_templates/Six Dives.html | 2 +- printing_templates/Table.html | 6 +++--- printing_templates/Two Dives.html | 10 +++++----- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/printing_templates/Flowlayout.html b/printing_templates/Flowlayout.html index f035e2172..cab684e7e 100644 --- a/printing_templates/Flowlayout.html +++ b/printing_templates/Flowlayout.html @@ -20,7 +20,7 @@ box-sizing: border-box; border:max(1px, 0.1vw); border-style:solid; - border-color: {{ template_options.color5 }}; + border-color: {{ template_options.color6 }}; } td { @@ -55,7 +55,7 @@ box-sizing: border-box; border:max(1px, 0.1vw); border-style:solid; - border-color: {{ template_options.color5 }}; + border-color: {{ template_options.color6 }}; float: left; } @@ -66,11 +66,11 @@ .fieldTitle { background-color: {{ template_options.color2 }}; overflow: hidden; - color: {{ template_options.color3 }}; + color: {{ template_options.color4 }}; } .fieldData { - color: {{ template_options.color4 }}; + color: {{ template_options.color5 }}; } .table_class { diff --git a/printing_templates/One Dive.html b/printing_templates/One Dive.html index 24108c69f..bdf7ab3a7 100644 --- a/printing_templates/One Dive.html +++ b/printing_templates/One Dive.html @@ -20,7 +20,7 @@ box-sizing: border-box; border:max(1px, 0.1vw); border-style:solid; - border-color: {{ template_options.color5 }}; + border-color: {{ template_options.color6 }}; } td { @@ -58,7 +58,7 @@ box-sizing: border-box; border:max(1px, 0.1vw); border-style:solid; - border-color: {{ template_options.color5 }}; + border-color: {{ template_options.color6 }}; float: left; } @@ -77,11 +77,11 @@ .fieldTitle { background-color: {{ template_options.color2 }}; overflow: hidden; - color: {{ template_options.color3 }}; + color: {{ template_options.color4 }}; } .fieldData { - color: {{ template_options.color4 }}; + color: {{ template_options.color5 }}; } .table_class { @@ -98,7 +98,7 @@ .textArea { line-height: {{ template_options.line_spacing }}; - color: {{ template_options.color4 }}; + color: {{ template_options.color5 }}; max-height: 19vh; overflow: hidden; } diff --git a/printing_templates/Six Dives.html b/printing_templates/Six Dives.html index 3c64d5ec3..65d81f1cb 100644 --- a/printing_templates/Six Dives.html +++ b/printing_templates/Six Dives.html @@ -63,7 +63,7 @@ box-sizing: border-box; border:max(0.1vw, 1px); border-style:solid; - border-color: {{ template_options.color5 }}; + border-color: {{ template_options.color6 }}; font-size: {{ template_options.font_size }}vw; } diff --git a/printing_templates/Table.html b/printing_templates/Table.html index 2668ccb62..3cf65be96 100644 --- a/printing_templates/Table.html +++ b/printing_templates/Table.html @@ -47,7 +47,7 @@ box-sizing: border-box; border:max(0.1vw, 1px); border-style:solid; - border-color: {{ template_options.color5 }}; + border-color: {{ template_options.color6 }}; } @@ -55,7 +55,7 @@
- + @@ -66,7 +66,7 @@ {% block main_rows %} {% for dive in dives %} - + diff --git a/printing_templates/Two Dives.html b/printing_templates/Two Dives.html index 463942ab5..288a20262 100644 --- a/printing_templates/Two Dives.html +++ b/printing_templates/Two Dives.html @@ -40,7 +40,7 @@ box-sizing: border-box; border:max(0.1vw, 1px); border-style:solid; - border-color: {{ template_options.color5 }}; + border-color: {{ template_options.color6 }}; } .table_class { @@ -53,7 +53,7 @@ box-sizing: border-box; border:max(0.1vw, 1px); border-style:solid; - border-color: {{ template_options.color5 }}; + border-color: {{ template_options.color6 }}; } .notes_table_class { @@ -66,18 +66,18 @@ box-sizing: border-box; border:max(0.1vw, 1px); border-style:solid; - border-color: {{ template_options.color5 }}; + border-color: {{ template_options.color6 }}; } .fieldTitle { background-color: {{ template_options.color2 }}; - color: {{ template_options.color3 }}; + color: {{ template_options.color4 }}; overflow: hidden; padding:0; } .fieldData { - color: {{ template_options.color4 }}; + color: {{ template_options.color5 }}; } .diveProfile { From 04fc07405a9931ee78292e1fef10c3a0b779734a Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Fri, 7 Aug 2015 10:07:57 +0200 Subject: [PATCH 13/35] Printing: add color3 to templates and make it effective Use the added color for 'Table cells 2' Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- printing_templates/Flowlayout.html | 1 + printing_templates/One Dive.html | 1 + printing_templates/Table.html | 2 +- printing_templates/Two Dives.html | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/printing_templates/Flowlayout.html b/printing_templates/Flowlayout.html index cab684e7e..c5b1d4ba9 100644 --- a/printing_templates/Flowlayout.html +++ b/printing_templates/Flowlayout.html @@ -71,6 +71,7 @@ .fieldData { color: {{ template_options.color5 }}; + background-color: {{ template_options.color3 }}; } .table_class { diff --git a/printing_templates/One Dive.html b/printing_templates/One Dive.html index bdf7ab3a7..4bf15decd 100644 --- a/printing_templates/One Dive.html +++ b/printing_templates/One Dive.html @@ -81,6 +81,7 @@ } .fieldData { + background-color: {{ template_options.color3 }}; color: {{ template_options.color5 }}; } diff --git a/printing_templates/Table.html b/printing_templates/Table.html index 3cf65be96..c21fc3f33 100644 --- a/printing_templates/Table.html +++ b/printing_templates/Table.html @@ -66,7 +66,7 @@ {% block main_rows %} {% for dive in dives %} - + diff --git a/printing_templates/Two Dives.html b/printing_templates/Two Dives.html index 288a20262..f3ecccebd 100644 --- a/printing_templates/Two Dives.html +++ b/printing_templates/Two Dives.html @@ -78,6 +78,7 @@ .fieldData { color: {{ template_options.color5 }}; + background-color: {{ template_options.color3 }}; } .diveProfile { From 0fadfae754208589ffa5be7757f2e6a03e3c4902 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Fri, 7 Aug 2015 10:10:22 +0200 Subject: [PATCH 14/35] Printing: replace dark and light colors Make dark colors for headers while lighter colors for data fields, this is more intuitive, and makes the palettes more appealing. Make dark color default for cells2 Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- qt-ui/printdialog.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/qt-ui/printdialog.cpp b/qt-ui/printdialog.cpp index 0095597fd..77a1c7e94 100644 --- a/qt-ui/printdialog.cpp +++ b/qt-ui/printdialog.cpp @@ -18,20 +18,20 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f { // initialize const colors ssrf_colors.color1 = QColor::fromRgb(0xff, 0xff, 0xff); - ssrf_colors.color2 = QColor::fromRgb(0xef, 0xf7, 0xff); - ssrf_colors.color3 = QColor::fromRgb(0xa6, 0xbc, 0xd7); + ssrf_colors.color2 = QColor::fromRgb(0xa6, 0xbc, 0xd7); + ssrf_colors.color3 = QColor::fromRgb(0xef, 0xf7, 0xff); ssrf_colors.color4 = QColor::fromRgb(0x34, 0x65, 0xa4); ssrf_colors.color5 = QColor::fromRgb(0x20, 0x4a, 0x87); ssrf_colors.color6 = QColor::fromRgb(0x17, 0x37, 0x64); almond_colors.color1 = QColor::fromRgb(255, 255, 255); - almond_colors.color2 = QColor::fromRgb(243, 234, 207); - almond_colors.color3 = QColor::fromRgb(253, 204, 156); + almond_colors.color2 = QColor::fromRgb(253, 204, 156); + almond_colors.color3 = QColor::fromRgb(243, 234, 207); almond_colors.color4 = QColor::fromRgb(136, 160, 150); almond_colors.color5 = QColor::fromRgb(187, 171, 139); almond_colors.color6 = QColor::fromRgb(239, 130, 117); blueshades_colors.color1 = QColor::fromRgb(255, 255, 255); - blueshades_colors.color2 = QColor::fromRgb(182, 192, 206); - blueshades_colors.color3 = QColor::fromRgb(142, 152, 166); + blueshades_colors.color2 = QColor::fromRgb(142, 152, 166); + blueshades_colors.color3 = QColor::fromRgb(182, 192, 206); blueshades_colors.color4 = QColor::fromRgb(31, 49, 75); blueshades_colors.color5 = QColor::fromRgb(21, 45, 84); blueshades_colors.color6 = QColor::fromRgb(5, 25, 56); From 519440111272bbeb0e56242de5c8a51bb55a73e6 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Fri, 7 Aug 2015 10:11:14 +0200 Subject: [PATCH 15/35] Printing: make default borders black Make all borders black by default. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- qt-ui/printdialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qt-ui/printdialog.cpp b/qt-ui/printdialog.cpp index 77a1c7e94..002f9b9f4 100644 --- a/qt-ui/printdialog.cpp +++ b/qt-ui/printdialog.cpp @@ -28,13 +28,13 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f almond_colors.color3 = QColor::fromRgb(243, 234, 207); almond_colors.color4 = QColor::fromRgb(136, 160, 150); almond_colors.color5 = QColor::fromRgb(187, 171, 139); - almond_colors.color6 = QColor::fromRgb(239, 130, 117); + almond_colors.color6 = QColor::fromRgb(0, 0, 0); blueshades_colors.color1 = QColor::fromRgb(255, 255, 255); blueshades_colors.color2 = QColor::fromRgb(142, 152, 166); blueshades_colors.color3 = QColor::fromRgb(182, 192, 206); blueshades_colors.color4 = QColor::fromRgb(31, 49, 75); blueshades_colors.color5 = QColor::fromRgb(21, 45, 84); - blueshades_colors.color6 = QColor::fromRgb(5, 25, 56); + blueshades_colors.color6 = QColor::fromRgb(0, 0, 0); // check if the options were previously stored in the settings; if not use some defaults. QSettings s; From ebd83b15dad4343d38bf5485b2308f0e5c079120 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Fri, 7 Aug 2015 15:16:32 +0200 Subject: [PATCH 16/35] Printing: make the actual data font width regular (not bold) The actual data needs to be regular font not a bold font, so use

instead of

tag for the actual data fields. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- printing_templates/Flowlayout.html | 27 ++++++++++++++++----------- printing_templates/One Dive.html | 27 ++++++++++++++++----------- printing_templates/Two Dives.html | 27 ++++++++++++++++----------- 3 files changed, 48 insertions(+), 33 deletions(-) diff --git a/printing_templates/Flowlayout.html b/printing_templates/Flowlayout.html index c5b1d4ba9..3141d0f3e 100644 --- a/printing_templates/Flowlayout.html +++ b/printing_templates/Flowlayout.html @@ -15,6 +15,11 @@ font-size: {{ template_options.font_size }}vw; } + p { + float: left; + font-size: {{ template_options.font_size }}vw; + } + table { -webkit-box-sizing: border-box; box-sizing: border-box; @@ -108,7 +113,7 @@

Dive No.

@@ -116,7 +121,7 @@

Date

@@ -124,7 +129,7 @@

Location

@@ -132,7 +137,7 @@

Max depth

@@ -140,7 +145,7 @@

Duration

Dive # Date Time
{{ dive.number }} {{ dive.date }} {{ dive.time }}
{{ dive.number }} {{ dive.date }} {{ dive.time }} -

{{ dive.number }}

+

{{ dive.number }}

-

{{ dive.date }}

+

{{ dive.date }}

-

{{ dive.location }}

+

{{ dive.location }}

-

{{ dive.depth }}

+

{{ dive.depth }}

-

{{ dive.duration }}

+

{{ dive.duration }}

@@ -150,7 +155,7 @@

Time.

-

{{ dive.time }}

+

{{ dive.time }}

@@ -158,7 +163,7 @@

Air Temp.

-

{{ dive.airTemp }}

+

{{ dive.airTemp }}

@@ -166,7 +171,7 @@

Water Temp.

-

{{ dive.waterTemp }}

+

{{ dive.waterTemp }}

@@ -174,7 +179,7 @@

Buddy

-

{{ dive.buddy }}

+

{{ dive.buddy }}

@@ -182,7 +187,7 @@

Dive Master

-

{{ dive.divemaster }}

+

{{ dive.divemaster }}

@@ -197,7 +202,7 @@
-

{{ dive.notes }}

+

{{ dive.notes }}

diff --git a/printing_templates/One Dive.html b/printing_templates/One Dive.html index 4bf15decd..362af29eb 100644 --- a/printing_templates/One Dive.html +++ b/printing_templates/One Dive.html @@ -15,6 +15,11 @@ font-size: {{ template_options.font_size }}vw; } + p { + float: left; + font-size: {{ template_options.font_size }}vw; + } + table { -webkit-box-sizing: border-box; box-sizing: border-box; @@ -121,7 +126,7 @@

Dive No.

-

{{ dive.number }}

+

{{ dive.number }}

@@ -129,7 +134,7 @@

Date

-

{{ dive.date }}

+

{{ dive.date }}

@@ -137,7 +142,7 @@

Location

-

{{ dive.location }}

+

{{ dive.location }}

@@ -145,7 +150,7 @@

Max depth

-

{{ dive.depth }}

+

{{ dive.depth }}

@@ -153,7 +158,7 @@

Duration

-

{{ dive.duration }}

+

{{ dive.duration }}

@@ -163,7 +168,7 @@

Time.

-

{{ dive.time }}

+

{{ dive.time }}

@@ -171,7 +176,7 @@

Air Temp.

-

{{ dive.airTemp }}

+

{{ dive.airTemp }}

@@ -179,7 +184,7 @@

Water Temp.

-

{{ dive.waterTemp }}

+

{{ dive.waterTemp }}

@@ -187,7 +192,7 @@

Buddy

-

{{ dive.buddy }}

+

{{ dive.buddy }}

@@ -195,7 +200,7 @@

Dive Master

-

{{ dive.divemaster }}

+

{{ dive.divemaster }}

@@ -210,7 +215,7 @@
-

{{ dive.notes }}

+

{{ dive.notes }}

diff --git a/printing_templates/Two Dives.html b/printing_templates/Two Dives.html index f3ecccebd..ed1013e18 100644 --- a/printing_templates/Two Dives.html +++ b/printing_templates/Two Dives.html @@ -15,6 +15,11 @@ float: left; } + p { + font-size: {{ template_options.font_size }}vw; + float: left; + } + #body_div { background-color: {{ template_options.color1 }}; } @@ -132,7 +137,7 @@

Dive No.

-

{{ dive.number }}

+

{{ dive.number }}

@@ -140,7 +145,7 @@

Date

-

{{ dive.date }}

+

{{ dive.date }}

@@ -148,7 +153,7 @@

Location

-

{{ dive.location }}

+

{{ dive.location }}

@@ -156,7 +161,7 @@

Max depth

-

{{ dive.depth }}

+

{{ dive.depth }}

@@ -164,7 +169,7 @@

Duration

-

{{ dive.duration }}

+

{{ dive.duration }}

@@ -174,7 +179,7 @@

Time.

-

{{ dive.time }}

+

{{ dive.time }}

@@ -182,7 +187,7 @@

Air Temp.

-

{{ dive.airTemp }}

+

{{ dive.airTemp }}

@@ -190,7 +195,7 @@

Water Temp.

-

{{ dive.waterTemp }}

+

{{ dive.waterTemp }}

@@ -198,7 +203,7 @@

Buddy

-

{{ dive.buddy }}

+

{{ dive.buddy }}

@@ -206,7 +211,7 @@

Dive Master

-

{{ dive.divemaster }}

+

{{ dive.divemaster }}

@@ -223,7 +228,7 @@
-

{{ dive.notes }}

+

{{ dive.notes }}

From dc56d1fa54e97d562a7b4df166faadf0b73e410c Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Fri, 7 Aug 2015 16:45:07 +0200 Subject: [PATCH 17/35] Printing: remove the outer most border for all templates Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- printing_templates/Flowlayout.html | 5 ----- printing_templates/One Dive.html | 5 ----- printing_templates/Two Dives.html | 5 ----- 3 files changed, 15 deletions(-) diff --git a/printing_templates/Flowlayout.html b/printing_templates/Flowlayout.html index 3141d0f3e..a322738ba 100644 --- a/printing_templates/Flowlayout.html +++ b/printing_templates/Flowlayout.html @@ -56,11 +56,6 @@ .diveDetails { width: 98%; - -webkit-box-sizing: border-box; - box-sizing: border-box; - border:max(1px, 0.1vw); - border-style:solid; - border-color: {{ template_options.color6 }}; float: left; } diff --git a/printing_templates/One Dive.html b/printing_templates/One Dive.html index 362af29eb..92ab3cf84 100644 --- a/printing_templates/One Dive.html +++ b/printing_templates/One Dive.html @@ -59,11 +59,6 @@ .diveDetails { width: 98%; height: 98%; - -webkit-box-sizing: border-box; - box-sizing: border-box; - border:max(1px, 0.1vw); - border-style:solid; - border-color: {{ template_options.color6 }}; float: left; } diff --git a/printing_templates/Two Dives.html b/printing_templates/Two Dives.html index ed1013e18..66b5bf46d 100644 --- a/printing_templates/Two Dives.html +++ b/printing_templates/Two Dives.html @@ -41,11 +41,6 @@ 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; - border-color: {{ template_options.color6 }}; } .table_class { From 636c26feedb3abc1784747fac9b31aeb2fcee3bd Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Sat, 8 Aug 2015 00:55:12 +0200 Subject: [PATCH 18/35] Printing: hide scrollbar from QWebview to fix padding issue The vertical scrollbar was causing a default margin at the right most of the page which corrupted the page layout calculations. By hidding the vertical scrollbar the issue is fixed. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- printer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/printer.cpp b/printer.cpp index eee0fdbd6..bce42c30d 100644 --- a/printer.cpp +++ b/printer.cpp @@ -149,6 +149,7 @@ void Printer::print() pageSize.setHeight(printerPtr->pageRect(QPrinter::Inch).height() * dpi); pageSize.setWidth(printerPtr->pageRect(QPrinter::Inch).width() * dpi); webView->page()->setViewportSize(pageSize); + webView->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); webView->setHtml(t.generate()); if (printOptions->color_selected && printerPtr->colorMode()) { printerPtr->setColorMode(QPrinter::Color); From d72ba4f15a2616888a777bf2b70c7df639979f31 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Sat, 8 Aug 2015 01:39:46 +0200 Subject: [PATCH 19/35] Printing: remove templates additional margins Remove extra margins and paddings in templates. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- printing_templates/Flowlayout.html | 14 +++++++------- printing_templates/One Dive.html | 22 +++++++++++----------- printing_templates/Six Dives.html | 4 ++-- printing_templates/Table.html | 10 +++++----- printing_templates/Two Dives.html | 15 ++++++--------- 5 files changed, 31 insertions(+), 34 deletions(-) diff --git a/printing_templates/Flowlayout.html b/printing_templates/Flowlayout.html index a322738ba..2686d8c66 100644 --- a/printing_templates/Flowlayout.html +++ b/printing_templates/Flowlayout.html @@ -38,9 +38,9 @@ } .mainContainer { - width: 96%; - margin-left: 2%; - margin-right: 2%; + width: 100%; + margin-left: 0%; + margin-right: 0%; margin-top: 0%; margin-bottom: 2%; overflow: hidden; @@ -49,13 +49,13 @@ } .innerContainer { - width: 98%; - padding: 1%; + width: 100%; + padding: 0%; overflow: hidden; } .diveDetails { - width: 98%; + width: 100%; float: left; } @@ -76,8 +76,8 @@ .table_class { float: left; + width: 49.25%; margin: 0.5%; - width: 49%; } .notes_table_class { diff --git a/printing_templates/One Dive.html b/printing_templates/One Dive.html index 92ab3cf84..546fc2f07 100644 --- a/printing_templates/One Dive.html +++ b/printing_templates/One Dive.html @@ -38,10 +38,10 @@ } .mainContainer { - width: 96%; + width: 98%; height: 100%; - margin-left: 2%; - margin-right: 2%; + margin-left: 1%; + margin-right: 1%; margin-top: 0%; margin-bottom: 0%; overflow: hidden; @@ -50,28 +50,28 @@ } .innerContainer { - width: 98%; - height: 98%; - padding: 1%; + width: 100%; + height: 100%; + padding: 0%; overflow: hidden; } .diveDetails { - width: 98%; + width: 100%; height: 98%; float: left; } .diveProfile { - width: 96%; + width: 99%; height: 40%; - margin: 2%; + margin: 0.5%; } .dataSection { - width: 98%; + width: 100%; height: 40%; - margin: 1%; + margin: 0%; } .fieldTitle { diff --git a/printing_templates/Six Dives.html b/printing_templates/Six Dives.html index 65d81f1cb..1d3966d3b 100644 --- a/printing_templates/Six Dives.html +++ b/printing_templates/Six Dives.html @@ -47,7 +47,7 @@ .innerContainer { height: 98%; width: 98%; - padding: 0%; + padding: 1%; margin-top: 1%; margin-bottom: 1%; overflow: hidden; @@ -86,7 +86,7 @@ } .diveDetails { - width: 98.5%; + width: 100%; float: left; } diff --git a/printing_templates/Table.html b/printing_templates/Table.html index c21fc3f33..4d692ef21 100644 --- a/printing_templates/Table.html +++ b/printing_templates/Table.html @@ -28,10 +28,10 @@ } .mainContainer { - width: 96%; + width: 99%; height: 100%; - margin-left: 2%; - margin-right: 2%; + margin-left: 0.5%; + margin-right: 0.5%; margin-top: 0%; margin-bottom: 0%; overflow: hidden; @@ -41,8 +41,8 @@ .table_class { overflow: hidden; - width: 97%; - margin: 1.5%; + width: 100%; + margin: 0%; -webkit-box-sizing: border-box; box-sizing: border-box; border:max(0.1vw, 1px); diff --git a/printing_templates/Two Dives.html b/printing_templates/Two Dives.html index 66b5bf46d..eb68cd18d 100644 --- a/printing_templates/Two Dives.html +++ b/printing_templates/Two Dives.html @@ -25,10 +25,10 @@ } .mainContainer { - width: 96%; + width: 99%; height: 50%; - margin-left: 2%; - margin-right: 2%; + margin-left: 0.5%; + margin-right: 0.5%; margin-top: 0; margin-bottom: 0; overflow: hidden; @@ -37,7 +37,6 @@ .innerContainer { height: 85%; - padding: 0.5%; margin-top: 1%; margin-bottom: 1%; overflow: hidden; @@ -45,8 +44,7 @@ .table_class { overflow: hidden; - max-width: 25%; - min-width: 25%; + width: 25%; margin: 0.5%; float: left; -webkit-box-sizing: border-box; @@ -58,8 +56,7 @@ .notes_table_class { overflow: hidden; - max-width: 100%; - min-width: 100%; + width: 99%; margin: 0.5%; float: left; -webkit-box-sizing: border-box; @@ -92,7 +89,7 @@ } .diveDetails { - width: 98.5%; + width: 100%; float: left; } From 06e2fab291295f377af19fcc6f4d7415477c0f44 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Sun, 9 Aug 2015 01:12:15 +0200 Subject: [PATCH 20/35] Printing: insert placeholders in empty feilds Don't leave fields empty, this may corrupt the layout, a better way is to insert placeholders for empty data, which also provides a better UX. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- templatelayout.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/templatelayout.cpp b/templatelayout.cpp index 437a6aea6..b0098fbd9 100644 --- a/templatelayout.cpp +++ b/templatelayout.cpp @@ -211,7 +211,7 @@ int Dive::rating() const void Dive::put_divemaster() { if (!dive->divemaster) - m_divemaster = ""; + m_divemaster = "--"; else m_divemaster = dive->divemaster; } @@ -227,6 +227,9 @@ void Dive::put_date_time() void Dive::put_location() { m_location = QString::fromUtf8(get_dive_location(dive)); + if (m_location.isEmpty()) { + m_location = "--"; + } } void Dive::put_depth() @@ -242,7 +245,7 @@ void Dive::put_duration() void Dive::put_buddy() { if (!dive->buddy) - m_buddy = ""; + m_buddy = "--"; else m_buddy = dive->buddy; } @@ -251,11 +254,20 @@ void Dive::put_temp() { m_airTemp = get_temperature_string(dive->airtemp, true); m_waterTemp = get_temperature_string(dive->watertemp, true); + if (m_airTemp.isEmpty()) { + m_airTemp = "--"; + } + if (m_waterTemp.isEmpty()) { + m_waterTemp = "--"; + } } void Dive::put_notes() { m_notes = QString::fromUtf8(dive->notes); + if (m_notes.isEmpty()) { + m_notes = "--"; + } } void Dive::put_tags() From de889b90adb7489923f9f19e11a15256ea648b80 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Sun, 9 Aug 2015 17:41:43 +0200 Subject: [PATCH 21/35] Printing: rename "Table cells" to "Table cells 1" Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- qt-ui/templateedit.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qt-ui/templateedit.ui b/qt-ui/templateedit.ui index 0a1b18c54..322193cc6 100644 --- a/qt-ui/templateedit.ui +++ b/qt-ui/templateedit.ui @@ -317,7 +317,7 @@ - Table cells + Table cells 1 From cfa34cc0221c206d00c8a8f40a1b0dfddb29aacd Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Mon, 10 Aug 2015 17:59:18 +0200 Subject: [PATCH 22/35] Printing: add more padding on the top of the profile add more padding on the top of the profile so that the left-right-top padding around the profile is the same. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- printing_templates/One Dive.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/printing_templates/One Dive.html b/printing_templates/One Dive.html index 546fc2f07..176698616 100644 --- a/printing_templates/One Dive.html +++ b/printing_templates/One Dive.html @@ -51,8 +51,8 @@ .innerContainer { width: 100%; - height: 100%; - padding: 0%; + height: 99%; + padding-top: 1%; overflow: hidden; } From d7f1a6b96e27999795798d066adb1cc8a1887ec3 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Mon, 10 Aug 2015 19:35:42 +0200 Subject: [PATCH 23/35] Printing: remove extra white spaces from 6 dives template The are some rounding errors in the 6 dives template. Solve them them by adding the color to the main body div. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- printing_templates/Six Dives.html | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/printing_templates/Six Dives.html b/printing_templates/Six Dives.html index 1d3966d3b..2bf23a145 100644 --- a/printing_templates/Six Dives.html +++ b/printing_templates/Six Dives.html @@ -32,6 +32,11 @@ float: left; } + #body_div { + background-color: {{ template_options.color1 }}; + float: left; + } + .mainContainer { width: 50%; height: 33.333333%; @@ -45,13 +50,12 @@ } .innerContainer { - height: 98%; + height: 99%; width: 98%; - padding: 1%; - margin-top: 1%; - margin-bottom: 1%; + padding-left: 1%; + padding-right: 1%; + padding-top: 1%; overflow: hidden; - background-color: {{ template_options.color1 }}; } .table_class { @@ -81,7 +85,7 @@ margin-left: 0%; margin-right: 0%; margin-bottom: 0%; - margin-top: 0.5%; + margin-top: 0%; float: right; } @@ -168,8 +172,8 @@
{% endfor %} {% endblock %} - + From efe8dc9b5771fe51171060170ac002c82f29e317 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Mon, 10 Aug 2015 20:06:43 +0200 Subject: [PATCH 24/35] Printing: remove the outer border from table template Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- printing_templates/Table.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/printing_templates/Table.html b/printing_templates/Table.html index 4d692ef21..0a65b2a92 100644 --- a/printing_templates/Table.html +++ b/printing_templates/Table.html @@ -21,6 +21,11 @@ -webkit-column-break-inside: avoid; padding-top: 1vh; padding-bottom: 1vh; + -webkit-box-sizing: border-box; + box-sizing: border-box; + border:max(1px, 0.1vw); + border-style:solid; + border-color: {{ template_options.color6 }}; } #body_div { @@ -43,11 +48,6 @@ overflow: hidden; width: 100%; margin: 0%; - -webkit-box-sizing: border-box; - box-sizing: border-box; - border:max(0.1vw, 1px); - border-style:solid; - border-color: {{ template_options.color6 }}; } From 0ced68f15d57fe7487ec7286fb0e2358dd604092 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Tue, 11 Aug 2015 20:33:43 +0200 Subject: [PATCH 25/35] Printing: fix scrolling bug by adding extra padding This bug occurs in "table" and "flowlayout" templates, it takes place when the size of the full web view to be rendered is not divisible by the size of the view port (Page size), This issue is fixed by adding extra padding to the bottom of the body so that the total body height is divisable by the view port size. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- printer.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/printer.cpp b/printer.cpp index bce42c30d..635778042 100644 --- a/printer.cpp +++ b/printer.cpp @@ -168,6 +168,10 @@ void Printer::print() } int Pages; 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); Pages = ceil(webView->page()->mainFrame()->contentsSize().height() / (float)pageSize.height()); } else { Pages = ceil(getTotalWork(printOptions) / (float)divesPerPage); From 59eddc62594d2c8003349812456befeef82e1bc2 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Tue, 11 Aug 2015 22:50:27 +0200 Subject: [PATCH 26/35] 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 Signed-off-by: Gehad elrobey --- printer.cpp | 3 +++ qt-ui/printoptions.h | 1 + templatelayout.h | 2 ++ 3 files changed, 6 insertions(+) diff --git a/printer.cpp b/printer.cpp index 635778042..115b17526 100644 --- a/printer.cpp +++ b/printer.cpp @@ -3,6 +3,7 @@ #include "statistics.h" #include "helpers.h" +#include #include #include #include @@ -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); diff --git a/qt-ui/printoptions.h b/qt-ui/printoptions.h index aff8ed1d9..24f8e4cc8 100644 --- a/qt-ui/printoptions.h +++ b/qt-ui/printoptions.h @@ -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 { diff --git a/templatelayout.h b/templatelayout.h index 07e3ae060..41a3cbfa9 100644 --- a/templatelayout.h +++ b/templatelayout.h @@ -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") { From 72b35d8e79e8d404b4dc0d47d9a9af82958be718 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Tue, 11 Aug 2015 23:02:00 +0200 Subject: [PATCH 27/35] Printing: use border width from Grantlee backend Find the border-width dynamically from the Grantlee backend. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- printing_templates/Flowlayout.html | 2 +- printing_templates/One Dive.html | 2 +- printing_templates/Six Dives.html | 2 +- printing_templates/Table.html | 2 +- printing_templates/Two Dives.html | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/printing_templates/Flowlayout.html b/printing_templates/Flowlayout.html index 2686d8c66..cb136c3f2 100644 --- a/printing_templates/Flowlayout.html +++ b/printing_templates/Flowlayout.html @@ -23,7 +23,7 @@ table { -webkit-box-sizing: border-box; box-sizing: border-box; - border:max(1px, 0.1vw); + border-width: {{ template_options.borderwidth }}px; border-style:solid; border-color: {{ template_options.color6 }}; } diff --git a/printing_templates/One Dive.html b/printing_templates/One Dive.html index 176698616..0014c4680 100644 --- a/printing_templates/One Dive.html +++ b/printing_templates/One Dive.html @@ -23,7 +23,7 @@ table { -webkit-box-sizing: border-box; box-sizing: border-box; - border:max(1px, 0.1vw); + border-width: {{ template_options.borderwidth }}px; border-style:solid; border-color: {{ template_options.color6 }}; } diff --git a/printing_templates/Six Dives.html b/printing_templates/Six Dives.html index 2bf23a145..5b2652f05 100644 --- a/printing_templates/Six Dives.html +++ b/printing_templates/Six Dives.html @@ -65,7 +65,7 @@ float: left; -webkit-box-sizing: border-box; box-sizing: border-box; - border:max(0.1vw, 1px); + border-width: {{ template_options.borderwidth }}px; border-style:solid; border-color: {{ template_options.color6 }}; font-size: {{ template_options.font_size }}vw; diff --git a/printing_templates/Table.html b/printing_templates/Table.html index 0a65b2a92..173904faf 100644 --- a/printing_templates/Table.html +++ b/printing_templates/Table.html @@ -23,7 +23,7 @@ padding-bottom: 1vh; -webkit-box-sizing: border-box; box-sizing: border-box; - border:max(1px, 0.1vw); + border-width: {{ template_options.borderwidth }}px; border-style:solid; border-color: {{ template_options.color6 }}; } diff --git a/printing_templates/Two Dives.html b/printing_templates/Two Dives.html index eb68cd18d..13cb5cff6 100644 --- a/printing_templates/Two Dives.html +++ b/printing_templates/Two Dives.html @@ -49,7 +49,7 @@ float: left; -webkit-box-sizing: border-box; box-sizing: border-box; - border:max(0.1vw, 1px); + border-width: {{ template_options.borderwidth }}px; border-style:solid; border-color: {{ template_options.color6 }}; } @@ -61,7 +61,7 @@ float: left; -webkit-box-sizing: border-box; box-sizing: border-box; - border:max(0.1vw, 1px); + border-width: {{ template_options.borderwidth }}px; border-style:solid; border-color: {{ template_options.color6 }}; } From 31df69c401ad8995d8201242a1db1b74de19a18a Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Wed, 12 Aug 2015 00:57:19 +0200 Subject: [PATCH 28/35] Printing: disable ui elements on statistics print Disable all the UI elements for "dive list print", disable all the template settings as well, Template Edit button will be enabled after statistics print supports color palettes. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- qt-ui/printoptions.cpp | 26 ++++++++++++++++++++++++-- qt-ui/printoptions.h | 4 ++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/qt-ui/printoptions.cpp b/qt-ui/printoptions.cpp index 1da95a94d..419098cf8 100644 --- a/qt-ui/printoptions.cpp +++ b/qt-ui/printoptions.cpp @@ -64,17 +64,39 @@ void PrintOptions::setup() } // print type radio buttons -void PrintOptions::on_radioDiveListPrint_clicked(bool check) +void PrintOptions::on_radioDiveListPrint_toggled(bool check) { if (check) { printOptions->type = print_options::DIVELIST; + + // print options + ui.printInColor->setEnabled(true); + ui.printSelected->setEnabled(true); + + // print template + ui.deleteButton->setEnabled(true); + ui.editButton->setEnabled(true); + ui.exportButton->setEnabled(true); + ui.importButton->setEnabled(true); + ui.printTemplate->setEnabled(true); } } -void PrintOptions::on_radioStatisticsPrint_clicked(bool check) +void PrintOptions::on_radioStatisticsPrint_toggled(bool check) { if (check) { printOptions->type = print_options::STATISTICS; + + // print options + ui.printInColor->setEnabled(false); + ui.printSelected->setEnabled(false); + + // print template + ui.deleteButton->setEnabled(false); + ui.editButton->setEnabled(false); + ui.exportButton->setEnabled(false); + ui.importButton->setEnabled(false); + ui.printTemplate->setEnabled(false); } } diff --git a/qt-ui/printoptions.h b/qt-ui/printoptions.h index 24f8e4cc8..6d7ffffee 100644 --- a/qt-ui/printoptions.h +++ b/qt-ui/printoptions.h @@ -75,8 +75,8 @@ private slots: void printInColorClicked(bool check); void printSelectedClicked(bool check); - void on_radioStatisticsPrint_clicked(bool check); - void on_radioDiveListPrint_clicked(bool check); + void on_radioStatisticsPrint_toggled(bool check); + void on_radioDiveListPrint_toggled(bool check); void on_printTemplate_currentIndexChanged(int index); void on_editButton_clicked(); void on_importButton_clicked(); From 6a9c4cb9d794056ccb75e6a0d35cde060473b71e Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Thu, 13 Aug 2015 23:23:07 +0200 Subject: [PATCH 29/35] Printing: don't break dives into successive pages While rendering a template with "0" dives per page value, try to fit as many dives per page but don't break a dive into 2 pages. Use a dynamically sized view port to fit the rendered area only, and don't render the full page. All the Template elements that shouldn't be broken should have the CSS class "dontbreak". Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- printer.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++-- printer.h | 1 + 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/printer.cpp b/printer.cpp index 115b17526..5d7adcacc 100644 --- a/printer.cpp +++ b/printer.cpp @@ -57,6 +57,46 @@ void Printer::putProfileImage(QRect profilePlaceholder, QRect viewPort, QPainter } } +void Printer::flowRender() +{ + // render the Qwebview + QPainter painter; + QRect viewPort(0, 0, 0, 0); + painter.begin(paintDevice); + painter.setRenderHint(QPainter::Antialiasing); + painter.setRenderHint(QPainter::SmoothPixmapTransform); + + // get all references to dontbreak divs + int start = 0, end = 0; + int fullPageResolution = webView->page()->mainFrame()->contentsSize().height(); + QWebElementCollection dontbreak = webView->page()->mainFrame()->findAllElements(".dontbreak"); + foreach (QWebElement dontbreakElement, dontbreak) { + if ((dontbreakElement.geometry().y() + dontbreakElement.geometry().height()) - start < pageSize.height()) { + // One more element can be placed + end = dontbreakElement.geometry().y() + dontbreakElement.geometry().height(); + } else { + QRegion reigon(0, 0, pageSize.width(), end - start); + viewPort.setRect(0, start, pageSize.width(), end - start); + + // render the base Html template + webView->page()->mainFrame()->render(&painter, QWebFrame::ContentsLayer, reigon); + + // scroll the webview to the next page + webView->page()->mainFrame()->scroll(0, dontbreakElement.geometry().y() - start); + + // rendering progress is 4/5 of total work + emit(progessUpdated((end * 80.0 / fullPageResolution) + done)); + static_cast(paintDevice)->newPage(); + start = dontbreakElement.geometry().y(); + } + } + // render the remianing page + QRegion reigon(0, 0, pageSize.width(), end - start); + webView->page()->mainFrame()->render(&painter, QWebFrame::ContentsLayer, reigon); + + painter.end(); +} + void Printer::render(int Pages = 0) { // keep original preferences @@ -175,11 +215,11 @@ void Printer::print() 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); - Pages = ceil(webView->page()->mainFrame()->contentsSize().height() / (float)pageSize.height()); + flowRender(); } else { Pages = ceil(getTotalWork(printOptions) / (float)divesPerPage); + render(Pages); } - render(Pages); } void Printer::print_statistics() diff --git a/printer.h b/printer.h index c0775fa4b..5c7652a8d 100644 --- a/printer.h +++ b/printer.h @@ -29,6 +29,7 @@ private: int done; int dpi; void render(int Pages); + void flowRender(); void putProfileImage(QRect box, QRect viewPort, QPainter *painter, struct dive *dive, QPointer profile); private slots: From c862636cf049321d73508ea10fe823aed64affa9 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Thu, 13 Aug 2015 23:23:33 +0200 Subject: [PATCH 30/35] Printing: add 'dontbreak' css class to dives Prevent breaking the dives in flowlayout, and the rows in the table template. They should have the 'dontbreak' css selector. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- printing_templates/Flowlayout.html | 2 +- printing_templates/Table.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/printing_templates/Flowlayout.html b/printing_templates/Flowlayout.html index cb136c3f2..a69494ce3 100644 --- a/printing_templates/Flowlayout.html +++ b/printing_templates/Flowlayout.html @@ -98,7 +98,7 @@
{% block main_rows %} {% for dive in dives %} -
+
diff --git a/printing_templates/Table.html b/printing_templates/Table.html index 173904faf..e4d921fae 100644 --- a/printing_templates/Table.html +++ b/printing_templates/Table.html @@ -66,7 +66,7 @@ {% block main_rows %} {% for dive in dives %} - + {{ dive.number }} {{ dive.date }} {{ dive.time }} From 4f9349f5487d59627b8b27875275c70c7fc913b1 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Thu, 13 Aug 2015 23:38:20 +0200 Subject: [PATCH 31/35] Printing: use the same background for all the data cells flow layout Dive notes should have the same background as the remaining data cells. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- printing_templates/Flowlayout.html | 2 +- printing_templates/One Dive.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/printing_templates/Flowlayout.html b/printing_templates/Flowlayout.html index a69494ce3..2615c35a8 100644 --- a/printing_templates/Flowlayout.html +++ b/printing_templates/Flowlayout.html @@ -195,7 +195,7 @@ - +

{{ dive.notes }}

diff --git a/printing_templates/One Dive.html b/printing_templates/One Dive.html index 0014c4680..020c67b30 100644 --- a/printing_templates/One Dive.html +++ b/printing_templates/One Dive.html @@ -208,7 +208,7 @@ - +

{{ dive.notes }}

From 2d360e8a6d99b510f06d42a1590ecafe7c3c7896 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Fri, 14 Aug 2015 02:05:31 +0200 Subject: [PATCH 32/35] Printing: add table backgrounds and borders to six dives template Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- printing_templates/Six Dives.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/printing_templates/Six Dives.html b/printing_templates/Six Dives.html index 5b2652f05..3f2c7b95e 100644 --- a/printing_templates/Six Dives.html +++ b/printing_templates/Six Dives.html @@ -8,6 +8,7 @@ font-size: {{ template_options.font_size }}vw; line-height: {{ template_options.line_spacing }}; font-family: {{ template_options.font }}; + color: {{ template_options.color4 }}; } h1 { @@ -69,6 +70,8 @@ border-style:solid; border-color: {{ template_options.color6 }}; font-size: {{ template_options.font_size }}vw; + background-color: {{ template_options.color3 }}; + color: {{ template_options.color4 }}; } .notes_table_class { From f7fcc96bff2ca9965a4edfd61524a13cb5e2c183 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Fri, 14 Aug 2015 21:15:07 +0200 Subject: [PATCH 33/35] Printing: enhance 2 dives template - Add more text padding on the left - Reduce the width of the profile so that the padding on the right of it is equal to the padding bottom from it. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- printing_templates/Two Dives.html | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/printing_templates/Two Dives.html b/printing_templates/Two Dives.html index 13cb5cff6..95cc9a088 100644 --- a/printing_templates/Two Dives.html +++ b/printing_templates/Two Dives.html @@ -45,6 +45,7 @@ .table_class { overflow: hidden; width: 25%; + height: 99%; margin: 0.5%; float: left; -webkit-box-sizing: border-box; @@ -58,7 +59,6 @@ overflow: hidden; width: 99%; margin: 0.5%; - float: left; -webkit-box-sizing: border-box; box-sizing: border-box; border-width: {{ template_options.borderwidth }}px; @@ -69,23 +69,20 @@ .fieldTitle { background-color: {{ template_options.color2 }}; color: {{ template_options.color4 }}; - overflow: hidden; - padding:0; + padding-left: 2%; } .fieldData { color: {{ template_options.color5 }}; background-color: {{ template_options.color3 }}; + padding-left: 2%; } .diveProfile { - width: 48%; - height: 95%; - margin-left: 0%; - margin-right: 0%; - margin-bottom: 0%; - margin-top: 0.5%; - float: right; + float: left; + height: 99%; + width: 47%; + margin: 0.5%; } .diveDetails { @@ -94,12 +91,16 @@ } .dataPart { - height: 45%; - max-height: 60%; + height: 64%; + padding-bottom: 1%; + width: 100%; + float: left; } .notesPart { height: 35%; + width: 100%; + float: left; } .textArea { @@ -213,7 +214,7 @@
- @@ -232,7 +233,7 @@ {% endfor %} {% endblock %} From 5892fb576272214410764ea542189799d896e4bf Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Fri, 14 Aug 2015 21:37:12 +0200 Subject: [PATCH 34/35] Printing: fill the QPainter background color before rendering While rendering a dynamically sized view port, it may not fit the full page size, But the background color should be the same for the whole page, So fill the page background color with the template background color before rendering. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- printer.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/printer.cpp b/printer.cpp index 5d7adcacc..b9f9b3363 100644 --- a/printer.cpp +++ b/printer.cpp @@ -75,6 +75,10 @@ void Printer::flowRender() // One more element can be placed end = dontbreakElement.geometry().y() + dontbreakElement.geometry().height(); } else { + // fill the page with background color + QRect fullPage(0, 0, pageSize.width(), pageSize.height()); + QBrush fillBrush(templateOptions->color_palette.color1); + painter.fillRect(fullPage, fillBrush); QRegion reigon(0, 0, pageSize.width(), end - start); viewPort.setRect(0, start, pageSize.width(), end - start); @@ -91,6 +95,9 @@ void Printer::flowRender() } } // render the remianing page + QRect fullPage(0, 0, pageSize.width(), pageSize.height()); + QBrush fillBrush(templateOptions->color_palette.color1); + painter.fillRect(fullPage, fillBrush); QRegion reigon(0, 0, pageSize.width(), end - start); webView->page()->mainFrame()->render(&painter, QWebFrame::ContentsLayer, reigon); From f3c5699714e43e91c8ff8f66119da454b314264d Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Fri, 14 Aug 2015 22:24:48 +0200 Subject: [PATCH 35/35] Printing: remove silly white line at end of each page QPrinter::pageRect() doesn't always return the correct value of the printable area, which results in white horizontal lines of un-rendered area at the bottom of each page, Use QPrinter::pageLayout() instead which fixes the issue. QPrinter::pageLayout() is added in QT 5.3, So use pageRect for previous versions. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Gehad elrobey --- printer.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/printer.cpp b/printer.cpp index b9f9b3363..b0caa0815 100644 --- a/printer.cpp +++ b/printer.cpp @@ -194,8 +194,13 @@ void Printer::print() connect(&t, SIGNAL(progressUpdated(int)), this, SLOT(templateProgessUpdated(int))); dpi = printerPtr->resolution(); //rendering resolution = selected paper size in inchs * printer dpi +#if QT_VERSION >= 0x050300 + pageSize.setHeight(printerPtr->pageLayout().paintRectPixels(dpi).height()); + pageSize.setWidth(printerPtr->pageLayout().paintRectPixels(dpi).width()); +#else pageSize.setHeight(printerPtr->pageRect(QPrinter::Inch).height() * dpi); pageSize.setWidth(printerPtr->pageRect(QPrinter::Inch).width() * dpi); +#endif webView->page()->setViewportSize(pageSize); webView->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); // export border width with at least 1 pixel
+

Notes