add material you style for battery
This commit is contained in:
parent
7b85ec95a4
commit
84d9c18982
@ -1,63 +1,71 @@
|
|||||||
import Quickshell
|
|
||||||
import Quickshell.Services.UPower
|
import Quickshell.Services.UPower
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell.Widgets
|
|
||||||
import "../../reusables/"
|
import "../../reusables/"
|
||||||
import "../../"
|
|
||||||
import "../../settings/"
|
import "../../settings/"
|
||||||
|
import "../../"
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
id: batLoader
|
id: batLoader
|
||||||
active: UPower.displayDevice.isLaptopBattery
|
active: UPower.displayDevice.isLaptopBattery
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
||||||
sourceComponent: Item {
|
sourceComponent: Rectangle {
|
||||||
id: root
|
id: container
|
||||||
|
radius: implicitHeight / 2
|
||||||
|
color: Colors.color0
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
implicitWidth: root.implicitWidth + 20
|
||||||
|
implicitHeight: Settings.config.barHeight - 10
|
||||||
|
Item {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
id: root
|
||||||
|
|
||||||
property bool frame1: UPower.displayDevice.percentage <= 0.16
|
property bool frame1: UPower.displayDevice.percentage <= 0.16
|
||||||
property bool frame2: UPower.displayDevice.percentage < 0.32
|
property bool frame2: UPower.displayDevice.percentage < 0.32
|
||||||
property bool frame3: UPower.displayDevice.percentage < 0.48
|
property bool frame3: UPower.displayDevice.percentage < 0.48
|
||||||
property bool frame4: UPower.displayDevice.percentage < 0.74
|
property bool frame4: UPower.displayDevice.percentage < 0.74
|
||||||
property bool frame5: UPower.displayDevice.percentage < 0.90
|
property bool frame5: UPower.displayDevice.percentage < 0.90
|
||||||
property bool frame6: UPower.displayDevice.percentage <= 1
|
property bool frame6: UPower.displayDevice.percentage <= 1
|
||||||
|
|
||||||
function getBatteryIcon() {
|
function getBatteryIcon() {
|
||||||
if (UPower.displayDevice.state == UPowerDeviceState.Charging) {
|
if (UPower.displayDevice.state == UPowerDeviceState.Charging) {
|
||||||
return "battery_android_frame_bolt";
|
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";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
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";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
implicitWidth: batRow.width
|
implicitWidth: batRow.width
|
||||||
implicitHeight: Settings.config.barHeight
|
implicitHeight: Settings.config.barHeight
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
id: batRow
|
id: batRow
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
spacing: 5
|
spacing: 5
|
||||||
CustomText {
|
CustomText {
|
||||||
id: batText
|
id: batText
|
||||||
text: Math.round(UPower.displayDevice.percentage * 100) + "%"
|
text: Math.round(UPower.displayDevice.percentage * 100) + "%"
|
||||||
}
|
}
|
||||||
CustomIcon {
|
CustomIcon {
|
||||||
id: batIcon
|
id: batIcon
|
||||||
text: root.getBatteryIcon()
|
text: root.getBatteryIcon()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,17 +9,17 @@ Rectangle {
|
|||||||
radius: implicitHeight / 2
|
radius: implicitHeight / 2
|
||||||
color: Colors.color0
|
color: Colors.color0
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
implicitWidth: root.implicitWidth
|
implicitWidth: root.implicitWidth
|
||||||
implicitHeight: Settings.config.barHeight - 10
|
implicitHeight: Settings.config.barHeight - 10
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
readonly property var activeWindow: ToplevelManager.activeToplevel
|
readonly property var activeWindow: ToplevelManager.activeToplevel
|
||||||
implicitWidth:titleText.implicitWidth + 20
|
implicitWidth: titleText.implicitWidth + 20
|
||||||
implicitHeight: Settings.config.barHeight
|
implicitHeight: Settings.config.barHeight
|
||||||
CustomText {
|
CustomText {
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
|
||||||
id: titleText
|
id: titleText
|
||||||
text: root.activeWindow.activated ? root.activeWindow.appId : "Desktop"
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
text: root.activeWindow ? root.activeWindow.activated ? root.activeWindow.appId : "Desktop" : "fail"
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user