diff options
author | Javier <dev.git@javispedro.com> | 2015-06-14 05:18:53 +0200 |
---|---|---|
committer | Javier <dev.git@javispedro.com> | 2015-06-14 05:18:53 +0200 |
commit | 2910de560ead3ff65db26292fc27e427a5cf9b5e (patch) | |
tree | 12f6c29b77244528176abeee0934bdc4c560f08d /notebookview.cc | |
parent | 46cb4b079be113996214660020d6ef0c3d1f1e80 (diff) | |
download | scribiu-2910de560ead3ff65db26292fc27e427a5cf9b5e.tar.gz scribiu-2910de560ead3ff65db26292fc27e427a5cf9b5e.zip |
add export feature and desktop file
Diffstat (limited to 'notebookview.cc')
-rw-r--r-- | notebookview.cc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/notebookview.cc b/notebookview.cc index 2bca4f7..f433664 100644 --- a/notebookview.cc +++ b/notebookview.cc @@ -88,6 +88,34 @@ void NotebookView::setZoom(int zoom) } } +QSize NotebookView::getCurPageSize() const +{ + return _nb->getPageSize(_curPage); +} + +QRect NotebookView::getCurPageTrim() const +{ + return _nb->getPageTrim(_curPage); +} + +QImage NotebookView::exportPage(int pageNum) const +{ + const QRect pageTrim = getCurPageTrim(); + QImage image(pageTrim.width() / 4, pageTrim.height() / 4, QImage::Format_RGB32); + QPainter painter(&image); + painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); + renderPage(&painter, pageNum, QRectF(), pageTrim); + return image; +} + +void NotebookView::renderPage(QPainter *painter, int pageNum, const QRectF &target, const QRectF &source) const +{ + QGraphicsScene scene; + PageItem *item = new PageItem(_nb, 0, pageNum); + scene.addItem(item); + scene.render(painter, target, source, Qt::KeepAspectRatio); +} + void NotebookView::requestPaperReplay(const QString &file, qint64 time) { emit paperReplayRequested(file, time); |