[Linux] Add cross device setting

This commit is contained in:
Tim Gromeyer
2025-04-19 10:56:13 +02:00
committed by Tim Gromeyer
parent 816992fd8a
commit 1c7bdf987c
2 changed files with 52 additions and 25 deletions

View File

@@ -30,6 +30,7 @@ class AirPodsTrayApp : public QObject {
Q_PROPERTY(bool rightPodInEar READ isRightPodInEar NOTIFY primaryChanged)
Q_PROPERTY(bool airpodsConnected READ areAirpodsConnected NOTIFY airPodsStatusChanged)
Q_PROPERTY(int earDetectionBehavior READ earDetectionBehavior WRITE setEarDetectionBehavior NOTIFY earDetectionBehaviorChanged)
Q_PROPERTY(bool crossDeviceEnabled READ crossDeviceEnabled WRITE setCrossDeviceEnabled NOTIFY crossDeviceEnabledChanged)
public:
AirPodsTrayApp(bool debugMode)
@@ -270,6 +271,20 @@ public slots:
emit earDetectionBehaviorChanged(behavior);
}
void setCrossDeviceEnabled(bool enabled)
{
if (CrossDevice.isEnabled == enabled)
{
LOG_INFO("Cross-device feature is already " << (enabled ? "enabled" : "disabled"));
return;
}
CrossDevice.isEnabled = enabled;
saveCrossDeviceEnabled();
connectToPhone();
emit crossDeviceEnabledChanged(enabled);
}
bool writePacketToSocket(const QByteArray &packet, const QString &logMessage)
{
if (socket && socket->isOpen())
@@ -578,10 +593,8 @@ private slots:
{
char primary = data[6];
char secondary = data[7];
m_primaryInEar = primary == 0x00;
m_secoundaryInEar = secondary == 0x00;
m_primaryInEar = primary == 0x00;
m_secoundaryInEar = secondary == 0x00;
m_primaryInEar = data[6] == 0x00;
m_secoundaryInEar = data[7] == 0x00;
m_earDetectionStatus = QString("Primary: %1, Secondary: %2")
.arg(getEarStatus(primary), getEarStatus(secondary));
LOG_INFO("Ear detection status: " << m_earDetectionStatus);