Printing: update preview on apply settings

On update call Printer to render on the QPixmap.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
Gehad elrobey 2015-07-11 12:50:14 +02:00 committed by Lubomir I. Ivanov
parent f1615e725c
commit d705cb34bb
2 changed files with 12 additions and 5 deletions

View file

@ -29,7 +29,16 @@ TemplateEdit::TemplateEdit(QWidget *parent, struct print_options *printOptions,
}
ui->plainTextEdit->setPlainText(grantlee_template);
updatePreview();
}
TemplateEdit::~TemplateEdit()
{
delete ui;
}
void TemplateEdit::updatePreview()
{
int width = ui->label->width();
int height = ui->label->height();
QPixmap map(width * 2, height * 2);
@ -39,11 +48,6 @@ TemplateEdit::TemplateEdit(QWidget *parent, struct print_options *printOptions,
ui->label->setPixmap(map.scaled(width, height, Qt::IgnoreAspectRatio));
}
TemplateEdit::~TemplateEdit()
{
delete ui;
}
void TemplateEdit::on_fontsize_valueChanged(int font_size)
{
newTemplateOptions.font_size = font_size;
@ -90,6 +94,7 @@ void TemplateEdit::on_buttonBox_clicked(QAbstractButton *button)
break;
case QDialogButtonBox::Apply:
saveSettings();
updatePreview();
break;
}
}

View file

@ -33,6 +33,8 @@ private:
struct print_options *printOptions;
QString grantlee_template;
void saveSettings();
void updatePreview();
};
#endif // TEMPLATEEDIT_H