Reset GUI when airpods disconnect, show notification

This commit is contained in:
Tim Gromeyer
2025-04-15 19:55:40 +02:00
parent ecab6a9858
commit c94295ae1c
5 changed files with 63 additions and 7 deletions

View File

@@ -27,6 +27,11 @@ TrayIconManager::TrayIconManager(QObject *parent) : QObject(parent)
trayIcon->show();
}
void TrayIconManager::showNotification(const QString &title, const QString &message)
{
trayIcon->showMessage(title, message, QSystemTrayIcon::Information, 3000);
}
void TrayIconManager::TrayIconManager::updateBatteryStatus(const QString &status)
{
trayIcon->setToolTip("Battery Status: " + status);
@@ -83,10 +88,20 @@ void TrayIconManager::setupMenuActions()
void TrayIconManager::updateIconFromBattery(const QString &status)
{
QStringList parts = status.split(", ");
int leftLevel = parts[0].split(": ")[1].replace("%", "").toInt();
int rightLevel = parts[1].split(": ")[1].replace("%", "").toInt();
int leftLevel = 0;
int rightLevel = 0;
if (!status.isEmpty())
{
// Parse the battery status string
QStringList parts = status.split(", ");
if (parts.size() >= 2)
{
leftLevel = parts[0].split(": ")[1].replace("%", "").toInt();
rightLevel = parts[1].split(": ")[1].replace("%", "").toInt();
}
}
int minLevel = (leftLevel == 0) ? rightLevel : (rightLevel == 0) ? leftLevel
: qMin(leftLevel, rightLevel);