mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-01 00:23:23 +00:00
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>
This commit is contained in:
parent
a600ea5201
commit
71561e720d
3 changed files with 51 additions and 1 deletions
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue