diff --git a/PdfForQtLib/sources/pdfpage.h b/PdfForQtLib/sources/pdfpage.h
index 675e7e3..41e05e2 100644
--- a/PdfForQtLib/sources/pdfpage.h
+++ b/PdfForQtLib/sources/pdfpage.h
@@ -66,7 +66,7 @@ private:
/// Object representing page in PDF document. Contains different page properties, such as
/// media box, crop box, rotation, etc. and also page content, resources.
-class PDFPage
+class PDFFORQTLIBSHARED_EXPORT PDFPage
{
public:
explicit PDFPage() = default;
diff --git a/PdfForQtViewer/PdfForQtViewer.pro b/PdfForQtViewer/PdfForQtViewer.pro
index 12d9319..bf30723 100644
--- a/PdfForQtViewer/PdfForQtViewer.pro
+++ b/PdfForQtViewer/PdfForQtViewer.pro
@@ -35,6 +35,7 @@ LIBS += -lPDFForQtLib
SOURCES += \
main.cpp \
pdfaboutdialog.cpp \
+ pdfdocumentpropertiesdialog.cpp \
pdfsidebarwidget.cpp \
pdfviewermainwindow.cpp \
pdfviewersettings.cpp \
@@ -43,6 +44,7 @@ SOURCES += \
HEADERS += \
pdfaboutdialog.h \
+ pdfdocumentpropertiesdialog.h \
pdfsidebarwidget.h \
pdfviewermainwindow.h \
pdfviewersettings.h \
@@ -51,6 +53,7 @@ HEADERS += \
FORMS += \
pdfaboutdialog.ui \
+ pdfdocumentpropertiesdialog.ui \
pdfsidebarwidget.ui \
pdfviewermainwindow.ui \
pdfviewersettingsdialog.ui
diff --git a/PdfForQtViewer/pdfdocumentpropertiesdialog.cpp b/PdfForQtViewer/pdfdocumentpropertiesdialog.cpp
new file mode 100644
index 0000000..8e443be
--- /dev/null
+++ b/PdfForQtViewer/pdfdocumentpropertiesdialog.cpp
@@ -0,0 +1,143 @@
+// Copyright (C) 2019 Jakub Melka
+//
+// This file is part of PdfForQt.
+//
+// PdfForQt is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// PdfForQt 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 Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with PDFForQt. If not, see .
+
+#include "pdfdocumentpropertiesdialog.h"
+#include "ui_pdfdocumentpropertiesdialog.h"
+
+#include "pdfdocument.h"
+#include "pdfwidgetutils.h"
+
+#include
+#include
+
+namespace pdfviewer
+{
+
+PDFDocumentPropertiesDialog::PDFDocumentPropertiesDialog(const pdf::PDFDocument* document,
+ const PDFFileInfo* fileInfo,
+ QWidget* parent) :
+ QDialog(parent),
+ ui(new Ui::PDFDocumentPropertiesDialog)
+{
+ ui->setupUi(this);
+
+ initializeProperties(document);
+ initializeFileInfoProperties(fileInfo);
+
+ const int defaultWidth = PDFWidgetUtils::getPixelSize(this, 240.0);
+ const int defaultHeight = PDFWidgetUtils::getPixelSize(this, 200.0);
+ resize(defaultWidth, defaultHeight);
+}
+
+PDFDocumentPropertiesDialog::~PDFDocumentPropertiesDialog()
+{
+ delete ui;
+}
+
+void PDFDocumentPropertiesDialog::initializeProperties(const pdf::PDFDocument* document)
+{
+ QLocale locale;
+
+ // Initialize document properties
+ QTreeWidgetItem* propertiesRoot = new QTreeWidgetItem({ tr("Properties") });
+
+ const pdf::PDFDocument::Info* info = document->getInfo();
+ const pdf::PDFCatalog* catalog = document->getCatalog();
+ new QTreeWidgetItem(propertiesRoot, { tr("Title"), info->title });
+ new QTreeWidgetItem(propertiesRoot, { tr("Subject"), info->subject });
+ new QTreeWidgetItem(propertiesRoot, { tr("Author"), info->author });
+ new QTreeWidgetItem(propertiesRoot, { tr("Keywords"), info->keywords });
+ new QTreeWidgetItem(propertiesRoot, { tr("Creator"), info->creator });
+ new QTreeWidgetItem(propertiesRoot, { tr("Producer"), info->producer });
+ new QTreeWidgetItem(propertiesRoot, { tr("Creation date"), locale.toString(info->creationDate) });
+ new QTreeWidgetItem(propertiesRoot, { tr("Modified date"), locale.toString(info->modifiedDate) });
+ new QTreeWidgetItem(propertiesRoot, { tr("Version"), QString::fromLatin1(catalog->getVersion()) });
+
+ QString trapped;
+ switch (info->trapped)
+ {
+ case pdf::PDFDocument::Info::Trapped::True:
+ trapped = tr("True");
+ break;
+
+ case pdf::PDFDocument::Info::Trapped::False:
+ trapped = tr("False");
+ break;
+
+ case pdf::PDFDocument::Info::Trapped::Unknown:
+ trapped = tr("Unknown");
+ break;
+
+ default:
+ Q_ASSERT(false);
+ break;
+ }
+
+ QTreeWidgetItem* contentRoot = new QTreeWidgetItem({ tr("Content") });
+ const pdf::PDFInteger pageCount = catalog->getPageCount();
+ new QTreeWidgetItem(contentRoot, { tr("Page count"), locale.toString(pageCount) });
+
+ if (pageCount > 0)
+ {
+ const pdf::PDFPage* firstPage = catalog->getPage(0);
+ QSizeF pageSizeMM = firstPage->getRectMM(firstPage->getRotatedMediaBox()).size();
+ QPageSize pageSize(pageSizeMM, QPageSize::Millimeter, QString(), QPageSize::FuzzyOrientationMatch);
+ QString paperSizeString = QString("%1 x %2 mm").arg(locale.toString(pageSizeMM.width()), locale.toString(pageSizeMM.height()));
+
+ new QTreeWidgetItem(contentRoot, { tr("Paper format"), pageSize.name() });
+ new QTreeWidgetItem(contentRoot, { tr("Paper size"), paperSizeString });
+ }
+ new QTreeWidgetItem(contentRoot, { tr("Trapped"), trapped });
+
+ ui->propertiesTreeWidget->addTopLevelItem(propertiesRoot);
+ ui->propertiesTreeWidget->addTopLevelItem(contentRoot);
+ ui->propertiesTreeWidget->expandAll();
+ ui->propertiesTreeWidget->resizeColumnToContents(0);
+}
+
+void PDFDocumentPropertiesDialog::initializeFileInfoProperties(const PDFFileInfo* fileInfo)
+{
+ QLocale locale;
+
+ // Initialize document file info
+ QTreeWidgetItem* fileInfoRoot = new QTreeWidgetItem({ tr("File information") });
+
+ new QTreeWidgetItem(fileInfoRoot, { tr("Name"), fileInfo->fileName });
+ new QTreeWidgetItem(fileInfoRoot, { tr("Directory"), fileInfo->path });
+ new QTreeWidgetItem(fileInfoRoot, { tr("Writable"), fileInfo->writable ? tr("Yes") : tr("No") });
+
+ QString fileSize;
+ if (fileInfo->fileSize > 1024 * 1024)
+ {
+ fileSize = QString("%1 MB (%2 bytes)").arg(locale.toString(fileInfo->fileSize / (1024.0 * 1024.0)), locale.toString(fileInfo->fileSize));
+ }
+ else
+ {
+ fileSize = QString("%1 kB (%2 bytes)").arg(locale.toString(fileInfo->fileSize / 1024.0), locale.toString(fileInfo->fileSize));
+ }
+
+ new QTreeWidgetItem(fileInfoRoot, { tr("Size"), fileSize });
+ new QTreeWidgetItem(fileInfoRoot, { tr("Created date"), locale.toString(fileInfo->creationTime) });
+ new QTreeWidgetItem(fileInfoRoot, { tr("Modified date"), locale.toString(fileInfo->lastModifiedTime) });
+ new QTreeWidgetItem(fileInfoRoot, { tr("Last read date"), locale.toString(fileInfo->lastReadTime) });
+
+ ui->fileInfoTreeWidget->addTopLevelItem(fileInfoRoot);
+ ui->fileInfoTreeWidget->expandAll();
+ ui->fileInfoTreeWidget->resizeColumnToContents(0);
+}
+
+} // namespace pdfviewer
diff --git a/PdfForQtViewer/pdfdocumentpropertiesdialog.h b/PdfForQtViewer/pdfdocumentpropertiesdialog.h
new file mode 100644
index 0000000..c2fdc55
--- /dev/null
+++ b/PdfForQtViewer/pdfdocumentpropertiesdialog.h
@@ -0,0 +1,68 @@
+// Copyright (C) 2019 Jakub Melka
+//
+// This file is part of PdfForQt.
+//
+// PdfForQt is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// PdfForQt 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 Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with PDFForQt. If not, see .
+
+#ifndef PDFDOCUMENTPROPERTIESDIALOG_H
+#define PDFDOCUMENTPROPERTIESDIALOG_H
+
+#include "pdfglobal.h"
+
+#include
+
+namespace Ui
+{
+class PDFDocumentPropertiesDialog;
+}
+
+namespace pdf
+{
+class PDFDocument;
+}
+
+namespace pdfviewer
+{
+
+struct PDFFileInfo
+{
+ QString fileName;
+ QString path;
+ pdf::PDFInteger fileSize = 0;
+ bool writable = false;
+ QDateTime creationTime;
+ QDateTime lastModifiedTime;
+ QDateTime lastReadTime;
+};
+
+class PDFDocumentPropertiesDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit PDFDocumentPropertiesDialog(const pdf::PDFDocument* document,
+ const PDFFileInfo* fileInfo,
+ QWidget* parent);
+ virtual ~PDFDocumentPropertiesDialog() override;
+
+private:
+ Ui::PDFDocumentPropertiesDialog* ui;
+
+ void initializeProperties(const pdf::PDFDocument* document);
+ void initializeFileInfoProperties(const PDFFileInfo* fileInfo);
+};
+
+} // namespace pdfviewer
+
+#endif // PDFDOCUMENTPROPERTIESDIALOG_H
diff --git a/PdfForQtViewer/pdfdocumentpropertiesdialog.ui b/PdfForQtViewer/pdfdocumentpropertiesdialog.ui
new file mode 100644
index 0000000..32b29cc
--- /dev/null
+++ b/PdfForQtViewer/pdfdocumentpropertiesdialog.ui
@@ -0,0 +1,141 @@
+
+
+ PDFDocumentPropertiesDialog
+
+
+
+ 0
+ 0
+ 807
+ 609
+
+
+
+ Document Properties
+
+
+ -
+
+
+ 0
+
+
+
+ Properties
+
+
+
-
+
+
+ Properties
+
+
+
-
+
+
+ 2
+
+
+ false
+
+
+
+ 1
+
+
+
+
+ 2
+
+
+
+
+
+
+
+ -
+
+
+ File Information
+
+
+
-
+
+
+ 2
+
+
+ false
+
+
+
+ 1
+
+
+
+
+ 2
+
+
+
+
+
+
+
+
+
+
+
+ Security
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Ok
+
+
+
+
+
+
+
+
+ buttonBox
+ accepted()
+ PDFDocumentPropertiesDialog
+ accept()
+
+
+ 248
+ 254
+
+
+ 157
+ 274
+
+
+
+
+ buttonBox
+ rejected()
+ PDFDocumentPropertiesDialog
+ reject()
+
+
+ 316
+ 260
+
+
+ 286
+ 274
+
+
+
+
+
diff --git a/PdfForQtViewer/pdfforqtviewer.qrc b/PdfForQtViewer/pdfforqtviewer.qrc
index fbc8104..92826ef 100644
--- a/PdfForQtViewer/pdfforqtviewer.qrc
+++ b/PdfForQtViewer/pdfforqtviewer.qrc
@@ -24,5 +24,6 @@
resources/synchronize.svg
resources/cache.svg
resources/shortcuts.svg
+ resources/info.svg
diff --git a/PdfForQtViewer/pdfviewermainwindow.cpp b/PdfForQtViewer/pdfviewermainwindow.cpp
index 5388a21..602e1a4 100644
--- a/PdfForQtViewer/pdfviewermainwindow.cpp
+++ b/PdfForQtViewer/pdfviewermainwindow.cpp
@@ -19,8 +19,9 @@
#include "ui_pdfviewermainwindow.h"
#include "pdfaboutdialog.h"
-#include "pdfviewersettingsdialog.h"
#include "pdfsidebarwidget.h"
+#include "pdfviewersettingsdialog.h"
+#include "pdfdocumentpropertiesdialog.h"
#include "pdfdocumentreader.h"
#include "pdfvisitor.h"
@@ -662,6 +663,8 @@ void PDFViewerMainWindow::updateUI(bool fullUpdate)
m_pageNumberSpinBox->setEnabled(false);
m_pageNumberLabel->setText(QString());
}
+
+ ui->actionProperties->setEnabled(m_pdfDocument);
}
else
{
@@ -710,6 +713,15 @@ void PDFViewerMainWindow::openDocument(const QString& fileName)
// First close old document
closeDocument();
+ QFileInfo fileInfo(fileName);
+ m_fileInfo.fileName = fileInfo.fileName();
+ m_fileInfo.path = fileInfo.path();
+ m_fileInfo.fileSize = fileInfo.size();
+ m_fileInfo.writable = fileInfo.isWritable();
+ m_fileInfo.creationTime = fileInfo.created();
+ m_fileInfo.lastModifiedTime = fileInfo.lastModified();
+ m_fileInfo.lastReadTime = fileInfo.lastRead();
+
// Password callback
auto getPasswordCallback = [this](bool* ok) -> QString
{
@@ -906,6 +918,14 @@ void PDFViewerMainWindow::on_actionOptions_triggered()
}
}
+void PDFViewerMainWindow::on_actionProperties_triggered()
+{
+ Q_ASSERT(m_pdfDocument);
+
+ PDFDocumentPropertiesDialog documentPropertiesDialog(m_pdfDocument.data(), &m_fileInfo, this);
+ documentPropertiesDialog.exec();
+}
+
void PDFViewerMainWindow::on_actionAbout_triggered()
{
PDFAboutDialog dialog(this);
diff --git a/PdfForQtViewer/pdfviewermainwindow.h b/PdfForQtViewer/pdfviewermainwindow.h
index 3afb3b1..85594d6 100644
--- a/PdfForQtViewer/pdfviewermainwindow.h
+++ b/PdfForQtViewer/pdfviewermainwindow.h
@@ -22,6 +22,7 @@
#include "pdfrenderer.h"
#include "pdfprogress.h"
#include "pdfviewersettings.h"
+#include "pdfdocumentpropertiesdialog.h"
#include
#include
@@ -76,6 +77,8 @@ private slots:
void on_actionFitWidth_triggered();
void on_actionFitHeight_triggered();
+ void on_actionProperties_triggered();
+
private:
void onActionOpenTriggered();
void onActionCloseTriggered();
@@ -129,6 +132,7 @@ private:
pdf::PDFProgress* m_progress;
QWinTaskbarButton* m_taskbarButton;
QWinTaskbarProgress* m_progressTaskbarIndicator;
+ PDFFileInfo m_fileInfo;
};
} // namespace pdfviewer
diff --git a/PdfForQtViewer/pdfviewermainwindow.ui b/PdfForQtViewer/pdfviewermainwindow.ui
index d3a573d..2cfa444 100644
--- a/PdfForQtViewer/pdfviewermainwindow.ui
+++ b/PdfForQtViewer/pdfviewermainwindow.ui
@@ -29,6 +29,9 @@
+
+
+
diff --git a/PdfForQtViewer/resources/info.svg b/PdfForQtViewer/resources/info.svg
new file mode 100644
index 0000000..9f7fbb2
--- /dev/null
+++ b/PdfForQtViewer/resources/info.svg
@@ -0,0 +1,126 @@
+
+
+
+