Commit a05df764 authored by Albert Astals Cid's avatar Albert Astals Cid

Move IsDigitallySigned code to part.cpp

It isn't really pdf generator specific
parent 076e17c6
Pipeline #33183 passed with stage
in 21 minutes and 52 seconds
......@@ -1491,17 +1491,6 @@ QVariant PDFGenerator::metaData(const QString &key, const QVariant &option) cons
return i18n("Using Poppler %1\n\nBuilt against Poppler %2", Poppler::Version::string(), POPPLER_VERSION);
}
#endif
} else if (key == QLatin1String("IsDigitallySigned")) {
const Okular::Document *doc = document();
uint numPages = doc->pages();
for (uint i = 0; i < numPages; i++) {
const QLinkedList<Okular::FormField *> formFields = doc->page(i)->formFields();
for (const Okular::FormField *f : formFields) {
if (f->type() == Okular::FormField::FormSignature)
return true;
}
}
return false;
}
return QVariant();
}
......
......@@ -93,6 +93,7 @@
#include "core/document.h"
#include "core/document_p.h"
#include "core/fileprinter.h"
#include "core/form.h"
#include "core/generator.h"
#include "core/page.h"
#include "core/printoptionswidget.h"
......@@ -1528,11 +1529,23 @@ bool Part::openFile()
m_formsMessage->setVisible(false);
}
if (ok && m_document->metaData(QStringLiteral("IsDigitallySigned")).toBool()) {
if (m_embedMode == PrintPreviewMode) {
m_signatureMessage->setText(i18n("All editing and interactive features for this document are disabled. Please save a copy and reopen to edit this document."));
} else {
m_signatureMessage->setText(i18n("This document is digitally signed."));
if (ok) {
const uint numPages = m_document->pages();
bool isDigitallySigned = false;
for (uint i = 0; i < numPages; i++) {
const QLinkedList<Okular::FormField *> formFields = m_document->page(i)->formFields();
for (const Okular::FormField *f : formFields) {
if (f->type() == Okular::FormField::FormSignature)
isDigitallySigned = true;
}
}
if (isDigitallySigned) {
if (m_embedMode == PrintPreviewMode) {
m_signatureMessage->setText(i18n("All editing and interactive features for this document are disabled. Please save a copy and reopen to edit this document."));
} else {
m_signatureMessage->setText(i18n("This document is digitally signed."));
}
}
m_signatureMessage->setVisible(true);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment