[poppler] 4 commits - qt4/demos
Pino Toscano
pino at kemper.freedesktop.org
Fri Jul 3 15:40:47 PDT 2009
qt4/demos/navigationtoolbar.cpp | 2 +-
qt4/demos/pageview.cpp | 11 +++++++----
qt4/demos/pageview.h | 2 ++
qt4/demos/permissions.cpp | 25 ++++++++-----------------
qt4/demos/permissions.h | 6 +++---
5 files changed, 21 insertions(+), 25 deletions(-)
New commits:
commit 92ad0ef89fe7690d83854b4821178dfdb2e22897
Author: Pino Toscano <pino at kde.org>
Date: Sat Jul 4 00:19:23 2009 +0200
[Qt4 demo] hopefully fix the page size on zoom change
diff --git a/qt4/demos/pageview.cpp b/qt4/demos/pageview.cpp
index e59e5e0..734dacb 100644
--- a/qt4/demos/pageview.cpp
+++ b/qt4/demos/pageview.cpp
@@ -54,12 +54,9 @@ void PageView::documentClosed()
void PageView::pageChanged(int page)
{
Poppler::Page *popplerPage = document()->page(page);
- QSize pageSize = popplerPage->pageSize();
- pageSize.setWidth(int(pageSize.width() / 72.0 * m_dpiX));
- pageSize.setHeight(int(pageSize.height() / 72.0 * m_dpiY));
const double resX = m_dpiX * m_zoom;
const double resY = m_dpiY * m_zoom;
- QImage image = popplerPage->renderToImage(resX, resY, 0, 0, pageSize.width(), pageSize.height());
+ QImage image = popplerPage->renderToImage(resX, resY);
if (!image.isNull()) {
m_imageLabel->resize(image.size());
m_imageLabel->setPixmap(QPixmap::fromImage(image));
commit 97094d13bc0f144b25e13c1de7a5328608ab13e3
Author: Pino Toscano <pino at kde.org>
Date: Sat Jul 4 00:07:12 2009 +0200
[Qt4 demo] show a list of checked/unchecked items for the document permissions
diff --git a/qt4/demos/permissions.cpp b/qt4/demos/permissions.cpp
index 0ac3a57..38205b2 100644
--- a/qt4/demos/permissions.cpp
+++ b/qt4/demos/permissions.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008, Pino Toscano <pino at kde.org>
+ * Copyright (C) 2008-2009, 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
@@ -20,21 +20,14 @@
#include <poppler-qt4.h>
-#include <QtGui/QTableWidget>
-
-static QString yesNoStatement(bool value)
-{
- return value ? QString::fromLatin1("yes") : QString::fromLatin1("no");
-}
+#include <QtGui/QListWidget>
PermissionsDock::PermissionsDock(QWidget *parent)
: AbstractInfoDock(parent)
{
- m_table = new QTableWidget(this);
+ m_table = new QListWidget(this);
setWidget(m_table);
setWindowTitle(tr("Permissions"));
- m_table->setColumnCount(2);
- m_table->setHorizontalHeaderLabels(QStringList() << tr("Permission") << tr("Value"));
m_table->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
}
@@ -44,14 +37,13 @@ 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; \
+ QListWidgetItem *item = new QListWidgetItem(); \
+ item->setFlags(item->flags() & ~Qt::ItemIsEnabled); \
+ item->setText(title); \
+ item->setCheckState(document()->function() ? Qt::Checked : Qt::Unchecked); \
+ m_table->addItem(item); \
} while (0)
ADD_ROW("Print", okToPrint);
ADD_ROW("PrintHiRes", okToPrintHighRes);
@@ -68,7 +60,6 @@ do { \
void PermissionsDock::documentClosed()
{
m_table->clear();
- m_table->setRowCount(0);
AbstractInfoDock::documentClosed();
}
diff --git a/qt4/demos/permissions.h b/qt4/demos/permissions.h
index 147f862..13bcbbf 100644
--- a/qt4/demos/permissions.h
+++ b/qt4/demos/permissions.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008, Pino Toscano <pino at kde.org>
+ * Copyright (C) 2008-2009, 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
@@ -21,7 +21,7 @@
#include "abstractinfodock.h"
-class QTableWidget;
+class QListWidget;
class PermissionsDock : public AbstractInfoDock
{
@@ -37,7 +37,7 @@ protected:
/*virtual*/ void fillInfo();
private:
- QTableWidget *m_table;
+ QListWidget *m_table;
};
#endif
commit 0d8f2ee0f03a14e7b8477c4b787c3441a758f26b
Author: Pino Toscano <pino at kde.org>
Date: Fri Jul 3 23:55:42 2009 +0200
[Qt4 demo] show page numbers in the toolbar as 1..n
diff --git a/qt4/demos/navigationtoolbar.cpp b/qt4/demos/navigationtoolbar.cpp
index ce7fb2e..e9ebafa 100644
--- a/qt4/demos/navigationtoolbar.cpp
+++ b/qt4/demos/navigationtoolbar.cpp
@@ -65,7 +65,7 @@ void NavigationToolBar::documentLoaded()
{
const int pageCount = document()->numPages();
for (int i = 0; i < pageCount; ++i) {
- m_pageCombo->addItem(QString::number(i));
+ m_pageCombo->addItem(QString::number(i + 1));
}
m_pageCombo->setEnabled(true);
}
commit b0d48df9121c55f8162ddf0ee63832f9adebf37b
Author: Pino Toscano <pino at kde.org>
Date: Fri Jul 3 17:55:31 2009 +0200
[Qt4 demo] correctly use DPI values for the page sizes
diff --git a/qt4/demos/pageview.cpp b/qt4/demos/pageview.cpp
index d774998..e59e5e0 100644
--- a/qt4/demos/pageview.cpp
+++ b/qt4/demos/pageview.cpp
@@ -20,6 +20,8 @@
#include <poppler-qt4.h>
+#include <QtGui/QApplication>
+#include <QtGui/QDesktopWidget>
#include <QtGui/QImage>
#include <QtGui/QLabel>
#include <QtGui/QPixmap>
@@ -27,6 +29,8 @@
PageView::PageView(QWidget *parent)
: QScrollArea(parent)
, m_zoom(1.0)
+ , m_dpiX(QApplication::desktop()->physicalDpiX())
+ , m_dpiY(QApplication::desktop()->physicalDpiY())
{
m_imageLabel = new QLabel(this);
m_imageLabel->resize(0, 0);
@@ -51,9 +55,11 @@ void PageView::pageChanged(int page)
{
Poppler::Page *popplerPage = document()->page(page);
QSize pageSize = popplerPage->pageSize();
- pageSize *= m_zoom;
- const double res = 72.0 * m_zoom;
- QImage image = popplerPage->renderToImage(res, res, 0, 0, pageSize.width(), pageSize.height());
+ pageSize.setWidth(int(pageSize.width() / 72.0 * m_dpiX));
+ pageSize.setHeight(int(pageSize.height() / 72.0 * m_dpiY));
+ const double resX = m_dpiX * m_zoom;
+ const double resY = m_dpiY * m_zoom;
+ QImage image = popplerPage->renderToImage(resX, resY, 0, 0, pageSize.width(), pageSize.height());
if (!image.isNull()) {
m_imageLabel->resize(image.size());
m_imageLabel->setPixmap(QPixmap::fromImage(image));
diff --git a/qt4/demos/pageview.h b/qt4/demos/pageview.h
index 018f246..2f7ad61 100644
--- a/qt4/demos/pageview.h
+++ b/qt4/demos/pageview.h
@@ -43,6 +43,8 @@ private Q_SLOTS:
private:
QLabel *m_imageLabel;
qreal m_zoom;
+ int m_dpiX;
+ int m_dpiY;
};
#endif
More information about the poppler
mailing list