Printing: add QPrintPreviewDialog to main dialog

Add preview dialog that shows the printer contents before printing.

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-06-21 04:59:15 +02:00 committed by Lubomir I. Ivanov
parent 74e2956986
commit bc0b443afd

View file

@ -93,6 +93,11 @@ void PrintDialog::onFinished()
void PrintDialog::previewClicked(void) void PrintDialog::previewClicked(void)
{ {
QPrintPreviewDialog previewDialog(&qprinter, this, Qt::Window
| Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint
| Qt::WindowTitleHint);
connect(&previewDialog, SIGNAL(paintRequested(QPrinter *)), this, SLOT(onPaintRequested(QPrinter *)));
previewDialog.exec();
} }
void PrintDialog::printClicked(void) void PrintDialog::printClicked(void)
@ -115,5 +120,9 @@ void PrintDialog::printClicked(void)
void PrintDialog::onPaintRequested(QPrinter *printerPtr) void PrintDialog::onPaintRequested(QPrinter *printerPtr)
{ {
connect(printer, SIGNAL(progessUpdated(int)), progressBar, SLOT(setValue(int)));
printer->print();
progressBar->setValue(0);
disconnect(printer, SIGNAL(progessUpdated(int)), progressBar, SLOT(setValue(int)));
} }
#endif #endif