import QtQuick Item { id: root property string label: "" property bool active: false property bool danger: false readonly property bool hovered: hover.containsMouse readonly property bool pressed: hover.pressed readonly property color iconColor: { if (danger && hovered) return Theme.danger if (active) return Theme.accentStrong if (hovered) return Theme.textPrimary return Theme.textSecondary } default property alias icon: iconHolder.data signal clicked() implicitWidth: Theme.controlHeight implicitHeight: Theme.controlHeight activeFocusOnTab: true Accessible.role: Accessible.Button Accessible.name: root.label Accessible.onPressAction: root.clicked() Keys.onReturnPressed: { event.accepted = true root.clicked() } Keys.onSpacePressed: { event.accepted = true root.clicked() } Rectangle { anchors.fill: parent radius: Theme.radiusSmall color: { if (root.danger && hover.pressed) return Theme.dangerSoftStrong if (root.danger && hover.containsMouse) return Theme.dangerSoft if (root.active) return Theme.accentSoft if (hover.pressed) return Theme.pressedFill if (hover.containsMouse) return Theme.hoverFill return "transparent" } Behavior on color { ColorAnimation { duration: Theme.animationFast } } } Item { id: iconHolder anchors.centerIn: parent width: 16 height: 16 } MouseArea { id: hover anchors.fill: parent hoverEnabled: true cursorShape: Qt.PointingHandCursor onClicked: root.clicked() } FocusFrame { radius: Theme.radiusSmall } NebulaToolTip { text: root.label active: hover.containsMouse && !hover.pressed && root.label.length > 0 } }