Commit 07b183c2 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Remove obsolete Choose Protocol page of NewCertificateWizard

GnuPG-bug-id: 5832
parent 6e8d0314
Pipeline #181409 passed with stage
in 1 minute and 59 seconds
......@@ -359,8 +359,6 @@ set(_kleopatra_SRCS
dialogs/weboftrustwidget.h
newcertificatewizard/advancedsettingsdialog.cpp
newcertificatewizard/advancedsettingsdialog_p.h
newcertificatewizard/chooseprotocolpage.cpp
newcertificatewizard/chooseprotocolpage_p.h
newcertificatewizard/enterdetailspage.cpp
newcertificatewizard/enterdetailspage_p.h
newcertificatewizard/keyalgo.cpp
......
/* -*- mode: c++; c-basic-offset:4 -*-
newcertificatewizard/chooseprotocolpage.cpp
This file is part of Kleopatra, the KDE keymanager
SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB
SPDX-FileCopyrightText: 2016, 2017 Bundesamt für Sicherheit in der Informationstechnik
SPDX-FileContributor: Intevation GmbH
SPDX-FileCopyrightText: 2022 g10 Code GmbH
SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <config-kleopatra.h>
#include "chooseprotocolpage_p.h"
#include "utils/scrollarea.h"
#include <KLocalizedString>
#include <QCommandLinkButton>
#include <QVBoxLayout>
using namespace Kleo;
using namespace Kleo::NewCertificateUi;
namespace
{
static void force_set_checked(QAbstractButton *b, bool on)
{
// work around Qt bug (tested: 4.1.4, 4.2.3, 4.3.4)
const bool autoExclusive = b->autoExclusive();
b->setAutoExclusive(false);
b->setChecked(b->isEnabled() && on);
b->setAutoExclusive(autoExclusive);
}
}
struct ChooseProtocolPage::UI {
QCommandLinkButton *pgpCLB = nullptr;
QCommandLinkButton *x509CLB = nullptr;
UI(QWizardPage *parent)
{
parent->setTitle(i18nc("@title", "Choose Type of Key Pair"));
parent->setSubTitle(i18n("Please choose which type of key pair you want to create."));
auto mainLayout = new QVBoxLayout{parent};
const auto margins = mainLayout->contentsMargins();
mainLayout->setContentsMargins(margins.left(), 0, margins.right(), 0);
auto scrollArea = new ScrollArea{parent};
scrollArea->setFocusPolicy(Qt::NoFocus);
scrollArea->setFrameStyle(QFrame::NoFrame);
scrollArea->setBackgroundRole(parent->backgroundRole());
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
auto scrollAreaLayout = qobject_cast<QBoxLayout *>(scrollArea->widget()->layout());
scrollAreaLayout->setContentsMargins(0, margins.top(), 0, margins.bottom());
pgpCLB = new QCommandLinkButton{parent};
pgpCLB->setText(i18n("Create a personal OpenPGP key pair"));
pgpCLB->setDescription(i18n("OpenPGP key pairs are certified by confirming the fingerprint of the public key."));
pgpCLB->setAccessibleDescription(pgpCLB->description());
pgpCLB->setCheckable(true);
pgpCLB->setAutoExclusive(true);
scrollAreaLayout->addWidget(pgpCLB);
x509CLB = new QCommandLinkButton{parent};
x509CLB->setText(i18n("Create a personal X.509 key pair and certification request"));
x509CLB->setDescription(i18n("X.509 key pairs are certified by a certification authority (CA). The generated request needs to be sent to a CA to finalize creation."));
x509CLB->setAccessibleDescription(x509CLB->description());
x509CLB->setCheckable(true);
x509CLB->setAutoExclusive(true);
scrollAreaLayout->addWidget(x509CLB);
scrollAreaLayout->addStretch(1);
mainLayout->addWidget(scrollArea);
}
};
ChooseProtocolPage::ChooseProtocolPage(QWidget *parent)
: WizardPage{parent}
, ui{new UI{this}}
{
setObjectName(QStringLiteral("Kleo__NewCertificateUi__ChooseProtocolPage"));
registerField(QStringLiteral("pgp"), ui->pgpCLB);
}
ChooseProtocolPage::~ChooseProtocolPage() = default;
void ChooseProtocolPage::setProtocol(GpgME::Protocol proto)
{
if (proto == GpgME::OpenPGP) {
ui->pgpCLB->setChecked(true);
} else if (proto == GpgME::CMS) {
ui->x509CLB->setChecked(true);
} else {
force_set_checked(ui->pgpCLB, false);
force_set_checked(ui->x509CLB, false);
}
}
GpgME::Protocol ChooseProtocolPage::protocol() const
{
return
ui->pgpCLB->isChecked() ? GpgME::OpenPGP :
ui->x509CLB->isChecked() ? GpgME::CMS : GpgME::UnknownProtocol;
}
void ChooseProtocolPage::initializePage() {
if (!initialized)
{
connect(ui->pgpCLB, &QAbstractButton::clicked, wizard(), &QWizard::next, Qt::QueuedConnection);
connect(ui->x509CLB, &QAbstractButton::clicked, wizard(), &QWizard::next, Qt::QueuedConnection);
}
initialized = true;
}
bool ChooseProtocolPage::isComplete() const
{
return protocol() != GpgME::UnknownProtocol;
}
// #include "chooseprotocolpage.moc"
/* -*- mode: c++; c-basic-offset:4 -*-
newcertificatewizard/chooseprotocolpage_p.h
This file is part of Kleopatra, the KDE keymanager
SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB
SPDX-FileCopyrightText: 2016, 2017 Bundesamt für Sicherheit in der Informationstechnik
SPDX-FileContributor: Intevation GmbH
SPDX-FileCopyrightText: 2022 g10 Code GmbH
SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include "wizardpage_p.h"
#include <memory>
class ChooseProtocolPage : public Kleo::NewCertificateUi::WizardPage
{
Q_OBJECT
public:
explicit ChooseProtocolPage(QWidget *parent = nullptr);
~ChooseProtocolPage() override;
void setProtocol(GpgME::Protocol proto);
GpgME::Protocol protocol() const;
void initializePage() override;
bool isComplete() const override;
private:
struct UI;
std::unique_ptr<UI> ui;
bool initialized = false;
};
......@@ -219,7 +219,6 @@ EnterDetailsPage::EnterDetailsPage(QWidget *p)
registerField(QStringLiteral("name"), ui->nameLE);
registerField(QStringLiteral("email"), ui->emailLE);
registerField(QStringLiteral("protectedKey"), ui->withPassCB);
updateForm();
setCommitPage(true);
setButtonText(QWizard::CommitButton, i18nc("@action", "Create"));
......@@ -252,8 +251,6 @@ void EnterDetailsPage::initializePage()
void EnterDetailsPage::cleanupPage()
{
saveValues();
// reset protocol when navigating back to "Choose Protocol" page
resetProtocol();
}
void EnterDetailsPage::registerDialogPropertiesAsFields()
......
......@@ -14,7 +14,6 @@
#include "newcertificatewizard.h"
#include "chooseprotocolpage_p.h"
#include "enterdetailspage_p.h"
#include "keycreationpage_p.h"
#include "resultpage_p.h"
......@@ -42,33 +41,27 @@ public:
}
private:
GpgME::Protocol initialProtocol = GpgME::UnknownProtocol;
GpgME::Protocol protocol = GpgME::UnknownProtocol;
QTemporaryDir tmp;
struct Ui {
ChooseProtocolPage chooseProtocolPage;
EnterDetailsPage enterDetailsPage;
KeyCreationPage keyCreationPage;
ResultPage resultPage;
explicit Ui(NewCertificateWizard *q)
: chooseProtocolPage(q),
enterDetailsPage(q),
: enterDetailsPage(q),
keyCreationPage(q),
resultPage(q)
{
KDAB_SET_OBJECT_NAME(chooseProtocolPage);
KDAB_SET_OBJECT_NAME(enterDetailsPage);
KDAB_SET_OBJECT_NAME(keyCreationPage);
KDAB_SET_OBJECT_NAME(resultPage);
q->setOptions(NoBackButtonOnStartPage|DisabledBackButtonOnLastPage);
q->setPage(ChooseProtocolPageId, &chooseProtocolPage);
q->setPage(EnterDetailsPageId, &enterDetailsPage);
q->setPage(KeyCreationPageId, &keyCreationPage);
q->setPage(ResultPageId, &resultPage);
q->setStartId(ChooseProtocolPageId);
}
} ui;
......@@ -93,26 +86,17 @@ void NewCertificateWizard::showEvent(QShowEvent *event)
void NewCertificateWizard::setProtocol(Protocol proto)
{
d->initialProtocol = proto;
d->ui.chooseProtocolPage.setProtocol(proto);
setStartId(proto == UnknownProtocol ? ChooseProtocolPageId : EnterDetailsPageId);
d->protocol = proto;
}
Protocol NewCertificateWizard::protocol() const
{
return d->ui.chooseProtocolPage.protocol();
}
void NewCertificateWizard::resetProtocol()
{
d->ui.chooseProtocolPage.setProtocol(d->initialProtocol);
return d->protocol;
}
void NewCertificateWizard::restartAtEnterDetailsPage()
{
const auto protocol = d->ui.chooseProtocolPage.protocol();
restart(); // resets the protocol to the initial protocol
d->ui.chooseProtocolPage.setProtocol(protocol);
restart();
while (currentId() != NewCertificateWizard::EnterDetailsPageId) {
next();
}
......
......@@ -36,7 +36,6 @@ public:
GpgME::Protocol protocol() const;
enum Pages {
ChooseProtocolPageId,
EnterDetailsPageId,
OverviewPageId,
KeyCreationPageId,
......
......@@ -41,9 +41,9 @@ protected:
return static_cast<NewCertificateWizard *>(QWizardPage::wizard());
}
void resetProtocol()
bool pgp() const
{
wizard()->resetProtocol();
return wizard()->protocol() == GpgME::OpenPGP;
}
void restartAtEnterDetailsPage()
......@@ -58,7 +58,6 @@ protected:
protected:
#define FIELD(type, name) type name() const { return field( QStringLiteral(#name) ).value<type>(); }
FIELD(bool, pgp)
FIELD(bool, signingAllowed)
FIELD(bool, encryptionAllowed)
FIELD(bool, certificationAllowed)
......
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