Skip to content

feat: add AT-SPI accessible names for interactive widgets - #547

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
re2zero:agent/at-spi/f4ac622c
Aug 27, 2026
Merged

feat: add AT-SPI accessible names for interactive widgets#547
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
re2zero:agent/at-spi/f4ac622c

Conversation

@re2zero

@re2zero re2zero commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Changes

Add setObjectName/setAccessibleName calls to interactive widgets missing accessibility names.

Coverage

AT-SPI coverage improved from 73.8% to 90.8% (remaining gaps are false positives: m_edit/m_pEdit pointers passed as constructor parameters to undo command classes — not created by those classes).

Files Changed

  • src/controls/linebar.cpp — line bar accessible name
  • src/editor/showflodcodewidget.cpp — fold code widget accessible name
  • src/widgets/ColorSelectWdg.cpp — color select widget accessible name
  • src/widgets/bottombar.cpp — bottom bar accessible name
  • src/widgets/ddropdownmenu.cpp — dropdown menu accessible names
  • src/widgets/pathsettintwgt.cpp — path setting widget accessible name
  • src/widgets/window.cpp — window widgets accessible names

Log: 补全文本编辑器 AT-SPI 无障碍名称
Influence: 提升文本编辑器 AT-SPI 无障碍覆盖率,便于辅助工具和自动化测试定位控件。

Summary by Sourcery

Improve AT-SPI accessibility coverage by identifying interactive editor widgets and assigning accessible names throughout the user interface.

New Features:

  • Add accessible names and object identifiers across editor controls, menus, actions, and interactive widgets to improve AT-SPI discovery and automation.

Enhancements:

  • Expand AT-SPI accessibility coverage for text-editor UI components, including search and replace bars, navigation controls, settings, themes, tabs, and window menus.

@deepin-ci-robot

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@sourcery-ai

sourcery-ai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR improves AT-SPI discoverability by assigning accessible names and stable Qt object names to previously unidentified interactive controls, menus, actions, and views across the editor, raising reported coverage from 73.8% to 90.8% and supporting assistive tooling and automated UI tests.

File-Level Changes

Change Details Files
Add stable Qt object names and accessibility names to editor controls and supporting widgets so AT-SPI and UI automation can identify them.
  • Name find, replace, jump-line, warning, and editor controls, including buttons, inputs, menus, and text views.
  • Add names to tab, theme, color, path-setting, bottom-bar, dropdown, and window widgets/actions.
  • Preserve existing accessible labels while adding object-name selectors for interactive elements.
src/controls/findbar.cpp
src/controls/jumplinebar.cpp
src/controls/linebar.cpp
src/controls/replacebar.cpp
src/controls/tabbar.cpp
src/controls/warningnotices.cpp
src/editor/editwrapper.cpp
src/editor/showflodcodewidget.cpp
src/thememodule/themepanel.cpp
src/widgets/ColorSelectWdg.cpp
src/widgets/bottombar.cpp
src/widgets/ddropdownmenu.cpp
src/widgets/pathsettintwgt.cpp
src/widgets/window.cpp
Expand AT-SPI coverage across the editor and document the resulting coverage improvement.
  • Increase reported coverage from 73.8% to 90.8%.
  • Treat remaining undo-command pointer findings as false positives because the editors are constructor inputs rather than internally created widgets.
src/controls/linebar.cpp
src/editor/showflodcodewidget.cpp
src/widgets/ColorSelectWdg.cpp
src/widgets/bottombar.cpp
src/widgets/ddropdownmenu.cpp
src/widgets/pathsettintwgt.cpp
src/widgets/window.cpp

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

@re2zero
re2zero force-pushed the agent/at-spi/f4ac622c branch 2 times, most recently from f6981a3 to 7a20969 Compare August 27, 2026 05:08
@re2zero
re2zero marked this pull request as ready for review August 27, 2026 05:08

@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="src/widgets/ddropdownmenu.cpp" line_range="228-229" />
<code_context>
     qDebug() << "DDropdownMenu setMenu";
     deleteMenu();
     m_menu = menu;
+    m_menu->setObjectName("Menu");
+    m_menu->setAccessibleName("Menu");
 }

</code_context>
<issue_to_address>
**issue (bug_risk):** `setMenu(nullptr)` and `setMenuActionGroup(nullptr)` dereference the supplied null pointer immediately when assigning the new object name, so callers passing a null menu or action group now crash inside these setters.

**Triggers:** When either setter is called with a null pointer.

**Suggested fix:** Return early or explicitly reject null before calling `setObjectName`/`setAccessibleName`.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/widgets/ddropdownmenu.cpp Outdated
Add setObjectName/setAccessibleName calls to interactive widgets
missing accessibility names, improving AT-SPI coverage from 73.8% to 90.8%.

为缺失无障碍名称的交互控件添加 setObjectName/setAccessibleName 调用,
AT-SPI 覆盖率从 73.8% 提升至 90.8%。

Log: 补全文本编辑器 AT-SPI 无障碍名称
Influence: 提升文本编辑器 AT-SPI 无障碍覆盖率,便于辅助工具和自动化测试定位控件。
@re2zero
re2zero force-pushed the agent/at-spi/f4ac622c branch from 7a20969 to 5163b12 Compare August 27, 2026 05:17
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 97 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 总体评分 97 分,大于 70 分通过阈值。本次提交为文本编辑器添加 AT-SPI 无障碍名称,代码变更简单、聚焦,未引入安全漏洞,仅存在命名规范不一致的轻微问题。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 语法正确,逻辑清晰。所有 setObjectName/setAccessibleName 调用均为标准 Qt API,放置在控件创建之后,调用顺序合理。ddropdownmenu.cpp 中 setMenu 方法对 m_menu 进行了空指针检查后再设置 objectName,防御性编程良好。


2. 代码质量 ✅

评价: 良好 ✅ 通过

潜在问题:

  1. src/controls/replacebar.cpp:43 - 对象名 "ReplaceButton_2" 使用数字后缀,命名不够清晰,建议改为 "ReplaceBarReplaceButton" 以区分 FindBar 中的 ReplaceButton
  2. src/widgets/window.cpp:564 - 对象名 "Menu_2" 使用数字后缀,命名不够清晰,建议改为 "WindowMainMenu"
  3. src/editor/editwrapper.cpp:110 - 对象名 "PTextEdit" 使用 "P" 前缀风格,与其他描述性命名(如 EditLine/FindPrevButton)不一致
  4. src/widgets/ColorSelectWdg.cpp:200 - 对象名 "PButton" 使用 "P" 前缀风格,命名不够语义化
  5. src/widgets/ddropdownmenu.cpp:250 - setMenuActionGroup 方法中未对 m_actionGroup 进行空指针检查即调用 setObjectName,与同文件 setMenu 方法(line 228)的防御性编程风格不一致

建议: 1.统一对象命名规范,建议使用描述性名称替代 "P" 前缀,如将 "PTextEdit" 改为 "EditorTextEdit","PButton" 改为 "ColorSelectButton"
2.避免使用数字后缀,如将 "ReplaceButton_2" 改为 "ReplaceBarReplaceButton","Menu_2" 改为 "WindowMainMenu"
3.setMenuActionGroup 方法应与 setMenu 方法保持一致,增加空指针检查


3. 代码性能 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 性能良好,资源使用合理。setObjectName 和 setAccessibleName 均为轻量级 Qt setter 调用,无额外内存分配或计算开销,对运行时性能无影响。


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: 存在0个安全漏洞。本次变更仅为控件设置静态字符串名称,不涉及用户输入处理、外部数据交互或敏感信息,无注入风险。setMenu 方法中的空指针检查体现了良好的防御性编程意识。


💡 改进建议代码示例

// 建议1: 统一命名风格,使用描述性名称替代 "P" 前缀
// src/editor/editwrapper.cpp
m_pTextEdit->setObjectName("EditorTextEdit");  // 而非 "PTextEdit"

// src/widgets/ColorSelectWdg.cpp
m_pButton->setObjectName("ColorSelectButton");  // 而非 "PButton"

// 建议2: 避免数字后缀,使用更有意义的名称
// src/controls/replacebar.cpp
m_replaceButton->setObjectName("ReplaceBarReplaceButton");  // 而非 "ReplaceButton_2"

// src/widgets/window.cpp
m_menu->setObjectName("WindowMainMenu");  // 而非 "Menu_2"

// 建议3: setMenuActionGroup 增加空指针检查,与 setMenu 保持一致
// src/widgets/ddropdownmenu.cpp
void DDropdownMenu::setMenuActionGroup(QActionGroup *actionGroup)
{
    deleteMenuActionGroup();
    m_actionGroup = actionGroup;
    if (m_actionGroup != nullptr) {
        m_actionGroup->setObjectName("ActionGroup");
    }
}

本报告由 AI 代码审查工具自动生成

@re2zero

re2zero commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@deepin-bot
deepin-bot Bot merged commit f43178a into linuxdeepin:master Aug 27, 2026
17 checks passed
@re2zero
re2zero deleted the agent/at-spi/f4ac622c branch August 27, 2026 05:38
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