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 <QPrinter>
#include <QGraphicsScene> #include <QGraphicsScene>
#include <QPrintPreviewDialog> #include <QPrintPreviewDialog>
#include <QPrintDialog>
#include <QtCore/qmath.h> #include <QtCore/qmath.h>
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
@ -81,6 +82,7 @@ TableWindow::TableWindow(QWidget *parent)
connect(ui->actionLayout, &QAction::triggered, this, &TableWindow::Layout); connect(ui->actionLayout, &QAction::triggered, this, &TableWindow::Layout);
connect(ui->listWidget, &QListWidget::currentRowChanged, this, &TableWindow::ShowPaper); connect(ui->listWidget, &QListWidget::currentRowChanged, this, &TableWindow::ShowPaper);
connect(ui->actionPrint_pre_view, &QAction::triggered, this, &TableWindow::PrintPreview); 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); QPrinter printer(def, QPrinter::ScreenResolution);
printer.setResolution(static_cast<int>(VApplication::PrintDPI)); printer.setResolution(static_cast<int>(VApplication::PrintDPI));
printer.setCreator(qApp->applicationDisplayName()+" "+qApp->applicationVersion());
printer.setDocName(fileName);
// display print preview dialog
QPrintPreviewDialog preview(&printer); QPrintPreviewDialog preview(&printer);
connect(&preview, &QPrintPreviewDialog::paintRequested, this, &TableWindow::Print); connect(&preview, &QPrintPreviewDialog::paintRequested, this, &TableWindow::Print);
preview.exec(); preview.exec();
@ -321,6 +326,21 @@ void TableWindow::Print(QPrinter *printer)
painter.end(); 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() void TableWindow::Layout()
{ {

View File

@ -42,6 +42,7 @@ namespace Ui
class QGraphicsScene; class QGraphicsScene;
class QGraphicsRectItem; class QGraphicsRectItem;
class QPrinter;
/** /**
* @brief TableWindow class layout window. * @brief TableWindow class layout window.
@ -61,6 +62,7 @@ public slots:
void ShowPaper(int index); void ShowPaper(int index);
void PrintPreview(); void PrintPreview();
void Print (QPrinter *printer); void Print (QPrinter *printer);
void LayoutPrint();
signals: signals:
/** @brief closed emit if window is closing. */ /** @brief closed emit if window is closing. */

View File

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