[poppler] 4 commits - qt4/demos

Pino Toscano pino at kemper.freedesktop.org
Wed Feb 20 15:59:45 PST 2008


 qt4/demos/CMakeLists.txt    |    1 
 qt4/demos/Makefile.am       |    3 +
 qt4/demos/embeddedfiles.cpp |   75 ++++++++++++++++++++++++++++++++++++++++++++
 qt4/demos/embeddedfiles.h   |   43 +++++++++++++++++++++++++
 qt4/demos/viewer.cpp        |   41 ++++++++++++++++++++++--
 qt4/demos/viewer.h          |    3 +
 6 files changed, 163 insertions(+), 3 deletions(-)

New commits:
commit b6f0c8f83924c08be20b602b128651bf018172a3
Author: Pino Toscano <pino at kde.org>
Date:   Thu Feb 21 00:54:26 2008 +0100

    Do not assign conflicting accelerators.

diff --git a/qt4/demos/viewer.cpp b/qt4/demos/viewer.cpp
index 00af774..b8c69c4 100644
--- a/qt4/demos/viewer.cpp
+++ b/qt4/demos/viewer.cpp
@@ -80,7 +80,7 @@ PdfViewer::PdfViewer()
 
     QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
     act = helpMenu->addAction(tr("&About"), this, SLOT(slotAbout()));
-    act = helpMenu->addAction(tr("&About Qt"), this, SLOT(slotAboutQt()));
+    act = helpMenu->addAction(tr("About &Qt"), this, SLOT(slotAboutQt()));
 
     NavigationToolBar *navbar = new NavigationToolBar(this);
     addToolBar(navbar);
commit e0c27a968c7e7a0f6a89a050ddbfe328229f431d
Author: Pino Toscano <pino at kde.org>
Date:   Thu Feb 21 00:53:24 2008 +0100

    Apply the antialias settings w/o notify the observers.

diff --git a/qt4/demos/viewer.cpp b/qt4/demos/viewer.cpp
index a8f13cc..00af774 100644
--- a/qt4/demos/viewer.cpp
+++ b/qt4/demos/viewer.cpp
@@ -165,8 +165,8 @@ void PdfViewer::loadDocument(const QString &file)
 
     m_doc = newdoc;
 
-    slotToggleTextAA(m_settingsTextAAAct->isChecked());
-    slotToggleGfxAA(m_settingsGfxAAAct->isChecked());
+    m_doc->setRenderHint(Poppler::Document::TextAntialiasing, m_settingsTextAAAct->isChecked());
+    m_doc->setRenderHint(Poppler::Document::Antialiasing, m_settingsGfxAAAct->isChecked());
     m_doc->setRenderBackend((Poppler::Document::RenderBackend)m_settingsRenderBackendGrp->checkedAction()->data().toInt());
 
     Q_FOREACH(DocumentObserver *obs, m_observers) {
commit 2c6149abcecda15c6f73a1dee537072240ddd545
Author: Pino Toscano <pino at kde.org>
Date:   Thu Feb 21 00:51:21 2008 +0100

    Add a settings menu to choose the render backend.

diff --git a/qt4/demos/viewer.cpp b/qt4/demos/viewer.cpp
index 78e639f..a8f13cc 100644
--- a/qt4/demos/viewer.cpp
+++ b/qt4/demos/viewer.cpp
@@ -63,6 +63,20 @@ PdfViewer::PdfViewer()
     m_settingsGfxAAAct = settingsMenu->addAction(tr("Graphics Antialias"));
     m_settingsGfxAAAct->setCheckable(true);
     connect(m_settingsGfxAAAct, SIGNAL(toggled(bool)), this, SLOT(slotToggleGfxAA(bool)));
+    QMenu *settingsRenderMenu = settingsMenu->addMenu(tr("Render Backend"));
+    m_settingsRenderBackendGrp = new QActionGroup(settingsRenderMenu);
+    m_settingsRenderBackendGrp->setExclusive(true);
+    act = settingsRenderMenu->addAction(tr("Splash"));
+    act->setCheckable(true);
+    act->setChecked(true);
+    act->setData(qVariantFromValue(0));
+    m_settingsRenderBackendGrp->addAction(act);
+    act = settingsRenderMenu->addAction(tr("Arthur"));
+    act->setCheckable(true);
+    act->setData(qVariantFromValue(1));
+    m_settingsRenderBackendGrp->addAction(act);
+    connect(m_settingsRenderBackendGrp, SIGNAL(triggered(QAction*)),
+            this, SLOT(slotRenderBackend(QAction*)));
 
     QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
     act = helpMenu->addAction(tr("&About"), this, SLOT(slotAbout()));
@@ -153,6 +167,7 @@ void PdfViewer::loadDocument(const QString &file)
 
     slotToggleTextAA(m_settingsTextAAAct->isChecked());
     slotToggleGfxAA(m_settingsGfxAAAct->isChecked());
+    m_doc->setRenderBackend((Poppler::Document::RenderBackend)m_settingsRenderBackendGrp->checkedAction()->data().toInt());
 
     Q_FOREACH(DocumentObserver *obs, m_observers) {
         obs->documentLoaded();
@@ -245,6 +260,19 @@ void PdfViewer::slotToggleGfxAA(bool value)
     }
 }
 
+void PdfViewer::slotRenderBackend(QAction *act)
+{
+    if (!m_doc || !act) {
+        return;
+    }
+
+    m_doc->setRenderBackend((Poppler::Document::RenderBackend)act->data().toInt());
+
+    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 06e0fb7..5e0eaaf 100644
--- a/qt4/demos/viewer.h
+++ b/qt4/demos/viewer.h
@@ -22,6 +22,7 @@
 #include <QtGui/QMainWindow>
 
 class QAction;
+class QActionGroup;
 class QLabel;
 class DocumentObserver;
 namespace Poppler {
@@ -50,6 +51,7 @@ private Q_SLOTS:
     void slotAboutQt();
     void slotToggleTextAA(bool value);
     void slotToggleGfxAA(bool value);
+    void slotRenderBackend(QAction *act);
 
 private:
     void setPage(int page);
@@ -61,6 +63,7 @@ private:
     QAction *m_fileSaveCopyAct;
     QAction *m_settingsTextAAAct;
     QAction *m_settingsGfxAAAct;
+    QActionGroup *m_settingsRenderBackendGrp;
 
     QList<DocumentObserver *> m_observers;
 
commit db2b0778dca364751a1d22294be29f8c7799e2e9
Author: Pino Toscano <pino at kde.org>
Date:   Thu Feb 21 00:33:23 2008 +0100

    Add a dock for showing the embedded files.
    
    TODO: show the checksum in a pretty format.

diff --git a/qt4/demos/CMakeLists.txt b/qt4/demos/CMakeLists.txt
index 07ffb52..2c7b370 100644
--- a/qt4/demos/CMakeLists.txt
+++ b/qt4/demos/CMakeLists.txt
@@ -11,6 +11,7 @@ include_directories(
 set(poppler_qt4viewer_SRCS
   abstractinfodock.cpp
   documentobserver.cpp
+  embeddedfiles.cpp
   fonts.cpp
   info.cpp
   main_viewer.cpp
diff --git a/qt4/demos/Makefile.am b/qt4/demos/Makefile.am
index c492986..0592dd7 100644
--- a/qt4/demos/Makefile.am
+++ b/qt4/demos/Makefile.am
@@ -25,6 +25,8 @@ poppler_qt4viewer_SOURCES =			\
 	abstractinfodock.h			\
 	documentobserver.cpp			\
 	documentobserver.h			\
+	embeddedfiles.cpp			\
+	embeddedfiles.h				\
 	fonts.cpp				\
 	fonts.h					\
 	info.cpp				\
@@ -42,6 +44,7 @@ poppler_qt4viewer_SOURCES =			\
 	viewer.h
 
 abstractinfodock.$(OBJEXT): abstractinfodock.moc
+embeddedfiles.cpp.$(OBJEXT): embeddedfiles.moc
 fonts.$(OBJEXT): fonts.moc
 info.$(OBJEXT): info.moc
 navigationtoolbar.$(OBJEXT): navigationtoolbar.moc
diff --git a/qt4/demos/embeddedfiles.cpp b/qt4/demos/embeddedfiles.cpp
new file mode 100644
index 0000000..a91d8dd
--- /dev/null
+++ b/qt4/demos/embeddedfiles.cpp
@@ -0,0 +1,75 @@
+/*
+ * 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 "embeddedfiles.h"
+
+#include <poppler-qt4.h>
+
+#include <QtGui/QTableWidget>
+
+EmbeddedFilesDock::EmbeddedFilesDock(QWidget *parent)
+    : AbstractInfoDock(parent)
+{
+    m_table = new QTableWidget(this);
+    setWidget(m_table);
+    setWindowTitle(tr("Embedded files"));
+    m_table->setColumnCount(6);
+    m_table->setHorizontalHeaderLabels(
+        QStringList() << tr("Name") << tr("Description") << tr("Size") << tr("Creation date")
+                      << tr("Modification date") << tr("Checksum"));
+#if QT_VERSION >= 0x040200
+    m_table->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
+#endif
+}
+
+EmbeddedFilesDock::~EmbeddedFilesDock()
+{
+}
+
+void EmbeddedFilesDock::fillInfo()
+{
+    m_table->setHorizontalHeaderLabels(
+        QStringList() << tr("Name") << tr("Description") << tr("Size") << tr("Creation date")
+                      << tr("Modification date") << tr("Checksum"));
+    if (!document()->hasEmbeddedFiles()) {
+        m_table->setItem(0, 0, new QTableWidgetItem(tr("No files")));
+        return;
+    }
+
+    const QList<Poppler::EmbeddedFile*> files = document()->embeddedFiles();
+    m_table->setRowCount(files.count());
+    int i = 0;
+    Q_FOREACH(Poppler::EmbeddedFile *file, files) {
+        m_table->setItem(i, 0, new QTableWidgetItem(file->name()));
+        m_table->setItem(i, 1, new QTableWidgetItem(file->description()));
+        m_table->setItem(i, 2, new QTableWidgetItem(QString::number(file->size())));
+        m_table->setItem(i, 3, new QTableWidgetItem(file->createDate().toString(Qt::SystemLocaleDate)));
+        m_table->setItem(i, 4, new QTableWidgetItem(file->modDate().toString(Qt::SystemLocaleDate)));
+        m_table->setItem(i, 5, new QTableWidgetItem("n/a")); // ### FIXME pretty display of the HEX checksum
+        ++i;
+    }
+}
+
+void EmbeddedFilesDock::documentClosed()
+{
+    m_table->clear();
+    m_table->setRowCount(0);
+    AbstractInfoDock::documentClosed();
+}
+
+#include "embeddedfiles.moc"
diff --git a/qt4/demos/embeddedfiles.h b/qt4/demos/embeddedfiles.h
new file mode 100644
index 0000000..b1b0d00
--- /dev/null
+++ b/qt4/demos/embeddedfiles.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 ATTACHMENTS_H
+#define ATTACHMENTS_H
+
+#include "abstractinfodock.h"
+
+class QTableWidget;
+
+class EmbeddedFilesDock : public AbstractInfoDock
+{
+    Q_OBJECT
+
+public:
+    EmbeddedFilesDock(QWidget *parent = 0);
+    ~EmbeddedFilesDock();
+
+    /*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 ea673ae..78e639f 100644
--- a/qt4/demos/viewer.cpp
+++ b/qt4/demos/viewer.cpp
@@ -18,6 +18,7 @@
 
 #include "viewer.h"
 
+#include "embeddedfiles.h"
 #include "fonts.h"
 #include "info.h"
 #include "navigationtoolbar.h"
@@ -99,6 +100,12 @@ PdfViewer::PdfViewer()
     viewMenu->addAction(permissionsDock->toggleViewAction());
     m_observers.append(permissionsDock);
 
+    EmbeddedFilesDock *embfilesDock = new EmbeddedFilesDock(this);
+    addDockWidget(Qt::BottomDockWidgetArea, embfilesDock);
+    embfilesDock->hide();
+    viewMenu->addAction(embfilesDock->toggleViewAction());
+    m_observers.append(embfilesDock);
+
     Q_FOREACH(DocumentObserver *obs, m_observers) {
         obs->m_viewer = this;
     }


More information about the poppler mailing list