summaryrefslogtreecommitdiffstats
path: root/qt-ui/templateedit.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-07-05 12:01:43 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-07-05 12:01:43 -0700
commit9c6a3a7ff387578ddede2e69d8b994a11cf8eaee (patch)
tree72a08592a24d8d3d1f4fc7d7713da8029bc80c3f /qt-ui/templateedit.cpp
parent35dc81410518e6d39ba8b3f99348884778bedc5b (diff)
parentcc53dc7acf801f022612678f697e6d76c2443153 (diff)
downloadsubsurface-9c6a3a7ff387578ddede2e69d8b994a11cf8eaee.tar.gz
Merge branch 'custom-print' of github.com:neolit123/subsurface
Diffstat (limited to 'qt-ui/templateedit.cpp')
-rw-r--r--qt-ui/templateedit.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/qt-ui/templateedit.cpp b/qt-ui/templateedit.cpp
new file mode 100644
index 000000000..82a71ea32
--- /dev/null
+++ b/qt-ui/templateedit.cpp
@@ -0,0 +1,61 @@
+#include "templateedit.h"
+#include "printoptions.h"
+#include "ui_templateedit.h"
+
+TemplateEdit::TemplateEdit(QWidget *parent, struct print_options *printOptions, struct template_options *templateOptions) :
+ QDialog(parent),
+ ui(new Ui::TemplateEdit)
+{
+ ui->setupUi(this);
+ this->templateOptions = templateOptions;
+ this->printOptions = printOptions;
+
+ // restore the settings and init the UI
+ ui->fontSelection->setCurrentIndex(templateOptions->font_index);
+ 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()
+{
+ delete ui;
+}
+
+void TemplateEdit::on_fontsize_valueChanged(int font_size)
+{
+ templateOptions->font_size = font_size;
+}
+
+void TemplateEdit::on_linespacing_valueChanged(double line_spacing)
+{
+ templateOptions->line_spacing = line_spacing;
+}
+
+void TemplateEdit::on_fontSelection_currentIndexChanged(int index)
+{
+ templateOptions->font_index = index;
+}
+
+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());
+ }
+}