From 55f09f01069cdfbb4b366824916409b66ddc11f5 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Tue, 28 Jul 2015 21:55:23 +0200 Subject: 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(-) (limited to 'qt-ui') 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(); -- cgit v1.2.3-70-g09d2 From dd7bae378e6463f5a4125f7b51a41ab6c0407578 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Wed, 29 Jul 2015 19:35:08 +0200 Subject: 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(-) (limited to 'qt-ui') 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; } } -- cgit v1.2.3-70-g09d2 From 1d22bdc08c04d3726154a5975ff5314c4f290c9d Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Wed, 29 Jul 2015 19:49:50 +0200 Subject: 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(-) (limited to 'qt-ui') 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; -- cgit v1.2.3-70-g09d2 From 88c19adc7880d21aed4fa0e498d0291c5fd9f9d4 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Mon, 3 Aug 2015 22:55:46 +0200 Subject: 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(+) (limited to 'qt-ui') 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); -- cgit v1.2.3-70-g09d2 From 1a2f154cf49041a223e5801328beb68cb8b42442 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Thu, 6 Aug 2015 20:39:38 +0200 Subject: 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(-) (limited to 'qt-ui') 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))); } -- cgit v1.2.3-70-g09d2 From 1dbe10fe278650430beca638976ea7df3b5c76fd Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Fri, 7 Aug 2015 09:54:09 +0200 Subject: 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(-) (limited to 'qt-ui') 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 -- cgit v1.2.3-70-g09d2 From 0fadfae754208589ffa5be7757f2e6a03e3c4902 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Fri, 7 Aug 2015 10:10:22 +0200 Subject: 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(-) (limited to 'qt-ui') 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); -- cgit v1.2.3-70-g09d2 From 519440111272bbeb0e56242de5c8a51bb55a73e6 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Fri, 7 Aug 2015 10:11:14 +0200 Subject: 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(-) (limited to 'qt-ui') 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; -- cgit v1.2.3-70-g09d2 From de889b90adb7489923f9f19e11a15256ea648b80 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Sun, 9 Aug 2015 17:41:43 +0200 Subject: 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(-) (limited to 'qt-ui') 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 -- cgit v1.2.3-70-g09d2 From 59eddc62594d2c8003349812456befeef82e1bc2 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Tue, 11 Aug 2015 22:50:27 +0200 Subject: 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(+) (limited to 'qt-ui') 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") { -- cgit v1.2.3-70-g09d2 From 31df69c401ad8995d8201242a1db1b74de19a18a Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Wed, 12 Aug 2015 00:57:19 +0200 Subject: 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(-) (limited to 'qt-ui') 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(); -- cgit v1.2.3-70-g09d2