fix: restore checkbox binding after menu item triggered#1433
fix: restore checkbox binding after menu item triggered#1433deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideRestores and maintains the binding between dock menu checkbox states and their corresponding Applet properties by always updating the property on trigger and re-establishing a checked binding to the property/value comparison. Sequence diagram for dock menu checkbox trigger and binding restorationsequenceDiagram
actor User
participant DockMenuItem
participant Applet
User->>DockMenuItem: click
activate DockMenuItem
DockMenuItem->>Applet: set prop = value
Applet-->>DockMenuItem: prop updated
DockMenuItem->>DockMenuItem: set checked binding
deactivate DockMenuItem
User->>Applet: change prop from other source
activate Applet
Applet-->>DockMenuItem: prop changed
DockMenuItem->>DockMenuItem: checked recomputed from Applet[prop] === value
deactivate Applet
State diagram for dock menu checkbox binding lifecyclestateDiagram-v2
[*] --> BoundToApplet
BoundToApplet: checked bound to Applet[prop] === value
BoundToApplet --> UserTriggered: user clicks menu item
UserTriggered: onTriggered handler runs
UserTriggered --> PropertyUpdated: Applet[prop] set to value
PropertyUpdated: Applet property updated
PropertyUpdated --> BindingRestored: checked binding recreated to Applet[prop] === value
BindingRestored: checked bound to Applet[prop] === value
BindingRestored --> BoundToApplet
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
1. Removed conditional check in onTriggered handler that prevented property updates when value was already set 2. Added explicit Qt.binding restoration for checked property after setting the value 3. This ensures checkbox state remains synchronized with Applet property even after user interaction 4. Fixes issue where checkbox state could become desynchronized from actual property value after menu item is triggered Log: Fixed dock menu checkbox state synchronization issue Influence: 1. Test dock menu items with checkbox to ensure state updates correctly 2. Verify checkbox reflects actual property value after clicking 3. Test multiple clicks on same menu item to ensure binding persists 4. Verify checkbox state updates when property changes from other sources 5. Test with different dock menu options (position, display mode, etc.) fix: 修复菜单项触发后复选框绑定问题 1. 移除了 onTriggered 处理器中的条件检查,该检查会在值已设置时阻止属性更新 2. 在设置值后添加了显式的 Qt.binding 恢复,用于 checked 属性 3. 确保复选框状态在用户交互后仍与 Applet 属性保持同步 4. 修复了菜单项触发后复选框状态可能与实际属性值不同步的问题 Log: 修复了任务栏菜单复选框状态同步问题 Influence: 1. 测试带复选框的任务栏菜单项,确保状态正确更新 2. 验证点击后复选框反映实际属性值 3. 测试多次点击同一菜单项,确保绑定持续有效 4. 验证属性从其他来源更改时复选框状态更新 5. 测试不同的任务栏菜单选项(位置、显示模式等) PMS: BUG-349947
5f43fa4 to
88fc663
Compare
deepin pr auto review这段代码是对一个QML组件(可能是菜单项或按钮)的修改,主要涉及属性绑定和状态更新的逻辑。以下是对该代码变更的详细审查和改进意见: 1. 代码逻辑审查变更分析:
潜在问题:
2. 代码质量与最佳实践改进意见:
3. 代码安全
4. 性能优化
5. 改进后的代码建议MenuItem {
id: menuItem
text: name
onTriggered: {
// 保留条件判断,避免不必要的赋值
if (Applet[prop] !== value) {
Applet[prop] = value
}
}
// 保持原有的绑定逻辑
checked: Applet[prop] === value
}6. 进一步优化(如果需要动态绑定)如果确实需要在运行时动态更新绑定逻辑(例如 MenuItem {
id: menuItem
text: name
onTriggered: {
if (Applet[prop] !== value) {
Applet[prop] = value
}
}
// 使用函数返回绑定表达式,确保动态更新
checked: {
return Applet[prop] === value
}
}总结原代码的变更试图通过动态绑定更新 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, Ivy233 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 |
|
/forcemerge |
|
This pr force merged! (status: unstable) |
Log: Fixed dock menu checkbox state synchronization issue
Influence:
fix: 修复菜单项触发后复选框绑定问题
Log: 修复了任务栏菜单复选框状态同步问题
Influence:
PMS: BUG-349947
Summary by Sourcery
Bug Fixes: