Logout, reboot and shut down now fill with accent liquid while held and run once full; letting go early drains it. A tap hints to hold. Replaces the Confirm/Cancel rows in the control center tile and dashboard tab. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
67 lines
2.0 KiB
QML
67 lines
2.0 KiB
QML
import QtQuick
|
|
import "../components"
|
|
import "../theme"
|
|
|
|
// Round icon toggle; filled with the accent while on. With `hold` it is a
|
|
// hold-to-confirm button instead: liquid fills it while held and held() fires
|
|
// once full; clicked() is not emitted.
|
|
Item {
|
|
id: root
|
|
property string glyph
|
|
property string fallback
|
|
property bool checked: false
|
|
property int size: 34
|
|
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
|
|
opacity: enabled ? 1 : 0.45
|
|
Accessible.role: Accessible.CheckBox
|
|
Accessible.checked: checked
|
|
GlassIcon {
|
|
anchors.fill: parent
|
|
size: root.size
|
|
radius: root.size / 2
|
|
glyph: root.glyph
|
|
fallback: root.fallback
|
|
active: root.checked
|
|
color: root.checked ? Theme.accent : area.containsMouse ? Theme.hover : Theme.surfaceVariant
|
|
border.width: root.checked ? 0 : 1
|
|
border.color: Theme.hairline
|
|
scale: area.pressed ? 0.92 : 1
|
|
Behavior on scale {
|
|
NumberAnimation {
|
|
duration: Theme.duration / 2
|
|
easing.type: Easing.OutCubic
|
|
}
|
|
}
|
|
HoldFill {
|
|
id: fill
|
|
anchors.fill: parent
|
|
visible: root.hold
|
|
holding: root.holding
|
|
glyph: root.glyph
|
|
fallback: root.fallback
|
|
glyphSize: Math.round(root.size * 0.5)
|
|
glyphWeight: Font.DemiBold
|
|
onCompleted: root.held()
|
|
onCancelled: root.holdCancelled()
|
|
}
|
|
}
|
|
MouseArea {
|
|
id: area
|
|
anchors.fill: parent
|
|
hoverEnabled: true
|
|
cursorShape: Qt.PointingHandCursor
|
|
onClicked: if (!root.hold)
|
|
root.clicked()
|
|
}
|
|
}
|