From 97bea481f99ea55395eb688ede292a035008fc8e Mon Sep 17 00:00:00 2001 From: yeshanshan Date: Tue, 17 Mar 2026 19:29:02 +0800 Subject: [PATCH] fix: add touchscreen long press support for app launcher MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- qml/windowed/AppListView.qml | 6 ++++++ qml/windowed/FreeSortListView.qml | 10 ++++++++++ qml/windowed/IconItemDelegate.qml | 6 ++++++ 3 files changed, 22 insertions(+) diff --git a/qml/windowed/AppListView.qml b/qml/windowed/AppListView.qml index 7f917fe7..c7ca1877 100644 --- a/qml/windowed/AppListView.qml +++ b/qml/windowed/AppListView.qml @@ -240,6 +240,12 @@ FocusScope { launchApp(desktopId) } } + // touchscreen long press. + onPressAndHold: function (mouse) { + if (mouse.button === Qt.NoButton) { + showContextMenu(itemDelegate, model) + } + } } background: ItemBackground { implicitWidth: DStyle.Style.itemDelegate.width diff --git a/qml/windowed/FreeSortListView.qml b/qml/windowed/FreeSortListView.qml index e6ce7992..895736c2 100644 --- a/qml/windowed/FreeSortListView.qml +++ b/qml/windowed/FreeSortListView.qml @@ -350,6 +350,16 @@ Item { launchItem() } } + + // touchscreen long press. + onPressAndHold: function (mouse) { + if (mouse.button === Qt.NoButton) { + showContextMenu(itemDelegate, model, { + hideMoveToTopMenu: index === 0 + }) + baseLayer.focus = true + } + } } } diff --git a/qml/windowed/IconItemDelegate.qml b/qml/windowed/IconItemDelegate.qml index cb7e4225..628950f5 100644 --- a/qml/windowed/IconItemDelegate.qml +++ b/qml/windowed/IconItemDelegate.qml @@ -64,6 +64,12 @@ Control { root.itemClicked() } } + // touchscreen long press. + onPressAndHold: function (mouse) { + if (mouse.button === Qt.NoButton) { + root.menuTriggered() + } + } } contentItem: Column { anchors.fill: parent