Commit 62ec8eee authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Simplify the action of the recipient key input field

Make the action of the recipient key input field always trigger the
details dialog of the current certificate or group (if there is one).
Note: This action is not accessible via keyboard or for screen readers,
but that's okay because the details dialog can also be opened via the
context menu.

Moreover, use only emblem-* icons for the action to give the different
statuses a unified look.

GnuPG-bug-id: 5845
parent 0f2c2caa
Pipeline #147453 passed with stage
in 1 minute and 48 seconds
......@@ -152,7 +152,7 @@ private:
std::shared_ptr<KeyFilter> mFilter;
bool mEditStarted = false;
bool mEditFinished = false;
QAction *const mLineAction;
QAction *const mStatusAction;
QAction *const mShowDetailsAction;
};
......@@ -163,13 +163,13 @@ CertificateLineEdit::Private::Private(CertificateLineEdit *qq, AbstractKeyListMo
, mCompleterFilterModel{new CompletionProxyModel{qq}}
, mCompleter{new QCompleter{qq}}
, mFilter{std::shared_ptr<KeyFilter>{filter}}
, mLineAction{new QAction{qq}}
, mStatusAction{new QAction{qq}}
, mShowDetailsAction{new QAction{qq}}
{
ui.lineEdit.setPlaceholderText(i18n("Please enter a name or email address..."));
ui.lineEdit.setClearButtonEnabled(true);
ui.lineEdit.setContextMenuPolicy(Qt::CustomContextMenu);
ui.lineEdit.addAction(mLineAction, QLineEdit::LeadingPosition);
ui.lineEdit.addAction(mStatusAction, QLineEdit::LeadingPosition);
mCompleterFilterModel->setKeyFilter(mFilter);
mCompleterFilterModel->setSourceModel(model);
......@@ -229,8 +229,8 @@ CertificateLineEdit::Private::Private(CertificateLineEdit *qq, AbstractKeyListMo
q, [this]() { editChanged(); });
connect(&ui.lineEdit, &QLineEdit::customContextMenuRequested,
q, [this](const QPoint &pos) { showContextMenu(pos); });
connect(mLineAction, &QAction::triggered,
q, &CertificateLineEdit::dialogRequested);
connect(mStatusAction, &QAction::triggered,
q, [this]() { openDetailsDialog(); });
connect(mShowDetailsAction, &QAction::triggered,
q, [this]() { openDetailsDialog(); });
connect(&ui.button, &QToolButton::clicked,
......@@ -344,8 +344,8 @@ void CertificateLineEdit::Private::updateKey()
auto newKey = Key();
auto newGroup = KeyGroup();
if (mailText.isEmpty()) {
mLineAction->setIcon(QIcon::fromTheme(QStringLiteral("resource-group-new")));
mLineAction->setToolTip(i18n("Open selection dialog."));
mStatusAction->setIcon(QIcon::fromTheme(QStringLiteral("emblem-unavailable")));
mStatusAction->setToolTip({});
ui.lineEdit.setToolTip({});
} else {
mFilterModel->setFilterFixedString(mailText);
......@@ -372,15 +372,9 @@ void CertificateLineEdit::Private::updateKey()
}
}
if (newKey.isNull() && newGroup.isNull()) {
if (mEditFinished) {
mLineAction->setIcon(QIcon::fromTheme(QStringLiteral("question")));
mLineAction->setToolTip(i18n("Multiple matching certificates found"));
ui.lineEdit.setToolTip(i18n("Multiple matching certificates found"));
} else {
mLineAction->setIcon(QIcon::fromTheme(QStringLiteral("resource-group-new")));
mLineAction->setToolTip(i18n("Open selection dialog."));
ui.lineEdit.setToolTip({});
}
mStatusAction->setIcon(QIcon::fromTheme(QStringLiteral("emblem-question")));
mStatusAction->setToolTip(i18n("Multiple matching certificates or groups found"));
ui.lineEdit.setToolTip(i18n("Multiple matching certificates or groups found"));
}
} else if (mFilterModel->rowCount() == 1) {
const auto index = mFilterModel->index(0, 0);
......@@ -388,14 +382,14 @@ void CertificateLineEdit::Private::updateKey()
newGroup = mFilterModel->data(index, KeyList::GroupRole).value<KeyGroup>();
Q_ASSERT(!newKey.isNull() || !newGroup.isNull());
if (newKey.isNull() && newGroup.isNull()) {
mLineAction->setIcon(QIcon::fromTheme(QStringLiteral("emblem-error")));
mLineAction->setToolTip(i18n("No matching certificates found.<br/>Click to import a certificate."));
ui.lineEdit.setToolTip(i18n("No matching certificates found"));
mStatusAction->setIcon(QIcon::fromTheme(QStringLiteral("emblem-error")));
mStatusAction->setToolTip(i18n("No matching certificates or groups found"));
ui.lineEdit.setToolTip(i18n("No matching certificates or groups found"));
}
} else {
mLineAction->setIcon(QIcon::fromTheme(QStringLiteral("emblem-error")));
mLineAction->setToolTip(i18n("No matching certificates found.<br/>Click to import a certificate."));
ui.lineEdit.setToolTip(i18n("No matching certificates found"));
mStatusAction->setIcon(QIcon::fromTheme(QStringLiteral("emblem-error")));
mStatusAction->setToolTip(i18n("No matching certificates or groups found"));
ui.lineEdit.setToolTip(i18n("No matching certificates or groups found"));
}
}
mKey = newKey;
......@@ -403,14 +397,12 @@ void CertificateLineEdit::Private::updateKey()
if (!mKey.isNull()) {
/* FIXME: This needs to be solved by a multiple UID supporting model */
mLineAction->setIcon(Formatting::iconForUid(mKey.userID(0)));
mLineAction->setToolTip(Formatting::validity(mKey.userID(0)) +
QLatin1String("<br/>") + i18n("Click for details."));
mStatusAction->setIcon(Formatting::iconForUid(mKey.userID(0)));
mStatusAction->setToolTip(Formatting::validity(mKey.userID(0)));
ui.lineEdit.setToolTip(Formatting::toolTip(mKey, Formatting::ToolTipOption::AllOptions));
} else if (!mGroup.isNull()) {
mLineAction->setIcon(Formatting::validityIcon(mGroup));
mLineAction->setToolTip(Formatting::validity(mGroup) +
QLatin1String("<br/>") + i18n("Click for details."));
mStatusAction->setIcon(Formatting::validityIcon(mGroup));
mStatusAction->setToolTip(Formatting::validity(mGroup));
ui.lineEdit.setToolTip(Formatting::toolTip(mGroup, Formatting::ToolTipOption::AllOptions));
}
......
......@@ -81,9 +81,6 @@ Q_SIGNALS:
/** Emitted when the entry is no longer empty. */
void editingStarted();
/** Emitted when the details dialog or the selection dialog is requested. */
void dialogRequested();
/** Emitted when the certificate selection dialog is requested. */
void certificateSelectionRequested();
......
......@@ -17,10 +17,7 @@
#include "settings.h"
#include "unknownrecipientwidget.h"
#include "commands/detailscommand.h"
#include "dialogs/certificateselectiondialog.h"
#include "dialogs/groupdetailsdialog.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
......@@ -278,8 +275,6 @@ CertificateLineEdit *SignEncryptWidget::addRecipientWidget()
this, &SignEncryptWidget::recpRemovalRequested);
connect(certSel, &CertificateLineEdit::editingStarted,
this, &SignEncryptWidget::recipientsChanged);
connect(certSel, &CertificateLineEdit::dialogRequested,
this, [this, certSel] () { dialogRequested(certSel); });
connect(certSel, &CertificateLineEdit::certificateSelectionRequested,
this, [this, certSel]() { certificateSelectionRequested(certSel); });
......@@ -304,24 +299,6 @@ void SignEncryptWidget::addRecipient(const KeyGroup &group)
}
}
void SignEncryptWidget::dialogRequested(CertificateLineEdit *certificateLineEdit)
{
if (!certificateLineEdit->key().isNull()) {
auto cmd = new Commands::DetailsCommand(certificateLineEdit->key(), nullptr);
cmd->start();
return;
}
if (!certificateLineEdit->group().isNull()) {
auto dlg = new GroupDetailsDialog;
dlg->setAttribute(Qt::WA_DeleteOnClose);
dlg->setGroup(certificateLineEdit->group());
dlg->show();
return;
}
certificateSelectionRequested(certificateLineEdit);
}
void SignEncryptWidget::certificateSelectionRequested(CertificateLineEdit *certificateLineEdit)
{
CertificateSelectionDialog dlg{this};
......
......@@ -102,7 +102,6 @@ protected Q_SLOTS:
void updateOp();
void recipientsChanged();
void recpRemovalRequested(CertificateLineEdit *w);
void dialogRequested(CertificateLineEdit *w);
void certificateSelectionRequested(CertificateLineEdit *w);
protected:
......
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