Skip to content

Commit

Permalink
FIX(a11y): Improve accessibility of configuration dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Hartmnt committed Jan 2, 2024
1 parent d83924e commit a3a15bd
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
81 changes: 81 additions & 0 deletions src/mumble/ConfigDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
#include <QtCore/QMutexLocker>
#include <QtGui/QScreen>
#include <QtWidgets/QDesktopWidget>
#include <QtWidgets/QGroupBox>
#include <QtWidgets/QMessageBox>
#include <QtWidgets/QPushButton>

#include <QDebug>


// init static member fields
QMutex ConfigDialog::s_existingWidgetsMutex;
Expand Down Expand Up @@ -77,13 +80,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->setFocusPolicy(Qt::NoFocus);

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,11 +116,14 @@ 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);
setTabOrder(qsa, pageButtonBox->button(QDialogButtonBox::Reset));
} else {
qhPages.insert(cw, cw);
qswPages->addWidget(cw);
setTabOrder(cw, pageButtonBox->button(QDialogButtonBox::Reset));
}
qmWidgets.insert(idx, cw);
cw->load(Global::get().s);
Expand Down Expand Up @@ -196,6 +206,77 @@ 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);

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;
/*
if (contentFocusWidget->nextInFocusChain()) {
contentFocusWidget = contentFocusWidget->nextInFocusChain();
}
while (contentFocusWidget
&& (qobject_cast< QGroupBox * >(contentFocusWidget) || contentFocusWidget->focusPolicy() == Qt::NoFocus)
&& contentFocusWidget->nextInFocusChain()) {
contentFocusWidget = contentFocusWidget->nextInFocusChain();
}*/
}

if (contentFocusWidget) {
qDebug() << contentFocusWidget->accessibleName() << " " << contentFocusWidget->metaObject()->className();
} else {
qDebug() << "No contentFocusWidget";
}

qDebug() << "page is: " << qswPages->currentWidget()->accessibleName() << " "
<< qswPages->currentWidget()->metaObject()->className();

setTabOrder(cancelButton, okButton);
setTabOrder(okButton, qlwIcons);
setTabOrder(qlwIcons, contentFocusWidget);
setTabOrder(contentFocusWidget, resetButton);
setTabOrder(resetButton, restoreButton);
setTabOrder(restoreButton, applyButton);
setTabOrder(applyButton, cancelButton);

if (restoreButton && restoreButton->nextInFocusChain()) {
qDebug() << "after defaults is: " << restoreButton->nextInFocusChain()->accessibleName() << " "
<< restoreButton->nextInFocusChain()->metaObject()->className();
} else {
qDebug() << "After restore is nullptr";
}

if (applyButton && applyButton->nextInFocusChain()) {
qDebug() << "after apply is: " << applyButton->nextInFocusChain()->accessibleName() << " "
<< applyButton->nextInFocusChain()->metaObject()->className();
} else {
qDebug() << "After apply is nullptr";
}

if (applyButton && applyButton->previousInFocusChain()) {
qDebug() << "previous apply is: " << applyButton->previousInFocusChain()->accessibleName() << " "
<< applyButton->previousInFocusChain()->metaObject()->className();
} else {
qDebug() << "previous apply is nullptr";
}
}

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 a3a15bd

Please sign in to comment.