mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
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>
This commit is contained in:
parent
c44496e23d
commit
cc53dc7acf
3 changed files with 23 additions and 0 deletions
|
@ -110,4 +110,5 @@ void PrintOptions::on_editButton_clicked()
|
||||||
{
|
{
|
||||||
TemplateEdit te(this, printOptions, templateOptions);
|
TemplateEdit te(this, printOptions, templateOptions);
|
||||||
te.exec();
|
te.exec();
|
||||||
|
setup();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,16 @@ TemplateEdit::TemplateEdit(QWidget *parent, struct print_options *printOptions,
|
||||||
ui->fontsize->setValue(templateOptions->font_size);
|
ui->fontsize->setValue(templateOptions->font_size);
|
||||||
ui->colorpalette->setCurrentIndex(templateOptions->color_palette_index);
|
ui->colorpalette->setCurrentIndex(templateOptions->color_palette_index);
|
||||||
ui->linespacing->setValue(templateOptions->line_spacing);
|
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()
|
TemplateEdit::~TemplateEdit()
|
||||||
|
@ -41,3 +51,11 @@ void TemplateEdit::on_colorpalette_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
templateOptions->color_palette_index = 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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define TEMPLATEEDIT_H
|
#define TEMPLATEEDIT_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include "templatelayout.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class TemplateEdit;
|
class TemplateEdit;
|
||||||
|
@ -23,10 +24,13 @@ private slots:
|
||||||
|
|
||||||
void on_colorpalette_currentIndexChanged(int index);
|
void on_colorpalette_currentIndexChanged(int index);
|
||||||
|
|
||||||
|
void on_TemplateEdit_finished(int result);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::TemplateEdit *ui;
|
Ui::TemplateEdit *ui;
|
||||||
struct template_options *templateOptions;
|
struct template_options *templateOptions;
|
||||||
struct print_options *printOptions;
|
struct print_options *printOptions;
|
||||||
|
QString grantlee_template;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TEMPLATEEDIT_H
|
#endif // TEMPLATEEDIT_H
|
||||||
|
|
Loading…
Reference in a new issue