[poppler] 2 commits - qt4/demos
Pino Toscano
pino at kemper.freedesktop.org
Sat Feb 16 15:33:26 PST 2008
qt4/demos/CMakeLists.txt | 1
qt4/demos/Makefile.am | 1
qt4/demos/permissions.cpp | 77 ++++++++++++++++++++++++++++++++++++++++++++++
qt4/demos/permissions.h | 43 +++++++++++++++++++++++++
qt4/demos/viewer.cpp | 48 ++++++++++++++++++++++++++++
qt4/demos/viewer.h | 4 ++
6 files changed, 174 insertions(+)
New commits:
commit 42987dcdd8d7432145f78cfc550f0c099e6e7311
Author: Pino Toscano <pino at kde.org>
Date: Sun Feb 17 00:33:01 2008 +0100
Add a Permissions dock.
diff --git a/qt4/demos/CMakeLists.txt b/qt4/demos/CMakeLists.txt
index bcf5cab..07ffb52 100644
--- a/qt4/demos/CMakeLists.txt
+++ b/qt4/demos/CMakeLists.txt
@@ -16,6 +16,7 @@ set(poppler_qt4viewer_SRCS
main_viewer.cpp
navigationtoolbar.cpp
pageview.cpp
+ permissions.cpp
toc.cpp
viewer.cpp
)
diff --git a/qt4/demos/Makefile.am b/qt4/demos/Makefile.am
index b53e2fa..4f53d07 100644
--- a/qt4/demos/Makefile.am
+++ b/qt4/demos/Makefile.am
@@ -28,6 +28,7 @@ poppler_qt4viewer_SOURCES = \
main_viewer.cpp \
navigationtoolbar.cpp \
pageview.cpp \
+ permissions.cpp \
toc.cpp \
viewer.cpp \
viewer.moc
diff --git a/qt4/demos/permissions.cpp b/qt4/demos/permissions.cpp
new file mode 100644
index 0000000..e26ba10
--- /dev/null
+++ b/qt4/demos/permissions.cpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2008, Pino Toscano <pino at kde.org>
+ *
+ * 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
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "permissions.h"
+
+#include <poppler-qt4.h>
+
+#include <QtGui/QTableWidget>
+
+static QString yesNoStatement(bool value)
+{
+ return value ? QString::fromLatin1("yes") : QString::fromLatin1("no");
+}
+
+PermissionsDock::PermissionsDock(QWidget *parent)
+ : AbstractInfoDock(parent)
+{
+ m_table = new QTableWidget(this);
+ setWidget(m_table);
+ setWindowTitle(tr("Permissions"));
+ m_table->setColumnCount(2);
+ m_table->setHorizontalHeaderLabels(QStringList() << tr("Permission") << tr("Value"));
+#if QT_VERSION >= 0x040200
+ m_table->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
+#endif
+}
+
+PermissionsDock::~PermissionsDock()
+{
+}
+
+void PermissionsDock::fillInfo()
+{
+ m_table->setHorizontalHeaderLabels(QStringList() << tr("Permission") << tr("Value"));
+ int i = 0;
+#define ADD_ROW(title, function) \
+do { \
+ m_table->setRowCount(i + 1); \
+ m_table->setItem(i, 0, new QTableWidgetItem(QString::fromLatin1(title))); \
+ m_table->setItem(i, 1, new QTableWidgetItem(yesNoStatement(document()->function()))); \
+ ++i; \
+} while (0)
+ ADD_ROW("Print", okToPrint);
+ ADD_ROW("PrintHiRes", okToPrintHighRes);
+ ADD_ROW("Change", okToChange);
+ ADD_ROW("Copy", okToCopy);
+ ADD_ROW("Add Notes", okToAddNotes);
+ ADD_ROW("Fill Forms", okToFillForm);
+ ADD_ROW("Create Forms", okToCreateFormFields);
+ ADD_ROW("Extract for accessibility", okToExtractForAccessibility);
+ ADD_ROW("Assemble", okToAssemble);
+#undef ADD_ROW
+}
+
+void PermissionsDock::documentClosed()
+{
+ m_table->clear();
+ m_table->setRowCount(0);
+ AbstractInfoDock::documentClosed();
+}
+
+#include "permissions.moc"
diff --git a/qt4/demos/permissions.h b/qt4/demos/permissions.h
new file mode 100644
index 0000000..147f862
--- /dev/null
+++ b/qt4/demos/permissions.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2008, Pino Toscano <pino at kde.org>
+ *
+ * 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
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef PERMISSIONS_H
+#define PERMISSIONS_H
+
+#include "abstractinfodock.h"
+
+class QTableWidget;
+
+class PermissionsDock : public AbstractInfoDock
+{
+ Q_OBJECT
+
+public:
+ PermissionsDock(QWidget *parent = 0);
+ ~PermissionsDock();
+
+ /*virtual*/ void documentClosed();
+
+protected:
+ /*virtual*/ void fillInfo();
+
+private:
+ QTableWidget *m_table;
+};
+
+#endif
diff --git a/qt4/demos/viewer.cpp b/qt4/demos/viewer.cpp
index 73cee1a..402fb80 100644
--- a/qt4/demos/viewer.cpp
+++ b/qt4/demos/viewer.cpp
@@ -22,6 +22,7 @@
#include "info.h"
#include "navigationtoolbar.h"
#include "pageview.h"
+#include "permissions.h"
#include "toc.h"
#include <poppler-qt4.h>
@@ -81,6 +82,12 @@ PdfViewer::PdfViewer()
viewMenu->addAction(fontsDock->toggleViewAction());
m_observers.append(fontsDock);
+ PermissionsDock *permissionsDock = new PermissionsDock(this);
+ addDockWidget(Qt::LeftDockWidgetArea, permissionsDock);
+ permissionsDock->hide();
+ viewMenu->addAction(permissionsDock->toggleViewAction());
+ m_observers.append(permissionsDock);
+
Q_FOREACH(DocumentObserver *obs, m_observers) {
obs->m_viewer = this;
}
commit 9d1dda64de1d9e3f6fc81e40a0c2246a6270dfa8
Author: Pino Toscano <pino at kde.org>
Date: Sat Feb 16 23:56:17 2008 +0100
Add settings for antialias.
diff --git a/qt4/demos/viewer.cpp b/qt4/demos/viewer.cpp
index f81fdea..73cee1a 100644
--- a/qt4/demos/viewer.cpp
+++ b/qt4/demos/viewer.cpp
@@ -47,6 +47,14 @@ PdfViewer::PdfViewer()
QMenu *viewMenu = menuBar()->addMenu(tr("&View"));
+ QMenu *settingsMenu = menuBar()->addMenu(tr("&Settings"));
+ m_settingsTextAAAct = settingsMenu->addAction(tr("Text Antialias"));
+ m_settingsTextAAAct->setCheckable(true);
+ connect(m_settingsTextAAAct, SIGNAL(toggled(bool)), this, SLOT(slotToggleTextAA(bool)));
+ m_settingsGfxAAAct = settingsMenu->addAction(tr("Graphics Antialias"));
+ m_settingsGfxAAAct->setCheckable(true);
+ connect(m_settingsGfxAAAct, SIGNAL(toggled(bool)), this, SLOT(slotToggleGfxAA(bool)));
+
NavigationToolBar *navbar = new NavigationToolBar(this);
addToolBar(navbar);
m_observers.append(navbar);
@@ -76,6 +84,10 @@ PdfViewer::PdfViewer()
Q_FOREACH(DocumentObserver *obs, m_observers) {
obs->m_viewer = this;
}
+
+ // activate AA by default
+ m_settingsTextAAAct->setChecked(true);
+ m_settingsGfxAAAct->setChecked(true);
}
PdfViewer::~PdfViewer()
@@ -114,6 +126,9 @@ void PdfViewer::loadDocument(const QString &file)
m_doc = newdoc;
+ slotToggleTextAA(m_settingsTextAAAct->isChecked());
+ slotToggleGfxAA(m_settingsGfxAAAct->isChecked());
+
Q_FOREACH(DocumentObserver *obs, m_observers) {
obs->documentLoaded();
obs->pageChanged(0);
@@ -144,6 +159,32 @@ void PdfViewer::slotOpenFile()
loadDocument(fileName);
}
+void PdfViewer::slotToggleTextAA(bool value)
+{
+ if (!m_doc) {
+ return;
+ }
+
+ m_doc->setRenderHint(Poppler::Document::TextAntialiasing, value);
+
+ Q_FOREACH(DocumentObserver *obs, m_observers) {
+ obs->pageChanged(m_currentPage);
+ }
+}
+
+void PdfViewer::slotToggleGfxAA(bool value)
+{
+ if (!m_doc) {
+ return;
+ }
+
+ m_doc->setRenderHint(Poppler::Document::Antialiasing, value);
+
+ Q_FOREACH(DocumentObserver *obs, m_observers) {
+ obs->pageChanged(m_currentPage);
+ }
+}
+
void PdfViewer::setPage(int page)
{
Q_FOREACH(DocumentObserver *obs, m_observers) {
diff --git a/qt4/demos/viewer.h b/qt4/demos/viewer.h
index c180b06..6ee179c 100644
--- a/qt4/demos/viewer.h
+++ b/qt4/demos/viewer.h
@@ -45,6 +45,8 @@ public:
private Q_SLOTS:
void slotOpenFile();
+ void slotToggleTextAA(bool value);
+ void slotToggleGfxAA(bool value);
private:
void setPage(int page);
@@ -53,6 +55,8 @@ private:
int m_currentPage;
QAction *m_fileOpenAct;
+ QAction *m_settingsTextAAAct;
+ QAction *m_settingsGfxAAAct;
QList<DocumentObserver *> m_observers;
More information about the poppler
mailing list