fix positioning
This commit is contained in:
parent
4e63016e0d
commit
14bebb0c68
@ -1,18 +1,48 @@
|
|||||||
pragma ComponentBehavior: Bound
|
pragma ComponentBehavior: Bound
|
||||||
import Quickshell.Services.UPower
|
import Quickshell.Services.UPower
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell.Widgets
|
|
||||||
import "../../"
|
import "../../"
|
||||||
import "../settings/"
|
import "../settings/"
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
id: root
|
id: root
|
||||||
visible: UPower.displayDevice.isLaptopBattery
|
active: UPower.displayDevice.isLaptopBattery
|
||||||
width: masterLayout.implicitWidth
|
width: masterLayout.implicitWidth
|
||||||
height: 34
|
height: 34
|
||||||
|
property bool isCharging: UPower.displayDevice.state === UPowerDeviceState.Charging
|
||||||
|
function getBatteryIcon() {
|
||||||
|
if (isCharging) {
|
||||||
|
return "battery_android_frame_bolt";
|
||||||
|
}
|
||||||
|
if (UPower.displayDevice.percentage < 0.12) {
|
||||||
|
return "battery_android_frame_0";
|
||||||
|
}
|
||||||
|
if (UPower.displayDevice.percentage < 0.24) {
|
||||||
|
return "battery_android_frame_1";
|
||||||
|
}
|
||||||
|
if (UPower.displayDevice.percentage < 0.36) {
|
||||||
|
return "battery_android_frame_2";
|
||||||
|
}
|
||||||
|
if (UPower.displayDevice.percentage < 0.48) {
|
||||||
|
return "battery_android_frame_3";
|
||||||
|
}
|
||||||
|
if (UPower.displayDevice.percentage < 0.60) {
|
||||||
|
return "battery_android_frame_4";
|
||||||
|
}
|
||||||
|
if (UPower.displayDevice.percentage < 0.72) {
|
||||||
|
return "battery_android_frame_5";
|
||||||
|
}
|
||||||
|
if (UPower.displayDevice.percentage < 0.84) {
|
||||||
|
return "battery_android_frame_6";
|
||||||
|
}
|
||||||
|
if (UPower.displayDevice.percentage > 0.84) {
|
||||||
|
return "battery_android_full";
|
||||||
|
}
|
||||||
|
}
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: masterLayout
|
id: masterLayout
|
||||||
|
implicitWidth: botText.width
|
||||||
spacing: 0
|
spacing: 0
|
||||||
Row {
|
Row {
|
||||||
spacing: 5
|
spacing: 5
|
||||||
@ -25,37 +55,7 @@ Loader {
|
|||||||
color: Colors.foreground
|
color: Colors.foreground
|
||||||
}
|
}
|
||||||
Icons {
|
Icons {
|
||||||
property bool isCharging: UPower.displayDevice.state === UPowerDeviceState.Charging
|
text: root.getBatteryIcon()
|
||||||
function getBatteryIcon() {
|
|
||||||
if (isCharging) {
|
|
||||||
return "battery_android_frame_bolt";
|
|
||||||
}
|
|
||||||
if (UPower.displayDevice.percentage < 0.12) {
|
|
||||||
return "battery_android_frame_0";
|
|
||||||
}
|
|
||||||
if (UPower.displayDevice.percentage < 0.24) {
|
|
||||||
return "battery_android_frame_1";
|
|
||||||
}
|
|
||||||
if (UPower.displayDevice.percentage < 0.36) {
|
|
||||||
return "battery_android_frame_2";
|
|
||||||
}
|
|
||||||
if (UPower.displayDevice.percentage < 0.48) {
|
|
||||||
return "battery_android_frame_3";
|
|
||||||
}
|
|
||||||
if (UPower.displayDevice.percentage < 0.60) {
|
|
||||||
return "battery_android_frame_4";
|
|
||||||
}
|
|
||||||
if (UPower.displayDevice.percentage < 0.72) {
|
|
||||||
return "battery_android_frame_5";
|
|
||||||
}
|
|
||||||
if (UPower.displayDevice.percentage < 0.84) {
|
|
||||||
return "battery_android_frame_6";
|
|
||||||
}
|
|
||||||
if (UPower.displayDevice.percentage > 0.84) {
|
|
||||||
return "battery_android_full";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
text: getBatteryIcon()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Text {
|
Text {
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import "../../"
|
|||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
implicitWidth: powerLayout.implicitWidth + 10
|
implicitWidth: powerLayout.implicitWidth
|
||||||
implicitHeight: 34
|
implicitHeight: 34
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|||||||
@ -53,9 +53,11 @@ Loader {
|
|||||||
id: styleLayout
|
id: styleLayout
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
implicitWidth: topText.width + icon.width
|
||||||
Row {
|
Row {
|
||||||
spacing: 2
|
spacing: 2
|
||||||
Text {
|
Text {
|
||||||
|
id: topText
|
||||||
PwObjectTracker {
|
PwObjectTracker {
|
||||||
objects: Pipewire.ready ? root.sink : []
|
objects: Pipewire.ready ? root.sink : []
|
||||||
}
|
}
|
||||||
@ -66,6 +68,7 @@ Loader {
|
|||||||
text: Pipewire.ready ? Math.round(root.sink.audio.volume * 100) + "%" : "0%"
|
text: Pipewire.ready ? Math.round(root.sink.audio.volume * 100) + "%" : "0%"
|
||||||
}
|
}
|
||||||
Icons {
|
Icons {
|
||||||
|
id: icon
|
||||||
text: root.getVolumeIcon()
|
text: root.getVolumeIcon()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user