repositories / dotfiles
dotfiles
bugabingas dorkfiles
owned by bugabinga
quickshell/nugu/StatusItem.qml
Rawimport QtQuick
Item {
id: root
required property QtObject theme
property string text: ""
property bool muted: false
property bool warning: false
property bool critical: false
property bool active: false
property int minWidth: 0
signal leftClicked()
signal middleClicked()
signal rightClicked()
signal wheelUp()
signal wheelDown()
// Shared status primitive keeps hover/active/signal semantics identical across
// widgets and prevents one-off colors from drifting away from Nugu. Warning
// and critical states use Nugu signal colors as fills because light-mode
// warning text over ui.backdrop is below WCAG AA contrast.
implicitWidth: Math.max(minWidth, label.implicitWidth + 14)
implicitHeight: 22
visible: text.length > 0
Rectangle {
anchors.fill: parent
radius: 7
color: root.active
? root.theme.ui.focus
: (mouse.containsMouse
? root.theme.ui.accent
: (root.critical ? root.theme.error : (root.warning ? root.theme.warning : "transparent")))
}
Text {
id: label
anchors.centerIn: parent
text: root.text
color: root.active || mouse.containsMouse || root.critical || root.warning
? root.theme.content.backdrop
: (root.muted ? root.theme.ui.minor : root.theme.ui.normal)
font.family: "IBM Plex Mono"
font.pixelSize: 12
font.features: { "tnum": 1 }
elide: Text.ElideRight
width: Math.min(implicitWidth, 240)
}
MouseArea {
id: mouse
anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton
onClicked: mouse => {
if (mouse.button === Qt.MiddleButton) root.middleClicked()
else if (mouse.button === Qt.RightButton) root.rightClicked()
else root.leftClicked()
}
}
WheelHandler {
// WheelHandler is separate from MouseArea so scroll gestures remain
// reliable on layer-shell surfaces while clicks keep their button routing.
onWheel: event => {
if (event.angleDelta.y > 0) root.wheelUp()
else if (event.angleDelta.y < 0) root.wheelDown()
}
}
}