status-desktop/ui/shared/status/StatusToolTip.qml

70 lines
2.1 KiB
QML
Raw Normal View History

import QtQuick 2.13
import QtQuick.Controls 2.13
import utils 1.0
import "../../shared"
import "../../shared/panels"
ToolTip {
id: tooltip
property int maxWidth: 800
2021-03-25 17:37:25 +00:00
property string orientation: "top"
implicitWidth: Math.min(maxWidth, textContent.implicitWidth + Style.current.bigPadding)
leftPadding: Style.current.smallPadding
rightPadding: Style.current.smallPadding
topPadding: Style.current.smallPadding
bottomPadding: Style.current.smallPadding
delay: 200
background: Item {
id: tooltipBg
Rectangle {
id: tooltipContentBg
color: Style.current.tooltipBackgroundColor
radius: Style.current.radius
anchors.fill: parent
anchors.bottomMargin: Style.current.smallPadding
}
Rectangle {
color: tooltipContentBg.color
height: 26
width: 26
2021-03-25 17:37:25 +00:00
rotation: 45
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") {
return tooltipContentBg.width - (width / 2) - 7
2021-03-25 17:37:25 +00:00
}
if (orientation === "right") {
return -width/2 + 7
2021-03-25 17:37:25 +00:00
}
}
y: {
if ((orientation === "bottom") || (tooltip.y > 0)) {
return -height / 2 + 5
2021-03-25 17:37:25 +00:00
}
if (orientation === "top") {
return tooltipBg.height - height - 5
2021-03-25 17:37:25 +00:00
}
if (orientation === "left" || orientation === "right") {
return tooltipContentBg.height / 2 - (height / 2)
}
}
}
}
contentItem: StyledText {
id: textContent
text: tooltip.text
color: Style.current.tooltipForegroundColor
wrapMode: Text.WordWrap
font.pixelSize: 13
font.weight: Font.Medium
horizontalAlignment: Text.AlignHCenter
bottomPadding: Style.current.smallPadding
}
}