Skip to content

Commit

Permalink
FIX(a11y): Make AccessibleQGroupBox not read empty table cells
Browse files Browse the repository at this point in the history
An AccessibleQGroupBox will try to compose an accessible description
based on the layout of labels within.
If a grid-layout is used, we read every row+column combination and
the corresponding grid cell content.

Previously, the AccessibleQGroup box would read row+column even if
there was not label in the actual cell, leading to unnecessary
text. (e.g. when using a sub headline)

This commit adds a check to skip a row+colum combination when
there is no label in the cell.
  • Loading branch information
Hartmnt committed Jan 11, 2025
1 parent 2aeb6cb commit 48a893b
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/mumble/widgets/AccessibleQGroupBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ QString AccessibleQGroupBox::textAtPosition(QGridLayout *gridLayout, int y, int
return "";
}

QString accessibleName = label->accessibleName();
if (!accessibleName.isEmpty()) {
return accessibleName;
}

QString content = Mumble::Accessibility::removeHTMLTags(label->text());
if (content.trimmed().isEmpty()) {
content = tr("empty");
Expand All @@ -47,11 +52,14 @@ void AccessibleQGroupBox::updateAccessibleText() {
for (int y = tableMode ? 1 : 0; y < gridLayout->rowCount(); y++) {
for (int x = tableMode ? 1 : 0; x < gridLayout->columnCount(); x++) {
if (tableMode) {
text += textAtPosition(gridLayout, y, 0);
text += " ";
text += textAtPosition(gridLayout, 0, x);
text += ", ";
text += textAtPosition(gridLayout, y, x);
QString cellContent = textAtPosition(gridLayout, y, x);
if (!cellContent.isEmpty()) {
text += textAtPosition(gridLayout, y, 0);
text += " ";
text += textAtPosition(gridLayout, 0, x);
text += ", ";
text += cellContent;
}
} else {
text += textAtPosition(gridLayout, y, x);
}
Expand Down

0 comments on commit 48a893b

Please sign in to comment.