Hello, I have fixed the 3 late patches and added one more patch for style fixing.
-- regards, Gehad
From ee86aebe3498debae579db10bc5d3f51f44dd64d Mon Sep 17 00:00:00 2001 From: Gehad elrobey <[email protected]> Date: Thu, 27 Aug 2015 22:40:04 +0200 Subject: [PATCH 1/4] Printing: support in-place editing for templates Edit the templates into the same file, which is more intuitive as Custom.html is a bit confusing. Signed-off-by: Gehad elrobey <[email protected]> --- printing_templates/Custom.html | 50 ------------------------------------------ qt-ui/templateedit.cpp | 6 +++-- 2 files changed, 4 insertions(+), 52 deletions(-) delete mode 100644 printing_templates/Custom.html diff --git a/printing_templates/Custom.html b/printing_templates/Custom.html deleted file mode 100644 index 52fdb4b..0000000 --- a/printing_templates/Custom.html +++ /dev/null @@ -1,50 +0,0 @@ -<html> -<head> - <style> - body { - background-color: white; - padding: 0; - margin: 0; - font-size: {{ template_options.font_size }}vw; - line-height: {{ template_options.line_spacing }}; - font-family: {{ template_options.font }}; - } - - h1 { - float: left; - font-size: {{ template_options.font_size }}vw; - } - - .mainContainer { - width: 96%; - height: 100%; - margin-left: 2%; - margin-right: 2%; - margin-top: 0%; - margin-bottom: 0%; - overflow: hidden; - border-width: 0; - page-break-inside: avoid; - } - - .innerContainer { - width: 98%; - height: 98%; - padding: 1%; - overflow: hidden; - } - </style> -</head> -<body data-numberofdives = 1> -{% block main_rows %} - {% for dive in dives %} - <div class="mainContainer"> - <div class="innerContainer"> - <h1>This template is empty</h1> - <!-- Template must be filled --> - </div> - </div> - {% endfor %} -{% endblock %} -</body> -</html> diff --git a/qt-ui/templateedit.cpp b/qt-ui/templateedit.cpp index b503380..7ca84c8 100644 --- a/qt-ui/templateedit.cpp +++ b/qt-ui/templateedit.cpp @@ -75,6 +75,9 @@ void TemplateEdit::updatePreview() // update critical UI elements ui->colorpalette->setCurrentIndex(newTemplateOptions.color_palette_index); + + // update grantlee template string + grantlee_template = TemplateLayout::readTemplate(printOptions->p_template); } void TemplateEdit::on_fontsize_valueChanged(int font_size) @@ -128,8 +131,7 @@ void TemplateEdit::saveSettings() if (msgBox.exec() == QMessageBox::Save) { memcpy(templateOptions, &newTemplateOptions, sizeof(struct template_options)); if (grantlee_template.compare(ui->plainTextEdit->toPlainText())) { - printOptions->p_template = "Custom.html"; - TemplateLayout::writeTemplate("Custom.html", ui->plainTextEdit->toPlainText()); + TemplateLayout::writeTemplate(printOptions->p_template, ui->plainTextEdit->toPlainText()); } if (templateOptions->color_palette_index == CUSTOM) { custom_colors = templateOptions->color_palette; -- 2.5.2
From 71955873624eb5468f8cdd19ce2e4b3cf01d7c87 Mon Sep 17 00:00:00 2001 From: Gehad elrobey <[email protected]> Date: Wed, 16 Sep 2015 20:44:58 -0300 Subject: [PATCH 2/4] Printing: show warning message when editing bundled templates When editing a bundled template show warning message. Signed-off-by: Gehad elrobey <[email protected]> --- qt-ui/templateedit.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/qt-ui/templateedit.cpp b/qt-ui/templateedit.cpp index 7ca84c8..0fa8b97 100644 --- a/qt-ui/templateedit.cpp +++ b/qt-ui/templateedit.cpp @@ -123,14 +123,24 @@ void TemplateEdit::on_colorpalette_currentIndexChanged(int index) void TemplateEdit::saveSettings() { + QStringList bundledTemplates; + bundledTemplates << "Flowlayout.html" << "One Dive.html" << "Six Dives.html" << "Table.html" << "Two Dives.html"; if ((*templateOptions) != newTemplateOptions || grantlee_template.compare(ui->plainTextEdit->toPlainText())) { QMessageBox msgBox; - msgBox.setText("Do you want to save your changes?"); + QString message = "Do you want to save your changes?"; + bool templateChanged = false; + if (grantlee_template.compare(ui->plainTextEdit->toPlainText())) { + if (bundledTemplates.contains(printOptions->p_template)) { + message = "You are about to modify a template bundled with Subsurface. Do you want to save your changes?"; + } + templateChanged = true; + } + msgBox.setText(message); msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Cancel); msgBox.setDefaultButton(QMessageBox::Cancel); if (msgBox.exec() == QMessageBox::Save) { memcpy(templateOptions, &newTemplateOptions, sizeof(struct template_options)); - if (grantlee_template.compare(ui->plainTextEdit->toPlainText())) { + if (templateChanged) { TemplateLayout::writeTemplate(printOptions->p_template, ui->plainTextEdit->toPlainText()); } if (templateOptions->color_palette_index == CUSTOM) { -- 2.5.2
From 0723f8d84eb258bb6c40f0698fa8848f492c8468 Mon Sep 17 00:00:00 2001 From: Gehad elrobey <[email protected]> Date: Wed, 16 Sep 2015 21:32:32 -0300 Subject: [PATCH 3/4] Printing: make statistics template editable Now inplace edit is supported, so enable editing the "Default" statistics template, Also show warning when editing this template. Signed-off-by: Gehad elrobey <[email protected]> --- qt-ui/templateedit.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/qt-ui/templateedit.cpp b/qt-ui/templateedit.cpp index 0fa8b97..b3ef5b8 100644 --- a/qt-ui/templateedit.cpp +++ b/qt-ui/templateedit.cpp @@ -22,6 +22,11 @@ TemplateEdit::TemplateEdit(QWidget *parent, struct print_options *printOptions, ui->linespacing->setValue(templateOptions->line_spacing); grantlee_template = TemplateLayout::readTemplate(printOptions->p_template); + if (printOptions->type == print_options::DIVELIST) { + grantlee_template = TemplateLayout::readTemplate(printOptions->p_template); + } else if (printOptions->type == print_options::STATISTICS) { + grantlee_template = TemplateLayout::readTemplate(QString::fromUtf8("statistics") + QDir::separator() + printOptions->p_template); + } // gui btnGroup = new QButtonGroup; @@ -35,9 +40,6 @@ TemplateEdit::TemplateEdit(QWidget *parent, struct print_options *printOptions, ui->plainTextEdit->setPlainText(grantlee_template); editingCustomColors = false; - if (printOptions->type == print_options::STATISTICS) { - ui->plainTextEdit->setEnabled(false); - } updatePreview(); } @@ -78,6 +80,11 @@ void TemplateEdit::updatePreview() // update grantlee template string grantlee_template = TemplateLayout::readTemplate(printOptions->p_template); + if (printOptions->type == print_options::DIVELIST) { + grantlee_template = TemplateLayout::readTemplate(printOptions->p_template); + } else if (printOptions->type == print_options::STATISTICS) { + grantlee_template = TemplateLayout::readTemplate(QString::fromUtf8("statistics") + QDir::separator() + printOptions->p_template); + } } void TemplateEdit::on_fontsize_valueChanged(int font_size) @@ -130,7 +137,7 @@ void TemplateEdit::saveSettings() QString message = "Do you want to save your changes?"; bool templateChanged = false; if (grantlee_template.compare(ui->plainTextEdit->toPlainText())) { - if (bundledTemplates.contains(printOptions->p_template)) { + if (bundledTemplates.contains(printOptions->p_template) || (printOptions->p_template == "Default.html" && printOptions->type == print_options::STATISTICS)) { message = "You are about to modify a template bundled with Subsurface. Do you want to save your changes?"; } templateChanged = true; @@ -142,6 +149,11 @@ void TemplateEdit::saveSettings() memcpy(templateOptions, &newTemplateOptions, sizeof(struct template_options)); if (templateChanged) { TemplateLayout::writeTemplate(printOptions->p_template, ui->plainTextEdit->toPlainText()); + if (printOptions->type == print_options::DIVELIST) { + TemplateLayout::writeTemplate(printOptions->p_template, ui->plainTextEdit->toPlainText()); + } else if (printOptions->type == print_options::STATISTICS) { + TemplateLayout::writeTemplate(QString::fromUtf8("statistics") + QDir::separator() + printOptions->p_template, ui->plainTextEdit->toPlainText()); + } } if (templateOptions->color_palette_index == CUSTOM) { custom_colors = templateOptions->color_palette; -- 2.5.2
From b441b100e8070d8366e0b35ef545e08b40dc3397 Mon Sep 17 00:00:00 2001 From: Gehad elrobey <[email protected]> Date: Wed, 16 Sep 2015 22:09:05 -0300 Subject: [PATCH 4/4] Printing: Remove braces around single lines in if/then Remove useless braces around single line if/then. Signed-off-by: Gehad elrobey <[email protected]> --- qt-ui/templateedit.cpp | 44 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/qt-ui/templateedit.cpp b/qt-ui/templateedit.cpp index b3ef5b8..267b67a 100644 --- a/qt-ui/templateedit.cpp +++ b/qt-ui/templateedit.cpp @@ -22,11 +22,10 @@ TemplateEdit::TemplateEdit(QWidget *parent, struct print_options *printOptions, ui->linespacing->setValue(templateOptions->line_spacing); grantlee_template = TemplateLayout::readTemplate(printOptions->p_template); - if (printOptions->type == print_options::DIVELIST) { + if (printOptions->type == print_options::DIVELIST) grantlee_template = TemplateLayout::readTemplate(printOptions->p_template); - } else if (printOptions->type == print_options::STATISTICS) { + else if (printOptions->type == print_options::STATISTICS) grantlee_template = TemplateLayout::readTemplate(QString::fromUtf8("statistics") + QDir::separator() + printOptions->p_template); - } // gui btnGroup = new QButtonGroup; @@ -80,11 +79,10 @@ void TemplateEdit::updatePreview() // update grantlee template string grantlee_template = TemplateLayout::readTemplate(printOptions->p_template); - if (printOptions->type == print_options::DIVELIST) { + if (printOptions->type == print_options::DIVELIST) grantlee_template = TemplateLayout::readTemplate(printOptions->p_template); - } else if (printOptions->type == print_options::STATISTICS) { + else if (printOptions->type == print_options::STATISTICS) grantlee_template = TemplateLayout::readTemplate(QString::fromUtf8("statistics") + QDir::separator() + printOptions->p_template); - } } void TemplateEdit::on_fontsize_valueChanged(int font_size) @@ -137,9 +135,8 @@ void TemplateEdit::saveSettings() QString message = "Do you want to save your changes?"; bool templateChanged = false; if (grantlee_template.compare(ui->plainTextEdit->toPlainText())) { - if (bundledTemplates.contains(printOptions->p_template) || (printOptions->p_template == "Default.html" && printOptions->type == print_options::STATISTICS)) { + if (bundledTemplates.contains(printOptions->p_template) || (printOptions->p_template == "Default.html" && printOptions->type == print_options::STATISTICS)) message = "You are about to modify a template bundled with Subsurface. Do you want to save your changes?"; - } templateChanged = true; } msgBox.setText(message); @@ -149,15 +146,13 @@ void TemplateEdit::saveSettings() memcpy(templateOptions, &newTemplateOptions, sizeof(struct template_options)); if (templateChanged) { TemplateLayout::writeTemplate(printOptions->p_template, ui->plainTextEdit->toPlainText()); - if (printOptions->type == print_options::DIVELIST) { + if (printOptions->type == print_options::DIVELIST) TemplateLayout::writeTemplate(printOptions->p_template, ui->plainTextEdit->toPlainText()); - } else if (printOptions->type == print_options::STATISTICS) { + else if (printOptions->type == print_options::STATISTICS) TemplateLayout::writeTemplate(QString::fromUtf8("statistics") + QDir::separator() + printOptions->p_template, ui->plainTextEdit->toPlainText()); - } } - if (templateOptions->color_palette_index == CUSTOM) { + if (templateOptions->color_palette_index == CUSTOM) custom_colors = templateOptions->color_palette; - } } } } @@ -203,35 +198,34 @@ void TemplateEdit::colorSelect(QAbstractButton *button) switch (btnGroup->id(button)) { case 1: color = QColorDialog::getColor(newTemplateOptions.color_palette.color1, this); - if (color.isValid()) { + if (color.isValid()) newTemplateOptions.color_palette.color1 = color; - } break; case 2: color = QColorDialog::getColor(newTemplateOptions.color_palette.color2, this); - if (color.isValid()) { + if (color.isValid()) newTemplateOptions.color_palette.color2 = color; - } break; + break; case 3: color = QColorDialog::getColor(newTemplateOptions.color_palette.color3, this); - if (color.isValid()) { + if (color.isValid()) newTemplateOptions.color_palette.color3 = color; - } break; + break; case 4: color = QColorDialog::getColor(newTemplateOptions.color_palette.color4, this); - if (color.isValid()) { + if (color.isValid()) newTemplateOptions.color_palette.color4 = color; - } break; + break; case 5: color = QColorDialog::getColor(newTemplateOptions.color_palette.color5, this); - if (color.isValid()) { + if (color.isValid()) newTemplateOptions.color_palette.color5 = color; - } break; + break; case 6: color = QColorDialog::getColor(newTemplateOptions.color_palette.color6, this); - if (color.isValid()) { + if (color.isValid()) newTemplateOptions.color_palette.color6 = color; - } break; + break; } newTemplateOptions.color_palette_index = CUSTOM; updatePreview(); -- 2.5.2
_______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
