[graphics/okular] /: Signing: Use KPasswordDialog for NSS instead QInputDialog
Sune Vuorela <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 1d7bbe79730f0051b7d985f02db827978e7f6c7e by Sune Vuorela.
Committed on 17/08/2026 at 10:29.
Pushed by sune into branch 'master'.
Signing: Use KPasswordDialog for NSS instead QInputDialog
This gives us the reveal password button and a slightly nicer user
interface
Also add a BIC-todo to fix some issues when we can in order to properly
parent the widget.
M +1 -0 core/signatureutils.h
M +16 -5 generators/poppler/pdfsignatureutils.cpp
https://invent.kde.org/graphics/okular/-/commit/1d7bbe79730f0051b7d985f02db827978e7f6c7e
diff --git a/core/signatureutils.h b/core/signatureutils.h
index d03ccf081..73d5b8bb4 100644
--- a/core/signatureutils.h
+++ b/core/signatureutils.h
@@ -541,6 +541,7 @@ private:
class OKULARCORE_EXPORT CertificateStore
{
public:
+ // TODO: BIC please add QWidget* parent's to the methods for showing a dialog
/**
* Destructor
*/
diff --git a/generators/poppler/pdfsignatureutils.cpp b/generators/poppler/pdfsignatureutils.cpp
index 54ebc27be..d15981493 100644
--- a/generators/poppler/pdfsignatureutils.cpp
+++ b/generators/poppler/pdfsignatureutils.cpp
@@ -8,8 +8,9 @@
#include "popplerversion.h"
#include <KLocalizedString>
+#include <KPasswordDialog>
#include <QDebug>
-#include <QInputDialog>
+#include <QPointer>
static Okular::CertificateInfo::KeyUsageExtensions fromPoppler(Poppler::CertificateInfo::KeyUsageExtensions popplerKu)
{
@@ -230,10 +231,20 @@ QList<Okular::CertificateInfo> PopplerCertificateStore::signingCertificates(bool
if (isNSS) {
auto PDFGeneratorNSSPasswordCallback = [&userCancelled](const char *element) -> char * {
- bool ok;
- const QString pwd = QInputDialog::getText(nullptr, i18n("Enter Password"), i18n("Enter password to open %1:", QString::fromUtf8(element)), QLineEdit::Password, QString(), &ok);
- *userCancelled = !ok;
- return ok ? strdup(pwd.toUtf8().constData()) : nullptr;
+ QPointer<KPasswordDialog> dialog = new KPasswordDialog(nullptr);
+ dialog->setRevealPasswordMode(KPassword::RevealMode::OnlyNew);
+ dialog->setPrompt(i18n("Enter password to open: %1", QString::fromUtf8(element)));
+ if (!dialog->exec()) {
+ *userCancelled = true;
+ delete dialog;
+ return nullptr;
+ }
+ if (dialog) {
+ const QString password = dialog->password();
+ delete dialog;
+ return strdup(password.toUtf8().constData());
+ }
+ return nullptr;
};
Poppler::setNSSPasswordCallback(PDFGeneratorNSSPasswordCallback);
}