From eb5ff050eb378de25f783e30b5e3b8e43f809b8d Mon Sep 17 00:00:00 2001 From: zhangkun2 Date: Mon, 14 Sep 2026 12:33:52 +0800 Subject: [PATCH] fix: make tooltip follow cursor position in launcher MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Root cause: all ToolTip attached properties relied on Qt default positioning (centered relative to parent item), without binding x/y to cursor position, causing tooltips to appear at fixed locations instead of following the mouse 2. Fix: add HoverHandler for cursor tracking where absent and bind ToolTip.toolTip.x/y to HoverHandler point.position in all 4 ToolTip usage sites 3. Impact: tooltips now appear at cursor position across fullscreen and windowed launcher modes; no change to tooltip text, visibility logic, or delay timing Log: Launcher tooltips now follow the mouse cursor instead of appearing at a fixed position Influence: 1. Test tooltip appears at cursor position in fullscreen mode 2. Test tooltip appears at cursor position in windowed mode 3. Verify tooltip still only shows when text is truncated 4. Verify tooltip delay and visibility logic unchanged fix: 启动器 tooltip 跟随光标位置显示 1. 根因:所有 ToolTip 附加属性依赖 Qt 默认定位逻辑(相对父项居中), 未绑定 x/y 到光标位置,导致 tooltip 固定出现在图标上方/下方而非跟随鼠标 2. 方案:为缺少 HoverHandler 的组件新增 HoverHandler 追踪光标,在全部 4 个 ToolTip 使用点绑定 ToolTip.toolTip.x/y 到 HoverHandler 的 point.position 3. 影响:全屏和窗口模式下 tooltip 均跟随光标位置显示;不改变 tooltip 文本、 显示/隐藏逻辑和延迟时间 Log: 启动器 tooltip 现在跟随鼠标光标位置显示,而非固定位置 Influence: 1. 测试全屏模式下 tooltip 跟随光标位置显示 2. 测试窗口模式下 tooltip 跟随光标位置显示 3. 验证 tooltip 仍仅在文字截断时显示 4. 验证 tooltip 延迟和显示/隐藏逻辑无变化 PMS: BUG-276573 --- qml/IconItemDelegate.qml | 5 +++++ qml/windowed/AppListView.qml | 2 ++ qml/windowed/FreeSortListView.qml | 2 ++ qml/windowed/IconItemDelegate.qml | 5 +++++ 4 files changed, 14 insertions(+) diff --git a/qml/IconItemDelegate.qml b/qml/IconItemDelegate.qml index 189335f9..ea4c6533 100644 --- a/qml/IconItemDelegate.qml +++ b/qml/IconItemDelegate.qml @@ -374,9 +374,14 @@ Control { } } } + HoverHandler { + id: toolTipHoverHandler + } ToolTip.text: root.text ToolTip.delay: 500 ToolTip.visible: hovered && iconItemLabel.truncated + ToolTip.toolTip.x: toolTipHoverHandler.point.position.x + ToolTip.toolTip.y: toolTipHoverHandler.point.position.y background: ItemBackground { radius: isWindowedMode ? 8 : 18 button: parent diff --git a/qml/windowed/AppListView.qml b/qml/windowed/AppListView.qml index d9159f41..a43cc744 100644 --- a/qml/windowed/AppListView.qml +++ b/qml/windowed/AppListView.qml @@ -220,6 +220,8 @@ FocusScope { ToolTip.text: text ToolTip.delay: 500 ToolTip.visible: hovered && contentItem.implicitWidth > contentItem.width + ToolTip.toolTip.x: itemHoverHandler.point.position.x + ToolTip.toolTip.y: itemHoverHandler.point.position.y Drag.dragType: Drag.Automatic Drag.active: mouseArea.drag.active diff --git a/qml/windowed/FreeSortListView.qml b/qml/windowed/FreeSortListView.qml index 78e06617..7766cb48 100644 --- a/qml/windowed/FreeSortListView.qml +++ b/qml/windowed/FreeSortListView.qml @@ -311,6 +311,8 @@ Item { ToolTip.text: text ToolTip.delay: 500 ToolTip.visible: hovered && contentItem.implicitWidth > contentItem.width + ToolTip.toolTip.x: itemHoverHandler.point.position.x + ToolTip.toolTip.y: itemHoverHandler.point.position.y Drag.hotSpot.x: width / 3 Drag.hotSpot.y: height / 2 diff --git a/qml/windowed/IconItemDelegate.qml b/qml/windowed/IconItemDelegate.qml index 9a8b403c..3ade161c 100644 --- a/qml/windowed/IconItemDelegate.qml +++ b/qml/windowed/IconItemDelegate.qml @@ -130,9 +130,14 @@ Control { font: DTK.fontManager.t9 } } + HoverHandler { + id: toolTipHoverHandler + } ToolTip.text: root.text ToolTip.delay: 500 ToolTip.visible: hovered && iconItemLabel.truncated + ToolTip.toolTip.x: toolTipHoverHandler.point.position.x + ToolTip.toolTip.y: toolTipHoverHandler.point.position.y background: ItemBackground { radius: 8 button: iconButton