Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 34 additions & 18 deletions qt6/src/qml/AlertToolTip.qml
Original file line number Diff line number Diff line change
@@ -1,25 +1,52 @@
// SPDX-FileCopyrightText: 2021 - 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2021 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

import QtQuick
import org.deepin.dtk 1.0 as D
import org.deepin.dtk.style 1.0 as DS

ToolTip {
Control {
id: control
property Item target
property string text
property int timeout: 0
property bool _expired: false
readonly property bool _shown: control.visible && !_expired

x: 0
y: target ? target.height + DS.Style.control.spacing : 0
y: (target ? target.height : 0) + (_shown ? DS.Style.control.spacing : 0)
Behavior on y {
NumberAnimation { duration: 200 }
}
opacity: _shown ? 1 : 0
enabled: _shown
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enabled不需要吧,

topPadding: DS.Style.alertToolTip.verticalPadding
bottomPadding: DS.Style.alertToolTip.verticalPadding
leftPadding: DS.Style.alertToolTip.horizontalPadding
rightPadding: DS.Style.alertToolTip.horizontalPadding
implicitWidth: Math.min(DS.Style.control.implicitWidth(control), target.width)
implicitWidth: target ? Math.min(DS.Style.control.implicitWidth(control), target.width) : DS.Style.control.implicitWidth(control)
implicitHeight: DS.Style.control.implicitHeight(control)
margins: 0
closePolicy: Popup.NoAutoClose
z: D.DTK.TopOrder

Timer {
id: autoHideTimer
interval: control.timeout
running: control.timeout > 0 && control.visible && !control._expired
onTriggered: control._expired = true
}

onVisibleChanged: {
_expired = false
if (visible && timeout > 0)
autoHideTimer.restart()
}

onTextChanged: {
_expired = false
if (visible && timeout > 0)
autoHideTimer.restart()
}

background: FloatingPanel {
radius: DS.Style.alertToolTip.radius
Expand All @@ -40,23 +67,12 @@ ToolTip {
wrapMode: Text.Wrap
}

enter: Transition {
// TODO: Transparency causes tooltips to appear through the window background - temporarily removed
// NumberAnimation { properties: "opacity"; from: 0.0; to: 1.0; duration: 200 }
NumberAnimation { properties: "y"; from: control.target.height; to: control.target.height + DS.Style.control.spacing; duration: 200 }
}

exit: Transition {
// NumberAnimation { properties: "opacity"; from: 1.0; to: 0.0 }
NumberAnimation { properties: "y"; from: control.target.height + DS.Style.control.spacing ; to: control.target.height }
}

BoxShadow {
id: line
property D.Palette dropShadowColor: DS.Style.alertToolTip.connecterdropShadow
property D.Palette backgroundColor: DS.Style.alertToolTip.connecterBackground
property D.Palette borderColor: DS.Style.control.border
y: - height * (0.75) - control.topMargin - control.topPadding
y: -height * 0.75
width: DS.Style.alertToolTip.connectorWidth
height: DS.Style.alertToolTip.connectorHeight
shadowBlur: 4
Expand Down
5 changes: 4 additions & 1 deletion qt6/src/qml/EditPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ Rectangle {
}
}

// Keep Loader active while there is alert text so we don't destroy/recreate when
// caller toggles showAlert to refresh the message; avoids wrong text (e.g. "systemd journal")
// from binding context during recreation.
Loader {
active: showAlert && alertText.length !== 0
active: alertText.length !== 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

重新创建会导致文本错误?

sourceComponent: AlertToolTip {
target: control
timeout: alertDuration
Expand Down
Loading