diff options
author | Gehad elrobey <gehadelrobey@gmail.com> | 2015-07-05 07:29:46 +0200 |
---|---|---|
committer | Lubomir I. Ivanov <neolit123@gmail.com> | 2015-07-05 21:03:12 +0300 |
commit | cc53dc7acf801f022612678f697e6d76c2443153 (patch) | |
tree | 6eabb01a37ec3d39db9956b764ab2ce58681bab6 /qt-ui/templateedit.cpp | |
parent | c44496e23d3e16ec6b5622eea73ae39d991e27bf (diff) | |
download | subsurface-cc53dc7acf801f022612678f697e6d76c2443153.tar.gz |
Printing: implement QPlainTextEdit in TemplateEdit
This is the main area to edit the templates inside Subsurface.
Whenever the user edits a template the edited template is saved in
custom.html and custom.html is considered the selected printing
template.
Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Diffstat (limited to 'qt-ui/templateedit.cpp')
-rw-r--r-- | qt-ui/templateedit.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/qt-ui/templateedit.cpp b/qt-ui/templateedit.cpp index aecfdc434..82a71ea32 100644 --- a/qt-ui/templateedit.cpp +++ b/qt-ui/templateedit.cpp @@ -15,6 +15,16 @@ TemplateEdit::TemplateEdit(QWidget *parent, struct print_options *printOptions, ui->fontsize->setValue(templateOptions->font_size); ui->colorpalette->setCurrentIndex(templateOptions->color_palette_index); ui->linespacing->setValue(templateOptions->line_spacing); + + if (printOptions->p_template == print_options::ONE_DIVE) { + grantlee_template = TemplateLayout::readTemplate("one_dive.html"); + } else if (printOptions->p_template == print_options::TWO_DIVE) { + grantlee_template = TemplateLayout::readTemplate("two_dives.html"); + } else if (printOptions->p_template == print_options::CUSTOM) { + grantlee_template = TemplateLayout::readTemplate("custom.html"); + } + + ui->plainTextEdit->setPlainText(grantlee_template); } TemplateEdit::~TemplateEdit() @@ -41,3 +51,11 @@ void TemplateEdit::on_colorpalette_currentIndexChanged(int index) { templateOptions->color_palette_index = index; } + +void TemplateEdit::on_TemplateEdit_finished(int result) +{ + if (grantlee_template.compare(ui->plainTextEdit->toPlainText())) { + printOptions->p_template = print_options::CUSTOM; + TemplateLayout::writeTemplate("custom.html", ui->plainTextEdit->toPlainText()); + } +} |