2025-12-21 20:59:33 +01:00
|
|
|
import Quickshell.Services.UPower
|
|
|
|
|
import QtQuick
|
|
|
|
|
import Quickshell.Widgets
|
2025-12-24 15:41:03 +01:00
|
|
|
import "."
|
|
|
|
|
import qs
|
2025-12-21 20:59:33 +01:00
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
id: root
|
|
|
|
|
implicitWidth: batRow.implicitWidth + 10
|
|
|
|
|
implicitHeight: batRow.implicitHeight
|
|
|
|
|
Row {
|
|
|
|
|
id: batRow
|
|
|
|
|
anchors.centerIn: parent
|
2025-12-24 15:41:03 +01:00
|
|
|
spacing: 5
|
2025-12-21 20:59:33 +01:00
|
|
|
IconImage {
|
2025-12-23 00:06:06 +01:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2025-12-21 20:59:33 +01:00
|
|
|
source: "root:/icons/" + UPower.displayDevice.iconName + ".svg"
|
2025-12-24 23:00:08 +01:00
|
|
|
width: 12
|
|
|
|
|
height: 12
|
2025-12-21 20:59:33 +01:00
|
|
|
}
|
|
|
|
|
Text {
|
|
|
|
|
id: batteryText
|
2025-12-23 00:06:06 +01:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2025-12-22 13:55:00 +01:00
|
|
|
font.weight: 900
|
2025-12-21 20:59:33 +01:00
|
|
|
font.family: Appearance.font
|
|
|
|
|
font.pixelSize: Appearance.fontSize
|
|
|
|
|
color: Colors.foreground
|
|
|
|
|
text: Math.round(UPower.displayDevice.percentage * 100) + "%"
|
|
|
|
|
}
|
2025-12-24 15:41:03 +01:00
|
|
|
Text {
|
|
|
|
|
id: powerProfile
|
|
|
|
|
text: PowerProfile.toString(PowerProfiles.profile)
|
|
|
|
|
font.weight: 900
|
|
|
|
|
color: Colors.foreground
|
|
|
|
|
font.family: Appearance.font
|
|
|
|
|
font.pixelSize: Appearance.fontSize
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
MouseArea {
|
|
|
|
|
acceptedButtons: Qt.LeftButton
|
|
|
|
|
cursorShape: Qt.OpenHandCursor
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
onClicked: {
|
|
|
|
|
const modes = [PowerProfile.PowerSaver, PowerProfile.Balanced, PowerProfile.Performance];
|
|
|
|
|
let current = PowerProfiles.profile;
|
|
|
|
|
let currentIndex = modes.indexOf(current);
|
|
|
|
|
let nextIndex = (currentIndex + 1) % modes.length;
|
|
|
|
|
PowerProfiles.profile = modes[nextIndex];
|
|
|
|
|
PowerProfiles.profile = profiles[nextIndex];
|
|
|
|
|
}
|
2025-12-21 20:59:33 +01:00
|
|
|
}
|
|
|
|
|
}
|