mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
d4382c7c4b
commit
7ca311ae85
3 changed files with 14 additions and 5 deletions
|
@ -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());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue