Skip to content

Commit

Permalink
FIX(a11y): Improve accessibility of configuration dialog buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
Hartmnt committed Jan 2, 2024
1 parent 4995a79 commit a9cc4dc
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/mumble/ConfigDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "AudioInput.h"
#include "AudioOutput.h"
#include "InlineWidgets.h"
#include "Global.h"

#include <QScrollArea>
Expand Down Expand Up @@ -77,13 +78,17 @@ ConfigDialog::ConfigDialog(QWidget *p) : QDialog(p) {
QPushButton *restoreAllButton = pageButtonBox->addButton(tr("Defaults (All)"), QDialogButtonBox::ResetRole);
restoreAllButton->setToolTip(tr("Restore all defaults"));
restoreAllButton->setWhatsThis(tr("This button will restore the defaults for all settings."));
restoreAllButton->installEventFilter(new OverrideTabOrderFilter(restoreAllButton, applyButton));

if (!Global::get().s.qbaConfigGeometry.isEmpty()) {
#ifdef USE_OVERLAY
if (!Global::get().ocIntercept)
#endif
restoreGeometry(Global::get().s.qbaConfigGeometry);
}

updateTabOrder();
qlwIcons->setFocus();
}

void ConfigDialog::addPage(ConfigWidget *cw, unsigned int idx) {
Expand All @@ -109,6 +114,7 @@ void ConfigDialog::addPage(ConfigWidget *cw, unsigned int idx) {
qsa->setFrameShape(QFrame::NoFrame);
qsa->setWidgetResizable(true);
qsa->setWidget(cw);
qsa->setFocusPolicy(Qt::NoFocus);
qhPages.insert(cw, qsa);
qswPages->addWidget(qsa);
} else {
Expand Down Expand Up @@ -196,7 +202,45 @@ void ConfigDialog::on_qlwIcons_currentItemChanged(QListWidgetItem *current, QLis
QWidget *w = qhPages.value(qmIconWidgets.value(current));
if (w)
qswPages->setCurrentWidget(w);

updateTabOrder();
}
}

void ConfigDialog::updateTabOrder() {
QPushButton *okButton = dialogButtonBox->button(QDialogButtonBox::Ok);
QPushButton *cancelButton = dialogButtonBox->button(QDialogButtonBox::Cancel);
QPushButton *applyButton = dialogButtonBox->button(QDialogButtonBox::Apply);
QPushButton *resetButton = pageButtonBox->button(QDialogButtonBox::Reset);
QPushButton *restoreButton = pageButtonBox->button(QDialogButtonBox::RestoreDefaults);
QPushButton *restoreAllButton = static_cast< QPushButton * >(pageButtonBox->buttons().last());

QWidget *contentFocusWidget = qswPages;

ConfigWidget *page;
QScrollArea *qsa = qobject_cast< QScrollArea * >(qswPages->currentWidget());
if (qsa) {
page = qobject_cast< ConfigWidget * >(qsa->widget());
} else {
page = qobject_cast< ConfigWidget * >(qswPages->currentWidget());
}

if (page) {
contentFocusWidget = page;
}

setTabOrder(cancelButton, okButton);
setTabOrder(okButton, qlwIcons);
setTabOrder(qlwIcons, contentFocusWidget);
if (resetButton && restoreButton && restoreAllButton) {
setTabOrder(contentFocusWidget, resetButton);
setTabOrder(resetButton, restoreButton);
setTabOrder(restoreButton, restoreAllButton);
setTabOrder(restoreAllButton, applyButton);
} else {
setTabOrder(contentFocusWidget, applyButton);
}
setTabOrder(applyButton, cancelButton);
}

void ConfigDialog::updateListView() {
Expand Down
2 changes: 2 additions & 0 deletions src/mumble/ConfigDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class ConfigDialog : public QDialog, public Ui::ConfigDialog {
private:
Q_OBJECT
Q_DISABLE_COPY(ConfigDialog)

void updateTabOrder();
protected:
static QMutex s_existingWidgetsMutex;
static QHash< QString, ConfigWidget * > s_existingWidgets;
Expand Down

0 comments on commit a9cc4dc

Please sign in to comment.