2020-08-21 11:23:47 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2020-09-17 19:45:57 +00:00
|
|
|
import "../../shared"
|
2021-10-14 13:09:35 +00:00
|
|
|
import "../../shared/panels"
|
2020-08-21 11:23:47 +00:00
|
|
|
|
|
|
|
ToolTip {
|
|
|
|
id: tooltip
|
2021-02-10 16:32:45 +00:00
|
|
|
property int maxWidth: 800
|
2021-03-25 17:37:25 +00:00
|
|
|
property string orientation: "top"
|
|
|
|
|
2021-02-10 16:25:54 +00:00
|
|
|
implicitWidth: Math.min(maxWidth, textContent.implicitWidth + Style.current.bigPadding)
|
2021-02-10 00:17:09 +00:00
|
|
|
leftPadding: Style.current.smallPadding
|
|
|
|
rightPadding: Style.current.smallPadding
|
2020-08-21 11:23:47 +00:00
|
|
|
topPadding: Style.current.smallPadding
|
|
|
|
bottomPadding: Style.current.smallPadding
|
|
|
|
delay: 200
|
2021-07-19 10:05:12 +00:00
|
|
|
|
2020-08-21 11:23:47 +00:00
|
|
|
background: Item {
|
|
|
|
id: tooltipBg
|
|
|
|
Rectangle {
|
|
|
|
id: tooltipContentBg
|
2021-01-19 15:26:34 +00:00
|
|
|
color: Style.current.tooltipBackgroundColor
|
2020-08-21 11:23:47 +00:00
|
|
|
radius: Style.current.radius
|
|
|
|
anchors.fill: parent
|
2021-02-10 00:17:09 +00:00
|
|
|
anchors.bottomMargin: Style.current.smallPadding
|
2020-08-21 11:23:47 +00:00
|
|
|
}
|
|
|
|
Rectangle {
|
|
|
|
color: tooltipContentBg.color
|
2021-05-28 17:35:21 +00:00
|
|
|
height: 26
|
|
|
|
width: 26
|
2021-03-25 17:37:25 +00:00
|
|
|
rotation: 45
|
2020-08-21 11:23:47 +00:00
|
|
|
radius: 1
|
2021-03-25 17:37:25 +00:00
|
|
|
x: {
|
|
|
|
if (orientation === "top" || orientation === "bottom") {
|
|
|
|
return tooltipBg.width / 2 - width / 2
|
|
|
|
}
|
|
|
|
if (orientation === "left") {
|
2021-05-28 17:35:21 +00:00
|
|
|
return tooltipContentBg.width - (width / 2) - 7
|
2021-03-25 17:37:25 +00:00
|
|
|
}
|
|
|
|
if (orientation === "right") {
|
2021-05-28 17:35:21 +00:00
|
|
|
return -width/2 + 7
|
2021-03-25 17:37:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
y: {
|
2021-07-19 10:05:12 +00:00
|
|
|
if ((orientation === "bottom") || (tooltip.y > 0)) {
|
2021-05-28 17:35:21 +00:00
|
|
|
return -height / 2 + 5
|
2021-03-25 17:37:25 +00:00
|
|
|
}
|
|
|
|
if (orientation === "top") {
|
2021-05-28 17:35:21 +00:00
|
|
|
return tooltipBg.height - height - 5
|
2021-03-25 17:37:25 +00:00
|
|
|
}
|
|
|
|
if (orientation === "left" || orientation === "right") {
|
|
|
|
return tooltipContentBg.height / 2 - (height / 2)
|
|
|
|
}
|
|
|
|
}
|
2020-08-21 11:23:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
contentItem: StyledText {
|
|
|
|
id: textContent
|
|
|
|
text: tooltip.text
|
2021-01-19 15:26:34 +00:00
|
|
|
color: Style.current.tooltipForegroundColor
|
2020-08-21 11:23:47 +00:00
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
font.pixelSize: 13
|
2021-01-25 20:50:42 +00:00
|
|
|
font.weight: Font.Medium
|
2020-08-21 11:23:47 +00:00
|
|
|
horizontalAlignment: Text.AlignHCenter
|
2021-02-10 00:17:09 +00:00
|
|
|
bottomPadding: Style.current.smallPadding
|
2020-08-21 11:23:47 +00:00
|
|
|
}
|
|
|
|
}
|