Commit 75d5c5f8 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Move handling of dialogs from CertificateLineEdit to SignEncryptWidget

This makes handling of multiple selected entries in the selection
dialog much easier, especially, once groups can also be selected in the
selection dialog.

GnuPG-bug-id: 5175, 5241
parent 5fc494bc
Pipeline #48288 failed with stage
in 12 minutes and 28 seconds
......@@ -18,8 +18,6 @@
#include "kleopatra_debug.h"
#include "commands/detailscommand.h"
#include <Libkleo/KeyCache>
#include <Libkleo/KeyFilter>
#include <Libkleo/KeyList>
......@@ -36,7 +34,6 @@
#include <QGpgME/Protocol>
using namespace Kleo;
using namespace Kleo::Dialogs;
using namespace GpgME;
Q_DECLARE_METATYPE(GpgME::Key)
......@@ -239,35 +236,6 @@ KeyGroup CertificateLineEdit::group() const
}
}
void CertificateLineEdit::dialogRequested()
{
if (!mKey.isNull()) {
auto cmd = new Commands::DetailsCommand(mKey, nullptr);
cmd->start();
return;
}
CertificateSelectionDialog *const dlg = new CertificateSelectionDialog(this);
dlg->setKeyFilter(mFilter);
if (dlg->exec()) {
const std::vector<Key> keys = dlg->selectedCertificates();
if (!keys.size()) {
return;
}
for (unsigned int i = 0; i < keys.size(); i++) {
if (!i) {
setKey(keys[i]);
} else {
Q_EMIT addRequested(keys[i]);
}
}
}
delete dlg;
updateKey();
}
void CertificateLineEdit::setKey(const Key &k)
{
QSignalBlocker blocky(this);
......
......@@ -17,8 +17,6 @@
#include <gpgme++/key.h>
#include "dialogs/certificateselectiondialog.h"
#include <memory>
class QLabel;
......@@ -78,12 +76,11 @@ Q_SIGNALS:
/** Emitted when the entry is no longer empty. */
void editingStarted();
/** Emitted when the certselectiondialog resulted in multiple certificates. */
void addRequested(const GpgME::Key &key);
/** Emitted when the details dialog or the selection dialog is requested. */
void dialogRequested();
private Q_SLOTS:
void updateKey();
void dialogRequested();
void editChanged();
void editFinished();
void checkLocate();
......
......@@ -14,6 +14,10 @@
#include "certificatelineedit.h"
#include "unknownrecipientwidget.h"
#include "commands/detailscommand.h"
#include "dialogs/certificateselectiondialog.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QGroupBox>
......@@ -244,8 +248,8 @@ void SignEncryptWidget::addRecipient(const Key &key)
this, &SignEncryptWidget::recpRemovalRequested);
connect(certSel, &CertificateLineEdit::editingStarted,
this, static_cast<void (SignEncryptWidget::*)()>(&SignEncryptWidget::addRecipient));
connect(certSel, &CertificateLineEdit::addRequested,
this, static_cast<void (SignEncryptWidget::*)(const Key&)>(&SignEncryptWidget::addRecipient));
connect(certSel, &CertificateLineEdit::dialogRequested,
this, [this, certSel] () { dialogRequested(certSel); });
if (!key.isNull()) {
certSel->setKey(key);
......@@ -253,6 +257,35 @@ void SignEncryptWidget::addRecipient(const Key &key)
}
}
void SignEncryptWidget::dialogRequested(CertificateLineEdit *certificateLineEdit)
{
if (!certificateLineEdit->key().isNull()) {
auto cmd = new Commands::DetailsCommand(certificateLineEdit->key(), nullptr);
cmd->start();
return;
}
CertificateSelectionDialog *const dlg = new CertificateSelectionDialog(this);
dlg->setKeyFilter(std::make_shared<EncryptCertificateFilter>(mCurrentProto));
if (dlg->exec()) {
const std::vector<Key> keys = dlg->selectedCertificates();
if (!keys.size()) {
return;
}
for (unsigned int i = 0; i < keys.size(); i++) {
if (!i) {
certificateLineEdit->setKey(keys[i]);
} else {
addRecipient(keys[i]);
}
}
}
delete dlg;
recipientsChanged();
}
void SignEncryptWidget::clearAddedRecipients()
{
for (auto w: qAsConst(mUnknownWidgets)) {
......
......@@ -88,6 +88,7 @@ protected Q_SLOTS:
void recipientsChanged();
void recpRemovalRequested(CertificateLineEdit *w);
void addRecipient();
void dialogRequested(CertificateLineEdit *w);
protected:
void loadKeys();
......
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