fix battery logic
This commit is contained in:
parent
d45beea1c2
commit
c13610253f
@ -8,80 +8,76 @@ import qs
|
|||||||
import qs.reusables
|
import qs.reusables
|
||||||
import qs.settings
|
import qs.settings
|
||||||
|
|
||||||
Loader {
|
Rectangle {
|
||||||
id: batLoader
|
id: container
|
||||||
active: UPower.displayDevice.isLaptopBattery
|
visible: UPower.displayDevice.isLaptopBattery
|
||||||
|
radius: implicitHeight / 2
|
||||||
|
color: Colors.surfaceContainer
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
implicitWidth: UPower.displayDevice.isLaptopBattery ? root.implicitWidth + 20 : 0
|
||||||
|
implicitHeight: Settings.config.barHeight - 10
|
||||||
|
Item {
|
||||||
|
id: root
|
||||||
|
anchors.centerIn: parent
|
||||||
|
|
||||||
sourceComponent: Rectangle {
|
property bool frame1: UPower.displayDevice.percentage <= 0.16
|
||||||
id: container
|
property bool frame2: UPower.displayDevice.percentage < 0.32
|
||||||
radius: implicitHeight / 2
|
property bool frame3: UPower.displayDevice.percentage < 0.48
|
||||||
color: Colors.surfaceContainer
|
property bool frame4: UPower.displayDevice.percentage < 0.74
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
property bool frame5: UPower.displayDevice.percentage < 0.90
|
||||||
implicitWidth: UPower.displayDevice.isLaptopBattery ? root.implicitWidth + 20 : 0
|
property bool frame6: UPower.displayDevice.percentage <= 1
|
||||||
implicitHeight: Settings.config.barHeight - 10
|
|
||||||
Item {
|
function getBatteryIcon() {
|
||||||
id: root
|
if (UPower.displayDevice.state == UPowerDeviceState.Charging) {
|
||||||
|
return "battery_android_frame_bolt";
|
||||||
|
}
|
||||||
|
if (frame1) {
|
||||||
|
return "battery_android_frame_1";
|
||||||
|
}
|
||||||
|
if (frame2) {
|
||||||
|
return "battery_android_frame_2";
|
||||||
|
}
|
||||||
|
if (frame3) {
|
||||||
|
return "battery_android_frame_3";
|
||||||
|
}
|
||||||
|
if (frame4) {
|
||||||
|
return "battery_android_frame_4";
|
||||||
|
}
|
||||||
|
if (frame5) {
|
||||||
|
return "battery_android_frame_5";
|
||||||
|
}
|
||||||
|
if (frame6) {
|
||||||
|
return "battery_android_frame_full";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function getProfileIcon() {
|
||||||
|
if (PowerProfiles.profile.toString() == "2") {
|
||||||
|
return "power-profile-performance-symbolic";
|
||||||
|
}
|
||||||
|
if (PowerProfiles.profile.toString() == "1") {
|
||||||
|
return "power-profile-balanced-symbolic";
|
||||||
|
}
|
||||||
|
if (PowerProfiles.profile.toString() == "0") {
|
||||||
|
return "power-profile-power-saver-symbolic";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
implicitWidth: batRow.width
|
||||||
|
implicitHeight: Settings.config.barHeight
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
id: batRow
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
|
height: parent.height
|
||||||
|
spacing: 5
|
||||||
|
CustomText {
|
||||||
|
id: batText
|
||||||
|
|
||||||
property bool frame1: UPower.displayDevice.percentage <= 0.16
|
text: Math.round(UPower.displayDevice.percentage * 100) + "%"
|
||||||
property bool frame2: UPower.displayDevice.percentage < 0.32
|
|
||||||
property bool frame3: UPower.displayDevice.percentage < 0.48
|
|
||||||
property bool frame4: UPower.displayDevice.percentage < 0.74
|
|
||||||
property bool frame5: UPower.displayDevice.percentage < 0.90
|
|
||||||
property bool frame6: UPower.displayDevice.percentage <= 1
|
|
||||||
|
|
||||||
function getBatteryIcon() {
|
|
||||||
if (UPower.displayDevice.state == UPowerDeviceState.Charging) {
|
|
||||||
return "battery_android_frame_bolt";
|
|
||||||
}
|
|
||||||
if (frame1) {
|
|
||||||
return "battery_android_frame_1";
|
|
||||||
}
|
|
||||||
if (frame2) {
|
|
||||||
return "battery_android_frame_2";
|
|
||||||
}
|
|
||||||
if (frame3) {
|
|
||||||
return "battery_android_frame_3";
|
|
||||||
}
|
|
||||||
if (frame4) {
|
|
||||||
return "battery_android_frame_4";
|
|
||||||
}
|
|
||||||
if (frame5) {
|
|
||||||
return "battery_android_frame_5";
|
|
||||||
}
|
|
||||||
if (frame6) {
|
|
||||||
return "battery_android_frame_full";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
function getProfileIcon() {
|
CustomIcon {
|
||||||
if (PowerProfiles.profile.toString() == "2") {
|
id: batIcon
|
||||||
return "power-profile-performance-symbolic";
|
text: root.getBatteryIcon()
|
||||||
}
|
|
||||||
if (PowerProfiles.profile.toString() == "1") {
|
|
||||||
return "power-profile-balanced-symbolic";
|
|
||||||
}
|
|
||||||
if (PowerProfiles.profile.toString() == "0") {
|
|
||||||
return "power-profile-power-saver-symbolic";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
implicitWidth: batRow.width
|
|
||||||
implicitHeight: Settings.config.barHeight
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
id: batRow
|
|
||||||
anchors.centerIn: parent
|
|
||||||
height: parent.height
|
|
||||||
spacing: 5
|
|
||||||
CustomText {
|
|
||||||
id: batText
|
|
||||||
|
|
||||||
text: Math.round(UPower.displayDevice.percentage * 100) + "%"
|
|
||||||
}
|
|
||||||
CustomIcon {
|
|
||||||
id: batIcon
|
|
||||||
text: root.getBatteryIcon()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user