summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-01-16 01:00:11 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2020-01-16 11:20:42 +0100
commit0a4e5bb265c4a2345a9cbffab1b5150124b8d31e (patch)
treeb243668d53f710af3d57a44c18e1ed0c40b100f7 /src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp
parent4772a2da15ae0624633f3fc4d029d5f0e1e33892 (diff)
parentbd828bacb982a51ee21f03487f8390cfc96cc6d3 (diff)
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts: src/widgets/kernel/qshortcut.cpp tests/auto/network/access/spdy/tst_spdy.cpp Change-Id: If76c434beac2c0a393440aa365f89f77439774ce
Diffstat (limited to 'src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp')
-rw-r--r--src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp
index c7c0deab3f..32a57473ad 100644
--- a/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp
+++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp
@@ -52,6 +52,8 @@
#include <qpa/qplatformintegration.h>
#include <QtWindowsUIAutomationSupport/private/qwindowsuiawrapper_p.h>
+#include <QtCore/private/qwinregistry_p.h>
+
QT_BEGIN_NAMESPACE
using namespace QWindowsUiAutomation;
@@ -85,12 +87,63 @@ bool QWindowsUiaAccessibility::handleWmGetObject(HWND hwnd, WPARAM wParam, LPARA
return false;
}
+// Retrieve sound name by checking the icon property of a message box
+// should it be the event object.
+static QString alertSound(const QObject *object)
+{
+ if (object->inherits("QMessageBox")) {
+ enum MessageBoxIcon { // Keep in sync with QMessageBox::Icon
+ Information = 1,
+ Warning = 2,
+ Critical = 3
+ };
+ switch (object->property("icon").toInt()) {
+ case Information:
+ return QStringLiteral("SystemAsterisk");
+ case Warning:
+ return QStringLiteral("SystemExclamation");
+ case Critical:
+ return QStringLiteral("SystemHand");
+ }
+ }
+ return QStringLiteral("SystemAsterisk");
+}
+
+static QString soundFileName(const QString &soundName)
+{
+ const QString key = QStringLiteral("AppEvents\\Schemes\\Apps\\.Default\\")
+ + soundName + QStringLiteral("\\.Current");
+ return QWinRegistryKey(HKEY_CURRENT_USER, key).stringValue(L"");
+}
+
+static void playSystemSound(const QString &soundName)
+{
+ if (!soundName.isEmpty() && !soundFileName(soundName).isEmpty()) {
+ PlaySound(reinterpret_cast<const wchar_t *>(soundName.utf16()), nullptr,
+ SND_ALIAS | SND_ASYNC | SND_NODEFAULT | SND_NOWAIT);
+ }
+}
+
// Handles accessibility update notifications.
void QWindowsUiaAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event)
{
if (!event)
return;
+ switch (event->type()) {
+ case QAccessible::PopupMenuStart:
+ playSystemSound(QStringLiteral("MenuPopup"));
+ break;
+ case QAccessible::MenuCommand:
+ playSystemSound(QStringLiteral("MenuCommand"));
+ break;
+ case QAccessible::Alert:
+ playSystemSound(alertSound(event->object()));
+ break;
+ default:
+ break;
+ }
+
QAccessibleInterface *accessible = event->accessibleInterface();
if (!isActive() || !accessible || !accessible->isValid())
return;