From ae92bfc4723481a0d2aaf09c250e44c93223fcab Mon Sep 17 00:00:00 2001 From: yeshanshan Date: Thu, 19 Mar 2026 15:04:41 +0800 Subject: [PATCH] fix: fix AlertToolTip positioning and z-order issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Changed AlertToolTip positioning from relative to absolute coordinates by calculating global position of target item 2. Added parent assignment to Overlay.overlay to ensure proper z- ordering above other UI elements 3. Added import for QtQuick.Controls to access Overlay component 4. Modified x and y calculations to use global coordinates instead of local coordinates 5. Added __itemGlobalPos property to compute cumulative position by traversing parent hierarchy Log: Fixed AlertToolTip display issues where tooltips were hidden behind other UI elements Influence: 1. Test AlertToolTip display with various target elements at different hierarchy levels 2. Verify tooltip appears above all other UI elements including dialogs and popups 3. Test tooltip positioning accuracy when target element is nested in multiple containers 4. Verify smooth animation behavior during tooltip show/hide transitions 5. Test tooltip display in complex layout scenarios with overlapping elements fix: 修复AlertToolTip定位和层级问题 1. 将AlertToolTip定位从相对坐标改为绝对坐标,通过计算目标项的全局位置 2. 添加父级设置为Overlay.overlay以确保正确的z轴排序,显示在其他UI元素 之上 3. 添加QtQuick.Controls导入以访问Overlay组件 4. 修改x和y计算使用全局坐标而非局部坐标 5. 添加__itemGlobalPos属性通过遍历父级层次结构计算累积位置 Log: 修复AlertToolTip显示问题,解决工具提示被其他UI元素遮挡的情况 Influence: 1. 测试AlertToolTip在不同层级目标元素上的显示 2. 验证工具提示是否显示在所有其他UI元素(包括对话框和弹出窗口)之上 3. 测试当目标元素嵌套在多个容器中时工具提示定位的准确性 4. 验证工具提示显示/隐藏过渡时的平滑动画行为 5. 测试在复杂布局场景中工具提示的显示效果 PMS: BUG-352961 --- qt6/src/qml/AlertToolTip.qml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/qt6/src/qml/AlertToolTip.qml b/qt6/src/qml/AlertToolTip.qml index 2f8d0fc2..53c35805 100644 --- a/qt6/src/qml/AlertToolTip.qml +++ b/qt6/src/qml/AlertToolTip.qml @@ -3,6 +3,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later import QtQuick +import QtQuick.Controls import org.deepin.dtk 1.0 as D import org.deepin.dtk.style 1.0 as DS @@ -14,11 +15,22 @@ Control { property bool _expired: false readonly property bool _shown: control.visible && !_expired - x: 0 - y: (target ? target.height : 0) + (_shown ? DS.Style.control.spacing : 0) + property point __itemGlobalPos: { + let x = 0, y = 0 + let a = target + while (a && a.parent) { + x += a.x + y += a.y + a = a.parent + } + return Qt.point(x, y) + } + x: __itemGlobalPos.x + y: __itemGlobalPos.y + (target ? target.height : 0) + (_shown ? DS.Style.control.spacing : 0) Behavior on y { NumberAnimation { duration: 200 } } + parent: Overlay.overlay opacity: _shown ? 1 : 0 enabled: _shown topPadding: DS.Style.alertToolTip.verticalPadding @@ -27,7 +39,6 @@ Control { rightPadding: DS.Style.alertToolTip.horizontalPadding implicitWidth: target ? Math.min(DS.Style.control.implicitWidth(control), target.width) : DS.Style.control.implicitWidth(control) implicitHeight: DS.Style.control.implicitHeight(control) - z: D.DTK.TopOrder Timer { id: autoHideTimer