From de27b71c1983768186b7f9df0a5158a7c5e6c903 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 31 Jan 2014 11:12:20 +0100 Subject: [PATCH] Windows: Fixed alert sound of QMessageBox. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-33303 Change-Id: I184f169a2ae0e1fa5e21b906c1f7659316030b34 Reviewed-by: Jan Arve Sæther --- .../accessible/qwindowsaccessibility.cpp | 47 +++++++++---------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp b/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp index 885bc37cff..307f2fc3bb 100644 --- a/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp +++ b/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp @@ -100,6 +100,25 @@ QWindowsAccessibility::QWindowsAccessibility() { } +// Retrieve sound name by checking the icon property of a message box +static inline QString messageBoxAlertSound(const QObject *messageBox) +{ + enum MessageBoxIcon { // Keep in sync with QMessageBox::Icon + Information = 1, + Warning = 2, + Critical = 3 + }; + switch (messageBox->property("icon").toInt()) { + case Information: + return QStringLiteral("SystemAsterisk"); + case Warning: + return QStringLiteral("SystemExclamation"); + case Critical: + return QStringLiteral("SystemHand"); + } + return QString(); +} + void QWindowsAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event) { QString soundName; @@ -113,32 +132,8 @@ void QWindowsAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event) break; case QAccessible::Alert: - { - /* ### FIXME -#ifndef QT_NO_MESSAGEBOX - QMessageBox *mb = qobject_cast(o); - if (mb) { - switch (mb->icon()) { - case QMessageBox::Warning: - soundName = QLatin1String("SystemExclamation"); - break; - case QMessageBox::Critical: - soundName = QLatin1String("SystemHand"); - break; - case QMessageBox::Information: - soundName = QLatin1String("SystemAsterisk"); - break; - default: - break; - } - } else -#endif // QT_NO_MESSAGEBOX -*/ - { - soundName = QLatin1String("SystemAsterisk"); - } - - } + soundName = event->object()->inherits("QMessageBox") ? + messageBoxAlertSound(event->object()) : QStringLiteral("SystemAsterisk"); break; default: break;