fix: show dock context menu on long press release#1571
Open
fly602 wants to merge 1 commit intolinuxdeepin:masterfrom
Open
fix: show dock context menu on long press release#1571fly602 wants to merge 1 commit intolinuxdeepin:masterfrom
fly602 wants to merge 1 commit intolinuxdeepin:masterfrom
Conversation
1. Add isLongPressing property to track long press state 2. Defer dock context menu display until long press is released for mouse input 3. Refactor touch long press to use same deferred release pattern 4. Add debug logging for both mouse and touch long press events Previously the dock context menu opened immediately on the longPressed signal, which could cause unexpected behavior while the user was still pressing. Now the menu only appears after the long press is released, providing a more natural and predictable interaction. Log: Changed dock long press behavior to show context menu on release instead of immediately Influence: 1. Test mouse long press on dock - verify context menu appears on release not during press 2. Test touch long press on dock - verify context menu appears on release not during press 3. Test short click/tap on dock - verify context menu does NOT appear 4. Test right-click on dock - verify normal context menu behavior is unaffected 5. Test long press and drag - verify no unexpected menu activation 6. Test rapid long press/release cycles - verify isLongPressing flag resets correctly fix: 修复任务栏长按上下文菜单在松开时才显示 1. 添加 isLongPressing 属性用于跟踪长按状态 2. 鼠标输入的长按上下文菜单延迟到松开时显示 3. 重构触摸长按逻辑,使用相同的延迟松开模式 4. 为鼠标和触摸长按事件添加调试日志 此前任务栏上下文菜单在 longPressed 信号触发时立即打开,可能导致用户仍在 按压时出现意外行为。现在菜单仅在长按松开后显示,提供更自然和可预测的交互 体验。 Log: 修改任务栏长按行为,上下文菜单在松开时显示而非立即显示 Influence: 1. 测试鼠标长按任务栏 - 验证上下文菜单在松开时而非按压时显示 2. 测试触摸长按任务栏 - 验证上下文菜单在松开时而非按压时显示 3. 测试短按/轻点任务栏 - 验证上下文菜单不会出现 4. 测试右键点击任务栏 - 验证正常的上下文菜单行为不受影响 5. 测试长按并拖动 - 验证不会意外激活菜单 6. 测试快速长按/松开循环 - 验证 isLongPressing 标志正确重置 PMS: BUG-358827 Change-Id: I23597cf45ae2c4cea634eb525a6ad09bde5fc89a
deepin pr auto review这段代码主要实现了在 Dock 面板中通过长按(鼠标或触摸屏)触发菜单显示的功能。以下是对这段代码的审查意见,包括语法逻辑、代码质量、代码性能和代码安全方面的建议: 1. 语法逻辑优点:
问题与改进:
2. 代码质量优点:
问题与改进:
3. 代码性能问题与改进:
4. 代码安全问题与改进:
5. 具体改进建议以下是优化后的代码示例: Window {
// ... 其他代码 ...
// 将 isLongPressing 移至更合适的作用域
property bool isLongPressing: false
// 提取共享逻辑
function handleLongPressRelease() {
if (!isLongPressing) return;
isLongPressing = false;
let lastActive = MenuHelper.activeMenu;
MenuHelper.closeCurrent();
dockMenuLoader.active = true;
if (lastActive !== dockMenuLoader.item) {
requestShowDockMenu();
}
}
TapHandler {
acceptedButtons: Qt.LeftButton | Qt.RightButton
gesturePolicy: TapHandler.WithinBounds
onTapped: {
if (tapCount === 2) {
viewDeactivated()
}
}
onLongPressed: {
console.debug("[Mouse Long Press] longPressed")
isLongPressing = true
}
onPressedChanged: {
console.debug("[Mouse Long Press] pressedChanged, pressed:", pressed, "isLongPressing:", isLongPressing)
if (!pressed) {
handleLongPressRelease();
}
}
}
// 触摸屏点击处理
TapHandler {
onTapped: {
if (tapCount === 2) {
viewDeactivated()
}
}
onLongPressed: {
console.debug("[Touch Long Press] longPressed")
isLongPressing = true
}
onPressedChanged: {
console.debug("[Touch Long Press] pressedChanged, pressed:", pressed, "isLongPressing:", isLongPressing)
if (!pressed) {
handleLongPressRelease();
}
}
}
}6. 其他建议
总结这段代码实现了基本功能,但在状态管理、代码复用和性能优化方面还有改进空间。通过提取共享逻辑、优化属性访问和增加状态保护机制,可以提升代码的健壮性和可维护性。 |
18202781743
approved these changes
Apr 28, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, fly602 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously the dock context menu opened immediately on the longPressed signal, which could cause unexpected behavior while the user was still pressing. Now the menu only appears after the long press is released, providing a more natural and predictable interaction.
Log: Changed dock long press behavior to show context menu on release instead of immediately
Influence:
fix: 修复任务栏长按上下文菜单在松开时才显示
此前任务栏上下文菜单在 longPressed 信号触发时立即打开,可能导致用户仍在
按压时出现意外行为。现在菜单仅在长按松开后显示,提供更自然和可预测的交互
体验。
Log: 修改任务栏长按行为,上下文菜单在松开时显示而非立即显示
Influence:
PMS: BUG-358827
Change-Id: I23597cf45ae2c4cea634eb525a6ad09bde5fc89a