repositories / dotfiles
dotfiles
bugabingas dorkfiles
owned by admin
quickshell/nuguland/PopupToolTip.qml
Rawimport QtQuick
import QtQuick.Templates as T
T.ToolTip {
id: root
required property Theme theme
// The owner wants this tooltip shown, e.g. hovered or keyboard focused; of all
// wanted tooltips only the most recently wanted one shows (Theme.toolTipClaimed).
property bool wanted: false
property bool superseded: false
// Show above the owner, e.g. so a disclosure's tooltip never covers what it reveals below.
property bool above: false
padding: theme.spaceSm
margins: theme.spaceSm
delay: 500
timeout: 5000
visible: wanted && !superseded
implicitWidth: Math.min(320, label.implicitWidth + leftPadding + rightPadding)
implicitHeight: label.implicitHeight + topPadding + bottomPadding
x: parent ? (parent.width - width) / 2 : 0
y: parent ? (above ? -height - 6 : parent.height + 6) : 0
closePolicy: T.Popup.CloseOnEscape | T.Popup.CloseOnPressOutsideParent
onWantedChanged: {
superseded = false;
if (wanted)
theme.toolTipClaimed(root);
}
Connections {
target: root.theme
function onToolTipClaimed(tip: QtObject): void {
if (tip !== root && root.wanted)
root.superseded = true;
}
}
contentItem: Text {
id: label
text: root.text
textFormat: Text.PlainText
wrapMode: Text.Wrap
font.family: root.theme.fontSans
font.pixelSize: root.theme.textMeta
color: root.theme.content.normal
}
background: Rectangle {
radius: root.theme.radiusControl
color: root.theme.content.backdrop
border.width: 1
border.color: root.theme.withAlpha(root.theme.ui.minor, 0.3)
}
}