themed icons for states
This commit is contained in:
parent
a67cdbd66f
commit
df58449ef5
4 changed files with 13 additions and 4 deletions
|
|
@ -17,6 +17,10 @@ M.BarSection {
|
|||
readonly property var dev: UPower.displayDevice
|
||||
readonly property real pct: (dev?.percentage ?? 0) * 100
|
||||
readonly property bool charging: dev?.state === UPowerDeviceState.Charging
|
||||
readonly property color _stateColor: charging ? M.Theme.base0B
|
||||
: pct < 15 ? M.Theme.base08
|
||||
: pct < 30 ? M.Theme.base09
|
||||
: M.Theme.base05
|
||||
|
||||
M.BarIcon {
|
||||
icon: {
|
||||
|
|
@ -25,13 +29,13 @@ M.BarSection {
|
|||
const icons = ["\uDB80\uDC8E", "\uDB80\uDC7A", "\uDB80\uDC7B", "\uDB80\uDC7C", "\uDB80\uDC7D", "\uDB80\uDC7E", "\uDB80\uDC7F", "\uDB80\uDC80", "\uDB80\uDC81", "\uDB80\uDC82", "\uDB85\uDFE2"];
|
||||
return icons[Math.min(10, Math.floor(root.pct / 10))];
|
||||
}
|
||||
color: root.pct < 15 ? M.Theme.base08 : M.Theme.base05
|
||||
color: root._stateColor
|
||||
font.pixelSize: M.Theme.fontSize + 2
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
M.BarLabel {
|
||||
label: Math.round(root.pct) + "%"
|
||||
color: root.pct < 15 ? M.Theme.base08 : M.Theme.base05
|
||||
color: root._stateColor
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue