Verified Commit c72081d7 authored by Ingo Klöcker's avatar Ingo Klöcker Committed by Ingo Klöcker
Browse files

Disable Certify action if key cannot be certified

GnuPG-bug-id: 6155
parent 6c387232
Pipeline #232168 failed with stage
in 1 minute and 17 seconds
......@@ -433,6 +433,7 @@ void CertificateDetailsWidget::Private::setupCommonProperties()
const bool isSMIME = key.protocol() == GpgME::CMS;
const bool isOwnKey = key.hasSecret();
const auto isLocalKey = !isRemoteKey(key);
const auto keyCanBeCertified = Kleo::canBeCertified(key);
// update visibility of UI elements
ui.userIDs->setVisible(isOpenPGP);
......@@ -477,7 +478,7 @@ void CertificateDetailsWidget::Private::setupCommonProperties()
const auto userCanSignUserIDs = userHasCertificationKey();
ui.addUserIDBtn->setEnabled(canBeUsedForSecretKeyOperations(key));
ui.setPrimaryUserIDBtn->setEnabled(false); // requires a selected user ID
ui.certifyBtn->setEnabled(userCanSignUserIDs && isLocalKey);
ui.certifyBtn->setEnabled(isLocalKey && keyCanBeCertified && userCanSignUserIDs);
ui.webOfTrustBtn->setEnabled(isLocalKey);
ui.revokeCertificationsBtn->setEnabled(userCanSignUserIDs && isLocalKey);
ui.revokeUserIDBtn->setEnabled(false); // requires a selected user ID
......@@ -806,6 +807,7 @@ void CertificateDetailsWidget::Private::userIDTableContextMenuRequested(const QP
#endif
const bool canSignUserIDs = userHasCertificationKey();
const auto isLocalKey = !isRemoteKey(key);
const auto keyCanBeCertified = Kleo::canBeCertified(key);
auto menu = new QMenu(q);
#ifdef QGPGME_SUPPORTS_SET_PRIMARY_UID
......@@ -829,7 +831,7 @@ void CertificateDetailsWidget::Private::userIDTableContextMenuRequested(const QP
q, [this]() {
certifyUserIDs();
});
action->setEnabled(isLocalKey && canSignUserIDs);
action->setEnabled(isLocalKey && keyCanBeCertified && canSignUserIDs);
}
if (Kleo::Commands::RevokeCertificationCommand::isSupported()) {
const auto actionText = userIDs.empty() ? i18nc("@action:inmenu", "Revoke Certifications...")
......
......@@ -193,10 +193,11 @@ public:
void updateActions() {
const auto userCanSignUserIDs = userHasCertificationKey();
const auto keyCanBeCertified = Kleo::canBeCertified(key);
const auto userID = selectedUserID();
const auto signature = selectedCertification();
detailsAction->setEnabled(!signature.isNull());
certifyAction->setEnabled(userCanSignUserIDs && (!userID.isNull() || !signature.isNull()));
certifyAction->setEnabled(keyCanBeCertified && userCanSignUserIDs && (!userID.isNull() || !signature.isNull()));
if (revokeAction) {
revokeAction->setToolTip({});
if (!signature.isNull()) {
......
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