From 71561e720dbfd85b3cb724dd1eb509b0d230d5db Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Mon, 29 Jun 2015 03:24:29 +0200 Subject: Printing: add QSettings for TemplateEdit class TemplateOptions struct must be saved to QSettings after the window is closed, also it must be recalled when initializing the window. Signed-off-by: Gehad elrobey Signed-off-by: Lubomir I. Ivanov --- qt-ui/printdialog.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'qt-ui/printdialog.cpp') diff --git a/qt-ui/printdialog.cpp b/qt-ui/printdialog.cpp index 341a84083..23c6f225e 100644 --- a/qt-ui/printdialog.cpp +++ b/qt-ui/printdialog.cpp @@ -23,6 +23,10 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f printOptions.landscape = false; printOptions.p_template = print_options::ONE_DIVE; printOptions.type = print_options::DIVELIST; + templateOptions.font_index = 0; + templateOptions.font_size = 9; + templateOptions.color_palette_index = 0; + templateOptions.line_spacing = 1; } else { s.beginGroup(SETTINGS_GROUP); printOptions.type = (print_options::print_type)s.value("type").toInt(); @@ -31,6 +35,10 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f printOptions.landscape = s.value("landscape").toBool(); printOptions.p_template = (print_options::print_template)s.value("template_selected").toInt(); qprinter.setOrientation((QPrinter::Orientation)printOptions.landscape); + templateOptions.font_index = s.value("font").toInt(); + templateOptions.font_size = s.value("font_size").toDouble(); + templateOptions.color_palette_index = s.value("color_palette").toInt(); + templateOptions.line_spacing = s.value("line_spacing").toDouble(); } // create a print options object and pass our options struct @@ -83,13 +91,20 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f void PrintDialog::onFinished() { - // save the settings QSettings s; s.beginGroup(SETTINGS_GROUP); + + // save print paper settings s.setValue("type", printOptions.type); s.setValue("print_selected", printOptions.print_selected); s.setValue("color_selected", printOptions.color_selected); s.setValue("template_selected", printOptions.p_template); + + // save template settings + s.setValue("font", templateOptions.font_index); + s.setValue("font_size", templateOptions.font_size); + s.setValue("color_palette", templateOptions.color_palette_index); + s.setValue("line_spacing", templateOptions.line_spacing); } void PrintDialog::previewClicked(void) -- cgit v1.2.3-70-g09d2