mirror of
https://github.com/kavishdevar/librepods.git
synced 2026-04-28 00:56:07 +00:00
[Linux] Fix UI not working (#137)
* Move mac adress to deviceinfo * Missing changes
This commit is contained in:
@@ -94,46 +94,46 @@ ApplicationWindow {
|
|||||||
spacing: 8
|
spacing: 8
|
||||||
|
|
||||||
PodColumn {
|
PodColumn {
|
||||||
isVisible: airPodsTrayApp.battery.leftPodAvailable
|
isVisible: airPodsTrayApp.deviceInfo.battery.leftPodAvailable
|
||||||
inEar: airPodsTrayApp.leftPodInEar
|
inEar: airPodsTrayApp.deviceInfo.leftPodInEar
|
||||||
iconSource: "qrc:/icons/assets/" + airPodsTrayApp.podIcon
|
iconSource: "qrc:/icons/assets/" + airPodsTrayApp.deviceInfo.podIcon
|
||||||
batteryLevel: airPodsTrayApp.battery.leftPodLevel
|
batteryLevel: airPodsTrayApp.deviceInfo.battery.leftPodLevel
|
||||||
isCharging: airPodsTrayApp.battery.leftPodCharging
|
isCharging: airPodsTrayApp.deviceInfo.battery.leftPodCharging
|
||||||
indicator: "L"
|
indicator: "L"
|
||||||
}
|
}
|
||||||
|
|
||||||
PodColumn {
|
PodColumn {
|
||||||
isVisible: airPodsTrayApp.battery.rightPodAvailable
|
isVisible: airPodsTrayApp.deviceInfo.battery.rightPodAvailable
|
||||||
inEar: airPodsTrayApp.rightPodInEar
|
inEar: airPodsTrayApp.deviceInfo.rightPodInEar
|
||||||
iconSource: "qrc:/icons/assets/" + airPodsTrayApp.podIcon
|
iconSource: "qrc:/icons/assets/" + airPodsTrayApp.deviceInfo.podIcon
|
||||||
batteryLevel: airPodsTrayApp.battery.rightPodLevel
|
batteryLevel: airPodsTrayApp.deviceInfo.battery.rightPodLevel
|
||||||
isCharging: airPodsTrayApp.battery.rightPodCharging
|
isCharging: airPodsTrayApp.deviceInfo.battery.rightPodCharging
|
||||||
indicator: "R"
|
indicator: "R"
|
||||||
}
|
}
|
||||||
|
|
||||||
PodColumn {
|
PodColumn {
|
||||||
isVisible: airPodsTrayApp.battery.caseAvailable
|
isVisible: airPodsTrayApp.deviceInfo.battery.caseAvailable
|
||||||
inEar: true
|
inEar: true
|
||||||
iconSource: "qrc:/icons/assets/" + airPodsTrayApp.caseIcon
|
iconSource: "qrc:/icons/assets/" + airPodsTrayApp.deviceInfo.caseIcon
|
||||||
batteryLevel: airPodsTrayApp.battery.caseLevel
|
batteryLevel: airPodsTrayApp.deviceInfo.battery.caseLevel
|
||||||
isCharging: airPodsTrayApp.battery.caseCharging
|
isCharging: airPodsTrayApp.deviceInfo.battery.caseCharging
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SegmentedControl {
|
SegmentedControl {
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
model: ["Off", "Noise Cancellation", "Transparency", "Adaptive"]
|
model: ["Off", "Noise Cancellation", "Transparency", "Adaptive"]
|
||||||
currentIndex: airPodsTrayApp.noiseControlMode
|
currentIndex: airPodsTrayApp.deviceInfo.noiseControlMode
|
||||||
onCurrentIndexChanged: airPodsTrayApp.noiseControlMode = currentIndex
|
onCurrentIndexChanged: airPodsTrayApp.setNoiseControlModeInt(currentIndex)
|
||||||
visible: airPodsTrayApp.airpodsConnected
|
visible: airPodsTrayApp.airpodsConnected
|
||||||
}
|
}
|
||||||
|
|
||||||
Slider {
|
Slider {
|
||||||
visible: airPodsTrayApp.adaptiveModeActive
|
visible: airPodsTrayApp.deviceInfo.adaptiveModeActive
|
||||||
from: 0
|
from: 0
|
||||||
to: 100
|
to: 100
|
||||||
stepSize: 1
|
stepSize: 1
|
||||||
value: airPodsTrayApp.adaptiveNoiseLevel
|
value: airPodsTrayApp.deviceInfo.adaptiveNoiseLevel
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
id: debounceTimer
|
id: debounceTimer
|
||||||
@@ -153,8 +153,8 @@ ApplicationWindow {
|
|||||||
Switch {
|
Switch {
|
||||||
visible: airPodsTrayApp.airpodsConnected
|
visible: airPodsTrayApp.airpodsConnected
|
||||||
text: "Conversational Awareness"
|
text: "Conversational Awareness"
|
||||||
checked: airPodsTrayApp.conversationalAwareness
|
checked: airPodsTrayApp.deviceInfo.conversationalAwareness
|
||||||
onCheckedChanged: airPodsTrayApp.conversationalAwareness = checked
|
onCheckedChanged: airPodsTrayApp.setConversationalAwareness(checked)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,8 +229,8 @@ ApplicationWindow {
|
|||||||
Switch {
|
Switch {
|
||||||
visible: airPodsTrayApp.airpodsConnected
|
visible: airPodsTrayApp.airpodsConnected
|
||||||
text: "One Bud ANC Mode"
|
text: "One Bud ANC Mode"
|
||||||
checked: airPodsTrayApp.oneBudANCMode
|
checked: airPodsTrayApp.deviceInfo.oneBudANCMode
|
||||||
onCheckedChanged: airPodsTrayApp.oneBudANCMode = checked
|
onCheckedChanged: airPodsTrayApp.deviceInfo.oneBudANCMode = checked
|
||||||
|
|
||||||
ToolTip {
|
ToolTip {
|
||||||
visible: parent.hovered
|
visible: parent.hovered
|
||||||
@@ -259,13 +259,13 @@ ApplicationWindow {
|
|||||||
|
|
||||||
TextField {
|
TextField {
|
||||||
id: newNameField
|
id: newNameField
|
||||||
placeholderText: airPodsTrayApp.deviceName
|
placeholderText: airPodsTrayApp.deviceInfo.deviceName
|
||||||
maximumLength: 32
|
maximumLength: 32
|
||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
text: "Rename"
|
text: "Rename"
|
||||||
onClicked: airPodsTrayApp.renameAirPods(newNameField.text)
|
onClicked: airPodsTrayApp.deviceInfo.renameAirPods(newNameField.text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
|
#include <QSettings>
|
||||||
#include "battery.hpp"
|
#include "battery.hpp"
|
||||||
#include "enums.h"
|
#include "enums.h"
|
||||||
|
|
||||||
@@ -26,6 +27,7 @@ class DeviceInfo : public QObject
|
|||||||
Q_PROPERTY(QString caseIcon READ caseIcon NOTIFY modelChanged)
|
Q_PROPERTY(QString caseIcon READ caseIcon NOTIFY modelChanged)
|
||||||
Q_PROPERTY(bool leftPodInEar READ isLeftPodInEar NOTIFY primaryChanged)
|
Q_PROPERTY(bool leftPodInEar READ isLeftPodInEar NOTIFY primaryChanged)
|
||||||
Q_PROPERTY(bool rightPodInEar READ isRightPodInEar NOTIFY primaryChanged)
|
Q_PROPERTY(bool rightPodInEar READ isRightPodInEar NOTIFY primaryChanged)
|
||||||
|
Q_PROPERTY(QString bluetoothAddress READ bluetoothAddress WRITE setBluetoothAddress NOTIFY bluetoothAddressChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DeviceInfo(QObject *parent = nullptr) : QObject(parent), m_battery(new Battery(this)) {}
|
explicit DeviceInfo(QObject *parent = nullptr) : QObject(parent), m_battery(new Battery(this)) {}
|
||||||
@@ -147,6 +149,16 @@ public:
|
|||||||
QString manufacturer() const { return m_manufacturer; }
|
QString manufacturer() const { return m_manufacturer; }
|
||||||
void setManufacturer(const QString &manufacturer) { m_manufacturer = manufacturer; }
|
void setManufacturer(const QString &manufacturer) { m_manufacturer = manufacturer; }
|
||||||
|
|
||||||
|
QString bluetoothAddress() const { return m_bluetoothAddress; }
|
||||||
|
void setBluetoothAddress(const QString &address)
|
||||||
|
{
|
||||||
|
if (m_bluetoothAddress != address)
|
||||||
|
{
|
||||||
|
m_bluetoothAddress = address;
|
||||||
|
emit bluetoothAddressChanged(address);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString podIcon() const { return getModelIcon(model()).first; }
|
QString podIcon() const { return getModelIcon(model()).first; }
|
||||||
QString caseIcon() const { return getModelIcon(model()).second; }
|
QString caseIcon() const { return getModelIcon(model()).second; }
|
||||||
bool isLeftPodInEar() const
|
bool isLeftPodInEar() const
|
||||||
@@ -174,6 +186,29 @@ public:
|
|||||||
setPrimaryInEar(false);
|
setPrimaryInEar(false);
|
||||||
setSecondaryInEar(false);
|
setSecondaryInEar(false);
|
||||||
setNoiseControlMode(NoiseControlMode::Off);
|
setNoiseControlMode(NoiseControlMode::Off);
|
||||||
|
setBluetoothAddress("");
|
||||||
|
}
|
||||||
|
|
||||||
|
void save() const
|
||||||
|
{
|
||||||
|
QSettings settings("AirpodsTrayApp", "DeviceInfo");
|
||||||
|
settings.beginGroup("DeviceInfo");
|
||||||
|
settings.setValue("deviceName", m_deviceName);
|
||||||
|
settings.setValue("bluetoothAddress", m_bluetoothAddress);
|
||||||
|
settings.setValue("magicAccIRK", m_magicAccIRK.toBase64());
|
||||||
|
settings.setValue("magicAccEncKey", m_magicAccEncKey.toBase64());
|
||||||
|
settings.endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void load()
|
||||||
|
{
|
||||||
|
QSettings settings("AirpodsTrayApp", "DeviceInfo");
|
||||||
|
settings.beginGroup("DeviceInfo");
|
||||||
|
setDeviceName(settings.value("deviceName", "").toString());
|
||||||
|
setBluetoothAddress(settings.value("bluetoothAddress", "").toString());
|
||||||
|
setMagicAccIRK(QByteArray::fromBase64(settings.value("magicAccIRK", "").toByteArray()));
|
||||||
|
setMagicAccEncKey(QByteArray::fromBase64(settings.value("magicAccEncKey", "").toByteArray()));
|
||||||
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@@ -187,6 +222,7 @@ signals:
|
|||||||
void primaryChanged();
|
void primaryChanged();
|
||||||
void oneBudANCModeChanged(bool enabled);
|
void oneBudANCModeChanged(bool enabled);
|
||||||
void modelChanged();
|
void modelChanged();
|
||||||
|
void bluetoothAddressChanged(const QString &address);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_batteryStatus;
|
QString m_batteryStatus;
|
||||||
@@ -202,8 +238,7 @@ private:
|
|||||||
QByteArray m_magicAccEncKey;
|
QByteArray m_magicAccEncKey;
|
||||||
bool m_oneBudANCMode = false;
|
bool m_oneBudANCMode = false;
|
||||||
AirPodsModel m_model = AirPodsModel::Unknown;
|
AirPodsModel m_model = AirPodsModel::Unknown;
|
||||||
|
|
||||||
// Additional metadata fields
|
|
||||||
QString m_modelNumber;
|
QString m_modelNumber;
|
||||||
QString m_manufacturer;
|
QString m_manufacturer;
|
||||||
|
QString m_bluetoothAddress;
|
||||||
};
|
};
|
||||||
@@ -389,11 +389,11 @@ private slots:
|
|||||||
|
|
||||||
void bluezDeviceDisconnected(const QString &address, const QString &name)
|
void bluezDeviceDisconnected(const QString &address, const QString &name)
|
||||||
{
|
{
|
||||||
if (address == connectedDeviceMacAddress.replace("_", ":"))
|
if (address == m_deviceInfo->bluetoothAddress())
|
||||||
{
|
{
|
||||||
onDeviceDisconnected(QBluetoothAddress(address)); }
|
onDeviceDisconnected(QBluetoothAddress(address));
|
||||||
else {
|
} else {
|
||||||
LOG_WARN("Disconnected device does not match connected device: " << address << " != " << connectedDeviceMacAddress);
|
LOG_WARN("Disconnected device does not match connected device: " << address << " != " << m_deviceInfo->bluetoothAddress());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -512,7 +512,7 @@ private slots:
|
|||||||
this, handleError);
|
this, handleError);
|
||||||
|
|
||||||
localSocket->connectToService(device.address(), QBluetoothUuid("74ec2172-0bad-4d01-8f77-997b2be0722a"));
|
localSocket->connectToService(device.address(), QBluetoothUuid("74ec2172-0bad-4d01-8f77-997b2be0722a"));
|
||||||
connectedDeviceMacAddress = device.address().toString().replace(":", "_");
|
m_deviceInfo->setBluetoothAddress(device.address().toString());
|
||||||
notifyAndroidDevice();
|
notifyAndroidDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -599,7 +599,7 @@ private slots:
|
|||||||
{
|
{
|
||||||
parseMetadata(data);
|
parseMetadata(data);
|
||||||
initiateMagicPairing();
|
initiateMagicPairing();
|
||||||
mediaController->setConnectedDeviceMacAddress(connectedDeviceMacAddress);
|
mediaController->setConnectedDeviceMacAddress(m_deviceInfo->bluetoothAddress().replace(":", "_"));
|
||||||
if (m_deviceInfo->oneOrMorePodsInEar()) // AirPods get added as output device only after this
|
if (m_deviceInfo->oneOrMorePodsInEar()) // AirPods get added as output device only after this
|
||||||
{
|
{
|
||||||
mediaController->activateA2dpProfile();
|
mediaController->activateA2dpProfile();
|
||||||
@@ -708,7 +708,7 @@ private slots:
|
|||||||
socket->close();
|
socket->close();
|
||||||
LOG_INFO("Disconnected from AirPods");
|
LOG_INFO("Disconnected from AirPods");
|
||||||
QProcess process;
|
QProcess process;
|
||||||
process.start("bluetoothctl", QStringList() << "disconnect" << connectedDeviceMacAddress.replace("_", ":"));
|
process.start("bluetoothctl", QStringList() << "disconnect" << m_deviceInfo->bluetoothAddress());
|
||||||
process.waitForFinished();
|
process.waitForFinished();
|
||||||
QString output = process.readAllStandardOutput().trimmed();
|
QString output = process.readAllStandardOutput().trimmed();
|
||||||
LOG_INFO("Bluetoothctl output: " << output);
|
LOG_INFO("Bluetoothctl output: " << output);
|
||||||
@@ -770,13 +770,13 @@ public:
|
|||||||
if (force) {
|
if (force) {
|
||||||
LOG_INFO("Forcing connection to AirPods");
|
LOG_INFO("Forcing connection to AirPods");
|
||||||
QProcess process;
|
QProcess process;
|
||||||
process.start("bluetoothctl", QStringList() << "connect" << connectedDeviceMacAddress.replace("_", ":"));
|
process.start("bluetoothctl", QStringList() << "connect" << m_deviceInfo->bluetoothAddress());
|
||||||
process.waitForFinished();
|
process.waitForFinished();
|
||||||
QString output = process.readAllStandardOutput().trimmed();
|
QString output = process.readAllStandardOutput().trimmed();
|
||||||
LOG_INFO("Bluetoothctl output: " << output);
|
LOG_INFO("Bluetoothctl output: " << output);
|
||||||
if (output.contains("Connection successful")) {
|
if (output.contains("Connection successful")) {
|
||||||
LOG_INFO("Connection successful, proceeding with L2CAP connection");
|
LOG_INFO("Connection successful, proceeding with L2CAP connection");
|
||||||
QBluetoothAddress btAddress(connectedDeviceMacAddress.replace("_", ":"));
|
QBluetoothAddress btAddress(m_deviceInfo->bluetoothAddress());
|
||||||
forceL2capConnection(btAddress);
|
forceL2capConnection(btAddress);
|
||||||
} else {
|
} else {
|
||||||
LOG_ERROR("Connection failed, cannot proceed with L2CAP connection");
|
LOG_ERROR("Connection failed, cannot proceed with L2CAP connection");
|
||||||
@@ -847,7 +847,6 @@ signals:
|
|||||||
private:
|
private:
|
||||||
QBluetoothSocket *socket = nullptr;
|
QBluetoothSocket *socket = nullptr;
|
||||||
QBluetoothSocket *phoneSocket = nullptr;
|
QBluetoothSocket *phoneSocket = nullptr;
|
||||||
QString connectedDeviceMacAddress;
|
|
||||||
QByteArray lastBatteryStatus;
|
QByteArray lastBatteryStatus;
|
||||||
QByteArray lastEarDetectionStatus;
|
QByteArray lastEarDetectionStatus;
|
||||||
MediaController* mediaController;
|
MediaController* mediaController;
|
||||||
|
|||||||
Reference in New Issue
Block a user