Skip to content

Commit 2da197f

Browse files
committed
fix: separate touchscreen and mouse context menu triggers in notification center
Split the context menu TapHandler into two separate handlers with device filtering to prevent touchscreen tap from incorrectly triggering the context menu when expanding collapsed notifications: 1. Mouse/other devices handler: uses acceptedDevices with PointerDevice.AllDevices & ~PointerDevice.TouchScreen to exclude touchscreen, as touchscreen events bypass acceptedButtons check in Qt 2. Touchscreen handler: only accepts long-press gesture from TouchScreen device This ensures that a single-finger tap on a collapsed notification only expands it without showing the context menu, while long-press still triggers the menu as expected. Log: fix touchscreen tap incorrectly triggering context menu when expanding collapsed notifications fix: 通知中心分离触摸屏和鼠标右键菜单触发方式 将右键菜单的 TapHandler 拆分为两个独立的处理器,并添加设备过滤, 防止触摸屏点击展开折叠通知时错误地触发右键菜单: 1. 鼠标/其他设备处理器:使用 acceptedDevices 设置为 PointerDevice.AllDevices & ~PointerDevice.TouchScreen 排除触摸屏, 因为 Qt 中触摸屏事件会绕过 acceptedButtons 检查 2. 触摸屏处理器:仅接受来自触摸屏设备的长按手势 这确保了在折叠通知上单指点击只会展开通知而不会显示右键菜单, 同时长按仍然可以按预期触发菜单。 Log: 修复触摸屏点击展开折叠通知时错误触发右键菜单的问题 PMS: BUG-355017
1 parent b4328cd commit 2da197f

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

panels/notification/center/NotifyViewDelegate.qml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,11 @@ DelegateChooser {
112112
defaultAction: model.defaultAction
113113
indexInGroup: model.indexInGroup
114114

115+
// Mouse/other devices right-click for context menu
116+
// Note: TouchScreen is excluded because its events bypass acceptedButtons check in Qt
115117
TapHandler {
116118
acceptedButtons: Qt.RightButton
119+
acceptedDevices: PointerDevice.AllDevices & ~PointerDevice.TouchScreen
117120
onPressedChanged: function () {
118121
if (pressed) {
119122
let pos = point.position
@@ -122,6 +125,15 @@ DelegateChooser {
122125
}
123126
}
124127

128+
// Touchscreen long-press for context menu
129+
TapHandler {
130+
acceptedDevices: PointerDevice.TouchScreen
131+
onLongPressed: {
132+
let pos = point.position
133+
setting(pos)
134+
}
135+
}
136+
125137
onSetting: function (pos) {
126138
let tmp = mapToItem(root.view, pos)
127139
root.setting(tmp, {
@@ -197,8 +209,11 @@ DelegateChooser {
197209
}
198210
}
199211

212+
// Mouse/other devices right-click for context menu
213+
// Note: TouchScreen is excluded because its events bypass acceptedButtons check in Qt
200214
TapHandler {
201215
acceptedButtons: Qt.RightButton
216+
acceptedDevices: PointerDevice.AllDevices & ~PointerDevice.TouchScreen
202217
onPressedChanged: function () {
203218
if (pressed) {
204219
let pos = point.position
@@ -207,6 +222,15 @@ DelegateChooser {
207222
}
208223
}
209224

225+
// Touchscreen long-press for context menu
226+
TapHandler {
227+
acceptedDevices: PointerDevice.TouchScreen
228+
onLongPressed: {
229+
let pos = point.position
230+
setting(pos)
231+
}
232+
}
233+
210234
onExpand: function ()
211235
{
212236
console.log("expand")

0 commit comments

Comments
 (0)