import QtQuick import "../components" import "../theme" // Round glyph button used by the media controls and the power tab. Rectangle { id: root property string glyph property string fallback property int size: 36 property real glyphScale: 0.45 property bool accented: false property bool active: false property bool danger: false property bool interactive: true // Hold-to-confirm: liquid fills the button while held, held() fires once // full and clicked() is not emitted. property bool hold: false // Callers may withhold filling, e.g. until an action is pending. property bool armed: true readonly property bool holding: hold && armed && area.pressed && area.containsMouse readonly property bool pressed: area.pressed readonly property bool filled: fill.active signal clicked signal held signal holdCancelled implicitWidth: size implicitHeight: size radius: size / 2 opacity: interactive ? 1 : 0.4 color: accented ? (area.pressed ? Theme.accentPressed : area.containsMouse ? Theme.accentHover : Theme.accent) : danger && area.containsMouse ? Qt.alpha("#ff5f57", 0.85) : active ? Qt.alpha(Theme.accent, 0.28) : area.containsMouse ? Theme.hover : Theme.fill border.width: accented ? 0 : 1 border.color: active ? Qt.alpha(Theme.accent, 0.6) : Theme.hairline scale: area.pressed ? 1 - 0.06 * Theme.intensity : 1 Behavior on color { ColorAnimation { duration: Theme.duration / 2 } } Behavior on scale { NumberAnimation { duration: Theme.duration / 2 easing.type: Easing.OutCubic } } Text { anchors.centerIn: parent text: Icons.available && root.glyph ? root.glyph : root.fallback font.family: Icons.available && root.glyph ? Icons.family : "" font.pixelSize: Math.round(root.size * root.glyphScale) color: root.accented ? Theme.accentText : root.active ? Theme.accentVivid : Theme.text } HoldFill { id: fill anchors.fill: parent visible: root.hold holding: root.holding glyph: root.glyph fallback: root.fallback glyphSize: Math.round(root.size * root.glyphScale) onCompleted: root.held() onCancelled: root.holdCancelled() } MouseArea { id: area anchors.fill: parent hoverEnabled: true enabled: root.interactive cursorShape: Qt.PointingHandCursor onClicked: if (!root.hold) root.clicked() } Accessible.role: Accessible.Button }