feat: add AT-SPI accessible names for interactive widgets - #547
Conversation
|
Skipping CI for Draft Pull Request. |
Reviewer's GuideThe 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
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
f6981a3 to
7a20969
Compare
There was a problem hiding this comment.
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>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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 无障碍覆盖率,便于辅助工具和自动化测试定位控件。
7a20969 to
5163b12
Compare
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 语法正确,逻辑清晰。所有 setObjectName/setAccessibleName 调用均为标准 Qt API,放置在控件创建之后,调用顺序合理。ddropdownmenu.cpp 中 setMenu 方法对 m_menu 进行了空指针检查后再设置 objectName,防御性编程良好。 2. 代码质量 ✅评价: 良好 ✅ 通过 潜在问题:
建议: 1.统一对象命名规范,建议使用描述性名称替代 "P" 前缀,如将 "PTextEdit" 改为 "EditorTextEdit","PButton" 改为 "ColorSelectButton" 3. 代码性能 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 性能良好,资源使用合理。setObjectName 和 setAccessibleName 均为轻量级 Qt setter 调用,无额外内存分配或计算开销,对运行时性能无影响。 4. 代码安全 🔒评价: 优秀 ✅ 通过
安全漏洞详情: 建议: 存在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 代码审查工具自动生成 |
|
/merge |
Changes
Add
setObjectName/setAccessibleNamecalls 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_pEditpointers passed as constructor parameters to undo command classes — not created by those classes).Files Changed
src/controls/linebar.cpp— line bar accessible namesrc/editor/showflodcodewidget.cpp— fold code widget accessible namesrc/widgets/ColorSelectWdg.cpp— color select widget accessible namesrc/widgets/bottombar.cpp— bottom bar accessible namesrc/widgets/ddropdownmenu.cpp— dropdown menu accessible namessrc/widgets/pathsettintwgt.cpp— path setting widget accessible namesrc/widgets/window.cpp— window widgets accessible namesLog: 补全文本编辑器 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:
Enhancements: