[Linux] Allow setting ear detection behaviour

This commit is contained in:
Tim Gromeyer
2025-04-18 18:03:43 +02:00
committed by Tim Gromeyer
parent c2db0afdf1
commit 0846c3eb48
3 changed files with 92 additions and 40 deletions

View File

@@ -6,14 +6,28 @@
class QProcess;
class MediaController : public QObject {
class MediaController : public QObject
{
Q_OBJECT
public:
enum MediaState { Playing, Paused, Stopped };
enum MediaState
{
Playing,
Paused,
Stopped
};
Q_ENUM(MediaState)
enum EarDetectionBehavior
{
PauseWhenOneRemoved,
PauseWhenBothRemoved,
Disabled
};
Q_ENUM(EarDetectionBehavior)
explicit MediaController(QObject *parent = nullptr);
~MediaController();
void initializeMprisInterface();
void handleEarDetection(const QString &status);
void followMediaChanges();
@@ -23,6 +37,9 @@ public:
void removeAudioOutputDevice();
void setConnectedDeviceMacAddress(const QString &macAddress);
void setEarDetectionBehavior(EarDetectionBehavior behavior);
inline EarDetectionBehavior getEarDetectionBehavior() const { return earDetectionBehavior; }
void pause();
Q_SIGNALS:
@@ -36,6 +53,7 @@ private:
bool wasPausedByApp = false;
int initialVolume = -1;
QString connectedDeviceMacAddress;
EarDetectionBehavior earDetectionBehavior = PauseWhenOneRemoved;
};
#endif // MEDIACONTROLLER_H
#endif // MEDIACONTROLLER_H