fix: fix AlertToolTip positioning and z-order issues#589
Merged
18202781743 merged 1 commit intolinuxdeepin:masterfrom Mar 19, 2026
Merged
fix: fix AlertToolTip positioning and z-order issues#58918202781743 merged 1 commit intolinuxdeepin:masterfrom
18202781743 merged 1 commit intolinuxdeepin:masterfrom
Conversation
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
Reviewer's guide (collapsed on small PRs)Reviewer's GuideConverts AlertToolTip from local, z-based positioning to an absolute-positioned overlay tooltip using computed global coordinates, ensuring it renders above all UI elements and animates vertically based on the target’s global position. Updated class diagram for AlertToolTip positioning and parentingclassDiagram
class AlertToolTip_Before {
+int x
+int y
+int z
+Item implicitParent
}
class AlertToolTip_After {
+point __itemGlobalPos
+int x
+int y
+Item parent
}
AlertToolTip_Before <.. AlertToolTip_After : updated_to
Flow diagram for computing AlertToolTip global positionflowchart TD
A["Start: need tooltip global position"] --> B["Set x = 0, y = 0"]
B --> C["a = target"]
C --> D{"a and a.parent?"}
D -->|yes| E["x += a.x; y += a.y"]
E --> F["a = a.parent"]
F --> D
D -->|no| G["Return Qt.point(x, y) as __itemGlobalPos"]
G --> H["Set Control.x = __itemGlobalPos.x"]
H --> I["Set Control.y = __itemGlobalPos.y + target.height + spacing"]
I --> J["Assign parent = Overlay.overlay"]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- Instead of manually accumulating x/y through the parent chain in
__itemGlobalPos, consider usingtarget.mapToItem(Overlay.overlay, 0, 0)(ormapToItem(null, 0, 0)if appropriate) to correctly handle transforms, scaling, and other non‑trivial layout cases. parent: Overlay.overlayassumes an Overlay is available; if this component can be used outside anApplicationWindow/Overlaycontext, consider a fallback or guard (e.g., using the window’s contentItem or checking forOverlay.overlay) to avoid runtime errors.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Instead of manually accumulating x/y through the parent chain in `__itemGlobalPos`, consider using `target.mapToItem(Overlay.overlay, 0, 0)` (or `mapToItem(null, 0, 0)` if appropriate) to correctly handle transforms, scaling, and other non‑trivial layout cases.
- `parent: Overlay.overlay` assumes an Overlay is available; if this component can be used outside an `ApplicationWindow`/`Overlay` context, consider a fallback or guard (e.g., using the window’s contentItem or checking for `Overlay.overlay`) to avoid runtime errors.
## Individual Comments
### Comment 1
<location path="qt6/src/qml/AlertToolTip.qml" line_range="18-26" />
<code_context>
- 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
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Use `mapToItem` instead of manually walking the parent chain for global coordinates.
You can replace the manual accumulation with the mapping API, for example:
```qml
property point __itemGlobalPos: target
? target.mapToItem(null, 0, 0)
: Qt.point(0, 0)
```
This correctly accounts for transforms, scaling, and complex parent relationships and reduces the chance of subtle positioning bugs.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Contributor
deepin pr auto review代码审查意见1. 语法逻辑
2. 代码质量
3. 代码性能
4. 代码安全
5. 其他建议
改进后的代码示例import QtQuick
import QtQuick.Controls
import org.deepin.dtk 1.0 as D
import org.deepin.dtk.style 1.0 as DS
Control {
id: control
property Item target: null
property bool _expired: false
readonly property bool _shown: control.visible && !_expired
function calculateGlobalPos(item) {
if (!item) return Qt.point(0, 0)
let x = 0, y = 0
let a = item
const MAX_ITERATIONS = 100
let iterations = 0
while (a && a.parent && iterations < MAX_ITERATIONS) {
x += a.x
y += a.y
a = a.parent
iterations++
}
return Qt.point(x, y)
}
property point _itemGlobalPos: calculateGlobalPos(target)
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
bottomPadding: DS.Style.alertToolTip.verticalPadding
leftPadding: DS.Style.alertToolTip.horizontalPadding
rightPadding: DS.Style.alertToolTip.horizontalPadding
implicitWidth: target ? Math.min(DS.Style.control.implicitWidth(control), target.width) : DS.Style.control.control.implicitWidth(control)
implicitHeight: DS.Style.control.implicitHeight(control)
Timer {
id: autoHideTimer
// ...
}
}总结
|
caixr23
approved these changes
Mar 19, 2026
BLumia
approved these changes
Mar 19, 2026
Contributor
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, BLumia, caixr23 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.
coordinates by calculating global position of target item
ordering above other UI elements
local coordinates
traversing parent hierarchy
Log: Fixed AlertToolTip display issues where tooltips were hidden behind
other UI elements
Influence:
hierarchy levels
and popups
multiple containers
elements
fix: 修复AlertToolTip定位和层级问题
之上
Log: 修复AlertToolTip显示问题,解决工具提示被其他UI元素遮挡的情况
Influence:
PMS: BUG-352961
Summary by Sourcery
Adjust AlertToolTip to use global positioning and the application overlay for correct display layering.
Bug Fixes:
Enhancements: