From 14bebb0c68e0fbb1659f7e9dabf3864c50bbae27 Mon Sep 17 00:00:00 2001 From: lucy Date: Wed, 31 Dec 2025 16:59:55 +0100 Subject: [PATCH] fix positioning --- modules/bar/Battery.qml | 66 +++++++++++++++++------------------ modules/bar/PowerProfiles.qml | 2 +- modules/bar/Volume.qml | 3 ++ 3 files changed, 37 insertions(+), 34 deletions(-) diff --git a/modules/bar/Battery.qml b/modules/bar/Battery.qml index f46f672..17a5ef2 100644 --- a/modules/bar/Battery.qml +++ b/modules/bar/Battery.qml @@ -1,18 +1,48 @@ pragma ComponentBehavior: Bound import Quickshell.Services.UPower import QtQuick -import Quickshell.Widgets import "../../" import "../settings/" import QtQuick.Layouts Loader { id: root - visible: UPower.displayDevice.isLaptopBattery + active: UPower.displayDevice.isLaptopBattery width: masterLayout.implicitWidth 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 { id: masterLayout + implicitWidth: botText.width spacing: 0 Row { spacing: 5 @@ -25,37 +55,7 @@ Loader { color: Colors.foreground } Icons { - 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"; - } - } - text: getBatteryIcon() + text: root.getBatteryIcon() } } Text { diff --git a/modules/bar/PowerProfiles.qml b/modules/bar/PowerProfiles.qml index eb8e30b..5e03795 100644 --- a/modules/bar/PowerProfiles.qml +++ b/modules/bar/PowerProfiles.qml @@ -6,7 +6,7 @@ import "../../" Item { id: root - implicitWidth: powerLayout.implicitWidth + 10 + implicitWidth: powerLayout.implicitWidth implicitHeight: 34 MouseArea { anchors.fill: parent diff --git a/modules/bar/Volume.qml b/modules/bar/Volume.qml index f710cb6..5dd5866 100644 --- a/modules/bar/Volume.qml +++ b/modules/bar/Volume.qml @@ -53,9 +53,11 @@ Loader { id: styleLayout anchors.centerIn: parent spacing: 0 + implicitWidth: topText.width + icon.width Row { spacing: 2 Text { + id: topText PwObjectTracker { objects: Pipewire.ready ? root.sink : [] } @@ -66,6 +68,7 @@ Loader { text: Pipewire.ready ? Math.round(root.sink.audio.volume * 100) + "%" : "0%" } Icons { + id: icon text: root.getVolumeIcon() } }