Skip to content

fix: allow right-click long press to trigger context menu on touchscreen#755

Open
wjyrich wants to merge 1 commit intolinuxdeepin:masterfrom
wjyrich:fix-bug-358827
Open

fix: allow right-click long press to trigger context menu on touchscreen#755
wjyrich wants to merge 1 commit intolinuxdeepin:masterfrom
wjyrich:fix-bug-358827

Conversation

@wjyrich
Copy link
Copy Markdown
Contributor

@wjyrich wjyrich commented Apr 29, 2026

  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

Summary by Sourcery

Bug Fixes:

  • Fix context menus not opening when performing a right-click long-press on icons across list and icon delegates in both normal and windowed modes.

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
@deepin-ci-robot
Copy link
Copy Markdown

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

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
Copy link
Copy Markdown

sourcery-ai Bot commented Apr 29, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Allows 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-click

sequenceDiagram
    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
Loading

File-Level Changes

Change Details Files
Allow right-click long-press to trigger the same context menu logic as touch long-press across icon/list delegates.
  • Updated onPressAndHold handlers to accept both Qt.NoButton and Qt.RightButton before invoking context menu actions.
  • Applied the updated condition consistently in main IconItemDelegate and windowed variants to keep behavior uniform.
  • Ensured app list and free-sort list views share the same expanded trigger condition for showing context menus.
qml/IconItemDelegate.qml
qml/windowed/AppListView.qml
qml/windowed/FreeSortListView.qml
qml/windowed/IconItemDelegate.qml

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

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

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

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread qml/IconItemDelegate.qml
// touchscreen long press.
onPressAndHold: function (mouse) {
if (mouse.button === Qt.NoButton) {
if (mouse.button === Qt.NoButton ||| mouse.button === Qt.RightButton) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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