fix: restore right-click context menu in windowed launcher's frequent…#759
Conversation
…ly used view The TapHandler addition in 957e8a7 caused MouseArea to participate in the pointer event delivery system, which bypassed the acceptedButtons filter and allowed right-click events to be consumed by onClicked, triggering app launch instead of the context menu. fix: 修复弹窗启动器"常用应用"区域右键菜单失效的问题 957e8a7 提交中新增的 TapHandler 导致 MouseArea 参与指针事件分发系统, 绕过了 acceptedButtons 过滤,右键事件被 onClicked 消费,触发启动应用 而非弹出右键菜单。 PMS: BUG-360855
Reviewer's guide (collapsed on small PRs)Reviewer's GuideRestricts the launcher icon MouseArea to handle only left-clicks so that right-click events are no longer consumed by the click handler, restoring the system context menu in the windowed launcher’s frequently used view. Sequence diagram for restored right-click context menu handlingsequenceDiagram
actor User
participant MouseArea
participant root
participant ContextMenu
User->>MouseArea: mousePress(button)
alt LeftButton
MouseArea->>MouseArea: onPressed(mouse)
MouseArea->>root: itemClicked() [via onClicked]
else RightButton
MouseArea->>MouseArea: onPressed(mouse)
MouseArea-->>User: mouse.accepted = false
User->>ContextMenu: showContextMenu()
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The left-button guard logic is duplicated between onPressed and onClicked; consider extracting a small helper or at least centralizing the button check so future changes don’t get out of sync.
- You’re explicitly rejecting non-left clicks in onPressed, but onClicked just returns without changing mouse.accepted; consider making the acceptance behavior consistent across both handlers so other handlers (e.g., context menu logic) see a predictable event state.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The left-button guard logic is duplicated between onPressed and onClicked; consider extracting a small helper or at least centralizing the button check so future changes don’t get out of sync.
- You’re explicitly rejecting non-left clicks in onPressed, but onClicked just returns without changing mouse.accepted; consider making the acceptance behavior consistent across both handlers so other handlers (e.g., context menu logic) see a predictable event state.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
deepin pr auto review你好!我是CodeGeeX,你的智能编程助手。我已仔细审查了你提供的 QML 代码的 这段代码的主要修改是为 以下是我从语法逻辑、代码质量、代码性能和代码安全四个维度提出的审查意见和改进建议: 1. 语法与逻辑
2. 代码质量
3. 代码性能
4. 代码安全
💡 综合改进后的代码建议基于以上分析,我为你优化了代码。主要改进点在于:增强了 onPressed: function (mouse) {
// 拦截非左键事件,使其穿透给父组件处理(如右键菜单)
if (!mouse || mouse.button !== Qt.LeftButton) {
mouse.accepted = false
return
}
isTouchLongPressed = false
if (root.dndEnabled) {
// TODO: 性能优化考虑 - 如果 appIcon 不常变化,可考虑缓存 result.url,避免每次 Press 都触发渲染
appIcon.grabToImage(function(result) {
if (result.url) {
root.Drag.imageSource = result.url;
}
})
}
}
onClicked: function(mouse) {
// 恢复长按状态(建议评估是否应放在 onReleased/onCanceled 中统一管理)
if (isTouchLongPressed) {
isTouchLongPressed = false
return
}
// 防御性编程:虽然 onPressed 已经拦截了非左键,但防止意外情况导致非左键触发 clicked
if (mouse && mouse.button !== Qt.LeftButton) {
return
}
if (!drag.active) {
root.itemClicked()
}
}如果你对上述建议有任何疑问,或者需要我进一步解释 QML 的事件分发机制,随时告诉我! |
|
[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: blocked) |
…ly used view
The TapHandler addition in 957e8a7 caused MouseArea to participate in the pointer event delivery system, which bypassed the acceptedButtons filter and allowed right-click events to be consumed by onClicked, triggering app launch instead of the context menu.
fix: 修复弹窗启动器"常用应用"区域右键菜单失效的问题
957e8a7 提交中新增的 TapHandler 导致 MouseArea 参与指针事件分发系统, 绕过了 acceptedButtons 过滤,右键事件被 onClicked 消费,触发启动应用
而非弹出右键菜单。
PMS: BUG-360855
Summary by Sourcery
Bug Fixes: