mirror of
https://github.com/kavishdevar/librepods.git
synced 2026-02-10 19:52:24 +00:00
[Linux] Add ear detection behavior setting
This commit is contained in:
committed by
Tim Gromeyer
parent
3aeff4d986
commit
816992fd8a
@@ -163,18 +163,31 @@ ApplicationWindow {
|
|||||||
Component {
|
Component {
|
||||||
id: settingsPage
|
id: settingsPage
|
||||||
Item {
|
Item {
|
||||||
// Add your settings page content here
|
ScrollView {
|
||||||
Column {
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
spacing: 20
|
contentWidth: parent.width
|
||||||
padding: 20
|
contentHeight: parent.height
|
||||||
|
|
||||||
Label {
|
Column {
|
||||||
text: "Settings Page"
|
spacing: 20
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
padding: 20
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: "Settings"
|
||||||
|
font.pixelSize: 24
|
||||||
|
// center the label
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
ComboBox {
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
model: ["Pause When One Removed", "Pause When Both Removed", "Never Pause"]
|
||||||
|
currentIndex: airPodsTrayApp.earDetectionBehavior
|
||||||
|
onActivated: {
|
||||||
|
airPodsTrayApp.earDetectionBehavior = currentIndex
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Floating back button
|
// Floating back button
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ class AirPodsTrayApp : public QObject {
|
|||||||
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(bool airpodsConnected READ areAirpodsConnected NOTIFY airPodsStatusChanged)
|
Q_PROPERTY(bool airpodsConnected READ areAirpodsConnected NOTIFY airPodsStatusChanged)
|
||||||
|
Q_PROPERTY(int earDetectionBehavior READ earDetectionBehavior WRITE setEarDetectionBehavior NOTIFY earDetectionBehaviorChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AirPodsTrayApp(bool debugMode)
|
AirPodsTrayApp(bool debugMode)
|
||||||
@@ -64,7 +65,9 @@ public:
|
|||||||
|
|
||||||
connect(m_battery, &Battery::primaryChanged, this, &AirPodsTrayApp::primaryChanged);
|
connect(m_battery, &Battery::primaryChanged, this, &AirPodsTrayApp::primaryChanged);
|
||||||
|
|
||||||
|
// Load settings
|
||||||
CrossDevice.isEnabled = loadCrossDeviceEnabled();
|
CrossDevice.isEnabled = loadCrossDeviceEnabled();
|
||||||
|
setEarDetectionBehavior(loadEarDetectionSettings());
|
||||||
|
|
||||||
monitor->checkAlreadyConnectedDevices();
|
monitor->checkAlreadyConnectedDevices();
|
||||||
LOG_INFO("AirPodsTrayApp initialized");
|
LOG_INFO("AirPodsTrayApp initialized");
|
||||||
@@ -120,6 +123,8 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool areAirpodsConnected() const { return socket && socket->isOpen() && socket->state() == QBluetoothSocket::SocketState::ConnectedState; }
|
bool areAirpodsConnected() const { return socket && socket->isOpen() && socket->state() == QBluetoothSocket::SocketState::ConnectedState; }
|
||||||
|
int earDetectionBehavior() const { return mediaController->getEarDetectionBehavior(); }
|
||||||
|
bool crossDeviceEnabled() const { return CrossDevice.isEnabled; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool debugMode;
|
bool debugMode;
|
||||||
@@ -252,6 +257,19 @@ public slots:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setEarDetectionBehavior(int behavior)
|
||||||
|
{
|
||||||
|
if (behavior == earDetectionBehavior())
|
||||||
|
{
|
||||||
|
LOG_INFO("Ear detection behavior is already set to: " << behavior);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mediaController->setEarDetectionBehavior(static_cast<MediaController::EarDetectionBehavior>(behavior));
|
||||||
|
saveEarDetectionSettings();
|
||||||
|
emit earDetectionBehaviorChanged(behavior);
|
||||||
|
}
|
||||||
|
|
||||||
bool writePacketToSocket(const QByteArray &packet, const QString &logMessage)
|
bool writePacketToSocket(const QByteArray &packet, const QString &logMessage)
|
||||||
{
|
{
|
||||||
if (socket && socket->isOpen())
|
if (socket && socket->isOpen())
|
||||||
@@ -819,9 +837,10 @@ signals:
|
|||||||
void modelChanged();
|
void modelChanged();
|
||||||
void primaryChanged();
|
void primaryChanged();
|
||||||
void airPodsStatusChanged();
|
void airPodsStatusChanged();
|
||||||
|
void earDetectionBehaviorChanged(int behavior);
|
||||||
|
void crossDeviceEnabledChanged(bool enabled);
|
||||||
|
|
||||||
private:
|
private : QSystemTrayIcon *trayIcon;
|
||||||
QSystemTrayIcon *trayIcon;
|
|
||||||
QMenu *trayMenu;
|
QMenu *trayMenu;
|
||||||
QBluetoothSocket *socket = nullptr;
|
QBluetoothSocket *socket = nullptr;
|
||||||
QBluetoothSocket *phoneSocket = nullptr;
|
QBluetoothSocket *phoneSocket = nullptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user