Commit 01b1022b authored by Andre Heinecke's avatar Andre Heinecke
Browse files

Store last selected own keys in SigEnc Widget

parent 20570ce6
......@@ -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,
......
......@@ -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());
}
}
......@@ -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".
......
Supports Markdown
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