Skip to content

Commit e52a343

Browse files
committed
Fix: Optimize tooltip positioning logic.
Log: The Popup is rendered on the window's Overlay layer and is not part of the content visual tree. As a result, the tooltip does not follow its anchor item during scrolling or window resizing, causing positional drift. To resolve this, AlertToolTip has been changed from a ToolTip (which uses Popup) to a regular Item, making it part of the content visual tree. This ensures it naturally scrolls with its parent, respects container clipping, and maintains correct positioning at all times. PMS: bug-341973
1 parent 6fe5e85 commit e52a343

2 files changed

Lines changed: 21 additions & 19 deletions

File tree

qt6/src/qml/AlertToolTip.qml

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
1-
// SPDX-FileCopyrightText: 2021 - 2022 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2021 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: LGPL-3.0-or-later
44

55
import QtQuick
66
import org.deepin.dtk 1.0 as D
77
import org.deepin.dtk.style 1.0 as DS
88

9-
ToolTip {
9+
Control {
1010
id: control
1111
property Item target
12+
property string text
13+
property int timeout: 0
1214

1315
x: 0
14-
y: target ? target.height + DS.Style.control.spacing : 0
16+
y: (target ? target.height : 0) + (visible ? DS.Style.control.spacing : 0)
17+
Behavior on y {
18+
NumberAnimation { duration: 200 }
19+
}
1520
topPadding: DS.Style.alertToolTip.verticalPadding
1621
bottomPadding: DS.Style.alertToolTip.verticalPadding
1722
leftPadding: DS.Style.alertToolTip.horizontalPadding
1823
rightPadding: DS.Style.alertToolTip.horizontalPadding
19-
implicitWidth: Math.min(DS.Style.control.implicitWidth(control), target.width)
24+
implicitWidth: target ? Math.min(DS.Style.control.implicitWidth(control), target.width) : DS.Style.control.implicitWidth(control)
2025
implicitHeight: DS.Style.control.implicitHeight(control)
21-
margins: 0
22-
closePolicy: Popup.NoAutoClose
26+
z: D.DTK.TopOrder
27+
28+
Timer {
29+
interval: control.timeout
30+
running: control.timeout > 0 && control.visible
31+
onTriggered: control.visible = false
32+
}
2333

2434
background: FloatingPanel {
2535
radius: DS.Style.alertToolTip.radius
@@ -40,23 +50,12 @@ ToolTip {
4050
wrapMode: Text.Wrap
4151
}
4252

43-
enter: Transition {
44-
// TODO: Transparency causes tooltips to appear through the window background - temporarily removed
45-
// NumberAnimation { properties: "opacity"; from: 0.0; to: 1.0; duration: 200 }
46-
NumberAnimation { properties: "y"; from: control.target.height; to: control.target.height + DS.Style.control.spacing; duration: 200 }
47-
}
48-
49-
exit: Transition {
50-
// NumberAnimation { properties: "opacity"; from: 1.0; to: 0.0 }
51-
NumberAnimation { properties: "y"; from: control.target.height + DS.Style.control.spacing ; to: control.target.height }
52-
}
53-
5453
BoxShadow {
5554
id: line
5655
property D.Palette dropShadowColor: DS.Style.alertToolTip.connecterdropShadow
5756
property D.Palette backgroundColor: DS.Style.alertToolTip.connecterBackground
5857
property D.Palette borderColor: DS.Style.control.border
59-
y: - height * (0.75) - control.topMargin - control.topPadding
58+
y: -height * 0.75
6059
width: DS.Style.alertToolTip.connectorWidth
6160
height: DS.Style.alertToolTip.connectorHeight
6261
shadowBlur: 4

qt6/src/qml/EditPanel.qml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ Rectangle {
3131
}
3232
}
3333

34+
// Keep Loader active while there is alert text so we don't destroy/recreate when
35+
// caller toggles showAlert to refresh the message; avoids wrong text (e.g. "systemd journal")
36+
// from binding context during recreation.
3437
Loader {
35-
active: showAlert && alertText.length !== 0
38+
active: alertText.length !== 0
3639
sourceComponent: AlertToolTip {
3740
target: control
3841
timeout: alertDuration

0 commit comments

Comments
 (0)