Skip to content

Commit 97bea48

Browse files
committed
fix: add touchscreen long press support for app launcher
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
1 parent 8e2a211 commit 97bea48

3 files changed

Lines changed: 22 additions & 0 deletions

File tree

qml/windowed/AppListView.qml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,12 @@ FocusScope {
240240
launchApp(desktopId)
241241
}
242242
}
243+
// touchscreen long press.
244+
onPressAndHold: function (mouse) {
245+
if (mouse.button === Qt.NoButton) {
246+
showContextMenu(itemDelegate, model)
247+
}
248+
}
243249
}
244250
background: ItemBackground {
245251
implicitWidth: DStyle.Style.itemDelegate.width

qml/windowed/FreeSortListView.qml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,16 @@ Item {
350350
launchItem()
351351
}
352352
}
353+
354+
// touchscreen long press.
355+
onPressAndHold: function (mouse) {
356+
if (mouse.button === Qt.NoButton) {
357+
showContextMenu(itemDelegate, model, {
358+
hideMoveToTopMenu: index === 0
359+
})
360+
baseLayer.focus = true
361+
}
362+
}
353363
}
354364
}
355365

qml/windowed/IconItemDelegate.qml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ Control {
6464
root.itemClicked()
6565
}
6666
}
67+
// touchscreen long press.
68+
onPressAndHold: function (mouse) {
69+
if (mouse.button === Qt.NoButton) {
70+
root.menuTriggered()
71+
}
72+
}
6773
}
6874
contentItem: Column {
6975
anchors.fill: parent

0 commit comments

Comments
 (0)