diff --git a/src/app/tablewindow.cpp b/src/app/tablewindow.cpp index c7dc9c2f3..f6471f3a6 100644 --- a/src/app/tablewindow.cpp +++ b/src/app/tablewindow.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #ifdef Q_OS_WIN @@ -81,6 +82,7 @@ TableWindow::TableWindow(QWidget *parent) connect(ui->actionLayout, &QAction::triggered, this, &TableWindow::Layout); connect(ui->listWidget, &QListWidget::currentRowChanged, this, &TableWindow::ShowPaper); connect(ui->actionPrint_pre_view, &QAction::triggered, this, &TableWindow::PrintPreview); + connect(ui->action_Print, &QAction::triggered, this, &TableWindow::LayoutPrint); } //--------------------------------------------------------------------------------------------------------------------- @@ -274,7 +276,10 @@ void TableWindow::PrintPreview() QPrinter printer(def, QPrinter::ScreenResolution); printer.setResolution(static_cast(VApplication::PrintDPI)); + printer.setCreator(qApp->applicationDisplayName()+" "+qApp->applicationVersion()); + printer.setDocName(fileName); + // display print preview dialog QPrintPreviewDialog preview(&printer); connect(&preview, &QPrintPreviewDialog::paintRequested, this, &TableWindow::Print); preview.exec(); @@ -321,6 +326,21 @@ void TableWindow::Print(QPrinter *printer) painter.end(); } +//--------------------------------------------------------------------------------------------------------------------- +void TableWindow::LayoutPrint() +{ + // display print dialog and if accepted print + QPrinter printer; + printer.setCreator(qApp->applicationDisplayName()+" "+qApp->applicationVersion()); + printer.setDocName(fileName); + QPrintDialog dialog( &printer, this ); + if ( dialog.exec() == QDialog::Accepted ) + { + printer.setResolution(static_cast(VApplication::PrintDPI)); + Print( &printer ); + } +} + //--------------------------------------------------------------------------------------------------------------------- void TableWindow::Layout() { diff --git a/src/app/tablewindow.h b/src/app/tablewindow.h index 0a55e4f76..f7221a94f 100644 --- a/src/app/tablewindow.h +++ b/src/app/tablewindow.h @@ -42,6 +42,7 @@ namespace Ui class QGraphicsScene; class QGraphicsRectItem; +class QPrinter; /** * @brief TableWindow class layout window. @@ -61,6 +62,7 @@ public slots: void ShowPaper(int index); void PrintPreview(); void Print (QPrinter *printer); + void LayoutPrint(); signals: /** @brief closed emit if window is closing. */ diff --git a/src/app/tablewindow.ui b/src/app/tablewindow.ui index a3fdd5d31..d34e4f652 100644 --- a/src/app/tablewindow.ui +++ b/src/app/tablewindow.ui @@ -193,11 +193,14 @@ - Save + &Save As... Save layout + + Ctrl+S + @@ -268,6 +271,9 @@ &Print... + + Ctrl+P +