// One action in the focus capsule. Kept local to the module so the capsule's
// low, tailored geometry does not leak into generic shell buttons.

import QtQuick
import qs.config
import qs.widgets

Rectangle {
    id: root

    property string icon: ""
    property string iconFallback: "dialog-information-symbolic"
    property string label: ""
    property bool destructive: false

    signal activated

    implicitHeight: 34
    radius: Theme.cardRadius - 2
    border.width: 0

    readonly property color actionColor: root.destructive ? Theme.danger : Theme.fg

    color: {
        if (mouse.pressed)
            return Theme.alpha(root.actionColor, 0.24);
        if (mouse.containsMouse)
            return Theme.alpha(root.actionColor, root.destructive ? 0.16 : Theme.hoverAlpha);
        return Theme.alpha(Theme.fg, 0.07);
    }

    Behavior on color {
        ColorAnimation { duration: Theme.durFast }
    }

    Row {
        anchors.centerIn: parent
        spacing: 7

        ThemedIcon {
            anchors.verticalCenter: parent.verticalCenter
            size: 15
            icon: root.icon
            iconFallback: root.iconFallback
            tint: root.actionColor
        }

        Text {
            anchors.verticalCenter: parent.verticalCenter
            text: root.label
            color: root.actionColor
            font.family: Theme.fontFamily
            font.pixelSize: Theme.fontSizeSmall
            font.weight: Font.Medium
        }
    }

    MouseArea {
        id: mouse
        anchors.fill: parent
        hoverEnabled: true
        cursorShape: Qt.PointingHandCursor
        onClicked: root.activated()
    }
}
