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

Give keyboard focus to the checked radio button when showing dialog

GnuPG-bug-id: 6080
parent f3c14393
......@@ -13,6 +13,7 @@
#include "expirydialog.h"
#include "utils/gui-helper.h"
#include "utils/qt-cxx20-compat.h"
#include <KDateComboBox>
......@@ -110,10 +111,12 @@ private:
private:
QDate inDate() const;
int inAmountByDate(const QDate &date) const;
void setInitialFocus();
private:
ExpiryDialog::Mode mode;
int inUnit;
bool initialFocusWasSet = false;
struct UI {
QRadioButton *neverRB;
......@@ -271,6 +274,16 @@ int ExpiryDialog::Private::inAmountByDate(const QDate &selected) const
return -1;
}
void ExpiryDialog::Private::setInitialFocus()
{
if (initialFocusWasSet) {
return;
}
// give focus to the checked radio button
(void) focusFirstCheckedButton({ui.neverRB, ui.inRB, ui.onRB});
initialFocusWasSet = true;
}
ExpiryDialog::ExpiryDialog(Mode mode, QWidget *p)
: QDialog{p}
, d{new Private{mode, this}}
......@@ -311,4 +324,10 @@ bool ExpiryDialog::updateExpirationOfAllSubkeys() const
return d->ui.updateSubkeysCheckBox->isChecked();
}
void ExpiryDialog::showEvent(QShowEvent *event)
{
d->setInitialFocus();
QDialog::showEvent(event);
}
#include "moc_expirydialog.cpp"
......@@ -16,6 +16,7 @@
#include <memory.h>
class QDate;
class QShowEvent;
namespace Kleo
{
......@@ -42,6 +43,9 @@ public:
void setUpdateExpirationOfAllSubkeys(bool update);
bool updateExpirationOfAllSubkeys() const;
protected:
void showEvent(QShowEvent *event) override;
private:
class Private;
std::unique_ptr<Private> d;
......
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