adjust colors
This commit is contained in:
parent
92c931d6aa
commit
d51555ee47
@ -16,8 +16,10 @@ Item {
|
||||
connectedSources: ["headsetcontrol -bc"]
|
||||
interval: pollingrate * 1e3
|
||||
onNewData: {
|
||||
if(data['exit_code'] > 0)
|
||||
return console.log('error lol');
|
||||
if(data['exit_code'] > 0) {
|
||||
batteryPercent = -2;
|
||||
return;
|
||||
}
|
||||
batteryPercent = data['stdout'];
|
||||
}
|
||||
}
|
||||
@ -25,13 +27,13 @@ Item {
|
||||
Plasmoid.preferredRepresentation: Plasmoid.compactRepresentation
|
||||
|
||||
Plasmoid.compactRepresentation: Item {
|
||||
Layout.minimumWidth: units.iconSizes.large
|
||||
Layout.minimumWidth: units.iconSizes.medium
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
||||
Rectangle { // battery
|
||||
id: container
|
||||
anchors.fill: parent
|
||||
anchors.rightMargin: 15
|
||||
anchors.rightMargin: 2
|
||||
anchors.topMargin: 2
|
||||
anchors.bottomMargin: 2
|
||||
color: "transparent"
|
||||
@ -50,6 +52,14 @@ Item {
|
||||
color: batteryColor()
|
||||
width: parent.width * Math.max(0, Math.min(batteryPercent, 100)) / 100
|
||||
}
|
||||
Kirigami.Icon { // headphones icon
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.topMargin: 1
|
||||
anchors.bottomMargin: 1
|
||||
source: "audio-headphones-symbolic"
|
||||
}
|
||||
}
|
||||
}
|
||||
Rectangle { // battery cap
|
||||
@ -61,43 +71,5 @@ Item {
|
||||
width: 2
|
||||
color: PlasmaCore.Theme.textColor
|
||||
}
|
||||
Rectangle { // symbol: headset
|
||||
anchors.fill: parent
|
||||
anchors.rightMargin: 23
|
||||
color: "transparent"
|
||||
Kirigami.Icon {
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.right
|
||||
height: container.height * 0.45
|
||||
source: "audio-headset-symbolic"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function batteryColor() {
|
||||
let color = "red"
|
||||
if(batteryPercent == -1) // charging
|
||||
color = "green";
|
||||
else if(batteryPercent == -2) // not connected
|
||||
color = "red";
|
||||
else if(batteryPercent > 80)
|
||||
color = "green";
|
||||
else if(batteryPercent > 60)
|
||||
color = "green";
|
||||
else if(batteryPercent > 40)
|
||||
color = "yellow";
|
||||
else if(batteryPercent > 20)
|
||||
color = "red";
|
||||
return color;
|
||||
}
|
||||
|
||||
function batteryLevel() {
|
||||
if(batteryPercent == -1)
|
||||
return "charging";
|
||||
else if(batteryPercent == -2)
|
||||
return "not connected";
|
||||
else
|
||||
return batteryPercent + "%";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user