]> cloud.milkyroute.net Git - dolphin.git/commitdiff
DolphinSettingsDialog: Move focus to Okay button last
authorFelix Ernst <felixernst@zohomail.eu>
Thu, 15 Aug 2024 17:56:39 +0000 (19:56 +0200)
committerFelix Ernst <felixernst@kde.org>
Fri, 16 Aug 2024 09:45:58 +0000 (09:45 +0000)
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.

src/settings/dolphinsettingsdialog.cpp

index c564dd196c0b692232c8fc8bc8a052e2f5f2f611..782a03ae9132494e4f32f9099565573c069f7bfb 100644 (file)
@@ -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);
 }