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

Allow setting the widget that shall have the initial focus

This is useful for focussing the group name if a new group is edited,
but focussing the keys filter if an existing group is edited (where
it is more likely that the user wants to change the keys in the group
than the name of the group).

GnuPG-bug-id: 5175, 5239
parent 9873a5a4
......@@ -194,9 +194,6 @@ public:
connect(ui.buttonBox, &QDialogButtonBox::accepted, q, &EditGroupDialog::accept);
connect(ui.buttonBox, &QDialogButtonBox::rejected, q, &EditGroupDialog::reject);
// give initial keyboard focus to the keys filter
ui.availableKeysFilter->setFocus();
// calculate default size with enough space for the key list
const auto fm = q->fontMetrics();
const QSize sizeHint = q->sizeHint();
......@@ -285,6 +282,20 @@ EditGroupDialog::~EditGroupDialog()
{
}
void EditGroupDialog::setInitialFocus(FocusWidget widget)
{
switch (widget) {
case GroupName:
d->ui.groupNameEdit->setFocus();
break;
case KeysFilter:
d->ui.availableKeysFilter->setFocus();
break;
default:
qCDebug(KLEOPATRA_LOG) << "EditGroupDialog::setInitialFocus - invalid focus widget:" << widget;
}
}
void EditGroupDialog::setGroupName(const QString &name)
{
d->ui.groupNameEdit->setText(name);
......
......@@ -29,9 +29,16 @@ class EditGroupDialog : public QDialog
{
Q_OBJECT
public:
enum FocusWidget {
GroupName,
KeysFilter
};
explicit EditGroupDialog(QWidget *parent = nullptr);
~EditGroupDialog() override;
void setInitialFocus(FocusWidget widget);
void setGroupName(const QString &name);
QString groupName() const;
......
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