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 91f2515
Show file tree
Hide file tree
Showing 6 changed files with 104 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
30 changes: 30 additions & 0 deletions src/mumble/PluginConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include <QtWidgets/QMessageBox>
#include "Global.h"

#include <QDebug>

const QString PluginConfig::name = QLatin1String("PluginConfig");

static ConfigWidget *PluginConfigDialogNew(Settings &st) {
Expand All @@ -38,6 +40,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 @@ -251,3 +258,26 @@ void PluginConfig::on_qtwPlugins_currentItemChanged(QTreeWidgetItem *current, QT
qpbUnload->setEnabled(false);
}
}

void PluginConfig::on_qtwPlugins_itemChanged(QTreeWidgetItem *item, int column) {
const_plugin_ptr_t plugin = pluginForItem(item);

switch (column) {
case 1:
qDebug() << "Triggered 1";
item->setData(1, Qt::AccessibleDescriptionRole, plugin->isLoaded() ? tr("checked") : tr("unchecked"));
break;
case 2:
qDebug() << "Triggered 2";
if (plugin->getFeatures() & MUMBLE_FEATURE_POSITIONAL) {
item->setData(2, Qt::AccessibleDescriptionRole, plugin->isPositionalDataEnabled() ? tr("checked") : tr("unchecked"));
} else {
item->setData(2, Qt::AccessibleDescriptionRole, tr("Not available"));
}
break;
case 3:
qDebug() << "Triggered 3";
item->setData(3, Qt::AccessibleDescriptionRole, plugin->isKeyboardMonitoringAllowed() ? tr("checked") : tr("unchecked"));
break;
}
}
3 changes: 3 additions & 0 deletions src/mumble/PluginConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public slots:
/// @param current The currently selected item
/// @param old The previously selected item (if applicable - otherwise NULL/nullptr)
void on_qtwPlugins_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *old);
/// @param item The changed item
/// @param column The column that has changed
void on_qtwPlugins_itemChanged(QTreeWidgetItem *item, int column);
};

#endif
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 91f2515

Please sign in to comment.