diff options
author | Fabio D'Urso <fabiodurso@hotmail.it> | 2013-02-15 12:24:18 +0100 |
---|---|---|
committer | Albert Astals Cid <aacid@kde.org> | 2013-06-30 21:10:27 +0200 |
commit | 5923cfb5f7e3a0703de17e21f4952f92a44f3c14 (patch) | |
tree | 58232fd1018dd2c54947ffe882b37c9c51eddc61 /qt4/demos | |
parent | 74ea15cc454f31b772e71b3525b71045dbfa5527 (diff) |
poppler_qt4viewer: Add combobox to select rotation
Diffstat (limited to 'qt4/demos')
-rw-r--r-- | qt4/demos/navigationtoolbar.cpp | 15 | ||||
-rw-r--r-- | qt4/demos/navigationtoolbar.h | 4 | ||||
-rw-r--r-- | qt4/demos/pageview.cpp | 24 | ||||
-rw-r--r-- | qt4/demos/pageview.h | 3 | ||||
-rw-r--r-- | qt4/demos/viewer.cpp | 2 |
5 files changed, 47 insertions, 1 deletions
diff --git a/qt4/demos/navigationtoolbar.cpp b/qt4/demos/navigationtoolbar.cpp index e9ebafab..79dd418a 100644 --- a/qt4/demos/navigationtoolbar.cpp +++ b/qt4/demos/navigationtoolbar.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2008-2009, Pino Toscano <pino@kde.org> + * Copyright (C) 2013, Fabio D'Urso <fabiodurso@hotmail.it> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -54,6 +55,15 @@ NavigationToolBar::NavigationToolBar(QWidget *parent) connect(m_zoomCombo, SIGNAL(currentIndexChanged(QString)), this, SLOT(slotZoomComboChanged(QString))); addWidget(m_zoomCombo); + m_rotationCombo = new QComboBox(this); + // NOTE: \302\260 = degree symbol + m_rotationCombo->addItem(trUtf8("0\302\260")); + m_rotationCombo->addItem(trUtf8("90\302\260")); + m_rotationCombo->addItem(trUtf8("180\302\260")); + m_rotationCombo->addItem(trUtf8("270\302\260")); + connect(m_rotationCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(slotRotationComboChanged(int))); + addWidget(m_rotationCombo); + documentClosed(); } @@ -126,4 +136,9 @@ void NavigationToolBar::slotZoomComboChanged(const QString &_text) } } +void NavigationToolBar::slotRotationComboChanged(int idx) +{ + emit rotationChanged(idx * 90); +} + #include "navigationtoolbar.moc" diff --git a/qt4/demos/navigationtoolbar.h b/qt4/demos/navigationtoolbar.h index 3469f01b..d7dbd5dd 100644 --- a/qt4/demos/navigationtoolbar.h +++ b/qt4/demos/navigationtoolbar.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2008-2009, Pino Toscano <pino@kde.org> + * Copyright (C) 2013, Fabio D'Urso <fabiodurso@hotmail.it> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -40,6 +41,7 @@ public: Q_SIGNALS: void zoomChanged(qreal value); + void rotationChanged(int rotation); private Q_SLOTS: void slotGoFirst(); @@ -48,6 +50,7 @@ private Q_SLOTS: void slotGoLast(); void slotComboActivated(int index); void slotZoomComboChanged(const QString &text); + void slotRotationComboChanged(int idx); private: QAction *m_firstAct; @@ -56,6 +59,7 @@ private: QAction *m_nextAct; QAction *m_lastAct; QComboBox *m_zoomCombo; + QComboBox *m_rotationCombo; }; #endif diff --git a/qt4/demos/pageview.cpp b/qt4/demos/pageview.cpp index 734dacb1..0dfa5e9e 100644 --- a/qt4/demos/pageview.cpp +++ b/qt4/demos/pageview.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2008-2009, Pino Toscano <pino@kde.org> + * Copyright (C) 2013, Fabio D'Urso <fabiodurso@hotmail.it> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,6 +30,7 @@ PageView::PageView(QWidget *parent) : QScrollArea(parent) , m_zoom(1.0) + , m_rotation(0) , m_dpiX(QApplication::desktop()->physicalDpiX()) , m_dpiY(QApplication::desktop()->physicalDpiY()) { @@ -56,7 +58,18 @@ void PageView::pageChanged(int page) Poppler::Page *popplerPage = document()->page(page); const double resX = m_dpiX * m_zoom; const double resY = m_dpiY * m_zoom; - QImage image = popplerPage->renderToImage(resX, resY); + + Poppler::Page::Rotation rot; + if (m_rotation == 0) + rot = Poppler::Page::Rotate0; + else if (m_rotation == 90) + rot = Poppler::Page::Rotate90; + else if (m_rotation == 180) + rot = Poppler::Page::Rotate180; + else // m_rotation == 270 + rot = Poppler::Page::Rotate270; + + QImage image = popplerPage->renderToImage(resX, resY, -1, -1, -1, -1, rot); if (!image.isNull()) { m_imageLabel->resize(image.size()); m_imageLabel->setPixmap(QPixmap::fromImage(image)); @@ -76,4 +89,13 @@ void PageView::slotZoomChanged(qreal value) reloadPage(); } +void PageView::slotRotationChanged(int value) +{ + m_rotation = value; + if (!document()) { + return; + } + reloadPage(); +} + #include "pageview.moc" diff --git a/qt4/demos/pageview.h b/qt4/demos/pageview.h index 2f7ad61b..24065028 100644 --- a/qt4/demos/pageview.h +++ b/qt4/demos/pageview.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2008-2009, Pino Toscano <pino@kde.org> + * Copyright (C) 2013, Fabio D'Urso <fabiodurso@hotmail.it> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -39,10 +40,12 @@ public: private Q_SLOTS: void slotZoomChanged(qreal value); + void slotRotationChanged(int value); private: QLabel *m_imageLabel; qreal m_zoom; + int m_rotation; int m_dpiX; int m_dpiY; }; diff --git a/qt4/demos/viewer.cpp b/qt4/demos/viewer.cpp index 0201eea3..c34af23f 100644 --- a/qt4/demos/viewer.cpp +++ b/qt4/demos/viewer.cpp @@ -2,6 +2,7 @@ * Copyright (C) 2008-2009, Pino Toscano <pino@kde.org> * Copyright (C) 2008, Albert Astals Cid <aacid@kde.org> * Copyright (C) 2009, Shawn Rutledge <shawn.t.rutledge@gmail.com> + * Copyright (C) 2013, Fabio D'Urso <fabiodurso@hotmail.it> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -148,6 +149,7 @@ PdfViewer::PdfViewer() } connect(navbar, SIGNAL(zoomChanged(qreal)), view, SLOT(slotZoomChanged(qreal))); + connect(navbar, SIGNAL(rotationChanged(int)), view, SLOT(slotRotationChanged(int))); // activate AA by default m_settingsTextAAAct->setChecked(true); |