-
Notifications
You must be signed in to change notification settings - Fork 55
fix: tooltip not centered when first hover #1361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
首次计算位置时先计算的bounding后设置的文字,所以首次计算结果肯定不正确. PMS: BUG-340869 Log:
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR fixes an initial tooltip misalignment in AppItem.qml by ensuring the tooltip text is set before computing and applying its bounding rectangle for docking panel positioning. Sequence diagram for corrected tooltip positioning on first hoversequenceDiagram
actor User
participant AppItem as AppItem_QML
participant Timer as HoverDelayTimer
participant ToolTip as ToolTip_QML
participant Positioner as DockPanelPositioner
User->>AppItem: hover enters AppItem
AppItem->>Timer: start(interval = 50ms)
Timer-->>AppItem: triggered
AppItem->>AppItem: point = mapToItem(null, width/2, height/2)
AppItem->>ToolTip: set text(name or trashTipText)
AppItem->>Positioner: set bounding(Qt.rect(point.x, point.y, ToolTip.width, ToolTip.height))
AppItem->>ToolTip: open()
Flow diagram for tooltip bounding calculation orderflowchart TD
A[Hover enters AppItem] --> B[Start HoverDelayTimer]
B --> C[Timer triggered]
C --> D[Calculate center point using mapToItem]
D --> E[Set ToolTip.text based on itemId]
E --> F[Set DockPanelPositioner.bounding using ToolTip.width and ToolTip.height]
F --> G[Open ToolTip]
G --> H[Tooltip appears centered on first hover]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review我来帮你分析这段代码的修改。这是一个关于工具提示(ToolTip)位置设置的改动。
Timer {
interval: 50
onTriggered: {
// 先设置文本内容
toolTip.text = root.itemId === "dde-trash" ? root.name + "-" + taskmanager.Applet.getTrashTipText() : root.name
// 等待文本内容更新后再计算位置
Qt.callLater(() => {
var point = root.mapToItem(null, root.width / 2, root.height / 2)
toolTip.DockPanelPositioner.bounding = Qt.rect(point.x, point.y, toolTip.width, toolTip.height)
toolTip.open()
})
}
}
这个改进建议主要是为了确保工具提示的位置计算更加准确,特别是在处理动态文本内容时。虽然原代码的修改已经有所改进,但使用 Qt.callLater 可以使代码更加健壮。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes - here's some feedback:
- Since the tooltip size now depends on setting
toolTip.textbefore computingDockPanelPositioner.bounding, consider adding a short comment explaining this ordering constraint to prevent future refactors from accidentally reintroducing the bug.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Since the tooltip size now depends on setting `toolTip.text` before computing `DockPanelPositioner.bounding`, consider adding a short comment explaining this ordering constraint to prevent future refactors from accidentally reintroducing the bug.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: BLumia, wjyrich 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 |
首次计算位置时先计算的bounding后设置的文字,所以首次计算结果肯定不正确.
Summary by Sourcery
Bug Fixes: