From 46d6cab930bb5bc0019ae34f21021f3b9cd0038d Mon Sep 17 00:00:00 2001 From: Tim Gromeyer <58736434+tim-gromeyer@users.noreply.github.com> Date: Sat, 1 Feb 2025 12:47:50 +0100 Subject: [PATCH] [Linux] Show correct battery level when 1 Airpod is disconnected It would show 0 previously --- linux/main.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/linux/main.cpp b/linux/main.cpp index 3b78f8d..e906095 100644 --- a/linux/main.cpp +++ b/linux/main.cpp @@ -339,7 +339,21 @@ public slots: QStringList parts = status.split(", "); int leftLevel = parts[0].split(": ")[1].replace("%", "").toInt(); int rightLevel = parts[1].split(": ")[1].replace("%", "").toInt(); - int minLevel = qMin(leftLevel, rightLevel); + + int minLevel; + if (leftLevel == 0) + { + minLevel = rightLevel; + } + else if (rightLevel == 0) + { + minLevel = leftLevel; + } + else + { + minLevel = qMin(leftLevel, rightLevel); + } + QPixmap pixmap(32, 32); pixmap.fill(Qt::transparent); @@ -952,4 +966,4 @@ int main(int argc, char *argv[]) { } -#include "main.moc" \ No newline at end of file +#include "main.moc"