From 57e68f712e9b45c606104456afcd782a95a0aa56 Mon Sep 17 00:00:00 2001 From: xiepengfei Date: Thu, 3 Dec 2026 19:52:41 +0800 Subject: [PATCH] feat: add accessible names for eye protection buttons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Set AccessibleName (eye_0..eye_3) on RoundColorWidget buttons in EyeProtectionAction so AT-SPI based UI automation can locate them. 2. objectName alone does not surface as the AT-SPI accessible name. 3. Stable locale-independent identifiers keep test selectors intact. Log: Improves UI automation testability; no change to eye protection behavior or visuals. Influence: 1. Verify eye protection mode switching from the main menu still works (classic/green/night/off). 2. Verify the buttons' tooltips remain unchanged. 3. Run the eye_care AT suite to confirm the buttons are locatable. feat: 补充护眼模式按钮的可访问名称 1. EyeProtectionAction 中为 RoundColorWidget 按钮设置 AccessibleName (eye_0..eye_3),供 AT-SPI 自动化定位。 2. 仅设置 objectName 不会进入 AT-SPI name。 3. 采用与语言无关的稳定标识,避免翻译变化破坏用例选择器。 Log: 提升自动化可测性;护眼模式行为与外观无变化。 Influence: 1. 验证主菜单中经典/绿色/夜间/无护眼切换功能正常。 2. 验证按钮 tooltip 文案不变。 3. 运行 eye_care AT 套件确认按钮可定位。 PMS: TASK-399111 --- reader/eyeprotection/EyeProtectionAction.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/reader/eyeprotection/EyeProtectionAction.cpp b/reader/eyeprotection/EyeProtectionAction.cpp index 55d5b33e7..228fb68ff 100644 --- a/reader/eyeprotection/EyeProtectionAction.cpp +++ b/reader/eyeprotection/EyeProtectionAction.cpp @@ -62,6 +62,9 @@ void EyeProtectionAction::initWidget(DWidget *parent) auto btn = new RoundColorWidget(color, pWidget); btn->setAllClickNotify(true); btn->setObjectName(QString("eye_%1").arg(i)); + // AT 自动化依赖 AccessibleName 定位(objectName 不进入 AT-SPI name); + // 取与 objectName 一致的稳定标识,避免随语言/翻译变化破坏用例选择器 + btn->setAccessibleName(QString("eye_%1").arg(i)); btn->setFixedSize(QSize(25, 25)); btn->setToolTip(QCoreApplication::translate("EyeProtection", s_modeNames[i])); btn->setSelected(static_cast(curMode) == i);