Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Telegram/SourceFiles/history/history_inner_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6625,6 +6625,30 @@ QAccessible::Role HistoryInner::accessibilityChildRole() const {
return QAccessible::Role::ListItem;
}

QAccessible::Role HistoryInner::accessibilityChildRoleAt(int index) const {
// The unread bar divides the read messages from the unread ones, it
// is not a message itself - a separator to a screen reader, which also
// keeps it out of the selection and the item count.
const auto barIndex = accessibilityUnreadBarIndex();
return (barIndex >= 0 && index == barIndex)
? QAccessible::Role::Separator
: accessibilityChildRole();
}

Ui::AccessibilitySetPosition HistoryInner::accessibilityChildSetPosition(
int index) const {
// The unread bar is not one of the messages: it has no position of its
// own and does not count, so the messages below it are not shifted.
const auto count = accessibilityChildCount();
const auto barIndex = accessibilityUnreadBarIndex();
if (barIndex < 0) {
return { index + 1, count };
} else if (index == barIndex) {
return {};
}
return { (index > barIndex) ? index : (index + 1), count - 1 };
}

QRect HistoryInner::accessibilityChildRect(int index) const {
const auto barIndex = accessibilityUnreadBarIndex();
if (barIndex >= 0 && index == barIndex) {
Expand Down
3 changes: 3 additions & 0 deletions Telegram/SourceFiles/history/history_inner_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ class HistoryInner
QString accessibilityChildName(int index) const override;
QAccessible::State accessibilityChildState(int index) const override;
QAccessible::Role accessibilityChildRole() const override;
QAccessible::Role accessibilityChildRoleAt(int index) const override;
Ui::AccessibilitySetPosition accessibilityChildSetPosition(
int index) const override;
QRect accessibilityChildRect(int index) const override;
int accessibilityChildColumnCount(int row) const override;
QAccessible::Role accessibilityChildSubItemRole() const override;
Expand Down
24 changes: 24 additions & 0 deletions Telegram/SourceFiles/history/view/history_view_list_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6282,6 +6282,30 @@ QAccessible::Role ListWidget::accessibilityChildRole() const {
return QAccessible::Role::ListItem;
}

QAccessible::Role ListWidget::accessibilityChildRoleAt(int index) const {
// The unread bar divides the read messages from the unread ones, it
// is not a message itself - a separator to a screen reader, which also
// keeps it out of the selection and the item count.
const auto barIndex = accessibilityUnreadBarIndex();
return (barIndex >= 0 && index == barIndex)
? QAccessible::Role::Separator
: accessibilityChildRole();
}

Ui::AccessibilitySetPosition ListWidget::accessibilityChildSetPosition(
int index) const {
// The unread bar is not one of the messages: it has no position of its
// own and does not count, so the messages below it are not shifted.
const auto count = accessibilityChildCount();
const auto barIndex = accessibilityUnreadBarIndex();
if (barIndex < 0) {
return { index + 1, count };
} else if (index == barIndex) {
return {};
}
return { (index > barIndex) ? index : (index + 1), count - 1 };
}

QRect ListWidget::accessibilityChildRect(int index) const {
const auto barIndex = accessibilityUnreadBarIndex();
if (barIndex >= 0 && index == barIndex) {
Expand Down
3 changes: 3 additions & 0 deletions Telegram/SourceFiles/history/view/history_view_list_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,9 @@ class ListWidget final
QString accessibilityChildName(int index) const override;
QAccessible::State accessibilityChildState(int index) const override;
QAccessible::Role accessibilityChildRole() const override;
QAccessible::Role accessibilityChildRoleAt(int index) const override;
Ui::AccessibilitySetPosition accessibilityChildSetPosition(
int index) const override;
QRect accessibilityChildRect(int index) const override;
int accessibilityChildColumnCount(int row) const override;
QAccessible::Role accessibilityChildSubItemRole() const override;
Expand Down
Loading