Skip to content

Commit

Permalink
FIX(a11y): Make search result tree accessible
Browse files Browse the repository at this point in the history
  • Loading branch information
Hartmnt committed Jan 8, 2024
1 parent a3f9ae5 commit 132828f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
27 changes: 27 additions & 0 deletions src/mumble/SearchDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// Mumble source tree or at <https://www.mumble.info/LICENSE>.

#include "SearchDialog.h"
#include "Accessibility.h"
#include "Channel.h"
#include "ClientUser.h"
#include "MainWindow.h"
Expand All @@ -26,6 +27,8 @@

#include <stack>

#include <QDebug>

namespace Search {

QString SearchDialog::toString(UserAction action) {
Expand Down Expand Up @@ -226,13 +229,37 @@ void SearchDialog::on_searchResultTree_currentItemChanged(QTreeWidgetItem *c, QT
if (user) {
// Only try to select the user if (s)he still exists
Global::get().mw->pmModel->setSelectedUser(user->uiSession);
item.setData(0, Qt::AccessibleTextRole, Mumble::Accessibility::userToText(user));
item.setData(1, Qt::AccessibleTextRole, Mumble::Accessibility::userToText(user));
item.setData(0, Qt::AccessibleDescriptionRole, Mumble::Accessibility::userToText(user));
item.setData(1, Qt::AccessibleDescriptionRole, Mumble::Accessibility::userToText(user));
item.setToolTip(0, Mumble::Accessibility::userToText(user));
item.setToolTip(1, Mumble::Accessibility::userToText(user));
qDebug() << Mumble::Accessibility::userToText(user);
qDebug() << searchResultTree->allColumnsShowFocus(); // false
qDebug() << searchResultTree->focusPolicy(); // strong focus
qDebug() << searchResultTree->hasFocus(); // true
qDebug() << searchResultTree->tabKeyNavigation(); // false
// searchResultTree->updateMicroFocus
}
} else {
const Channel *channel = Channel::get(static_cast< int >(item.getID()));

if (channel) {
// Only try to select the channel if it still exists
Global::get().mw->pmModel->setSelectedChannel(channel->iId);
item.setData(0, Qt::AccessibleTextRole, Mumble::Accessibility::channelToText(channel));
item.setData(1, Qt::AccessibleTextRole, Mumble::Accessibility::channelToText(channel));
item.setData(0, Qt::AccessibleDescriptionRole, Mumble::Accessibility::channelToText(channel));
item.setData(1, Qt::AccessibleDescriptionRole, Mumble::Accessibility::channelToText(channel));
item.setToolTip(0, Mumble::Accessibility::channelToText(channel));
item.setToolTip(1, Mumble::Accessibility::channelToText(channel));
qDebug() << Mumble::Accessibility::channelToText(channel);
qDebug() << searchResultTree->allColumnsShowFocus();
qDebug() << searchResultTree->focusPolicy();
qDebug() << searchResultTree->hasFocus();
qDebug() << searchResultTree->tabKeyNavigation();
// searchResultTree->updateMicroFocus
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/mumble/SearchDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
</item>
<item row="2" column="0" colspan="2">
<widget class="SearchDialogTree" name="searchResultTree">
<property name="focusPolicy">
<enum>Qt::TabFocus</enum>
</property>
<property name="accessibleName">
<string>Search results</string>
</property>
Expand Down
3 changes: 3 additions & 0 deletions src/mumble/widgets/SearchDialogTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

#include <QResizeEvent>

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

void SearchDialogTree::resizeEvent(QResizeEvent *event) {
// We have to update the layout on every resize since we have wrapping text that is displayed in the
// different rows of this tree. That means that by changing its size we potentially change the way
Expand Down
6 changes: 4 additions & 2 deletions src/mumble/widgets/SearchDialogTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
#ifndef MUMBLE_MUMBLE_WIDGETS_SEARCHDIALOGTREE_H_
#define MUMBLE_MUMBLE_WIDGETS_SEARCHDIALOGTREE_H_

#include "MultiColumnTreeWidget.h"

#include <QTreeWidget>

class QResizeEvent;

class SearchDialogTree : public QTreeWidget {
class SearchDialogTree : public MultiColumnTreeWidget {
public:
using QTreeWidget::QTreeWidget;
SearchDialogTree(QWidget *parent = nullptr);

protected:
void resizeEvent(QResizeEvent *event) override;
Expand Down

0 comments on commit 132828f

Please sign in to comment.