Commit 89467cf4 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Insert all selected certificates/groups back-to-back

If multiple certificates/groups are selected, then they are inserted
in the list of recipients back-to-back. Previously, all but the first
selected certificates were appended to the list possibly after the
trailing empty recipient input field.

GnuPG-bug-id: 5845
parent 4a3594fa
Pipeline #155597 passed with stage
in 4 minutes and 6 seconds
......@@ -256,18 +256,27 @@ void SignEncryptWidget::setEncryptWithPasswordText(const QString& text)
CertificateLineEdit *SignEncryptWidget::addRecipientWidget()
{
return insertRecipientWidget(nullptr);
}
CertificateLineEdit *SignEncryptWidget::insertRecipientWidget(CertificateLineEdit *after)
{
Q_ASSERT(!after || mRecpLayout->indexOf(after) != -1);
const auto index = after ? mRecpLayout->indexOf(after) + 1 : mRecpLayout->count();
auto certSel = new CertificateLineEdit(mModel,
new EncryptCertificateFilter(mCurrentProto),
this);
certSel->setAccessibleNameOfLineEdit(i18nc("text for screen readers", "recipient key"));
certSel->setEnabled(mEncOtherChk->isChecked());
mRecpWidgets << certSel;
mRecpWidgets.insert(index, certSel);
if (mRecpLayout->count() > 0) {
auto lastWidget = mRecpLayout->itemAt(mRecpLayout->count() - 1)->widget();
setTabOrder(lastWidget, certSel);
auto prevWidget = after ? after : mRecpLayout->itemAt(mRecpLayout->count() - 1)->widget();
setTabOrder(prevWidget, certSel);
}
mRecpLayout->addWidget(certSel);
mRecpLayout->insertWidget(index, certSel);
connect(certSel, &CertificateLineEdit::keyChanged,
this, &SignEncryptWidget::recipientsChanged);
......@@ -324,22 +333,22 @@ void SignEncryptWidget::certificateSelectionRequested(CertificateLineEdit *certi
if (keys.size() == 0 && groups.size() == 0) {
return;
}
bool isFirstItem = true;
CertificateLineEdit *certWidget = nullptr;
for (const Key &key : keys) {
if (isFirstItem) {
certificateLineEdit->setKey(key);
isFirstItem = false;
if (!certWidget) {
certWidget = certificateLineEdit;
} else {
addRecipient(key);
certWidget = insertRecipientWidget(certWidget);
}
certWidget->setKey(key);
}
for (const KeyGroup &group : groups) {
if (isFirstItem) {
certificateLineEdit->setGroup(group);
isFirstItem = false;
if (!certWidget) {
certWidget = certificateLineEdit;
} else {
addRecipient(group);
certWidget = insertRecipientWidget(certWidget);
}
certWidget->setGroup(group);
}
}
......
......@@ -122,6 +122,9 @@ Q_SIGNALS:
private:
CertificateLineEdit* addRecipientWidget();
/** Inserts a new recipient widget after widget @p after or at the end
* if @p after is null. */
CertificateLineEdit* insertRecipientWidget(CertificateLineEdit *after);
void onProtocolChanged();
void updateCheckBoxes();
......
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