Commit 3229c51b authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Create UI of Enter Details page in code

GnuPG-bug-id: 5969
parent 14bfcf7c
......@@ -342,7 +342,6 @@ ki18n_wrap_ui(_kleopatra_SRCS
dialogs/trustchainwidget.ui
dialogs/subkeyswidget.ui
newcertificatewizard/listwidget.ui
newcertificatewizard/enterdetailspage.ui
newcertificatewizard/keycreationpage.ui
newcertificatewizard/resultpage.ui
newcertificatewizard/advancedsettingsdialog.ui
......
......@@ -19,7 +19,6 @@
#include "utils/validation.h"
#include <settings.h>
#include <ui_enterdetailspage.h>
#include <Libkleo/Compat>
#include <Libkleo/Dn>
......@@ -27,11 +26,20 @@
#include <Libkleo/OidMap>
#include <Libkleo/Stl_Util>
#include <KLocalizedString>
#include <QGpgME/CryptoConfig>
#include <QGpgME/Protocol>
#include <QCheckBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QMetaProperty>
#include <QPushButton>
#include <QSpacerItem>
#include <QValidator>
#include <QVBoxLayout>
#include "kleopatra_debug.h"
......@@ -77,13 +85,98 @@ static QString attributeFromKey(QString key)
return key.remove(QLatin1Char('!'));
}
struct EnterDetailsPage::UI
{
QGridLayout *gridLayout = nullptr;
QLabel *nameLB = nullptr;
QLineEdit *nameLE = nullptr;
QLabel *nameRequiredLB = nullptr;
QLabel *emailLB = nullptr;
QLineEdit *emailLE = nullptr;
QLabel *emailRequiredLB = nullptr;
QCheckBox *withPassCB = nullptr;
QLineEdit *resultLE = nullptr;
QLabel *errorLB = nullptr;
QPushButton *advancedPB = nullptr;
UI(QWizardPage *parent)
{
parent->setTitle(i18nc("@title", "Enter Details"));
auto mainLayout = new QVBoxLayout{parent};
gridLayout = new QGridLayout;
int row = 0;
nameLB = new QLabel{i18n("Real name:"), parent};
nameLE = new QLineEdit{parent};
nameRequiredLB = new QLabel{i18n("(required)"), parent};
gridLayout->addWidget(nameLB, row, 0, 1, 1);
gridLayout->addWidget(nameLE, row, 1, 1, 1);
gridLayout->addWidget(nameRequiredLB, row, 2, 1, 1);
row++;
emailLB = new QLabel{i18n("EMail address:"), parent};
emailLE = new QLineEdit{parent};
emailRequiredLB = new QLabel{i18n("(required)"), parent};
gridLayout->addWidget(emailLB, row, 0, 1, 1);
gridLayout->addWidget(emailLE, row, 1, 1, 1);
gridLayout->addWidget(emailRequiredLB, row, 2, 1, 1);
row++;
withPassCB = new QCheckBox{i18n("Protect the generated key with a passphrase."), parent};
withPassCB->setToolTip(i18n("Encrypts the secret key with an unrecoverable passphrase. You will be asked for the passphrase during key generation."));
gridLayout->addWidget(withPassCB, row, 1, 1, 2);
mainLayout->addLayout(gridLayout);
auto verticalSpacer = new QSpacerItem{20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding};
mainLayout->addItem(verticalSpacer);
resultLE = new QLineEdit{parent};
resultLE->setFrame(false);
resultLE->setAlignment(Qt::AlignCenter);
resultLE->setReadOnly(true);
mainLayout->addWidget(resultLE);
auto horizontalLayout = new QHBoxLayout;
errorLB = new QLabel{parent};
QSizePolicy sizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(errorLB->sizePolicy().hasHeightForWidth());
errorLB->setSizePolicy(sizePolicy);
QPalette palette;
QBrush brush(QColor(255, 0, 0, 255));
brush.setStyle(Qt::SolidPattern);
palette.setBrush(QPalette::Active, QPalette::WindowText, brush);
palette.setBrush(QPalette::Inactive, QPalette::WindowText, brush);
QBrush brush1(QColor(114, 114, 114, 255));
brush1.setStyle(Qt::SolidPattern);
palette.setBrush(QPalette::Disabled, QPalette::WindowText, brush1);
errorLB->setPalette(palette);
errorLB->setTextFormat(Qt::RichText);
horizontalLayout->addWidget(errorLB);
advancedPB = new QPushButton{i18n("Advanced Settings..."), parent};
advancedPB->setAutoDefault(false);
horizontalLayout->addWidget(advancedPB);
mainLayout->addLayout(horizontalLayout);
}
};
EnterDetailsPage::EnterDetailsPage(QWidget *p)
: WizardPage{p}
, ui{new Ui_EnterDetailsPage}
, ui{new UI{this}}
, dialog{new AdvancedSettingsDialog{this}}
{
ui->setupUi(this);
setObjectName(QStringLiteral("Kleo__NewCertificateUi__EnterDetailsPage"));
Settings settings;
if (settings.hideAdvanced()) {
......@@ -99,6 +192,7 @@ EnterDetailsPage::EnterDetailsPage(QWidget *p)
ui->errorLB->setFixedHeight(ui->errorLB->minimumSizeHint().height());
ui->errorLB->clear();
connect(ui->advancedPB, &QPushButton::clicked, this, &EnterDetailsPage::slotAdvancedSettingsClicked);
connect(ui->resultLE, &QLineEdit::textChanged,
this, &QWizardPage::completeChanged);
// The email doesn't necessarily show up in ui->resultLE:
......
<ui version="4.0" >
<class>Kleo::NewCertificateUi::EnterDetailsPage</class>
<widget class="QWizardPage" name="Kleo::NewCertificateUi::EnterDetailsPage" >
<property name="title" >
<string comment="@title" >Enter Details</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<layout class="QGridLayout" name="gridLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="nameLB" >
<property name="text" >
<string>Real name:</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLineEdit" name="nameLE" />
</item>
<item row="0" column="2" >
<widget class="QLabel" name="nameRequiredLB" >
<property name="text" >
<string>(required)</string>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="emailLB" >
<property name="text" >
<string>EMail address:</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLineEdit" name="emailLE" />
</item>
<item row="1" column="2" >
<widget class="QLabel" name="emailRequiredLB" >
<property name="text" >
<string>(required)</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QCheckBox" name="withPassCB">
<property name="text" >
<string>Protect the generated key with a passphrase.</string>
</property>
<property name="toolTip" >
<string>Encrypts the secret key with an unrecoverable passphrase. You will be asked for the passphrase during key generation.</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLineEdit" name="resultLE" >
<property name="frame" >
<bool>false</bool>
</property>
<property name="alignment" >
<set>Qt::AlignCenter</set>
</property>
<property name="readOnly" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<widget class="QLabel" name="errorLB" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="MinimumExpanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette" >
<palette>
<active>
<colorrole role="WindowText" >
<brush brushstyle="SolidPattern" >
<color alpha="255" >
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText" >
<brush brushstyle="SolidPattern" >
<color alpha="255" >
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText" >
<brush brushstyle="SolidPattern" >
<color alpha="255" >
<red>114</red>
<green>114</green>
<blue>114</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="textFormat" >
<enum>Qt::RichText</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="advancedPB" >
<property name="text" >
<string>Advanced Settings...</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>advancedPB</sender>
<signal>clicked()</signal>
<receiver>Kleo::NewCertificateUi::EnterDetailsPage</receiver>
<slot>slotAdvancedSettingsClicked()</slot>
<hints>
<hint type="sourcelabel" >
<x>359</x>
<y>173</y>
</hint>
<hint type="destinationlabel" >
<x>459</x>
<y>175</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>slotAdvancedSettingsClicked()</slot>
</slots>
</ui>
......@@ -16,11 +16,6 @@
class AdvancedSettingsDialog;
class QLineEdit;
namespace Kleo::NewCertificateUi
{
class Ui_EnterDetailsPage;
}
class EnterDetailsPage : public Kleo::NewCertificateUi::WizardPage
{
Q_OBJECT
......@@ -55,7 +50,9 @@ private Q_SLOTS:
void slotUpdateResultLabel();
private:
std::unique_ptr<Kleo::NewCertificateUi::Ui_EnterDetailsPage> ui;
struct UI;
std::unique_ptr<UI> ui;
QVector<Line> lineList;
QList<QWidget *> dynamicWidgets;
QMap<QString, QString> savedValues;
......
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