Printing: add preview to TemplateEdit dialog

Show QPixmap in QLabel, Use Printer class to render the Preview 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-10 21:45:27 +02:00 committed by Lubomir I. Ivanov
parent 3a69638366
commit d4382c7c4b
4 changed files with 38 additions and 22 deletions

View file

@ -1,5 +1,6 @@
#include "templateedit.h"
#include "printoptions.h"
#include "printer.h"
#include "ui_templateedit.h"
#include <QMessageBox>
@ -27,6 +28,14 @@ TemplateEdit::TemplateEdit(QWidget *parent, struct print_options *printOptions,
}
ui->plainTextEdit->setPlainText(grantlee_template);
int width = ui->label->width();
int height = ui->label->height();
QPixmap map(width * 2, height * 2);
map.fill(QColor::fromRgb(255, 255, 255));
Printer printer(&map, printOptions, templateOptions, Printer::PREVIEW);
printer.previewOnePage();
ui->label->setPixmap(map.scaled(width, height, Qt::IgnoreAspectRatio));
}
TemplateEdit::~TemplateEdit()