summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Heinecke <aheinecke@intevation.de>2016-08-05 12:17:20 (GMT)
committerAndre Heinecke <aheinecke@intevation.de>2016-08-05 12:17:20 (GMT)
commit01b1022b289f2f841be939a574b7bfc9df040e13 (patch)
tree20f503e56eec3d1fc81359d5fea122cb46fdf5c8
parent20570ce63677578d761d22204dc0ffd61b2a123a (diff)
Store last selected own keys in SigEnc Widget
-rw-r--r--src/crypto/gui/signencryptfileswizard.cpp1
-rw-r--r--src/crypto/gui/signencryptwidget.cpp30
-rw-r--r--src/crypto/gui/signencryptwidget.h6
3 files changed, 37 insertions, 0 deletions
diff --git a/src/crypto/gui/signencryptfileswizard.cpp b/src/crypto/gui/signencryptfileswizard.cpp
index b2c3466..f705ffd 100644
--- a/src/crypto/gui/signencryptfileswizard.cpp
+++ b/src/crypto/gui/signencryptfileswizard.cpp
@@ -121,6 +121,7 @@ public:
{
bool sign = !mWidget->signKey().isNull();
bool encrypt = !mWidget->selfKey().isNull() || !mWidget->recipients().empty();
+ mWidget->saveOwnKeys();
if (sign && !encrypt && mArchive) {
return KMessageBox::warningContinueCancel(this,
diff --git a/src/crypto/gui/signencryptwidget.cpp b/src/crypto/gui/signencryptwidget.cpp
index 1d59e4d..108b0bb 100644
--- a/src/crypto/gui/signencryptwidget.cpp
+++ b/src/crypto/gui/signencryptwidget.cpp
@@ -42,11 +42,13 @@
#include <QScrollArea>
#include <Libkleo/DefaultKeyFilter>
+#include <Libkleo/KeyCache>
#include <Libkleo/KeyListModel>
#include <Libkleo/KeySelectionCombo>
#include <Libkleo/KeyListSortFilterProxyModel>
#include <KLocalizedString>
+#include <KConfigGroup>
#include <KSharedConfig>
using namespace Kleo;
@@ -181,6 +183,7 @@ SignEncryptWidget::SignEncryptWidget(QWidget *parent)
lay->addWidget(encBox);
+ loadKeys();
setLayout(lay);
addRecipient(Key());
updateOp();
@@ -319,3 +322,30 @@ bool SignEncryptWidget::symEncrypt() const
{
return mSymetric->isChecked();
}
+
+void SignEncryptWidget::loadKeys()
+{
+ KConfigGroup keys(KSharedConfig::openConfig(), "SignEncryptKeys");
+ auto cache = KeyCache::instance();
+ const auto sigFpr = keys.readEntry("SigningKey", QString());
+ const auto encFpr = keys.readEntry("EncryptKey", QString());
+ if (!sigFpr.isEmpty()) {
+ mSigSelect->setCurrentKey(cache->findByFingerprint(sigFpr.toUtf8().constData()));
+ }
+ if (!encFpr.isEmpty()) {
+ mSelfSelect->setCurrentKey(cache->findByFingerprint(encFpr.toUtf8().constData()));
+ }
+}
+
+void SignEncryptWidget::saveOwnKeys() const
+{
+ KConfigGroup keys(KSharedConfig::openConfig(), "SignEncryptKeys");
+ auto sigKey = mSigSelect->currentKey();
+ auto encKey = mSelfSelect->currentKey();
+ if (!sigKey.isNull()) {
+ keys.writeEntry("SigningKey", sigKey.primaryFingerprint());
+ }
+ if (!encKey.isNull()) {
+ keys.writeEntry("EncryptKey", encKey.primaryFingerprint());
+ }
+}
diff --git a/src/crypto/gui/signencryptwidget.h b/src/crypto/gui/signencryptwidget.h
index 542d0f2..a1e81ae 100644
--- a/src/crypto/gui/signencryptwidget.h
+++ b/src/crypto/gui/signencryptwidget.h
@@ -70,6 +70,9 @@ public:
/** Wether or not symetric encryption should also be used. */
bool symEncrypt() const;
+ /** Save the currently selected signing and encrypt to self keys. */
+ void saveOwnKeys() const;
+
protected Q_SLOTS:
void updateOp();
void recipientsChanged();
@@ -77,6 +80,9 @@ protected Q_SLOTS:
void addRecipient();
void addRecipient(const GpgME::Key &key);
+protected:
+ void loadKeys();
+
Q_SIGNALS:
/* Emitted when the certificate selection changed the operation
* with that selection. e.g. "Sign" or "Sign/Encrypt".