┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/accessibility/kitemlistviewaccessible.cpp
diff options
context:
space:
mode:
authorFelix Ernst <[email protected]>2024-12-29 11:27:18 +0000
committerFelix Ernst <[email protected]>2024-12-29 11:27:18 +0000
commit3696213ccbbe27e9ef3fc85eb97dd32fd669066f (patch)
tree7b6db1a823da09b3bedab8aaf2ea0e82393ceab5 /src/kitemviews/accessibility/kitemlistviewaccessible.cpp
parent4f71b3c539eb54c3db184d85ebc9bfce5ecfb989 (diff)
Have special keyboard controls in selection mode
Prior to this commit keyboard controls and behaviour of Dolphin's main view were identical no matter if selection mode was enabled or not. While selection mode makes it impossible to accidentally clear the selection by singular mouse clicks, any press of an arrow key on the keyboard would still clear the full selection which goes against selection mode's objective. Furthermore, keyboard-only users had no reason to ever enable selection mode because it made no difference to them. This commit changes this by offering a changed control scheme for key presses while in selection mode. Arrow key presses without modifier now only move focus between items but do no longer clear or change the selection. Similarly, Page Up/Down, Home, and End key presses only move keyboard focus. Enter, Return, and Space key presses now only toggle the selection for the current item. The above controls are however mostly unchanged when combining them with Modifier keys like Shift or Control. The type-ahead feature is also changed in selection mode to only move keyboard focus without changing the selection. This way keyboard users are less likely to clear their selection by mistake. Regression tests are added for these selection mode controls. The code changes to change this keyboard behaviour are quite minimal. Most of the added code is for making selection mode accessible. That's because we need to make sure the changed control scheme is properly announced and communicated or a blind user will be left utterly confused why the normal keyboard controls "stopped working". Enabling or disabling selection mode is announced to accessibility software. Furthermore whenever focus goes to the main view, the selection mode state is also mentioned when active. BUG: 458091
Diffstat (limited to 'src/kitemviews/accessibility/kitemlistviewaccessible.cpp')
-rw-r--r--src/kitemviews/accessibility/kitemlistviewaccessible.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/kitemviews/accessibility/kitemlistviewaccessible.cpp b/src/kitemviews/accessibility/kitemlistviewaccessible.cpp
index f8c14bf4a..f58527be6 100644
--- a/src/kitemviews/accessibility/kitemlistviewaccessible.cpp
+++ b/src/kitemviews/accessibility/kitemlistviewaccessible.cpp
@@ -280,8 +280,18 @@ QString KItemListViewAccessible::text(QAccessible::Text t) const
if (numberOfSelectedItems < 1 || (numberOfSelectedItems == 1 && isSelected(currentItem))) {
// We do not announce the number of selected items if the only selected item is the current item
// because the selection state of the current item is already announced elsewhere.
+ if (m_selectionMode) {
+ return i18nc("@info accessibility, 1 is path", "in a grid layout in selection mode in location %1", modelRootUrl.toDisplayString());
+ }
return i18nc("@info accessibility, 1 is path", "in a grid layout in location %1", modelRootUrl.toDisplayString());
}
+ if (m_selectionMode) {
+ return i18ncp("@info accessibility, 2 is path",
+ "%1 selected item in a grid layout in selection mode in location %2",
+ "%1 selected items in a grid layout in selection mode in location %2",
+ numberOfSelectedItems,
+ modelRootUrl.toDisplayString());
+ }
return i18ncp("@info accessibility, 2 is path",
"%1 selected item in a grid layout in location %2",
"%1 selected items in a grid layout in location %2",
@@ -293,8 +303,18 @@ QString KItemListViewAccessible::text(QAccessible::Text t) const
if (numberOfSelectedItems < 1 || (numberOfSelectedItems == 1 && isSelected(currentItem))) {
// We do not announce the number of selected items if the only selected item is the current item
// because the selection state of the current item is already announced elsewhere.
+ if (m_selectionMode) {
+ return i18nc("@info accessibility, 1 is path", "in selection mode in location %1", modelRootUrl.toDisplayString());
+ }
return i18nc("@info accessibility, 1 is path", "in location %1", modelRootUrl.toDisplayString());
}
+ if (m_selectionMode) {
+ return i18ncp("@info accessibility, 2 is path",
+ "%1 selected item in selection mode in location %2",
+ "%1 selected items in selection mode in location %2",
+ numberOfSelectedItems,
+ modelRootUrl.toDisplayString());
+ }
return i18ncp("@info accessibility, 2 is path",
"%1 selected item in location %2",
"%1 selected items in location %2",
@@ -490,3 +510,14 @@ void KItemListViewAccessible::slotAnnounceCurrentItemTimerTimeout()
QAccessible::updateAccessibility(&announceAccessibleDescriptionEvent);
}
}
+
+void KItemListViewAccessible::announceSelectionModeEnabled(const bool enabled)
+{
+ m_selectionMode = enabled;
+#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0) // QAccessibleAnnouncementEvent is only available since 6.8
+ QAccessibleAnnouncementEvent announceChangedControlsEvent(view(),
+ enabled ? i18nc("accessibility announcement", "Selection mode enabled")
+ : i18nc("accessibility announcement", "Selection mode disabled"));
+ QAccessible::updateAccessibility(&announceChangedControlsEvent);
+#endif
+}