import QtQuick // A keyboard-focusable, branded button. Primary buttons are amber; secondary // buttons are a raised surface. Focus is always visible. Rectangle { id: btn property string label: "" property bool primary: false property bool danger: false property bool compact: false property bool actionEnabled: true signal clicked readonly property bool hovered: mouse.containsMouse readonly property color baseBg: { if (danger) return Qt.darker(Theme.danger, 1.25); if (primary) return hovered ? Theme.amber : Theme.amberDeep; return hovered ? Theme.surfaceRaised : Theme.surface; } implicitHeight: compact ? 34 : 46 implicitWidth: Math.max(compact ? 80 : 120, labelText.implicitWidth + (compact ? 28 : 48)) radius: Theme.radiusSmall color: actionEnabled ? baseBg : Theme.surface border.width: (primary || danger) ? 0 : 1 border.color: activeFocus ? Theme.focusRing : Theme.border opacity: actionEnabled ? 1 : 0.55 activeFocusOnTab: true Accessible.role: Accessible.Button Accessible.name: label Accessible.onPressAction: if (actionEnabled) btn.clicked() Keys.onReturnPressed: if (btn.actionEnabled) btn.clicked() Keys.onEnterPressed: if (btn.actionEnabled) btn.clicked() Keys.onSpacePressed: if (btn.actionEnabled) btn.clicked() Rectangle { anchors.fill: parent anchors.margins: -3 radius: btn.radius + 3 color: "transparent" border.width: 2 border.color: Theme.focusRing visible: btn.activeFocus } Text { id: labelText anchors.centerIn: parent text: btn.label color: (btn.primary || btn.danger) ? Theme.charcoal : Theme.warmWhite font.family: Theme.family font.pixelSize: btn.compact ? Theme.fontSmall : Theme.fontBody font.weight: btn.primary ? Font.DemiBold : Font.Normal } MouseArea { id: mouse anchors.fill: parent hoverEnabled: true cursorShape: Qt.PointingHandCursor enabled: btn.actionEnabled onClicked: btn.clicked() } }