From c90d5b891df873a6a69f5da618d42af998b4620f Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Tue, 7 Jul 2015 03:14:43 +0200 Subject: [PATCH] Printing: show confirmation message before overwriting the template Before overwriting the new template show confirmation message. Signed-off-by: Gehad elrobey Signed-off-by: Lubomir I. Ivanov --- qt-ui/templateedit.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/qt-ui/templateedit.cpp b/qt-ui/templateedit.cpp index 82a71ea32..0a8c4ca92 100644 --- a/qt-ui/templateedit.cpp +++ b/qt-ui/templateedit.cpp @@ -2,6 +2,8 @@ #include "printoptions.h" #include "ui_templateedit.h" +#include + TemplateEdit::TemplateEdit(QWidget *parent, struct print_options *printOptions, struct template_options *templateOptions) : QDialog(parent), ui(new Ui::TemplateEdit) @@ -55,7 +57,13 @@ void TemplateEdit::on_colorpalette_currentIndexChanged(int 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()); + 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) { + printOptions->p_template = print_options::CUSTOM; + TemplateLayout::writeTemplate("custom.html", ui->plainTextEdit->toPlainText()); + } } }