From 1d3017f3e38a633d735f65f744009b82ddc1d9a5 Mon Sep 17 00:00:00 2001 From: Robertkill Date: Sat, 31 Jan 2026 10:41:32 +0800 Subject: [PATCH] fix: fix dock hide timer behavior with context menu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Added menuClosed signal to MenuHelper to notify when context menu closes 2. Modified hide timer to stop when context menu is opened via right- click 3. Added connection to restart hide timer when menu closes based on hide mode 4. Prevented dock hide animation when context menu is active The issue was that when a context menu was opened via right-click on the dock, the dock would still hide automatically because the hide timer continued running. This caused the menu to disappear when the dock hid itself. The fix ensures the hide timer stops when menu opens and restarts appropriately when menu closes, only if the dock should be in hidden state based on current hide mode. Log: Fixed dock disappearing when right-click context menu is open Influence: 1. Test right-clicking on dock to open context menu - dock should not hide while menu is open 2. Test closing context menu - dock should resume normal hide behavior based on hide mode 3. Test left-click functionality remains unchanged 4. Test drag operations while menu is open 5. Verify all hide modes (KeepHidden, SmartHide) work correctly with context menu fix: 修复任务栏右键菜单与隐藏计时器的交互问题 1. 在 MenuHelper 中添加 menuClosed 信号,用于通知右键菜单关闭事件 2. 修改隐藏计时器,在通过右键点击打开上下文菜单时停止计时 3. 添加连接逻辑,在菜单关闭时根据当前隐藏模式重新启动隐藏计时器 4. 防止在上下文菜单激活时任务栏执行隐藏动画 问题在于当通过右键点击任务栏打开上下文菜单时,任务栏仍会自动隐藏,因为隐 藏计时器继续运行。这导致菜单在任务栏隐藏时消失。修复确保在菜单打开时停止 隐藏计时器,并在菜单关闭时适当重新启动计时器(仅当任务栏根据当前隐藏模式 应处于隐藏状态时)。 Log: 修复了右键菜单打开时任务栏消失的问题 Influence: 1. 测试右键点击任务栏打开上下文菜单 - 菜单打开时任务栏不应隐藏 2. 测试关闭上下文菜单 - 任务栏应根据隐藏模式恢复正常隐藏行为 3. 测试左键点击功能保持不变 4. 测试菜单打开时的拖拽操作 5. 验证所有隐藏模式(KeepHidden、SmartHide)与上下文菜单的正常交互 PMS: BUG-349371 --- panels/dock/MenuHelper.qml | 10 +++++++++- panels/dock/package/main.qml | 16 +++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/panels/dock/MenuHelper.qml b/panels/dock/MenuHelper.qml index f59859322..46775f090 100644 --- a/panels/dock/MenuHelper.qml +++ b/panels/dock/MenuHelper.qml @@ -8,12 +8,20 @@ import Qt.labs.platform Item { property Menu activeMenu: null + + signal menuClosed() + Connections { + target: activeMenu + function onAboutToHide() { + activeMenu = null + menuClosed() + } + } function openMenu(menu: Menu) { if (activeMenu) { activeMenu.close() } menu.open() - menu.aboutToHide.connect(() => { activeMenu = null }) activeMenu = menu } function closeMenu(menu: Menu) { diff --git a/panels/dock/package/main.qml b/panels/dock/package/main.qml index 22a618c42..456bbd6b3 100644 --- a/panels/dock/package/main.qml +++ b/panels/dock/package/main.qml @@ -160,7 +160,7 @@ Window { running: false repeat: false onTriggered: { - if (!dock.isDragging) + if (!dock.isDragging && !MenuHelper.activeMenu) hideShowAnimation.start() } } @@ -416,6 +416,7 @@ Window { // maybe has popup visible, close it. Panel.requestClosePopup() viewDeactivated() + hideTimer.stop() MenuHelper.openMenu(dockMenuLoader.item) } if (button === Qt.LeftButton) { @@ -752,6 +753,19 @@ Window { target: Panel } + Connections { + function onMenuClosed() { + // 当右键菜单关闭时,根据当前隐藏模式重新启动隐藏计时器 + if (Panel.hideMode === Dock.KeepHidden + || Panel.hideMode === Dock.SmartHide + || Panel.hideState === Dock.Hide) { + hideTimer.running = true + } + } + + target: MenuHelper + } + function position2Anchors(position) { switch (position) { case Dock.Top: