Skip to content

Commit

Permalink
FIX(a11y): Make global shortcut settings more accessible
Browse files Browse the repository at this point in the history
  • Loading branch information
Hartmnt committed Jan 7, 2024
1 parent 85f7370 commit 88f7c81
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
22 changes: 20 additions & 2 deletions src/mumble/GlobalShortcut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ ShortcutActionWidget::ShortcutActionWidget(QWidget *p) : MUComboBox(p) {
setModel(proxy);

model()->sort(0);
setFocusPolicy(Qt::ClickFocus);
clearFocus();
}

void ShortcutActionWidget::setIndex(int idx) {
Expand Down Expand Up @@ -347,14 +349,16 @@ ShortcutTargetWidget::ShortcutTargetWidget(QWidget *p) : QFrame(p) {

qtbEdit = new QToolButton();
qtbEdit->setText(tr("..."));
qtbEdit->setFocusPolicy(Qt::ClickFocus);
qtbEdit->setFocusPolicy(Qt::TabFocus);
qtbEdit->setObjectName(QLatin1String("qtbEdit"));

QHBoxLayout *l = new QHBoxLayout(this);
l->setContentsMargins(0, 0, 0, 0);
l->addWidget(qleTarget, 1);
l->addWidget(qtbEdit);

setFocusProxy(qtbEdit);

QMetaObject::connectSlotsByName(this);
}

Expand Down Expand Up @@ -556,11 +560,16 @@ GlobalShortcutConfig::GlobalShortcutConfig(Settings &st) : ConfigWidget(st) {
qtwShortcuts->setColumnCount(canSuppress ? 4 : 3);
qtwShortcuts->setItemDelegate(new ShortcutDelegate(qtwShortcuts));

qtwShortcuts->headerItem()->setData(0, Qt::AccessibleTextRole, tr("Shortcut action"));
qtwShortcuts->headerItem()->setData(1, Qt::AccessibleTextRole, tr("Shortcut data"));
qtwShortcuts->headerItem()->setData(2, Qt::AccessibleTextRole, tr("Shortcut input combinations"));

qtwShortcuts->header()->setSectionResizeMode(0, QHeaderView::Fixed);
qtwShortcuts->header()->resizeSection(0, 150);
qtwShortcuts->header()->setSectionResizeMode(2, QHeaderView::Stretch);
if (canSuppress)
if (canSuppress) {
qtwShortcuts->header()->setSectionResizeMode(3, QHeaderView::ResizeToContents);
}

qcbEnableGlobalShortcuts->setVisible(canDisable);

Expand Down Expand Up @@ -705,6 +714,14 @@ void GlobalShortcutConfig::on_qtwShortcuts_itemChanged(QTreeWidgetItem *item, in
if (gs && sc.qvData.userType() != gs->qvDefault.userType()) {
item->setData(1, Qt::DisplayRole, gs->qvDefault);
}

if (gs) {
item->setData(0, Qt::AccessibleTextRole, gs->name);
} else {
item->setData(0, Qt::AccessibleTextRole, tr("Unassigned"));
}
item->setData(1, Qt::AccessibleTextRole, sc.qvData);
item->setData(3, Qt::AccessibleDescriptionRole, item->checkState(3) == Qt::Checked ? tr("checked") : tr("unchecked"));
}

QString GlobalShortcutConfig::title() const {
Expand Down Expand Up @@ -811,6 +828,7 @@ void GlobalShortcutConfig::reload() {
foreach (const Shortcut &sc, qlShortcuts) {
QTreeWidgetItem *item = itemForShortcut(sc);
qtwShortcuts->addTopLevelItem(item);
on_qtwShortcuts_itemChanged(item, 0);
}
#ifdef Q_OS_MAC
if (!Global::get().s.bSuppressMacEventTapWarning) {
Expand Down
12 changes: 11 additions & 1 deletion src/mumble/GlobalShortcut.ui
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,16 @@
</widget>
</item>
<item>
<widget class="QTreeWidget" name="qtwShortcuts">
<widget class="MultiColumnTreeWidget" name="qtwShortcuts">
<property name="toolTip">
<string>List of configured shortcuts</string>
</property>
<property name="accessibleName">
<string>Configured shortcuts</string>
</property>
<property name="accessibleDescription">
<string>Use up and down keys to navigate through your added shortcuts. Use left and right keys to navigate between actions and options for a single shortcut.</string>
</property>
<property name="editTriggers">
<set>QAbstractItemView::AllEditTriggers</set>
</property>
Expand Down Expand Up @@ -271,6 +274,13 @@ Without this option enabled, using Mumble's global shortcuts in privileged appli
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>MultiColumnTreeWidget</class>
<extends>QTreeWidget</extends>
<header>widgets/MultiColumnTreeWidget.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

0 comments on commit 88f7c81

Please sign in to comment.