Add connection state

This commit is contained in:
Tim Gromeyer
2025-03-23 21:49:27 +01:00
parent cb625d0889
commit 06f7b6bdb8
4 changed files with 49 additions and 0 deletions

View File

@@ -128,6 +128,11 @@ BleScanner::BleScanner(QWidget *parent) : QMainWindow(parent)
bothPodsInCaseLabel = new QLabel(this);
detailsLayout->addWidget(bothPodsInCaseLabel, 14, 1);
// Row 15: Connection State
detailsLayout->addWidget(new QLabel("Connection State:"), 15, 0);
connectionStateLabel = new QLabel(this);
detailsLayout->addWidget(connectionStateLabel, 15, 1);
mainLayout->addWidget(detailsGroup);
detailsGroup->setVisible(false);
@@ -302,6 +307,7 @@ void BleScanner::onDeviceSelected()
thisPodInCaseLabel->setText(device.isThisPodInTheCase ? "Yes" : "No");
onePodInCaseLabel->setText(device.isOnePodInCase ? "Yes" : "No");
bothPodsInCaseLabel->setText(device.areBothPodsInCase ? "Yes" : "No");
connectionStateLabel->setText(getConnectionStateName(device.connectionState));
detailsGroup->setVisible(true);
}
@@ -368,4 +374,27 @@ QString BleScanner::getColorName(quint8 colorId)
default:
return "Unknown";
}
}
QString BleScanner::getConnectionStateName(DeviceInfo::ConnectionState state)
{
using ConnectionState = DeviceInfo::ConnectionState;
switch (state)
{
case ConnectionState::DISCONNECTED:
return QString("Disconnected");
case ConnectionState::IDLE:
return QString("Idle");
case ConnectionState::MUSIC:
return QString("Playing Music");
case ConnectionState::CALL:
return QString("On Call");
case ConnectionState::RINGING:
return QString("Ringing");
case ConnectionState::HANGING_UP:
return QString("Hanging Up");
case ConnectionState::UNKNOWN:
default:
return QString("Unknown");
}
}