Gui: default implementation of MDIView::print(), MDIView::printPdf() and MDIView::printPreview()
This commit is contained in:
@@ -28,6 +28,8 @@
|
||||
# include <QEvent>
|
||||
# include <QCloseEvent>
|
||||
# include <QMdiSubWindow>
|
||||
# include <QPrintDialog>
|
||||
# include <QPrintPreviewDialog>
|
||||
# include <QPrinter>
|
||||
# include <QPrinterInfo>
|
||||
# include <QRegularExpression>
|
||||
@@ -41,6 +43,7 @@
|
||||
#include "MDIViewPy.h"
|
||||
#include "Application.h"
|
||||
#include "Document.h"
|
||||
#include "FileDialog.h"
|
||||
#include "MainWindow.h"
|
||||
#include "ViewProviderDocumentObject.h"
|
||||
|
||||
@@ -236,17 +239,33 @@ void MDIView::print(QPrinter* printer)
|
||||
|
||||
void MDIView::print()
|
||||
{
|
||||
std::cerr << "Printing not implemented for " << this->metaObject()->className() << std::endl;
|
||||
QPrinter printer(QPrinter::ScreenResolution);
|
||||
printer.setFullPage(true);
|
||||
QPrintDialog dlg(&printer, this);
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
print(&printer);
|
||||
}
|
||||
}
|
||||
|
||||
void MDIView::printPdf()
|
||||
{
|
||||
std::cerr << "Printing PDF not implemented for " << this->metaObject()->className() << std::endl;
|
||||
QString filename = FileDialog::getSaveFileName(this, tr("Export PDF"), QString(),
|
||||
QString::fromLatin1("%1 (*.pdf)").arg(tr("PDF file")));
|
||||
if (!filename.isEmpty()) {
|
||||
QPrinter printer(QPrinter::ScreenResolution);
|
||||
printer.setOutputFormat(QPrinter::PdfFormat);
|
||||
printer.setOutputFileName(filename);
|
||||
print(&printer);
|
||||
}
|
||||
}
|
||||
|
||||
void MDIView::printPreview()
|
||||
{
|
||||
std::cerr << "Printing preview not implemented for " << this->metaObject()->className() << std::endl;
|
||||
QPrinter printer(QPrinter::ScreenResolution);
|
||||
QPrintPreviewDialog dlg(&printer, this);
|
||||
connect(&dlg, SIGNAL(paintRequested (QPrinter *)),
|
||||
this, SLOT(print(QPrinter *)));
|
||||
dlg.exec();
|
||||
}
|
||||
|
||||
void MDIView::savePrinterSettings(QPrinter* printer)
|
||||
|
||||
Reference in New Issue
Block a user