diff --git a/linux/Main.qml b/linux/Main.qml index 7ed16e0..059a8f0 100644 --- a/linux/Main.qml +++ b/linux/Main.qml @@ -163,18 +163,31 @@ ApplicationWindow { Component { id: settingsPage Item { - // Add your settings page content here - Column { + ScrollView { anchors.fill: parent - spacing: 20 - padding: 20 + contentWidth: parent.width + contentHeight: parent.height - Label { - text: "Settings Page" - anchors.horizontalCenter: parent.horizontalCenter + Column { + spacing: 20 + 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 diff --git a/linux/main.cpp b/linux/main.cpp index aa0900f..67f5d89 100644 --- a/linux/main.cpp +++ b/linux/main.cpp @@ -29,6 +29,7 @@ class AirPodsTrayApp : public QObject { Q_PROPERTY(bool leftPodInEar READ isLeftPodInEar NOTIFY primaryChanged) 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) public: AirPodsTrayApp(bool debugMode) @@ -64,7 +65,9 @@ public: connect(m_battery, &Battery::primaryChanged, this, &AirPodsTrayApp::primaryChanged); + // Load settings CrossDevice.isEnabled = loadCrossDeviceEnabled(); + setEarDetectionBehavior(loadEarDetectionSettings()); monitor->checkAlreadyConnectedDevices(); LOG_INFO("AirPodsTrayApp initialized"); @@ -120,6 +123,8 @@ public: } } 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: 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(behavior)); + saveEarDetectionSettings(); + emit earDetectionBehaviorChanged(behavior); + } + bool writePacketToSocket(const QByteArray &packet, const QString &logMessage) { if (socket && socket->isOpen()) @@ -819,9 +837,10 @@ signals: void modelChanged(); void primaryChanged(); void airPodsStatusChanged(); + void earDetectionBehaviorChanged(int behavior); + void crossDeviceEnabledChanged(bool enabled); -private: - QSystemTrayIcon *trayIcon; + private : QSystemTrayIcon *trayIcon; QMenu *trayMenu; QBluetoothSocket *socket = nullptr; QBluetoothSocket *phoneSocket = nullptr;