From b3745e04116ecd7e126f852e0999bb3f385d8dc5 Mon Sep 17 00:00:00 2001 From: Lukáš Lalinský Date: Thu, 9 Jul 2009 23:46:47 +0200 Subject: Print support --- src/mainwindow.cpp | 24 +++++++++++++++++++++++- src/mainwindow.h | 1 + src/src.pro | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index cd29586..863af82 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -52,6 +53,8 @@ public: QStackedWidget *propertyEditorsStack; QMap propertyEditorsIndexes; + QAction *printAction; + QActionGroup *notationActionGroup; QMenu *notationMenu; @@ -215,9 +218,14 @@ MainWindow::setupActions() //connect(m_undoGroup, SIGNAL(cleanChanged(bool)), m_actionSaveAs, SLOT(setDisabled(bool))); m_actionExportPNG = new QAction(this); - m_actionExportPNG->setText(tr("Export...")); + m_actionExportPNG->setText(tr("E&xport...")); connect(m_actionExportPNG, SIGNAL(triggered(bool)), SLOT(exportPNG())); + d->printAction = new QAction(this); + d->printAction->setText(tr("&Print...")); + d->printAction->setIcon(loadIcon("document-print")); + connect(d->printAction, SIGNAL(triggered(bool)), SLOT(print())); + for (int i = 0; i < MaxRecentFiles; i++) { m_actionRecentFile[i] = new QAction(this); m_actionRecentFile[i]->setVisible(false); @@ -378,6 +386,7 @@ MainWindow::setupMenuBar() menu->addSeparator(); menu->addAction(m_actionExportPNG); + menu->addAction(d->printAction); m_actionRecentFilesSeparator = menu->addSeparator(); for (int i = 0; i < MaxRecentFiles; i++) menu->addAction(m_actionRecentFile[i]); @@ -493,6 +502,19 @@ MainWindow::exportPNG() } } +void +MainWindow::print() +{ + QPrinter printer; + QPrintDialog printDialog(&printer, this); + if (printDialog.exec() == QDialog::Accepted) { + QPainter painter(&printer); + m_model->setPrinting(true); + m_model->render(&painter); + m_model->setPrinting(false); + } +} + void MainWindow::newModel(DiagramDocument *newModel) { diff --git a/src/mainwindow.h b/src/mainwindow.h index eaf7626..ace4ea6 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -53,6 +53,7 @@ public slots: bool maybeSave(); bool saveAs(); void exportPNG(); + void print(); void setViewScale(const QString &scale); void about(); diff --git a/src/src.pro b/src/src.pro index 4d9cc63..3796f56 100644 --- a/src/src.pro +++ b/src/src.pro @@ -1,5 +1,5 @@ TARGET = dbmodel -VERSION = 0.2.0 +VERSION = 0.3dev DESTDIR = ../ -- cgit v1.2.3-54-g00ecf