diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2020-01-16 01:00:11 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2020-01-16 11:20:42 +0100 |
commit | 0a4e5bb265c4a2345a9cbffab1b5150124b8d31e (patch) | |
tree | b243668d53f710af3d57a44c18e1ed0c40b100f7 /src/plugins/platforms/windows | |
parent | 4772a2da15ae0624633f3fc4d029d5f0e1e33892 (diff) | |
parent | bd828bacb982a51ee21f03487f8390cfc96cc6d3 (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')
-rw-r--r-- | src/plugins/platforms/windows/qwindowscontext.cpp | 13 | ||||
-rw-r--r-- | src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp | 53 |
2 files changed, 58 insertions, 8 deletions
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index a2dd25f8cc..d31352b854 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -604,15 +604,12 @@ QString QWindowsContext::registerWindowClass(QString cname, // each one has to have window class names with a unique name // The first instance gets the unmodified name; if the class // has already been registered by another instance of Qt then - // add a UUID. - static int classExists = -1; - + // add a UUID. The check needs to be performed for each name + // in case new message windows are added (QTBUG-81347). const auto appInstance = static_cast<HINSTANCE>(GetModuleHandle(nullptr)); - if (classExists == -1) { - WNDCLASS wcinfo; - classExists = GetClassInfo(appInstance, reinterpret_cast<LPCWSTR>(cname.utf16()), &wcinfo); - classExists = classExists && wcinfo.lpfnWndProc != proc; - } + WNDCLASS wcinfo; + const bool classExists = GetClassInfo(appInstance, reinterpret_cast<LPCWSTR>(cname.utf16()), &wcinfo) == TRUE + && wcinfo.lpfnWndProc != proc; if (classExists) cname += QUuid::createUuid().toString(); 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; |