bar/modules/deprecated/Battery_orig.qml.bak (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
import "../.."
import QtQuick
import QtQuick.Layouts
import Quickshell.Services.UPower
import "classes"
RowLayout {
layoutDirection: Qt.RightToLeft
Repeater {
model: UPower.devices.values.filter(d => {
return d.model;
})
RowLayout {
property var lvl: Math.round(modelData.percentage * 100)
property var charge_state: UPowerDeviceState.toString(modelData.state)
property var device_type: UPowerDeviceType.toString(modelData.type)
spacing: 2
layoutDirection: Qt.RightToLeft
Text {
id: battery_level_indicator
Layout.alignment: Qt.AlignCenter
font.pixelSize: 16 * Size.scale
renderType: Text.NativeRendering
font.family: font_proggy.name
text: lvl + "%"
color: (charge_state == "Charging") ? Style.saffron : (lvl < 20) ? Style.scarlet : Style.fg
}
Text {
id: battery_device_icon
Layout.alignment: Qt.AlignCenter
font.family: font_icon.name
text: modelData.isLaptopBattery ? Icons.devices.battery : modelData.model == "Jupiter of the Monkey" ? Icons.devices.headphones : {
"Headphones": Icons.devices.headphones,
"Headset": Icons.devices.headphones,
"Gaming Input": Icons.devices.controller,
"Keyboard": Icons.devices.keyboard,
"Mouse": Icons.devices.mouse,
"Unknown": Icons.devices.unknown,
"Speakers": Icons.devices.speaker,
"Printer": Icons.devices.printer,
"Camera": Icons.devices.camera,
"Phone": Icons.devices.phone
}[device_type] ?? modelData.model
font.pixelSize: (device_type == "Gaming Input") ? 14 * Size.scale : Resources.fontsize.bottombar_icon
color: modelData.model == "Jupiter of the Monkey" ? "#897bc7" : (charge_state == "Charging") ? Style.saffron : lvl < 20 ? Style.scarlet : (charge_state == "FullyCharged") ? Style.cyan : Style.orange
}
Sep {
Layout.alignment: Qt.AlignBaseline
}
}
}
}
|