fix: add touchscreen long press support for app launcher#739
fix: add touchscreen long press support for app launcher#73918202781743 merged 1 commit intolinuxdeepin:masterfrom
Conversation
Added touchscreen long press event handling to three QML components to enable context menu activation on touch devices. Previously, only mouse right-click triggered context menus, leaving touchscreen users unable to access these features. 1. Modified AppListView.qml to add onPressAndHold handler for touchscreen long press 2. Modified FreeSortListView.qml to add onPressAndHold handler with additional logic for hiding "Move to Top" menu on first item 3. Modified IconItemDelegate.qml to add onPressAndHold handler that triggers menu functionality 4. All handlers check for Qt.NoButton to distinguish touch events from mouse events Log: Touchscreen users can now long press on app icons to open context menus Influence: 1. Test long press on app icons in both AppListView and FreeSortListView modes 2. Verify context menu appears correctly on touchscreen devices 3. Test that mouse right-click functionality remains unchanged 4. Verify "Move to Top" menu item is hidden when long pressing first item in FreeSortListView 5. Test that regular tap/click behavior remains unaffected 6. Verify context menu options work correctly after touch activation fix: 为应用启动器添加触摸屏长按支持 为三个QML组件添加了触摸屏长按事件处理,使触摸设备用户能够激活上下文菜 单。之前只有鼠标右键点击能触发上下文菜单,触摸屏用户无法使用这些功能。 1. 修改AppListView.qml,为触摸屏长按添加onPressAndHold处理器 2. 修改FreeSortListView.qml,添加onPressAndHold处理器,包含隐藏首项"移至 顶部"菜单的额外逻辑 3. 修改IconItemDelegate.qml,添加触发菜单功能的onPressAndHold处理器 4. 所有处理器都检查Qt.NoButton以区分触摸事件和鼠标事件 Log: 触摸屏用户现在可以通过长按应用图标打开上下文菜单 Influence: 1. 在AppListView和FreeSortListView模式下测试应用图标长按 2. 验证在触摸屏设备上上下文菜单正确显示 3. 测试鼠标右键点击功能保持不变 4. 验证在FreeSortListView中长按第一项时"移至顶部"菜单项被隐藏 5. 测试常规点击行为不受影响 6. 验证通过触摸激活后上下文菜单选项正常工作 PMS: BUG-352989
Reviewer's GuideAdds touchscreen long-press handling to app launcher QML views and delegates so that touch users can open the same context menus previously available only via mouse right-click, including preserving existing menu behavior such as hiding "Move to Top" for the first item in the free-sort view. Sequence diagram for touchscreen long-press handling in FreeSortListViewsequenceDiagram
actor TouchUser
participant FreeSortListView
participant IconItemDelegate
participant MouseArea
participant ContextMenu
TouchUser->>IconItemDelegate: long_press_on_app_icon
IconItemDelegate->>MouseArea: emit_pressAndHold(mouse_button_NoButton)
MouseArea->>FreeSortListView: onPressAndHold(mouse)
FreeSortListView->>FreeSortListView: check_mouse_button_is_NoButton
alt index_is_first_item
FreeSortListView->>ContextMenu: showContextMenu(itemDelegate, model, hideMoveToTopMenu_true)
else index_is_not_first_item
FreeSortListView->>ContextMenu: showContextMenu(itemDelegate, model, hideMoveToTopMenu_false)
end
FreeSortListView->>FreeSortListView: baseLayer_focus_true
ContextMenu-->>TouchUser: display_context_menu
Updated class diagram for app launcher QML components with touch long-press supportclassDiagram
class AppListView {
+showContextMenu(itemDelegate, model)
+onPressAndHold(mouse)
}
class FreeSortListView {
+showContextMenu(itemDelegate, model, hideMoveToTopMenu)
+onPressAndHold(mouse)
+index
+baseLayer_focus
}
class IconItemDelegate {
+itemClicked()
+menuTriggered()
+onPressAndHold(mouse)
}
class MouseArea {
+onClicked(mouse)
+onPressAndHold(mouse)
}
class ContextMenuHelper {
+showContextMenu(itemDelegate, model)
+showContextMenu(itemDelegate, model, hideMoveToTopMenu)
}
AppListView --> IconItemDelegate : uses_delegate
FreeSortListView --> IconItemDelegate : uses_delegate
IconItemDelegate --> MouseArea : contains
AppListView --> ContextMenuHelper : calls
FreeSortListView --> ContextMenuHelper : calls
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review这段代码 diff 主要是为了在三个不同的 QML 组件( 以下是对这段代码的详细审查和改进建议: 1. 语法与逻辑审查
2. 代码质量
3. 代码性能
4. 代码安全与健壮性
5. 改进建议建议 1:增强对鼠标长按的支持(可选)如果希望鼠标左键长按也能触发菜单,建议修改判断逻辑,或者移除 // 建议修改后的逻辑(如果希望支持鼠标长按)
onPressAndHold: function (mouse) {
// 接受触摸(NoButton)和鼠标左键(LeftButton)的长按
// 或者直接不判断 button,取决于具体需求
if (mouse.button === Qt.NoButton || mouse.button === Qt.LeftButton) {
showContextMenu(itemDelegate, model)
}
}建议 2:防止事件冲突在
建议 3:代码一致性在
总结这段代码的实现是正确且有效的,专门针对触摸屏长按场景进行了适配。主要的改进点在于是否需要兼容鼠标长按操作以及确保与点击事件不冲突。如果这是一个纯触摸屏应用,当前代码完全没问题;如果是混合输入设备应用,建议考虑建议 1。 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, BLumia 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 |
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="qml/windowed/FreeSortListView.qml" line_range="354-356" />
<code_context>
launchApp(desktopId)
}
}
+ // touchscreen long press.
+ onPressAndHold: function (mouse) {
+ if (mouse.button === Qt.NoButton) {
+ showContextMenu(itemDelegate, model)
+ }
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Guarding onPressAndHold with `mouse.button === Qt.NoButton` might miss some legitimate long-press events.
Using `mouse.button === Qt.NoButton` as a proxy for touch vs mouse is likely to be inconsistent across platforms and devices (e.g., some touch or stylus events can still report `Qt.LeftButton`). If you just want to ignore mouse long-press, prefer using `mouse.source` (where supported) or handle both input types uniformly and differentiate behavior at a higher level. Also confirm the actual event values on your target platforms to ensure this condition behaves as expected.
Suggested implementation:
```
// long press (mouse or touch).
onPressAndHold: function (mouse) {
showContextMenu(itemDelegate, model, {
hideMoveToTopMenu: index === 0
})
baseLayer.focus = true
}
```
If you later need to differentiate mouse vs touch behavior:
1. Inspect `mouse.source` in this handler (e.g., `mouse.source === Qt.MouseEventSynthesizedBySystem` for some touch-generated events) and log actual values on your target platforms.
2. Adjust the condition accordingly or route the event information upward so a higher-level component can decide how to handle different input sources.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Added touchscreen long press event handling to three QML components to
enable context menu activation on touch devices. Previously, only mouse
right-click triggered context menus, leaving touchscreen users unable to
access these features.
touchscreen long press
additional logic for hiding "Move to Top" menu on first item
triggers menu functionality
mouse events
Log: Touchscreen users can now long press on app icons to open context
menus
Influence:
modes
item in FreeSortListView
fix: 为应用启动器添加触摸屏长按支持
为三个QML组件添加了触摸屏长按事件处理,使触摸设备用户能够激活上下文菜
单。之前只有鼠标右键点击能触发上下文菜单,触摸屏用户无法使用这些功能。
顶部"菜单的额外逻辑
Log: 触摸屏用户现在可以通过长按应用图标打开上下文菜单
Influence:
PMS: BUG-352989
Summary by Sourcery
Add touchscreen long-press support to app launcher list and icon views to open existing context menus on touch devices.
Bug Fixes:
Enhancements: