forked from Shinonome/dots-hyprland
make battery icons adapt to battery percentage
This commit is contained in:
@@ -8,6 +8,17 @@ import qs.services
|
|||||||
Singleton {
|
Singleton {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
function getBatteryIcon(percentage: int): string {
|
||||||
|
if (percentage >= 93) return "battery_android_full";
|
||||||
|
if (percentage >= 78) return "battery_android_6";
|
||||||
|
if (percentage >= 64) return "battery_android_5";
|
||||||
|
if (percentage >= 50) return "battery_android_4";
|
||||||
|
if (percentage >= 35) return "battery_android_3";
|
||||||
|
if (percentage >= 21) return "battery_android_2";
|
||||||
|
if (percentage >= 7) return "battery_android_1";
|
||||||
|
return "battery_android_0";
|
||||||
|
}
|
||||||
|
|
||||||
function getBluetoothDeviceMaterialSymbol(systemIconName: string): string {
|
function getBluetoothDeviceMaterialSymbol(systemIconName: string): string {
|
||||||
if (systemIconName.includes("headset") || systemIconName.includes("headphones"))
|
if (systemIconName.includes("headset") || systemIconName.includes("headphones"))
|
||||||
return "headphones";
|
return "headphones";
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ HBarWidgetWithPopout {
|
|||||||
return "energy_savings_leaf";
|
return "energy_savings_leaf";
|
||||||
if (PowerProfiles.profile == PowerProfile.Performance)
|
if (PowerProfiles.profile == PowerProfile.Performance)
|
||||||
return "local_fire_department";
|
return "local_fire_department";
|
||||||
return "battery_android_full";
|
return C.Icons.getBatteryIcon(battCircProg.value * 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ StyledPopup {
|
|||||||
|
|
||||||
// Header
|
// Header
|
||||||
StyledPopupHeaderRow {
|
StyledPopupHeaderRow {
|
||||||
icon: "battery_android_full"
|
icon: Icons.getBatteryIcon(Battery.percentage * 100)
|
||||||
label: Translation.tr("Battery")
|
label: Translation.tr("Battery")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ MouseArea {
|
|||||||
|
|
||||||
IconAndTextPair {
|
IconAndTextPair {
|
||||||
visible: Battery.available
|
visible: Battery.available
|
||||||
icon: Battery.isCharging ? "bolt" : "battery_android_full"
|
icon: Battery.isCharging ? "bolt" : Icons.getBatteryIcon(Battery.percentage * 100)
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ Rectangle {
|
|||||||
id: boltIcon
|
id: boltIcon
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
fill: 1
|
fill: 1
|
||||||
text: Battery.isCharging ? "bolt" : "battery_android_full"
|
text: Battery.isCharging ? "bolt" : Icons.getBatteryIcon(Battery.percentage * 100)
|
||||||
color: batteryWidget.colText
|
color: batteryWidget.colText
|
||||||
iconSize: 24
|
iconSize: 24
|
||||||
animateChange: true
|
animateChange: true
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ MouseArea {
|
|||||||
id: boltIcon
|
id: boltIcon
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
fill: 1
|
fill: 1
|
||||||
text: isCharging ? "bolt" : "battery_android_full"
|
text: isCharging ? "bolt" : Icons.getBatteryIcon(Battery.percentage * 100)
|
||||||
iconSize: Appearance.font.pixelSize.normal
|
iconSize: Appearance.font.pixelSize.normal
|
||||||
animateChange: true
|
animateChange: true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user