Commit 26fe7b5b authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Remove the simple Add Email dialog

GnuPG-bug-id: 5916
parent 7aae07cb
......@@ -135,7 +135,6 @@ set(_kleopatra_SRCS
dialogs/revokecertificationwidget.cpp
dialogs/revokecertificationdialog.cpp
dialogs/adduseriddialog.cpp
dialogs/addemaildialog.cpp
dialogs/deletecertificatesdialog.cpp
dialogs/setinitialpindialog.cpp
dialogs/certificatedetailsdialog.cpp
......
......@@ -14,7 +14,6 @@
#include "command_p.h"
#include "dialogs/adduseriddialog.h"
#include "dialogs/addemaildialog.h"
#include <Libkleo/Formatting>
#include <QGpgME/Protocol>
......@@ -46,7 +45,6 @@ public:
private:
void slotDialogAccepted();
void slotSimpleDialogAccepted();
void slotDialogRejected();
void slotResult(const Error &err);
......@@ -59,7 +57,6 @@ private:
private:
GpgME::Key key;
QPointer<AddUserIDDialog> dialog;
QPointer<AddEmailDialog> simpleDialog;
QPointer<QGpgME::AddUserIDJob> job;
};
......@@ -90,9 +87,6 @@ AddUserIDCommand::Private::~Private()
if (dialog) {
delete dialog;
}
if (simpleDialog) {
delete simpleDialog;
}
}
AddUserIDCommand::AddUserIDCommand(KeyListController *c)
......@@ -141,32 +135,11 @@ void AddUserIDCommand::doStart()
const UserID uid = d->key.userID(0);
// d->simpleDialog->setEmail(Formatting::prettyEMail(uid.email(), uid.id()));
d->dialog->setName(QString::fromUtf8(uid.name()));
d->dialog->setEmail(Formatting::prettyEMail(uid.email(), uid.id()));
d->dialog->setComment(QString::fromUtf8(uid.comment()));
d->simpleDialog->show();
}
void AddUserIDCommand::Private::slotSimpleDialogAccepted()
{
if (simpleDialog->advancedSelected()) {
qDebug() << "thinking advanced selected";
dialog->show();
return;
}
createJob();
if (!job) {
finished();
return;
}
if (const Error err = job->start(key, QString(), simpleDialog->email(), QString())) {
showErrorDialog(err);
finished();
}
d->dialog->show();
}
void AddUserIDCommand::Private::slotDialogAccepted()
......@@ -177,7 +150,6 @@ void AddUserIDCommand::Private::slotDialogAccepted()
if (!job) {
finished();
}
else if (const Error err = job->start(key, dialog->name(), dialog->email(), dialog->comment())) {
showErrorDialog(err);
finished();
......@@ -221,12 +193,6 @@ void AddUserIDCommand::Private::ensureDialogCreated()
connect(dialog, SIGNAL(accepted()), q, SLOT(slotDialogAccepted()));
connect(dialog, SIGNAL(rejected()), q, SLOT(slotDialogRejected()));
simpleDialog = new AddEmailDialog;
applyWindowID(simpleDialog);
connect(simpleDialog, SIGNAL(accepted()), q, SLOT(slotSimpleDialogAccepted()));
connect(simpleDialog, SIGNAL(rejected()), q, SLOT(slotDialogRejected()));
}
void AddUserIDCommand::Private::createJob()
......
......@@ -50,7 +50,6 @@ private:
Q_PRIVATE_SLOT(d_func(), void slotResult(GpgME::Error))
Q_PRIVATE_SLOT(d_func(), void slotDialogAccepted())
Q_PRIVATE_SLOT(d_func(), void slotDialogRejected())
Q_PRIVATE_SLOT(d_func(), void slotSimpleDialogAccepted())
};
}
......
/* -*- mode: c++; c-basic-offset:4 -*-
dialogs/addemaildialog.cpp
This file is part of Kleopatra, the KDE keymanager
SPDX-FileCopyrightText: 2019 g 10 Code GmbH
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <config-kleopatra.h>
#include "addemaildialog.h"
#include <utils/validation.h>
#include <QString>
#include <QPushButton>
#include <QDialogButtonBox>
#include <QLineEdit>
#include <QLabel>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <KLocalizedString>
#include "kleopatra_debug.h"
using namespace Kleo;
using namespace Kleo::Dialogs;
class AddEmailDialog::Private
{
public:
Private(AddEmailDialog *qq):
q(qq)
{
auto mainLay = new QVBoxLayout(q);
auto btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
mOkButton = btnBox->button(QDialogButtonBox::Ok);
QObject::connect (btnBox, &QDialogButtonBox::accepted, q, [this] () {
q->accept();
});
QObject::connect (btnBox, &QDialogButtonBox::rejected, q, &QDialog::reject);
btnBox->addButton(i18n("Advanced"), QDialogButtonBox::HelpRole);
QObject::connect (btnBox, &QDialogButtonBox::helpRequested, q, [this] () {
mAdvancedSelected = true;
q->accept();
});
mainLay->addStretch(-1);
auto emailLay = new QHBoxLayout;
auto emailLbl = new QLabel(i18n("EMail") + QLatin1Char(':'));
mEmailEdit = new QLineEdit(q);
mEmailEdit->setValidator(Validation::email(mEmailEdit));
connect(mEmailEdit, &QLineEdit::textChanged, q, [this] () {
mOkButton->setEnabled(!mEmailEdit->text().isEmpty() && mEmailEdit->hasAcceptableInput());
});
emailLbl->setBuddy(mEmailEdit);
emailLay->addWidget(emailLbl);
emailLay->addWidget(mEmailEdit);
mainLay->addLayout(emailLay);
mainLay->addWidget(btnBox);
mOkButton->setEnabled(!mEmailEdit->text().isEmpty() && mEmailEdit->hasAcceptableInput());
}
AddEmailDialog *const q;
QPushButton *mOkButton = nullptr;
QLineEdit *mEmailEdit = nullptr;
bool mAdvancedSelected = false;
};
AddEmailDialog::AddEmailDialog(QWidget *parent):
QDialog(parent),
d(new Private(this))
{
setWindowTitle(i18nc("@title:window", "Add New EMail"));
}
AddEmailDialog::~AddEmailDialog()
{
}
void AddEmailDialog::setEmail(const QString &email)
{
return d->mEmailEdit->setText(email);
}
QString AddEmailDialog::email() const
{
return d->mEmailEdit->text().trimmed();
}
bool AddEmailDialog::advancedSelected()
{
return d->mAdvancedSelected;
}
/* -*- mode: c++; c-basic-offset:4 -*-
dialogs/addemaildialog.h
This file is part of Kleopatra, the KDE keymanager
SPDX-FileCopyrightText: 2019 g 10 Code GmbH
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <QDialog>
#include <memory>
class QString;
namespace Kleo
{
namespace Dialogs
{
class AddEmailDialog : public QDialog
{
Q_OBJECT
public:
explicit AddEmailDialog(QWidget *parent = nullptr);
~AddEmailDialog() override;
void setEmail(const QString &email);
QString email() const;
bool advancedSelected();
private:
class Private;
std::shared_ptr<Private> d;
};
}
}
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