diff options
| author | Felix Ernst <[email protected]> | 2024-11-02 00:39:19 +0100 |
|---|---|---|
| committer | Felix Ernst <[email protected]> | 2024-12-05 15:42:53 +0000 |
| commit | 179e53591b726acc0c5272e728e398de41fb51c9 (patch) | |
| tree | 3fa159c1f044a3d2ad144332ab64f6a495119b14 /src/kitemviews/kitemlistview.cpp | |
| parent | daf5a04d6d34e40ba0ad03d778566be0c3ebea95 (diff) | |
Adapt to Orca 47
The screen reader Orca has seen some fundamental changes between
Orca 46 and Orca 47. While they are improvements overall, they do
require changes to Dolphin to preserve the intended user
experience for Orca users.
The biggest change is perhaps that Orca will now not only announce
changes to the currently focused item, but also of its parent,
which means we do not need to pass focus around between file items
and the main view within Dolphin, but can keep focus on the file
items most of the time. This commit implements this.
The only exception of when we cannot have focus on the items within
the main view is when the current location is empty or not loaded
yet. Only then is the focus moved to the view itself and the
placeholderMessage is announced.
This commit worsens the UX for users of Orca 46 or older, so this
should only be merged once most users are on Orca 47 or later.
Diffstat (limited to 'src/kitemviews/kitemlistview.cpp')
| -rw-r--r-- | src/kitemviews/kitemlistview.cpp | 35 |
1 files changed, 3 insertions, 32 deletions
diff --git a/src/kitemviews/kitemlistview.cpp b/src/kitemviews/kitemlistview.cpp index 38ec6841a..d3caa5560 100644 --- a/src/kitemviews/kitemlistview.cpp +++ b/src/kitemviews/kitemlistview.cpp @@ -1244,11 +1244,6 @@ void KItemListView::slotItemsInserted(const KItemRangeList &itemRanges) if (useAlternateBackgrounds()) { updateAlternateBackgrounds(); } -#ifndef QT_NO_ACCESSIBILITY - if (QAccessible::isActive()) { // Announce that the count of items has changed. - static_cast<KItemListViewAccessible *>(QAccessible::queryAccessibleInterface(this))->announceDescriptionChange(); - } -#endif } void KItemListView::slotItemsRemoved(const KItemRangeList &itemRanges) @@ -1367,11 +1362,6 @@ void KItemListView::slotItemsRemoved(const KItemRangeList &itemRanges) if (useAlternateBackgrounds()) { updateAlternateBackgrounds(); } -#ifndef QT_NO_ACCESSIBILITY - if (QAccessible::isActive()) { // Announce that the count of items has changed. - static_cast<KItemListViewAccessible *>(QAccessible::queryAccessibleInterface(this))->announceDescriptionChange(); - } -#endif } void KItemListView::slotItemsMoved(const KItemRange &itemRange, const QList<int> &movedToIndexes) @@ -1429,15 +1419,7 @@ void KItemListView::slotItemsChanged(const KItemRangeList &itemRanges, const QSe updateVisibleGroupHeaders(); doLayout(NoAnimation); } - -#ifndef QT_NO_ACCESSIBILITY - QAccessibleTableModelChangeEvent ev(this, QAccessibleTableModelChangeEvent::DataChanged); - ev.setFirstRow(itemRange.index); - ev.setLastRow(itemRange.index + itemRange.count); - QAccessible::updateAccessibility(&ev); -#endif } - doLayout(NoAnimation); } @@ -1510,19 +1492,11 @@ void KItemListView::slotCurrentChanged(int current, int previous) KItemListWidget *currentWidget = m_visibleItems.value(current, nullptr); if (currentWidget) { currentWidget->setCurrent(true); - if (hasFocus() || (previousWidget && previousWidget->hasFocus())) { - currentWidget->setFocus(); // Mostly for accessibility, because keyboard events are handled correctly either way. - } } } #ifndef QT_NO_ACCESSIBILITY - if (QAccessible::isActive()) { - if (current >= 0) { - QAccessibleEvent accessibleFocusCurrentItemEvent(this, QAccessible::Focus); - accessibleFocusCurrentItemEvent.setChild(current); - QAccessible::updateAccessibility(&accessibleFocusCurrentItemEvent); - } - static_cast<KItemListViewAccessible *>(QAccessible::queryAccessibleInterface(this))->announceDescriptionChange(); + if (current != previous && QAccessible::isActive()) { + static_cast<KItemListViewAccessible *>(QAccessible::queryAccessibleInterface(this))->announceCurrentItem(); } #endif } @@ -1544,14 +1518,11 @@ void KItemListView::slotSelectionChanged(const KItemSet ¤t, const KItemSet // Let the screen reader announce "selected" or "not selected" for the active item. const bool wasSelected(previous.contains(index)); if (isSelected != wasSelected) { - QAccessibleEvent accessibleSelectionChangedEvent(this, QAccessible::Selection); + QAccessibleEvent accessibleSelectionChangedEvent(this, QAccessible::SelectionAdd); accessibleSelectionChangedEvent.setChild(index); QAccessible::updateAccessibility(&accessibleSelectionChangedEvent); } } - // Usually the below does not have an effect because the view will not have focus at this moment but one of its list items. Still we announce the - // change of the accessibility description just in case the user manually moved focus up by one. - static_cast<KItemListViewAccessible *>(QAccessible::queryAccessibleInterface(this))->announceDescriptionChange(); #else } Q_UNUSED(previous) |
