Actions print.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2015-04-11 18:16:30 +03:00
parent fc54866019
commit e97cceb65b
3 changed files with 29 additions and 1 deletions

View File

@ -42,6 +42,7 @@
#include <QPrinter>
#include <QGraphicsScene>
#include <QPrintPreviewDialog>
#include <QPrintDialog>
#include <QtCore/qmath.h>
#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<int>(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<int>(VApplication::PrintDPI));
Print( &printer );
}
}
//---------------------------------------------------------------------------------------------------------------------
void TableWindow::Layout()
{

View File

@ -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. */

View File

@ -193,11 +193,14 @@
</iconset>
</property>
<property name="text">
<string>Save</string>
<string>&amp;Save As...</string>
</property>
<property name="toolTip">
<string>Save layout</string>
</property>
<property name="shortcut">
<string>Ctrl+S</string>
</property>
</action>
<action name="actionStop">
<property name="icon">
@ -268,6 +271,9 @@
<property name="text">
<string>&amp;Print...</string>
</property>
<property name="shortcut">
<string>Ctrl+P</string>
</property>
</action>
<action name="actionSave_to_p_df">
<property name="enabled">