summaryrefslogtreecommitdiff
path: root/qt5
diff options
context:
space:
mode:
authorFabio D'Urso <fabiodurso@hotmail.it>2013-02-15 12:24:18 +0100
committerAlbert Astals Cid <aacid@kde.org>2013-06-30 21:10:28 +0200
commit35cfb6914e1be4c5eda2f355900b1a0a1fa69d19 (patch)
tree1935c938a417c48e5069d3d00f9130cd6d1bd879 /qt5
parentde2a93c0bc6e92a95c687796f59780c998b90ca4 (diff)
poppler_qt5viewer: Add combobox to select rotation
Diffstat (limited to 'qt5')
-rw-r--r--qt5/demos/navigationtoolbar.cpp15
-rw-r--r--qt5/demos/navigationtoolbar.h4
-rw-r--r--qt5/demos/pageview.cpp24
-rw-r--r--qt5/demos/pageview.h3
-rw-r--r--qt5/demos/viewer.cpp2
5 files changed, 47 insertions, 1 deletions
diff --git a/qt5/demos/navigationtoolbar.cpp b/qt5/demos/navigationtoolbar.cpp
index 4278aaba..0b6c8622 100644
--- a/qt5/demos/navigationtoolbar.cpp
+++ b/qt5/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/qt5/demos/navigationtoolbar.h b/qt5/demos/navigationtoolbar.h
index 0bde3768..e249adbc 100644
--- a/qt5/demos/navigationtoolbar.h
+++ b/qt5/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/qt5/demos/pageview.cpp b/qt5/demos/pageview.cpp
index 0a74080b..cb2731b1 100644
--- a/qt5/demos/pageview.cpp
+++ b/qt5/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/qt5/demos/pageview.h b/qt5/demos/pageview.h
index 3030c84c..95795a5a 100644
--- a/qt5/demos/pageview.h
+++ b/qt5/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/qt5/demos/viewer.cpp b/qt5/demos/viewer.cpp
index 2a295092..a95d7f33 100644
--- a/qt5/demos/viewer.cpp
+++ b/qt5/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);