Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

quickshell/nuguland/PopupCard.qml

Raw
import QtQuick

PopupButton {
    id: root

    default property alias content: contentItem.data
    property bool active: false
    property bool revealed: false
    property bool attention: false
    property bool externallyPressed: false
    property int padding: theme.spaceMd

    readonly property bool highlighted: active || revealed || attention || destructive
    readonly property color cardColor: destructive ? theme.error : (attention ? theme.warning : theme.ui.accent)
    // A selectable card (interactive or a hoverable row) that is active, e.g. the
    // selected result or the default device, adds a rail on its leading edge, so
    // selection never relies on the tint alone.
    readonly property bool selectionMarked: active && (interactive || hoverable)

    implicitWidth: contentItem.implicitWidth + padding * 2
    implicitHeight: Math.max(44, contentItem.implicitHeight + padding * 2)
    interactive: false
    showText: false
    accessibleName: role === "normal" ? "" : role
    tooltip: ""
    radius: theme.radiusCard
    color: theme.withAlpha(highlighted ? cardColor : theme.ui.normal, pressed || externallyPressed ? 0.16 : (hovered ? 0.1 : (highlighted ? 0.09 : 0.025)))
    border.width: controlFocused ? 2 : (attention || destructive ? 1 : 0)
    border.color: controlFocused ? theme.content.focus : theme.withAlpha(cardColor, 0.45)
    Accessible.role: interactive ? Accessible.Button : Accessible.Pane
    Accessible.checked: active

    Rectangle {
        objectName: "selectionRail"
        visible: root.selectionMarked
        x: 3
        width: 3
        height: Math.max(0, parent.height - root.theme.spaceMd * 2)
        anchors.verticalCenter: parent.verticalCenter
        radius: width / 2
        color: root.cardColor
    }

    Item {
        id: contentItem

        anchors.fill: parent
        anchors.margins: root.padding
        readonly property Item child: children.length > 0 ? children[0] : null
        implicitWidth: child ? child.implicitWidth : 0
        implicitHeight: child ? child.implicitHeight : 0
    }
}