fix: allow right-click long press to trigger context menu on touchscreen#755
fix: allow right-click long press to trigger context menu on touchscreen#755wjyrich wants to merge 1 commit intolinuxdeepin:masterfrom
Conversation
1. Previously, onPressAndHold handlers only triggered when mouse.button was Qt.NoButton 2. Added Qt.RightButton as an additional trigger condition for long press 3. This allows right-click long press to also trigger context menus 4. Applied consistently across all relevant QML files: IconItemDelegate, AppListView, FreeSortListView, and windowed IconItemDelegate Log: Fixed context menu not opening on right-click long press Influence: 1. Test right-click long press on icons to verify context menu appears 2. Test regular long press (no button) still works as before 3. Verify no regression for touchscreen long press behavior 4. Test in both normal and windowed mode fix: 允许右键长按触发上下文菜单 1. 之前 onPressAndHold 处理器仅在 mouse.button 为 Qt.NoButton 时触发 2. 增加了 Qt.RightButton 作为长按的额外触发条件 3. 使右键长按也能触发上下文菜单 4. 在所有相关的 QML 文件中统一应用此修改:IconItemDelegate、 AppListView、FreeSortListView 和窗口模式下的 IconItemDelegate Log: 修复右键长按时上下文菜单无法打开的问题 Influence: 1. 在图标上测试右键长按,验证上下文菜单是否弹出 2. 测试常规长按(无按钮)是否仍正常工作 3. 验证触控屏长按行为没有回归问题 4. 在普通模式和窗口模式下分别测试 PMS: BUG-358827
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: wjyrich 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 |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAllows long-press context menus to be triggered by both touch (no button) and right mouse button across icon and app list delegates, by relaxing the onPressAndHold button check in relevant QML views. Sequence diagram for long press context menu triggering with touch and right-clicksequenceDiagram
actor User
participant InputDevice
participant QMLDelegate
participant ContextMenu
User->>InputDevice: LongPressOnIcon
InputDevice->>QMLDelegate: onPressAndHold(mouse)
alt Touchscreen_long_press
Note right of InputDevice: mouse.button = Qt.NoButton
QMLDelegate->>QMLDelegate: checkButton(mouse.button)
QMLDelegate->>ContextMenu: open()
else Right_click_long_press
Note right of InputDevice: mouse.button = Qt.RightButton
QMLDelegate->>QMLDelegate: checkButton(mouse.button)
QMLDelegate->>ContextMenu: open()
else Other_buttons
QMLDelegate->>QMLDelegate: ignore event
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 found 1 issue, and left some high level feedback:
- In
IconItemDelegate.qmlthe updated condition uses|||instead of||, which will cause a syntax error and needs to be corrected. - Since the same
mouse.button === Qt.NoButton || mouse.button === Qt.RightButtoncondition is now repeated across several QML files, consider extracting this into a shared helper or function to keep the behavior consistent and easier to maintain.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `IconItemDelegate.qml` the updated condition uses `|||` instead of `||`, which will cause a syntax error and needs to be corrected.
- Since the same `mouse.button === Qt.NoButton || mouse.button === Qt.RightButton` condition is now repeated across several QML files, consider extracting this into a shared helper or function to keep the behavior consistent and easier to maintain.
## Individual Comments
### Comment 1
<location path="qml/IconItemDelegate.qml" line_range="161" />
<code_context>
// touchscreen long press.
onPressAndHold: function (mouse) {
- if (mouse.button === Qt.NoButton) {
+ if (mouse.button === Qt.NoButton ||| mouse.button === Qt.RightButton) {
root.menuTriggered()
}
</code_context>
<issue_to_address>
**issue (bug_risk):** Fix the `|||` operator, which is invalid JavaScript/QML syntax.
Use `||` here (as in the other handlers) so the condition parses correctly and matches the intended `NoButton` or `RightButton` behavior.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| // touchscreen long press. | ||
| onPressAndHold: function (mouse) { | ||
| if (mouse.button === Qt.NoButton) { | ||
| if (mouse.button === Qt.NoButton ||| mouse.button === Qt.RightButton) { |
There was a problem hiding this comment.
issue (bug_risk): Fix the ||| operator, which is invalid JavaScript/QML syntax.
Use || here (as in the other handlers) so the condition parses correctly and matches the intended NoButton or RightButton behavior.
Log: Fixed context menu not opening on right-click long press
Influence:
fix: 允许右键长按触发上下文菜单
Log: 修复右键长按时上下文菜单无法打开的问题
Influence:
PMS: BUG-358827
Summary by Sourcery
Bug Fixes: