]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinviewcontainer.cpp
Accessibility: Fix message boxes not being announced
[dolphin.git] / src / dolphinviewcontainer.cpp
index c89621dbd616dbe67a579a64aba7425989c4bfd3..62c29a1fc684eb4fc5a4c4cbeca2c0a9578bb9c9 100644 (file)
@@ -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()