forked from Shinonome/dots-hyprland
overlay: add battery level
This commit is contained in:
@@ -178,7 +178,7 @@ Item { // Bar content region
|
|||||||
}
|
}
|
||||||
|
|
||||||
BatteryIndicator {
|
BatteryIndicator {
|
||||||
visible: (root.useShortenedForm < 2 && UPower.displayDevice.isLaptopBattery)
|
visible: (root.useShortenedForm < 2 && Battery.available)
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ MouseArea {
|
|||||||
opacity: root.toolbarOpacity
|
opacity: root.toolbarOpacity
|
||||||
|
|
||||||
IconAndTextPair {
|
IconAndTextPair {
|
||||||
visible: UPower.displayDevice.isLaptopBattery
|
visible: Battery.available
|
||||||
icon: Battery.isCharging ? "bolt" : "battery_android_full"
|
icon: Battery.isCharging ? "bolt" : "battery_android_full"
|
||||||
text: Math.round(Battery.percentage * 100)
|
text: Math.round(Battery.percentage * 100)
|
||||||
color: (Battery.isLow && !Battery.isCharging) ? Appearance.colors.colError : Appearance.colors.colOnSurfaceVariant
|
color: (Battery.isLow && !Battery.isCharging) ? Appearance.colors.colError : Appearance.colors.colOnSurfaceVariant
|
||||||
|
|||||||
@@ -49,8 +49,13 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Separator {}
|
Separator {}
|
||||||
|
|
||||||
TimeWidget {}
|
TimeWidget {}
|
||||||
|
Separator {
|
||||||
|
visible: Battery.available
|
||||||
|
}
|
||||||
|
BatteryWidget {
|
||||||
|
visible: Battery.available
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
component Separator: Rectangle {
|
component Separator: Rectangle {
|
||||||
@@ -67,12 +72,44 @@ Rectangle {
|
|||||||
Layout.rightMargin: 6
|
Layout.rightMargin: 6
|
||||||
|
|
||||||
text: DateTime.time
|
text: DateTime.time
|
||||||
|
color: Appearance.colors.colOnSurface
|
||||||
font {
|
font {
|
||||||
family: Appearance.font.family.numbers
|
family: Appearance.font.family.numbers
|
||||||
variableAxes: Appearance.font.variableAxes.numbers
|
variableAxes: Appearance.font.variableAxes.numbers
|
||||||
pixelSize: 22
|
pixelSize: 22
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
component BatteryWidget: Row {
|
||||||
|
id: batteryWidget
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
Layout.leftMargin: 6
|
||||||
|
Layout.rightMargin: 6
|
||||||
|
spacing: 2
|
||||||
|
property color colText: Battery.isLowAndNotCharging ? Appearance.colors.colError : Appearance.colors.colOnSurface
|
||||||
|
|
||||||
|
MaterialSymbol {
|
||||||
|
id: boltIcon
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
fill: 1
|
||||||
|
text: Battery.isCharging ? "bolt" : "battery_android_full"
|
||||||
|
color: batteryWidget.colText
|
||||||
|
iconSize: 24
|
||||||
|
animateChange: true
|
||||||
|
}
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
id: batteryText
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
text: Math.round(Battery.percentage * 100) + "%"
|
||||||
|
color: batteryWidget.colText
|
||||||
|
font {
|
||||||
|
family: Appearance.font.family.numbers
|
||||||
|
variableAxes: Appearance.font.variableAxes.numbers
|
||||||
|
pixelSize: 18
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
component WidgetButton: RippleButton {
|
component WidgetButton: RippleButton {
|
||||||
id: widgetButton
|
id: widgetButton
|
||||||
|
|||||||
@@ -148,11 +148,11 @@ Item { // Bar content region
|
|||||||
}
|
}
|
||||||
|
|
||||||
HorizontalBarSeparator {
|
HorizontalBarSeparator {
|
||||||
visible: UPower.displayDevice.isLaptopBattery
|
visible: Battery.available
|
||||||
}
|
}
|
||||||
|
|
||||||
BatteryIndicator {
|
BatteryIndicator {
|
||||||
visible: UPower.displayDevice.isLaptopBattery
|
visible: Battery.available
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: false
|
Layout.fillHeight: false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user