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: 12

    readonly property bool highlighted: active || revealed || attention || destructive
    readonly property color cardColor: destructive ? theme.error : (attention ? theme.warning : theme.ui.accent)

    implicitWidth: contentItem.implicitWidth + padding * 2
    implicitHeight: Math.max(44, contentItem.implicitHeight + padding * 2)
    interactive: false
    showText: false
    accessibleName: role === "normal" ? "" : role
    tooltip: ""
    radius: 10
    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

    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
    }
}