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 2981398
Show file tree
Hide file tree
Showing 2 changed files with 165 additions and 0 deletions.
163 changes: 163 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,6 +116,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 +204,162 @@ 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 = pageButtonBox->button(QDialogButtonBox::ResetRole);

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);
if (resetButton && restoreButton && restoreAllButton) {
setTabOrder(contentFocusWidget, resetButton);
setTabOrder(resetButton, restoreButton);
setTabOrder(restoreButton, restoreAllButton);
setTabOrder(restoreAllButton, applyButton);
} else {
setTabOrder(contentFocusWidget, applyButton);
}
setTabOrder(applyButton, cancelButton);


if (resetButton && resetButton->previousInFocusChain()) {
qDebug() << "previous reset is: " << resetButton->previousInFocusChain()->accessibleName() << " "
<< resetButton->previousInFocusChain()->metaObject()->className();

QAbstractButton *button = qobject_cast< QAbstractButton * >(resetButton->previousInFocusChain());
if(button){
qDebug() << button->text();
}
} else {
qDebug() << "previous reset is nullptr";
}

if (resetButton && resetButton->nextInFocusChain()) {
qDebug() << "after reset is: " << resetButton->nextInFocusChain()->accessibleName() << " "
<< resetButton->nextInFocusChain()->metaObject()->className();

QAbstractButton *button = qobject_cast< QAbstractButton * >(resetButton->nextInFocusChain());
if(button){
qDebug() << button->text();
}
} else {
qDebug() << "After reset is nullptr";
}

if (restoreButton && restoreButton->previousInFocusChain()) {
qDebug() << "previous restore is: " << restoreButton->previousInFocusChain()->accessibleName() << " "
<< restoreButton->previousInFocusChain()->metaObject()->className();

QAbstractButton *button = qobject_cast< QAbstractButton * >(restoreButton->previousInFocusChain());
if(button){
qDebug() << button->text();
}
} else {
qDebug() << "previous restore is nullptr";
}

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

QAbstractButton *button = qobject_cast< QAbstractButton * >(restoreButton->nextInFocusChain());
if(button){
qDebug() << button->text();
}
} else {
qDebug() << "After restore is nullptr";
}


if (restoreAllButton && restoreAllButton->previousInFocusChain()) {
qDebug() << "previous restoreall is: " << restoreAllButton->previousInFocusChain()->accessibleName() << " "
<< restoreAllButton->previousInFocusChain()->metaObject()->className();

QAbstractButton *button = qobject_cast< QAbstractButton * >(restoreAllButton->previousInFocusChain());
if(button){
qDebug() << button->text();
}
} else {
qDebug() << "previous restoreall is nullptr";
}

if (restoreAllButton && restoreAllButton->nextInFocusChain()) {
qDebug() << "after restoreall is: " << restoreAllButton->nextInFocusChain()->accessibleName() << " "
<< restoreAllButton->nextInFocusChain()->metaObject()->className();

QAbstractButton *button = qobject_cast< QAbstractButton * >(restoreAllButton->nextInFocusChain());
if(button){
qDebug() << button->text();
}
} else {
qDebug() << "After restoreall is nullptr";
}

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

QAbstractButton *button = qobject_cast< QAbstractButton * >(applyButton->previousInFocusChain());
if(button){
qDebug() << button->text();
}
} else {
qDebug() << "previous apply is nullptr";
}

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

QAbstractButton *button = qobject_cast< QAbstractButton * >(applyButton->nextInFocusChain());
if(button){
qDebug() << button->text();
}
} else {
qDebug() << "After apply is nullptr";
}

}

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 2981398

Please sign in to comment.