From: Felix Ernst Date: Thu, 15 Aug 2024 17:56:39 +0000 (+0200) Subject: DolphinSettingsDialog: Move focus to Okay button last X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/9e98b66e6b3b86556e6a942b2231e33e575ea25f DolphinSettingsDialog: Move focus to Okay button last This commit changes the Tab order in Dolphin's Configure dialog so that the items which are visually at the end of the dialog are also last in the keyboard focus order when cycling through the interface using the Tab key. Previously, the "Cancel", "Defaults", "Okay", and "Apply" buttons received focus prior to the actual contents of the pages which does not make sense from a workflow perspective. This change should also make navigating this dialog easier when relying on screen readers because reading those buttons out prior to users even having a chance to change any setting did not make any sense. --- diff --git a/src/settings/dolphinsettingsdialog.cpp b/src/settings/dolphinsettingsdialog.cpp index c564dd196..782a03ae9 100644 --- a/src/settings/dolphinsettingsdialog.cpp +++ b/src/settings/dolphinsettingsdialog.cpp @@ -39,14 +39,6 @@ DolphinSettingsDialog::DolphinSettingsDialog(const QUrl &url, QWidget *parent, K setFaceType(List); setWindowTitle(i18nc("@title:window", "Configure")); - QDialogButtonBox *box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel | QDialogButtonBox::RestoreDefaults); - box->button(QDialogButtonBox::Apply)->setEnabled(false); - box->button(QDialogButtonBox::Ok)->setDefault(true); - setButtonBox(box); - - connect(box->button(QDialogButtonBox::Ok), &QAbstractButton::clicked, this, &DolphinSettingsDialog::applySettings); - connect(box->button(QDialogButtonBox::Apply), &QAbstractButton::clicked, this, &DolphinSettingsDialog::applySettings); - connect(box->button(QDialogButtonBox::RestoreDefaults), &QAbstractButton::clicked, this, &DolphinSettingsDialog::restoreDefaults); // Interface InterfaceSettingsPage *interfaceSettingsPage = new InterfaceSettingsPage(this); @@ -112,6 +104,16 @@ DolphinSettingsDialog::DolphinSettingsDialog(const QUrl &url, QWidget *parent, K } #endif + // Create the buttons last so they are also last in the keyboard Tab focus order. + QDialogButtonBox *box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel | QDialogButtonBox::RestoreDefaults); + box->button(QDialogButtonBox::Apply)->setEnabled(false); + box->button(QDialogButtonBox::Ok)->setDefault(true); + setButtonBox(box); + + connect(box->button(QDialogButtonBox::Ok), &QAbstractButton::clicked, this, &DolphinSettingsDialog::applySettings); + connect(box->button(QDialogButtonBox::Apply), &QAbstractButton::clicked, this, &DolphinSettingsDialog::applySettings); + connect(box->button(QDialogButtonBox::RestoreDefaults), &QAbstractButton::clicked, this, &DolphinSettingsDialog::restoreDefaults); + const KConfigGroup dialogConfig(KSharedConfig::openStateConfig(), QStringLiteral("SettingsDialog")); KWindowConfig::restoreWindowSize(windowHandle(), dialogConfig); }