mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
Handling of encrypted documents - basic functionality for standard encryption handler revision 2,3,4
This commit is contained in:
@ -38,6 +38,7 @@
|
||||
#include <QTreeView>
|
||||
#include <QLayout>
|
||||
#include <QHeaderView>
|
||||
#include <QInputDialog>
|
||||
|
||||
namespace pdfviewer
|
||||
{
|
||||
@ -268,9 +269,15 @@ void PDFViewerMainWindow::openDocument(const QString& fileName)
|
||||
// First close old document
|
||||
closeDocument();
|
||||
|
||||
// Password callback
|
||||
auto getPasswordCallback = [this](bool* ok) -> QString
|
||||
{
|
||||
return QInputDialog::getText(this, tr("Encrypted document"), tr("Enter password to acces document content"), QLineEdit::Password, QString(), ok);
|
||||
};
|
||||
|
||||
// Try to open a new document
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
pdf::PDFDocumentReader reader;
|
||||
pdf::PDFDocumentReader reader(qMove(getPasswordCallback));
|
||||
pdf::PDFDocument document = reader.readFromFile(fileName);
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
|
Reference in New Issue
Block a user