diff options
author | Gehad elrobey <gehadelrobey@gmail.com> | 2015-07-11 01:06:43 +0200 |
---|---|---|
committer | Lubomir I. Ivanov <neolit123@gmail.com> | 2015-07-20 15:28:07 +0300 |
commit | 7ca311ae859199f1e07279bf78e1c36efc97768c (patch) | |
tree | 97ae2718b5fcfe7a4e7b4c4018a0911c0d5e223a /qt-ui/templateedit.cpp | |
parent | d4382c7c4b802b030bab5e64de4b1641f603d543 (diff) | |
download | subsurface-7ca311ae859199f1e07279bf78e1c36efc97768c.tar.gz |
Printing: save only if data is changed in template_options
Check if data is changed before saving the new settings.
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 | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/qt-ui/templateedit.cpp b/qt-ui/templateedit.cpp index 19f5db609..0354131ef 100644 --- a/qt-ui/templateedit.cpp +++ b/qt-ui/templateedit.cpp @@ -11,6 +11,7 @@ TemplateEdit::TemplateEdit(QWidget *parent, struct print_options *printOptions, { ui->setupUi(this); this->templateOptions = templateOptions; + newTemplateOptions = *templateOptions; this->printOptions = printOptions; // restore the settings and init the UI @@ -45,32 +46,33 @@ TemplateEdit::~TemplateEdit() void TemplateEdit::on_fontsize_valueChanged(int font_size) { - templateOptions->font_size = font_size; + newTemplateOptions.font_size = font_size; } void TemplateEdit::on_linespacing_valueChanged(double line_spacing) { - templateOptions->line_spacing = line_spacing; + newTemplateOptions.line_spacing = line_spacing; } void TemplateEdit::on_fontSelection_currentIndexChanged(int index) { - templateOptions->font_index = index; + newTemplateOptions.font_index = index; } void TemplateEdit::on_colorpalette_currentIndexChanged(int index) { - templateOptions->color_palette_index = index; + newTemplateOptions.color_palette_index = index; } void TemplateEdit::on_TemplateEdit_finished(int result) { - if (grantlee_template.compare(ui->plainTextEdit->toPlainText())) { + if ((*templateOptions) != newTemplateOptions || grantlee_template.compare(ui->plainTextEdit->toPlainText())) { QMessageBox msgBox; msgBox.setText("Do you want to save your changes?"); msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard); msgBox.setDefaultButton(QMessageBox::Discard); if (msgBox.exec() == QMessageBox::Save) { + memcpy(templateOptions, &newTemplateOptions, sizeof(struct template_options)); printOptions->p_template = print_options::CUSTOM; TemplateLayout::writeTemplate("custom.html", ui->plainTextEdit->toPlainText()); } |