From bc0b443afd73e0bc7c18b293d051aa01bf82d99f Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Sun, 21 Jun 2015 04:59:15 +0200 Subject: Printing: add QPrintPreviewDialog to main dialog Add preview dialog that shows the printer contents before printing. Signed-off-by: Gehad elrobey Signed-off-by: Lubomir I. Ivanov --- qt-ui/printdialog.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/qt-ui/printdialog.cpp b/qt-ui/printdialog.cpp index 6f30f89f5..9949b104d 100644 --- a/qt-ui/printdialog.cpp +++ b/qt-ui/printdialog.cpp @@ -93,6 +93,11 @@ void PrintDialog::onFinished() 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) @@ -115,5 +120,9 @@ void PrintDialog::printClicked(void) 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 -- cgit v1.2.3-70-g09d2