summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLukáš Lalinský <lalinsky@gmail.com>2009-07-09 23:46:47 +0200
committerLukáš Lalinský <lalinsky@gmail.com>2009-07-09 23:46:47 +0200
commitb3745e04116ecd7e126f852e0999bb3f385d8dc5 (patch)
tree7e4d269de06fddd49022a95959446cc0f3e5bca3 /src
parent59e144904551274571ecb68177bc1e2457904105 (diff)
downloaddbmodel-b3745e04116ecd7e126f852e0999bb3f385d8dc5.tar.xz
Print support
Diffstat (limited to 'src')
-rw-r--r--src/mainwindow.cpp24
-rw-r--r--src/mainwindow.h1
-rw-r--r--src/src.pro2
3 files changed, 25 insertions, 2 deletions
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 <QImage>
#include <QSettings>
#include <QPrinter>
+#include <QPrintDialog>
#include <QMessageBox>
#include <QDebug>
#include <QDockWidget>
@@ -52,6 +53,8 @@ public:
QStackedWidget *propertyEditorsStack;
QMap<QString, int> 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]);
@@ -494,6 +503,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)
{
if (!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 = ../