battery critical blink animation
This commit is contained in:
parent
5d7f1f3fd9
commit
dca0b7c217
1 changed files with 12 additions and 2 deletions
|
|
@ -18,9 +18,17 @@ M.BarSection {
|
||||||
readonly property var dev: UPower.displayDevice
|
readonly property var dev: UPower.displayDevice
|
||||||
readonly property real pct: (dev?.percentage ?? 0) * 100
|
readonly property real pct: (dev?.percentage ?? 0) * 100
|
||||||
readonly property bool charging: dev?.state === UPowerDeviceState.Charging
|
readonly property bool charging: dev?.state === UPowerDeviceState.Charging
|
||||||
property color _stateColor: charging ? M.Theme.base0B : pct < 15 ? M.Theme.base09 : pct < 30 ? M.Theme.base0A : M.Theme.base08
|
readonly property bool _critical: pct < 15 && !charging
|
||||||
|
property color _stateColor: charging ? M.Theme.base0B : _critical ? M.Theme.base09 : pct < 30 ? M.Theme.base0A : M.Theme.base08
|
||||||
|
property real _blinkOpacity: 1
|
||||||
|
|
||||||
Behavior on _stateColor { ColorAnimation { duration: 300 } }
|
SequentialAnimation {
|
||||||
|
running: root._critical
|
||||||
|
loops: Animation.Infinite
|
||||||
|
NumberAnimation { target: root; property: "_blinkOpacity"; to: 0.2; duration: 400; easing.type: Easing.InOutQuad }
|
||||||
|
NumberAnimation { target: root; property: "_blinkOpacity"; to: 1; duration: 400; easing.type: Easing.InOutQuad }
|
||||||
|
onRunningChanged: if (!running) root._blinkOpacity = 1
|
||||||
|
}
|
||||||
|
|
||||||
property bool _warnSent: false
|
property bool _warnSent: false
|
||||||
property bool _critSent: false
|
property bool _critSent: false
|
||||||
|
|
@ -49,12 +57,14 @@ M.BarSection {
|
||||||
return icons[Math.min(10, Math.floor(root.pct / 10))];
|
return icons[Math.min(10, Math.floor(root.pct / 10))];
|
||||||
}
|
}
|
||||||
color: root._stateColor
|
color: root._stateColor
|
||||||
|
opacity: root._blinkOpacity
|
||||||
font.pixelSize: M.Theme.fontSize + 2
|
font.pixelSize: M.Theme.fontSize + 2
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
M.BarLabel {
|
M.BarLabel {
|
||||||
label: Math.round(root.pct) + "%"
|
label: Math.round(root.pct) + "%"
|
||||||
color: root._stateColor
|
color: root._stateColor
|
||||||
|
opacity: root._blinkOpacity
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue