import QtQuick import Quickshell.Widgets Rectangle { id: root required property Theme theme property string text: "" property string icon: "" property url iconSource: "" property string role: "normal" property bool checked: false property int iconSize: 14 property bool primary: role === "primary" signal clicked readonly property bool destructive: role === "destructive" readonly property color stateColor: destructive ? theme.error : (primary || checked ? theme.ui.accent : theme.ui.normal) implicitWidth: labelRow.implicitWidth + 24 implicitHeight: 34 radius: 10 opacity: enabled ? 1 : 0.48 color: theme.withAlpha(stateColor, tap.pressed ? 0.38 : (hover.hovered ? 0.28 : (checked || primary ? 0.2 : 0.1))) border.width: activeFocus || checked ? 2 : 1 border.color: activeFocus ? theme.content.focus : theme.withAlpha(stateColor, enabled ? 0.72 : 0.35) activeFocusOnTab: enabled Accessible.role: Accessible.Button Accessible.name: text Accessible.checked: checked Keys.onPressed: event => { if (enabled && (event.key === Qt.Key_Return || event.key === Qt.Key_Enter || event.key === Qt.Key_Space)) { event.accepted = true; root.clicked(); } } Row { id: labelRow anchors.centerIn: parent spacing: 7 IconImage { visible: root.iconSource.toString().length > 0 anchors.verticalCenter: parent.verticalCenter width: root.iconSize height: root.iconSize source: root.iconSource } Text { visible: root.icon.length > 0 anchors.verticalCenter: parent.verticalCenter color: root.theme.content.normal font.family: "Symbols Nerd Font Mono" font.pixelSize: root.iconSize text: root.icon } NuguText { theme: root.theme color: root.theme.content.normal text: root.text } } HoverHandler { id: hover } TapHandler { id: tap enabled: root.enabled gesturePolicy: TapHandler.ReleaseWithinBounds onTapped: root.clicked() } Behavior on color { ColorAnimation { duration: root.theme.lowPowerMode ? 0 : 90 } } }