Commit 9cd07dc4 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Disable Ok button if no signatures can be revoked

If no certification key is selected (can only happen if users try to
revoke certifications on their only secret key) or no user IDs are
selected, then disable the OK button.

GnuPG-bug-id: 5858
parent 29b3f108
Pipeline #141826 passed with stage
in 2 minutes
......@@ -39,7 +39,8 @@ class RevokeCertificationDialog::Private
RevokeCertificationDialog *const q;
public:
explicit Private(RevokeCertificationDialog *qq);
~Private();
void updateOkButton();
private:
void saveGeometry();
......@@ -47,6 +48,7 @@ private:
private:
RevokeCertificationWidget *mainWidget = nullptr;
QPushButton *okButton = nullptr;
};
......@@ -55,8 +57,10 @@ RevokeCertificationDialog::Private::Private(RevokeCertificationDialog *qq)
{
}
RevokeCertificationDialog::Private::~Private()
void RevokeCertificationDialog::Private::updateOkButton()
{
okButton->setEnabled(!mainWidget->certificationKey().isNull()
&& !mainWidget->selectedUserIDs().empty());
}
void RevokeCertificationDialog::Private::saveGeometry()
......@@ -87,19 +91,28 @@ RevokeCertificationDialog::RevokeCertificationDialog(QWidget *p, Qt::WindowFlags
d->mainWidget = new RevokeCertificationWidget(this);
mainLay->addWidget(d->mainWidget);
auto buttonBox = new QDialogButtonBox();
auto buttonBox = new QDialogButtonBox(this);
mainLay->addWidget(buttonBox);
buttonBox->setStandardButtons(QDialogButtonBox::Cancel |
QDialogButtonBox::Ok);
KGuiItem::assign(buttonBox->button(QDialogButtonBox::Ok), KStandardGuiItem::ok());
KGuiItem::assign(buttonBox->button(QDialogButtonBox::Cancel), KStandardGuiItem::cancel());
buttonBox->button(QDialogButtonBox::Ok)->setText(i18n("Revoke Certification"));
connect(buttonBox->button(QDialogButtonBox::Ok), &QAbstractButton::clicked,
d->okButton = buttonBox->button(QDialogButtonBox::Ok);
auto cancelButton = buttonBox->button(QDialogButtonBox::Cancel);
KGuiItem::assign(d->okButton, KStandardGuiItem::ok());
KGuiItem::assign(cancelButton, KStandardGuiItem::cancel());
d->okButton->setText(i18n("Revoke Certification"));
connect(d->mainWidget, &RevokeCertificationWidget::certificationKeyChanged,
this, [this]() { d->updateOkButton(); });
connect(d->mainWidget, &RevokeCertificationWidget::selectedUserIDsChanged,
this, [this]() { d->updateOkButton(); });
d->updateOkButton();
connect(d->okButton, &QAbstractButton::clicked,
this, [this] () {
d->mainWidget->saveConfig();
accept();
});
connect(buttonBox->button(QDialogButtonBox::Cancel), &QAbstractButton::clicked,
connect(cancelButton, &QAbstractButton::clicked,
this, [this] () { close(); });
d->restoreGeometry(QSize(640, 480));
......
......@@ -180,6 +180,13 @@ public:
mainLayout->addWidget(mPublishCB);
loadConfig();
connect(mCertificationKeySelect, &KeySelectionCombo::currentKeyChanged,
q, &RevokeCertificationWidget::certificationKeyChanged);
connect(&mUserIDModel, &UserIDModel::itemChanged,
q, [this]() {
Q_EMIT q->selectedUserIDsChanged(q->selectedUserIDs());
});
}
~Private()
......
......@@ -54,6 +54,10 @@ public:
void saveConfig() const;
Q_SIGNALS:
void certificationKeyChanged(const GpgME::Key &key);
void selectedUserIDsChanged(const std::vector<GpgME::UserID> &uids);
private:
class Private;
const std::unique_ptr<Private> d;
......
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