Skip to content

Commit 854d702

Browse files
a11y uia: Report locale via UIA_CulturePropertyId
Map QAccessible::Attribute::Locale to UIA_CulturePropertyId [1] in the Windows UIA accessibility bridge: > Identifies the Culture property, which contains a > locale identifier for the automation element (for > example, 0x0409 for "en-US" or English (United States)). In a test with 2 spinboxes whose locales were explicitly set to * QLocale(QLocale::English, QLocale::UnitedStates)) * QLocale(QLocale::Chinese, QLocale::China)) , retrieving the current value of UIA_CulturePropertyId (30015) using NVDA's Python console gives the expected result: With the spinbox whose locale is set to English/United States: >>> hex(focus.UIAElement.GetCurrentPropertyValue(30015)) '0x409' With the spinbox whose locale is set to Chinese/China: >>> hex(focus.UIAElement.GetCurrentPropertyValue(30015)) '0x804' as "[MS-LCID]: Windows Language Code Identifier (LCID) Reference" [2] lists these identifiers as follows: * 0x0409 en-US * 0x0804 zh-CN [1] https://learn.microsoft.com/en-us/windows/win32/winauto/uiauto-automation-element-propids [2] https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/70feba9f-294e-491e-b6eb-56532684c37f Task-number: QTBUG-137144 Change-Id: I2b0cad9ab7ede9f01dee3d7f3efddb8c5335caaf Reviewed-by: Volker Hilsheimer <[email protected]>
1 parent bb21215 commit 854d702

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,20 @@ HRESULT QWindowsUiaMainProvider::GetPropertyValue(PROPERTYID idProp, VARIANT *pR
535535
*pRetVal = QComVariant{ className }.release();
536536
}
537537
break;
538+
case UIA_CulturePropertyId:
539+
{
540+
QLocale locale;
541+
if (QAccessibleAttributesInterface *attributesIface = accessible->attributesInterface()) {
542+
const QVariant localeVariant = attributesIface->attributeValue(QAccessible::Attribute::Locale);
543+
if (localeVariant.isValid()) {
544+
Q_ASSERT(localeVariant.canConvert<QLocale>());
545+
locale = localeVariant.toLocale();
546+
}
547+
}
548+
LCID lcid = LocaleNameToLCID(qUtf16Printable(locale.bcp47Name()), 0);
549+
*pRetVal = QComVariant{ long(lcid) }.release();
550+
break;
551+
}
538552
case UIA_DescribedByPropertyId:
539553
fillVariantArrayForRelation(accessible, QAccessible::DescriptionFor, pRetVal);
540554
break;

0 commit comments

Comments
 (0)