Skip to content

feat: add accessible names for eye protection buttons - #470

Merged
pengfeixx merged 1 commit into
linuxdeepin:masterfrom
pengfeixx:feat/eye-protection-accessible-names
Dec 3, 2026
Merged

pengfeixx merged 1 commit into
linuxdeepin:masterfrom
pengfeixx:feat/eye-protection-accessible-names

Conversation

@pengfeixx

@pengfeixx pengfeixx commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

变更说明 / Changes

为护眼模式主菜单中的四个圆形色块按钮(RoundColorWidget)补充 setAccessibleName(eye_0 ~ eye_3),供 AT-SPI 自动化测试定位。

  • 仅设置 objectName 不会进入 AT-SPI accessible name,自动化无法定位这些按钮
  • 采用与 objectName 一致的稳定标识,不随语言/翻译变化,保证测试选择器稳定
  • 不改变护眼模式的功能逻辑与视觉效果

动机 / Motivation

V25 AT 用例库新增的护眼模式用例(2029057–2029083 共 14 条)需要对护眼按钮进行 GUI 自动化定位;当前构建中这些按钮对 AT-SPI 完全不可见,导致 eye_care 套件无法可靠执行。

关联 AT 用例仓库变更:app-test-v25 deepin-reader eye_care 套件(多平台任务 V-10048)。

PMS: TASK-399111

测试 / Test

  • 本地构建通过(含 eye_N AccessibleName)
  • 护眼模式切换功能实测正常(经典/绿色/夜间/无护眼)
  • 平台 CI

Summary by Sourcery

New Features:

  • Expose stable accessible names (eye_0 through eye_3) for the eye-protection color buttons so accessibility automation can locate them.

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
@sourcery-ai

sourcery-ai Bot commented Dec 3, 2026

Copy link
Copy Markdown

Reviewer's Guide

UI

Assign stable accessible names to the eye-protection color buttons so AT-SPI automation can locate them without changing their behavior or tooltips.

  • reader/eyeprotection/EyeProtectionAction.cpp L65-67

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="reader/eyeprotection/EyeProtectionAction.cpp" line_range="67" />
<code_context>
         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]));
</code_context>
<issue_to_address>
**Screen readers announce machine IDs**

When a user navigates these controls with a screen reader, screen readers use the explicit accessible name instead of a meaningful mode label, so users hear identifiers such as “eye_0” rather than which eye-protection mode the color represents.

Use a localized, descriptive accessible name for each mode and expose the stable automation identifier through a separate selector mechanism.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

btn->setObjectName(QString("eye_%1").arg(i));
// AT 自动化依赖 AccessibleName 定位(objectName 不进入 AT-SPI name);
// 取与 objectName 一致的稳定标识,避免随语言/翻译变化破坏用例选择器
btn->setAccessibleName(QString("eye_%1").arg(i));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Screen readers announce machine IDs

When a user navigates these controls with a screen reader, screen readers use the explicit accessible name instead of a meaningful mode label, so users hear identifiers such as “eye_0” rather than which eye-protection mode the color represents.

Use a localized, descriptive accessible name for each mode and expose the stable automation identifier through a separate selector mechanism.

Prompt for AI agents
In `reader/eyeprotection/EyeProtectionAction.cpp` at line 67:

**Screen readers announce machine IDs**

When a user navigates these controls with a screen reader, screen readers use the explicit accessible name instead of a meaningful mode label, so users hear identifiers such as “eye_0” rather than which eye-protection mode the color represents.

Use a localized, descriptive accessible name for each mode and expose the stable automation identifier through a separate selector mechanism.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: lzwind, pengfeixx

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@pengfeixx
pengfeixx merged commit fc7177a into linuxdeepin:master Dec 3, 2026
1 of 2 checks passed
@pengfeixx
pengfeixx deleted the feat/eye-protection-accessible-names branch December 3, 2026 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants