import QtQuick import Quickshell import Quickshell.Wayland // One badge in a bottom corner of the screen. leftSide picks the corner. PanelWindow { id: root required property Theme theme required property bool leftSide required property string label required property color boxColor // Opacity of boxColor behind the text, 0 to 1. required property real boxOpacity required property color textColor signal clicked color: "transparent" anchors { bottom: true left: root.leftSide right: !root.leftSide } margins { bottom: root.theme.badgeMargin left: root.theme.badgeMargin right: root.theme.badgeMargin } // One flare bigger than the box, so the curves fit. implicitWidth: body.width + root.theme.badgeFlare implicitHeight: body.height + root.theme.badgeFlare exclusionMode: ExclusionMode.Ignore WlrLayershell.namespace: "quickshell:workspace-badge" WlrLayershell.layer: WlrLayer.Top WlrLayershell.keyboardFocus: WlrKeyboardFocus.None // Only the box takes clicks. The space around the curves lets them through. mask: Region { item: body } FlareGlass { anchors.fill: parent theme: root.theme tint: Qt.rgba(root.boxColor.r, root.boxColor.g, root.boxColor.b, root.boxOpacity) radius: root.theme.badgeRadius flare: root.theme.badgeFlare leftSide: root.leftSide } Item { id: body anchors.bottom: parent.bottom anchors.left: root.leftSide ? parent.left : undefined anchors.right: root.leftSide ? undefined : parent.right width: nameText.width + root.theme.badgePadding * 2 height: root.theme.badgeHeight Text { id: nameText anchors.centerIn: parent width: Math.min(nameText.implicitWidth, root.theme.badgeMaxNameWidth) text: root.label color: root.textColor font.pixelSize: root.theme.badgeFontSize elide: Text.ElideRight } MouseArea { anchors.fill: parent cursorShape: Qt.PointingHandCursor onClicked: root.clicked() } } }