From db98f2cd86e01ddf1c582adf936a2f6a7d01da70 Mon Sep 17 00:00:00 2001 From: Micah Stanley Date: Fri, 6 Mar 2026 01:13:34 +0000 Subject: [PATCH] statusbar: fix hidden batteries from taking up space in the statusbar I noticed at some point after updating my main phone, that non visible external device batteries started taking up extra space in the statusbar. This fixes the issue by filtering out external device batteries by using KSortFilterProxyModel. Before (with external peripheral connected) ![Screenshot_20260303_124043](/uploads/a469eda41ff6d2a10b85c6a3de88785f/Screenshot_20260303_124043.png){width=399 height=28} After ![Screenshot_20260303_123956](/uploads/521a7dc7bb16cf08ef026c3ef0655b93/Screenshot_20260303_123956.png){width=399 height=28} --- components/mobileshell/CMakeLists.txt | 1 + .../qml/statusbar/indicators/BatteryIndicator.qml | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/components/mobileshell/CMakeLists.txt b/components/mobileshell/CMakeLists.txt index e60c45c8..c66c2ad6 100644 --- a/components/mobileshell/CMakeLists.txt +++ b/components/mobileshell/CMakeLists.txt @@ -162,6 +162,7 @@ target_link_libraries(mobileshellplugin KF6::Service KF6::Package KF6::ConfigGui + KF6::ItemModels LayerShellQt::Interface ) diff --git a/components/mobileshell/qml/statusbar/indicators/BatteryIndicator.qml b/components/mobileshell/qml/statusbar/indicators/BatteryIndicator.qml index 5eaa6517..fb26fdbb 100644 --- a/components/mobileshell/qml/statusbar/indicators/BatteryIndicator.qml +++ b/components/mobileshell/qml/statusbar/indicators/BatteryIndicator.qml @@ -10,6 +10,7 @@ import QtQuick 2.6 import QtQuick.Layouts 1.4 import org.kde.kirigami 2.20 as Kirigami +import org.kde.kitemmodels import org.kde.plasma.components 3.0 as PlasmaComponents import org.kde.plasma.workspace.components 2.0 as PW @@ -26,7 +27,7 @@ RowLayout { id: batteryRepeater spacing: 0 - model: MobileShell.BatteryInfo.batteries + model: filterModel orientation: ListView.Horizontal Layout.alignment: Qt.AlignVCenter @@ -34,6 +35,14 @@ RowLayout { Layout.fillHeight: true Layout.fillWidth: false + KSortFilterProxyModel { + id: filterModel + sourceModel: MobileShell.BatteryInfo.batteries + + filterRoleName: "Type" + filterString: "Battery" // only show internal batteries + } + delegate: RowLayout { id: batteryBase @@ -42,8 +51,6 @@ RowLayout { height: batteryRepeater.height - visible: Type === "Battery" // only show the internal battery - PW.BatteryIcon { id: battery