Compare commits
No commits in common. "be0fb14eabb4533f1aa0b60854b111ff14c776cf" and "39179f260a72197571df05eaad3fc34cc02a7bef" have entirely different histories.
be0fb14eab
...
39179f260a
2 changed files with 9 additions and 8 deletions
|
|
@ -21,9 +21,9 @@ Switch {
|
||||||
}
|
}
|
||||||
|
|
||||||
indicator: Rectangle {
|
indicator: Rectangle {
|
||||||
id: indicator
|
id: indicator
|
||||||
|
|
||||||
property int padding: 8
|
property int padding: 8
|
||||||
|
|
||||||
implicitWidth: 48
|
implicitWidth: 48
|
||||||
implicitHeight: 24
|
implicitHeight: 24
|
||||||
|
|
@ -51,5 +51,5 @@ Switch {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
background: null
|
background: undefined
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import qs.components
|
import qs.components
|
||||||
import qs.config
|
import qs.config
|
||||||
import qs.constants
|
import qs.constants
|
||||||
|
import qs.widgets
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import Quickshell.Services.UPower
|
import Quickshell.Services.UPower
|
||||||
|
|
@ -8,7 +9,7 @@ import Quickshell.Services.UPower
|
||||||
StyledButton {
|
StyledButton {
|
||||||
id: root
|
id: root
|
||||||
property UPowerDevice laptopBattery: UPower.devices.values.find(device => device.isLaptopBattery)
|
property UPowerDevice laptopBattery: UPower.devices.values.find(device => device.isLaptopBattery)
|
||||||
property bool isCritical: laptopBattery?.percentage < 0.10
|
property bool isCritical: laptopBattery.percentage < 0.10
|
||||||
|
|
||||||
contentItem: RowLayout {
|
contentItem: RowLayout {
|
||||||
spacing: 4
|
spacing: 4
|
||||||
|
|
@ -25,16 +26,16 @@ StyledButton {
|
||||||
}
|
}
|
||||||
font.pixelSize: 16
|
font.pixelSize: 16
|
||||||
text: {
|
text: {
|
||||||
if (root.laptopBattery?.state == UPowerDeviceState.Charging) {
|
if (root.laptopBattery.state == UPowerDeviceState.Charging) {
|
||||||
return Icons.batteryCharging;
|
return Icons.batteryCharging;
|
||||||
}
|
}
|
||||||
if (root.isCritical) {
|
if (root.isCritical) {
|
||||||
return Icons.batteryWarning;
|
return Icons.batteryWarning;
|
||||||
}
|
}
|
||||||
if (root.laptopBattery?.percentage < 0.33) {
|
if (root.laptopBattery.percentage < 0.33) {
|
||||||
return Icons.batteryLow;
|
return Icons.batteryLow;
|
||||||
}
|
}
|
||||||
if (root.laptopBattery?.percentage < 0.66) {
|
if (root.laptopBattery.percentage < 0.66) {
|
||||||
return Icons.batteryMedium;
|
return Icons.batteryMedium;
|
||||||
}
|
}
|
||||||
return Icons.batteryFull;
|
return Icons.batteryFull;
|
||||||
|
|
@ -52,7 +53,7 @@ StyledButton {
|
||||||
}
|
}
|
||||||
return Theme.palette.basecontent;
|
return Theme.palette.basecontent;
|
||||||
}
|
}
|
||||||
text: `${(root.laptopBattery?.percentage.toFixed(2) * 100)}%`
|
text: `${(root.laptopBattery.percentage.toFixed(2) * 100)}%`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
visible: laptopBattery
|
visible: laptopBattery
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue