Improve panes system and add battery pane
This commit is contained in:
60
Widgets/Battery.qml
Normal file
60
Widgets/Battery.qml
Normal file
@@ -0,0 +1,60 @@
|
||||
import Quickshell.Services.UPower
|
||||
import Quickshell.Widgets
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import "." as Widgets
|
||||
|
||||
Item {
|
||||
anchors {
|
||||
top: parent.top
|
||||
bottom: parent.bottom
|
||||
}
|
||||
width: children[1].width + 20
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 4
|
||||
color: hover.hovered ? "#11ffffff" : "#00ffffff"
|
||||
radius: 8
|
||||
bottomLeftRadius: 12
|
||||
}
|
||||
Row {
|
||||
anchors {
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
x: 8
|
||||
spacing: 4
|
||||
Image {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: 20
|
||||
height: width
|
||||
sourceSize { width: width; height: height }
|
||||
source: {
|
||||
if (UPower.displayDevice.state === UPowerDeviceState.Charging)
|
||||
return Quickshell.shellPath("assets/battery-charging-symbolic.svg")
|
||||
switch (PowerProfiles.profile) {
|
||||
case PowerProfile.PowerSaver:
|
||||
return Quickshell.shellPath("assets/power-saver-symbolic.svg")
|
||||
break;
|
||||
case PowerProfile.Balanced:
|
||||
return Quickshell.shellPath("assets/balanced-symbolic.svg")
|
||||
break;
|
||||
case PowerProfile.Performance:
|
||||
return Quickshell.shellPath("assets/performance-symbolic.svg")
|
||||
break;
|
||||
}
|
||||
return Quickshell.shellPath("assets/battery-performance-symbolic.svg")
|
||||
}
|
||||
}
|
||||
Text {
|
||||
id: content
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
x: 10
|
||||
color: "white"
|
||||
text: `${Math.round(UPower.displayDevice.percentage * 100)}% · ${Math.round(UPower.displayDevice.changeRate)}W`
|
||||
}
|
||||
}
|
||||
HoverHandler {id: hover}
|
||||
TapHandler {onTapped: {
|
||||
background.index = 2
|
||||
}}
|
||||
}
|
||||
Reference in New Issue
Block a user