diff options
author | Gehad elrobey <gehadelrobey@gmail.com> | 2015-09-16 21:32:32 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-09-16 21:17:41 -0700 |
commit | bdedc97036d06cbc864a6edac8c4ac5b9ef9b05d (patch) | |
tree | ec6292582571a37533737f3b593fd468ac836cf9 /qt-ui/templateedit.cpp | |
parent | d3c75f2c72ba635eae8ea1df45b6ee9b2f4bb872 (diff) | |
download | subsurface-bdedc97036d06cbc864a6edac8c4ac5b9ef9b05d.tar.gz |
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 <gehadelrobey@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/templateedit.cpp')
-rw-r--r-- | qt-ui/templateedit.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/qt-ui/templateedit.cpp b/qt-ui/templateedit.cpp index 0fa8b97ac..b3ef5b8ec 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; |