aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Gehad elrobey <gehadelrobey@gmail.com>2015-06-29 03:24:29 +0200
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2015-07-05 21:00:28 +0300
commit71561e720dbfd85b3cb724dd1eb509b0d230d5db (patch)
treed7fedba86fd42877b766d8a4e719804a5e516676
parenta600ea5201f55a3182cb24a0553d02aefad2c51b (diff)
downloadsubsurface-71561e720dbfd85b3cb724dd1eb509b0d230d5db.tar.gz
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 <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
-rw-r--r--qt-ui/printdialog.cpp17
-rw-r--r--qt-ui/templateedit.cpp26
-rw-r--r--qt-ui/templateedit.h9
3 files changed, 51 insertions, 1 deletions
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)
diff --git a/qt-ui/templateedit.cpp b/qt-ui/templateedit.cpp
index 40e14c221..a4236d036 100644
--- a/qt-ui/templateedit.cpp
+++ b/qt-ui/templateedit.cpp
@@ -7,9 +7,35 @@ TemplateEdit::TemplateEdit(QWidget *parent, struct template_options *templateOpt
{
ui->setupUi(this);
this->templateOptions = templateOptions;
+
+ // restore the settings and init the UI
+ ui->fontSelection->setCurrentIndex(templateOptions->font_index);
+ ui->fontsize->setValue(templateOptions->font_size);
+ ui->colorpalette->setCurrentIndex(templateOptions->color_palette_index);
+ ui->linespacing->setValue(templateOptions->line_spacing);
}
TemplateEdit::~TemplateEdit()
{
delete ui;
}
+
+void TemplateEdit::on_fontsize_valueChanged(int font_size)
+{
+ templateOptions->font_size = font_size;
+}
+
+void TemplateEdit::on_linespacing_valueChanged(double line_spacing)
+{
+ templateOptions->line_spacing = line_spacing;
+}
+
+void TemplateEdit::on_fontSelection_currentIndexChanged(int index)
+{
+ templateOptions->font_index = index;
+}
+
+void TemplateEdit::on_colorpalette_currentIndexChanged(int index)
+{
+ templateOptions->color_palette_index = index;
+}
diff --git a/qt-ui/templateedit.h b/qt-ui/templateedit.h
index 2790c619b..73a5e9fbb 100644
--- a/qt-ui/templateedit.h
+++ b/qt-ui/templateedit.h
@@ -21,6 +21,15 @@ class TemplateEdit : public QDialog
public:
explicit TemplateEdit(QWidget *parent, struct template_options *templateOptions);
~TemplateEdit();
+private slots:
+ void on_fontsize_valueChanged(int font_size);
+
+ void on_linespacing_valueChanged(double line_spacing);
+
+ void on_fontSelection_currentIndexChanged(int index);
+
+ void on_colorpalette_currentIndexChanged(int index);
+
private:
Ui::TemplateEdit *ui;
struct template_options *templateOptions;