74 lines
1.8 KiB
QML
74 lines
1.8 KiB
QML
//@ pragma IconTheme Adwaita
|
|
|
|
import Quickshell
|
|
import Quickshell.Wayland
|
|
import Quickshell.Io
|
|
import Quickshell.Widgets
|
|
import Quickshell.Services.UPower
|
|
import QtQuick
|
|
import QtQuick.Layouts
|
|
import QtQuick.Controls
|
|
import "../Config"
|
|
|
|
PanelWindow {
|
|
anchors {
|
|
bottom: true
|
|
right: true
|
|
}
|
|
|
|
width: text.width + 70
|
|
color: "transparent"
|
|
|
|
function getIcon() {
|
|
if (UPower.displayDevice.percentage > 0.9) {
|
|
if (UPower.onBattery == false) {
|
|
return "xfce4-battery-full-charging"
|
|
}
|
|
else {
|
|
return "xfce4-battery-full"
|
|
}
|
|
}
|
|
else if (0.5 < UPower.displayDevice.percentage) {
|
|
if (UPower.onBattery == false) {
|
|
return "xfce4-battery-ok-charging"
|
|
}
|
|
else {
|
|
return "xfce4-battery-ok"
|
|
}
|
|
}
|
|
else if (0.1 < UPower.displayDevice.percentage) {
|
|
if (UPower.onBattery == false) {
|
|
return "xfce4-battery-low-charging"
|
|
}
|
|
else {
|
|
return "xfce4-battery-low"
|
|
}
|
|
}
|
|
}
|
|
|
|
Rectangle {
|
|
anchors.fill: parent
|
|
|
|
topLeftRadius: 20
|
|
opacity: 0.95
|
|
color: Colours.colour1
|
|
|
|
Row {
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
IconImage {
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
width: 50
|
|
height: 50
|
|
source: Quickshell.iconPath(getIcon())
|
|
}
|
|
Text {
|
|
id: text
|
|
color: Colours.foreground
|
|
font.family: "Departure Mono"
|
|
font.pixelSize: 50
|
|
text: Math.floor(UPower.displayDevice.percentage * 100) + "%"
|
|
}
|
|
}
|
|
}
|
|
}
|