Skip to content

Commit

Permalink
FIX(a11y): Make plugin config accessible
Browse files Browse the repository at this point in the history
  • Loading branch information
Hartmnt committed Jan 7, 2024
1 parent 1f41199 commit d0ec8fb
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/mumble/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ set(MUMBLE_SOURCES
"widgets/MUComboBox.h"
"widgets/MultiStyleWidgetWrapper.cpp"
"widgets/MultiStyleWidgetWrapper.h"
"widgets/MultiColumnTreeWidget.cpp"
"widgets/MultiColumnTreeWidget.h"
"widgets/RichTextItemDelegate.cpp"
"widgets/RichTextItemDelegate.h"
"widgets/SearchDialogItemDelegate.cpp"
Expand Down
15 changes: 15 additions & 0 deletions src/mumble/PluginConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ PluginConfig::PluginConfig(Settings &st) : ConfigWidget(st) {
qtwPlugins->header()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
qtwPlugins->header()->setSectionResizeMode(3, QHeaderView::ResizeToContents);

qtwPlugins->headerItem()->setData(0, Qt::AccessibleTextRole, tr("Plugin name"));
qtwPlugins->headerItem()->setData(1, Qt::AccessibleTextRole, tr("Plugin enabled checkbox"));
qtwPlugins->headerItem()->setData(2, Qt::AccessibleTextRole, tr("Plugin positional audio permission checkbox"));
qtwPlugins->headerItem()->setData(3, Qt::AccessibleTextRole, tr("Plugin keyboard event listen permission checkbox"));

qpbUnload->setEnabled(false);

refillPluginList();
Expand Down Expand Up @@ -245,6 +250,16 @@ void PluginConfig::on_qtwPlugins_currentItemChanged(QTreeWidgetItem *current, QT
qpbConfig->setEnabled(plugin->providesConfigDialog());

qpbUnload->setEnabled(true);

current->setData(1, Qt::AccessibleDescriptionRole, plugin->isLoaded() ? tr("checked") : tr("unchecked"));

if (plugin->getFeatures() & MUMBLE_FEATURE_POSITIONAL) {
current->setData(2, Qt::AccessibleDescriptionRole, plugin->isPositionalDataEnabled() ? tr("checked") : tr("unchecked"));
} else {
current->setData(2, Qt::AccessibleDescriptionRole, tr("Not available"));
}

current->setData(3, Qt::AccessibleDescriptionRole, plugin->isKeyboardMonitoringAllowed() ? tr("checked") : tr("unchecked"));
} else {
qpbAbout->setEnabled(false);
qpbConfig->setEnabled(false);
Expand Down
15 changes: 14 additions & 1 deletion src/mumble/PluginConfig.ui
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,16 @@
</property>
<layout class="QVBoxLayout">
<item>
<widget class="QTreeWidget" name="qtwPlugins">
<widget class="MultiColumnTreeWidget" name="qtwPlugins">
<property name="accessibleName">
<string>List of plugins</string>
</property>
<property name="accessibleDescription">
<string>Use up and down keys to navigate through plugins. Use left and right keys to navigate between single plugin permissions.</string>
</property>
<property name="tabKeyNavigation">
<bool>false</bool>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
Expand Down Expand Up @@ -159,6 +165,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>MultiColumnTreeWidget</class>
<extends>QTreeWidget</extends>
<header>widgets/MultiColumnTreeWidget.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
33 changes: 33 additions & 0 deletions src/mumble/widgets/MultiColumnTreeWidget.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright 2024 The Mumble Developers. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.

#include "MultiColumnTreeWidget.h"

#include <algorithm>

#include <QDebug>

MultiColumnTreeWidget::MultiColumnTreeWidget(QWidget *parent) : QTreeWidget(parent) {
}

QModelIndex MultiColumnTreeWidget::moveCursor(QAbstractItemView::CursorAction cursorAction, Qt::KeyboardModifiers modifiers) {
QModelIndex mi = QTreeWidget::moveCursor(cursorAction, modifiers);

if (cursorAction == QAbstractItemView::MoveLeft) {
mi = model()->index(mi.row(), std::max(0, mi.column() - 1));
}

if (cursorAction == QAbstractItemView::MoveRight) {
mi = model()->index(mi.row(), std::min(model()->columnCount() - 1, mi.column() + 1));
}

if (cursorAction == QAbstractItemView::MoveUp || cursorAction == QAbstractItemView::MoveDown) {
mi = model()->index(mi.row(), 0);
}

qDebug() << cursorAction << " - " << modifiers << " = " << mi;

return mi;
}
22 changes: 22 additions & 0 deletions src/mumble/widgets/MultiColumnTreeWidget.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2024 The Mumble Developers. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.

#ifndef MUMBLE_MUMBLE_WIDGETS_MULTICOLUMNTREEWIDGET_H_
#define MUMBLE_MUMBLE_WIDGETS_MULTICOLUMNTREEWIDGET_H_

#include <QTreeWidget>
#include <QModelIndex>
#include <QAbstractItemView>

class MultiColumnTreeWidget : public QTreeWidget {
Q_OBJECT;

public:
MultiColumnTreeWidget(QWidget *parent = nullptr);

QModelIndex moveCursor(QAbstractItemView::CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override;
};

#endif

0 comments on commit d0ec8fb

Please sign in to comment.