fix positioning

This commit is contained in:
lucy 2025-12-31 16:59:55 +01:00
parent 4e63016e0d
commit 14bebb0c68
3 changed files with 37 additions and 34 deletions

View File

@ -1,30 +1,15 @@
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
ColumnLayout {
id: masterLayout
spacing: 0
Row {
spacing: 5
Text {
id: topText
font.weight: 900
font.family: Settings.font
font.pixelSize: Settings.fontSize
text: Math.round(UPower.displayDevice.percentage * 100) + "%"
color: Colors.foreground
}
Icons {
property bool isCharging: UPower.displayDevice.state === UPowerDeviceState.Charging property bool isCharging: UPower.displayDevice.state === UPowerDeviceState.Charging
function getBatteryIcon() { function getBatteryIcon() {
if (isCharging) { if (isCharging) {
@ -55,7 +40,22 @@ Loader {
return "battery_android_full"; return "battery_android_full";
} }
} }
text: getBatteryIcon() ColumnLayout {
id: masterLayout
implicitWidth: botText.width
spacing: 0
Row {
spacing: 5
Text {
id: topText
font.weight: 900
font.family: Settings.font
font.pixelSize: Settings.fontSize
text: Math.round(UPower.displayDevice.percentage * 100) + "%"
color: Colors.foreground
}
Icons {
text: root.getBatteryIcon()
} }
} }
Text { Text {

View File

@ -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

View File

@ -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()
} }
} }