Printing support #1525: add print preview dialog

This adds a print preview step before printing in the Database Structure
tab.

This is nice to have, but it also aims to work around the problem found in
Windows, reported at issue #760.
This commit is contained in:
mgr
2018-09-27 21:04:55 +02:00
parent ab991c5755
commit 54cf4cf140

View File

@@ -53,7 +53,7 @@
#include <QUrlQuery>
#include <QDataStream> // This include seems to only be necessary for the Windows build
#include <QPrinter>
#include <QPrintDialog>
#include <QPrintPreviewDialog>
#ifdef Q_OS_MACX //Needed only on macOS
#include <QOpenGLWidget>
@@ -3484,10 +3484,14 @@ void MainWindow::printDbStructure ()
document->setHtml(strStream);
QPrinter printer;
printer.setDocName(treeView->windowTitle());
QPrintDialog *dialog = new QPrintDialog(&printer);
if (dialog->exec() == QDialog::Accepted)
document->print(&printer);
QPrintPreviewDialog *dialog = new QPrintPreviewDialog(&printer);
connect(dialog, &QPrintPreviewDialog::paintRequested, [&](QPrinter *previewPrinter) {
document->print(previewPrinter);
});
dialog->exec();
delete dialog;
delete document;