[ui] show tooltip when hovering over line number or color bar

This commit is contained in:
Loïc Vital 2022-10-04 10:54:00 +02:00
parent f4b8cb080d
commit 3e2478bd24

View file

@ -199,30 +199,36 @@ Item {
property var duration: textView.model.get(index).duration property var duration: textView.model.get(index).duration
// Colored marker to quickly indicate duration Item {
Rectangle { Layout.minimumWidth: childrenRect.width
width: 4
Layout.fillHeight: true Layout.fillHeight: true
color: Colors.interpolate(Colors.grey, Colors.red, duration/180) RowLayout {
} height: parent.height
// Colored marker to quickly indicate duration
// Line number Rectangle {
// displays a tooltip with the duration when hovered width: 4
Label { Layout.fillHeight: true
text: index + 1 color: Colors.interpolate(Colors.grey, Colors.red, duration/180)
Layout.minimumWidth: lineMetrics.width }
rightPadding: 2 // Line number
Layout.fillHeight: true Label {
horizontalAlignment: Text.AlignRight text: index + 1
color: "#CCCCCC" Layout.minimumWidth: lineMetrics.width
rightPadding: 6
Layout.fillHeight: true
horizontalAlignment: Text.AlignRight
color: "#CCCCCC"
}
}
// Display a tooltip with the duration when hovered
MouseArea {
id: mouseArea
hoverEnabled: true
anchors.fill: parent
}
enabled: duration > 0 enabled: duration > 0
ToolTip.text: "Elapsed time: " + Format.getTimeStr(duration) ToolTip.text: "Elapsed time: " + Format.getTimeStr(duration)
ToolTip.visible: mouseArea.containsMouse ToolTip.visible: mouseArea.containsMouse
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
}
} }
Loader { Loader {