┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dolphinviewcontainer.cpp
diff options
context:
space:
mode:
authorFelix Ernst <[email protected]>2024-10-03 11:18:59 +0200
committerFelix Ernst <[email protected]>2024-10-08 09:21:54 +0000
commitf3b4d53720e2b8ab9c20eb9fb9e05fcc2386b5cf (patch)
treedfd4100abb079071fcb53024743ee0c31b316221 /src/dolphinviewcontainer.cpp
parent2328cb7f923e5c6eeb7617eebf3ee73c0bb8e50b (diff)
Accessibility: Fix message boxes not being announced
This commit moves the focus to the message of newly shown passive messages when accessibility software is used. Moving focus to an object generally means that it will be announced, so this makes sure that users of accessibility software know when they are being notified of a change.
Diffstat (limited to 'src/dolphinviewcontainer.cpp')
-rw-r--r--src/dolphinviewcontainer.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp
index c89621dbd..62c29a1fc 100644
--- a/src/dolphinviewcontainer.cpp
+++ b/src/dolphinviewcontainer.cpp
@@ -33,6 +33,9 @@
#include <KShell>
#include <kio_version.h>
+#ifndef QT_NO_ACCESSIBILITY
+#include <QAccessible>
+#endif
#include <QApplication>
#include <QDesktopServices>
#include <QDropEvent>
@@ -436,6 +439,14 @@ void DolphinViewContainer::showMessage(const QString &message, KMessageWidget::M
m_messageWidget->hide();
}
m_messageWidget->animatedShow();
+
+#ifndef QT_NO_ACCESSIBILITY
+ if (QAccessible::isActive() && isActive()) {
+ // To announce the new message keyboard focus must be moved to the message label. However, we do not have direct access to the label that is internal
+ // to the KMessageWidget. Instead we setFocus() on the KMessageWidget and trust that it has set correct focus handling.
+ m_messageWidget->setFocus();
+ }
+#endif
}
void DolphinViewContainer::readSettings()