Skip to content

feat(accessibility): add AT-SPI accessible names to UI controls - #516

Open
re2zero wants to merge 1 commit into
linuxdeepin:masterfrom
re2zero:fix/at-spi-completion-20260812
Open

feat(accessibility): add AT-SPI accessible names to UI controls#516
re2zero wants to merge 1 commit into
linuxdeepin:masterfrom
re2zero:fix/at-spi-completion-20260812

Conversation

@re2zero

@re2zero re2zero commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Add setAccessibleName and setObjectName for all interactive UI controls and assertion-required elements across the editor.

Changes

  • Titlebar: Menu actions (新窗口/打开/保存/设置/etc.) and window buttons (最小化/最大化/关闭/etc.)
  • Find/Replace/JumpLine bars: All buttons, labels, and text inputs
  • Tab bar: Main tab bar and right-click context menu items
  • Editor: Right-click context menu (undo/redo/cut/copy/paste/etc.) and text edit area
  • Bottom bar: Position label, char count, cursor status, scale, progress bar
  • Theme panel: Theme list view
  • Settings: Path selection checkboxes and browse button
  • Warning notices: Reload, Save As, Edit Anyway buttons
  • Dialogs: Save confirm, invalid char, settings, print preview
  • Copyright: Updated years for modified files

Related Issue

V-1559

Report

报告详见 Issue 评论附件。

Summary by Sourcery

Add AT-SPI accessible and object names across core editor UI components to improve screen reader and assistive technology support.

New Features:

  • Define stable accessible names for main window, editor stack, tab bar, editor text area, bottom bar, and dropdown controls.
  • Expose accessible names and identifiers for find/replace/jump-line bars, warning notices, and theme list views.
  • Provide accessible identifiers for editor and tab bar context menu actions, including bookmarks, folding, and file operations.
  • Introduce an expected_names.yaml mapping of widget IDs to AT-SPI roles and descriptions for deepin-editor.

Enhancements:

  • Update SPDX copyright years on several UI-related source files to reflect changes.
  • Tag key dialogs such as invalid character save prompts with accessible names for better identification in assistive tools.

Tests:

  • Add an AT-SPI expected_names.yaml fixture describing accessible names, roles, and descriptions for editor UI elements to support accessibility validation.

@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

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 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

@sourcery-ai

sourcery-ai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds AT-SPI-facing accessible names and object names to key editor UI components (menus, buttons, bars, dialogs, and panels), plus updates copyright years and introduces an expected-names YAML used for accessibility validation.

File-Level Changes

Change Details Files
Add accessible names and object names to editor right-click menu actions and color-mark submenu to expose them to AT-SPI.
  • Set accessibleName on the editor context DMenu and Color Mark submenu
  • Assign stable objectName identifiers to all QAction items in the editor context menu (undo/redo/cut/copy/paste/etc.)
  • Assign objectName identifiers for color marking actions and bookmark-related actions
src/editor/dtextedit.cpp
Wire up accessible names for the main window, titlebar menu actions/buttons, dialogs, and main editor/bottom bar widgets.
  • Set accessibleName on the main window, central widget, and editor stack container
  • Assign objectName to titlebar menu QActions (NewWindow/NewTab/OpenFile/Save/etc.)
  • Set accessibleName on titlebar icon buttons (AddTab/OptionMenu/Minimize/Maximize/QuitFullscreen/Close)
  • Set accessibleName on invalid-character save dialog
src/widgets/window.cpp
src/editor/editwrapper.cpp
Add accessible names to find/replace/jump-line controls so labels, inputs, and buttons are identifiable to assistive technologies.
  • Set accessibleName for find bar label, input, navigation buttons, and close button
  • Set accessibleName for replace bar labels, inputs, action buttons, and close button
  • Set accessibleName for jump-line close button, label, and line-number spinbox
src/controls/findbar.cpp
src/controls/replacebar.cpp
src/controls/jumplinebar.cpp
Expose bottom bar status labels and progress bar with meaningful accessible names.
  • Set accessibleName on position, char count, cursor status, scale, and progress labels
  • Set accessibleName on the bottom progress bar widget
src/widgets/bottombar.cpp
Add accessible naming to tab bar, tab context menu actions, theme panel list view, path settings, warning notices, and dropdown tool button.
  • Set accessibleName on the main editor tab bar and its context menu
  • Assign objectName identifiers for tab context menu actions and "More options" submenu
  • Set accessibleName on the theme list view
  • Set accessibleName on path-setting checkboxes, custom path edit, and browse button
  • Set accessibleName on warning notice buttons (Reload/SaveAs/EditAnyway)
  • Set accessibleName on dropdown menu tool button
src/controls/tabbar.cpp
src/thememodule/themepanel.cpp
src/widgets/pathsettintwgt.cpp
src/controls/warningnotices.cpp
src/widgets/ddropdownmenu.cpp
Update copyright headers to the current year range in several controls and introduce an AT-SPI expected accessible names spec for testing.
  • Bump SPDX-FileCopyrightText year ranges to 2026 in jump line bar, theme panel, and settings dialog
  • Add test YAML listing expected AT-SPI element IDs, names, roles, and descriptions for deepin-editor
src/controls/jumplinebar.cpp
src/thememodule/themepanel.cpp
src/controls/settingsdialog.cpp
test/at/spi/expected_names.yaml

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 fix/at-spi-completion-20260812 branch from 15e33be to 610c6bd Compare August 12, 2026 03:20
@re2zero

re2zero commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

PR 验证结果

验证摘要

✅ 代码审查

代码修改清晰规范:

  • 所有 setAccessibleName/setObjectName 调用置于控件创建后、布局设置前,符合 Qt 惯例
  • 命名风格一致(驼峰命名,如 FindInputAddTabOptionMenu
  • 版权年份已更新至 2026
  • 涉及 14 个源文件修改 + 1 个新增测试文件

✅ 编译验证

  • dpkg-buildpackage -us -uc -b -tc 编译通过
  • 生成 deepin-editor_6.5.58_amd64.deb
  • 无新编译错误

⚠️ 待调整事项

REUSE dep5 规则需要修改
当前 .reuse/dep5 中 AT 测试文件声明为:

Files: test/at/spi/*

应改为父目录范围以覆盖后续可能增加的 AT 测试文件:

Files: test/at/*

请 PR 作者更新该行。

清理情况

  • 已验证的 cherry-pick 已清理还原
  • 构建产物已清理
  • 工作区已恢复干净

@re2zero
re2zero force-pushed the fix/at-spi-completion-20260812 branch from 610c6bd to 0f1b8f0 Compare August 12, 2026 03:48
@re2zero
re2zero marked this pull request as ready for review August 12, 2026 03:49

@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.

Sorry @re2zero, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@re2zero
re2zero force-pushed the fix/at-spi-completion-20260812 branch from 0f1b8f0 to 06e7ef7 Compare August 12, 2026 05:23
Add setAccessibleName and setObjectName for all interactive UI
controls and assertion-required elements across the editor:

- Titlebar menu actions and window buttons
- Find/Replace/JumpLine floating bars
- Tab bar, context menus, and editor right-click menus
- Bottom bar status labels and progress bar
- Theme panel, path settings, warning notices, dropdown button
- Editor text area and central widgets
- Dialogs (save confirm, settings, print preview)
- Update copyright years for modified files
- Add REUSE dep5 entry for test/at/spi/ directory

This allows AT-SPI/accessibility frameworks to properly identify
and interact with all operable UI elements.

Issue: V-1559
@re2zero
re2zero force-pushed the fix/at-spi-completion-20260812 branch from 06e7ef7 to c7df007 Compare August 12, 2026 05:38
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:98分

■ 【总体评价】

代码系统性地为deepin-editor补充了AT-SPI无障碍访问支持,实现规范且无安全风险
逻辑完全正确且覆盖全面,仅因测试用例与代码实现存在微小不同步扣2分

■ 【详细分析】

  • 1.语法逻辑(完全正确)✓

findbar.cppreplacebar.cppwindow.cpp 等多个文件的控件实例化后,准确调用了 setAccessibleName()。对于 QAction 类型(如 dtextedit.cpp 中的右键菜单项),正确使用了 setObjectName() 而非 setAccessibleName(),因为 QAction 不直接提供 setAccessibleName 接口,完全符合 Qt 的 API 设计规范与 AT-SPI 桥接机制。
潜在问题:无
建议:无

  • 2.代码质量(优秀)✓

命名规范高度统一,采用大驼峰命名法(如 FindInputReplaceFindLabelCloseJumpLine),语义清晰且与控件功能强相关。新增的 expected_names.yaml 测试文件结构清晰,为后续自动化无障碍测试提供了良好基础。
潜在问题:test/at/spi/expected_names.yaml 中声明了 SaveConfirmDialogSettingsDialogPrintPreview 等控件的预期无障碍名称,但在本次 C++ 代码 diff 中并未看到这些控件被赋予对应的 setAccessibleName,可能导致自动化测试用例运行失败或产生误报。
建议:补充 SaveConfirmDialogSettingsDialogPrintPreview 等对话框的无障碍名称设置代码,或者从测试 YAML 文件中移除尚未实现的断言项以保持一致性。

  • 3.代码性能(无性能问题)✓

所有修改均为在控件初始化阶段设置静态字符串属性,不涉及复杂计算、循环或系统调用,对运行时性能零影响。
潜在问题:无
建议:无

  • 4.代码安全(存在0个安全漏洞)✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
代码中所有传入 setAccessibleNamesetObjectName 的参数均为硬编码的纯英文字符串常量,不包含任何外部输入、动态拼接或敏感信息泄露风险,完全符合安全编码标准。

  • 建议:保持当前安全的硬编码方式,无需额外安全修复。

■ 【改进建议代码示例】

// src/widgets/window.cpp 或相关对话框触发位置补充缺失的无障碍名称设置
// 以保持与 test/at/spi/expected_names.yaml 测试用例的严格对齐

// 示例1:补充保存确认对话框的无障碍名称
DDialog *saveConfirmDialog = new DDialog(this);
saveConfirmDialog->setAccessibleName("SaveConfirmDialog");
saveConfirmDialog->setTitle(tr("Unsaved Changes"));
saveConfirmDialog->setMessage(tr("Do you want to save the changes?"));

// 示例2:补充设置对话框的无障碍名称(假设在打开设置的地方)
void Window::showSettingsDialog()
{
    SettingsDialog *settingsDialog = new SettingsDialog(this);
    settingsDialog->setAccessibleName("SettingsDialog");
    settingsDialog->exec();
    settingsDialog->deleteLater();
}

// 示例3:补充打印预览对话框的无障碍名称
void Window::showPrintPreview()
{
    QPrintPreviewDialog *previewDialog = new QPrintPreviewDialog(this);
    previewDialog->setAccessibleName("PrintPreview");
    previewDialog->exec();
    previewDialog->deleteLater();
}

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.

2 participants