summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Weghorn <[email protected]>2025-05-27 17:04:00 +0200
committerMichael Weghorn <[email protected]>2025-05-29 21:59:26 +0200
commit854d7021b80a68370d7d3a69af04881e11681abc (patch)
treecb47802ab24868c3e806e63cdc2ec1110dabd43c
parentbb2121551c3d7b1af1553710bc211ba0e39b4212 (diff)
a11y uia: Report locale via UIA_CulturePropertyIdHEADdev
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]>
-rw-r--r--src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp
index ef1f212bc4f..5eaba7fbb37 100644
--- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp
+++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp
@@ -535,6 +535,20 @@ HRESULT QWindowsUiaMainProvider::GetPropertyValue(PROPERTYID idProp, VARIANT *pR
*pRetVal = QComVariant{ className }.release();
}
break;
+ case UIA_CulturePropertyId:
+ {
+ QLocale locale;
+ if (QAccessibleAttributesInterface *attributesIface = accessible->attributesInterface()) {
+ const QVariant localeVariant = attributesIface->attributeValue(QAccessible::Attribute::Locale);
+ if (localeVariant.isValid()) {
+ Q_ASSERT(localeVariant.canConvert<QLocale>());
+ locale = localeVariant.toLocale();
+ }
+ }
+ LCID lcid = LocaleNameToLCID(qUtf16Printable(locale.bcp47Name()), 0);
+ *pRetVal = QComVariant{ long(lcid) }.release();
+ break;
+ }
case UIA_DescribedByPropertyId:
fillVariantArrayForRelation(accessible, QAccessible::DescriptionFor, pRetVal);
break;