Commit 86b349a9 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Improve usability of CSR creation

* Do not set an empty card holder name; this would clear the preset value
* Create input widgets before DN widget; this makes fixTabOrder()
  superfluous and automatically gives input focus to the first
  input widget
* Select the preset text in the first line edit; this allows the user
  to overwrite it easily
* Explicitly call the slots connected to textChanged() signals once
  the setup is complete
* Remember the attribute values entered by the user as presets for
  the next CSR creation

GnuPG-bug-id: 5127
parent 4385c4db
Pipeline #44232 passed with stage
in 19 minutes and 21 seconds
......@@ -143,7 +143,9 @@ void CreateCSRForCardKeyCommand::Private::start()
ensureDialogCreated();
dialog->setWindowTitle(i18n("Certificate Details"));
dialog->setName(card->cardHolder());
if (!card->cardHolder().isEmpty()) {
dialog->setName(card->cardHolder());
}
dialog->show();
}
......
......@@ -156,6 +156,8 @@ public:
ui.gridLayout = new QGridLayout();
mainLayout->addLayout(ui.gridLayout);
createForm();
mainLayout->addStretch(1);
ui.dn = new QLineEdit();
......@@ -190,12 +192,26 @@ public:
ui.error->clear();
mainLayout->addWidget(ui.error);
createForm();
fixTabOrder();
// select the preset text in the first line edit
if (!ui.lines.empty()) {
ui.lines.first().edit->selectAll();
}
// explicitly update DN and check requirements after setup is complete
updateDN();
checkRequirements();
}
~Private()
{
// remember current attribute values as presets for next certificate
KConfigGroup config(KSharedConfig::openConfig(), "CertificateCreationWizard");
for ( const Line &line : ui.lines ) {
const QString attr = attributeFromKey(line.attr);
const QString value = line.edit->text().trimmed();
config.writeEntry(attr, value);
}
config.sync();
}
void createForm()
......@@ -248,17 +264,6 @@ public:
}
}
void fixTabOrder()
{
QVector<QWidget *> widgets;
widgets.reserve(ui.lines.size() + 1);
for ( const Line &line : ui.lines ) {
widgets.push_back(line.edit);
}
widgets.push_back(ui.dn);
kdtools::for_each_adjacent_pair(widgets.begin(), widgets.end(), &QWidget::setTabOrder);
}
void updateDN()
{
ui.dn->setText(cmsDN());
......
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