2022-05-12 17:35:50 +08:00
|
|
|
#ifndef VOLUMNMODEL_H
|
|
|
|
#define VOLUMNMODEL_H
|
|
|
|
|
2022-09-16 20:12:52 +00:00
|
|
|
#include "org_deepin_daemon_audio.h"
|
|
|
|
#include "org_deepin_daemon_audio_sink.h"
|
2022-05-12 17:35:50 +08:00
|
|
|
|
2022-09-16 20:12:52 +00:00
|
|
|
#include <QObject>
|
2022-05-17 20:57:09 +08:00
|
|
|
|
2022-09-16 20:12:52 +00:00
|
|
|
using DBusAudio = org::deepin::daemon::Audio1;
|
|
|
|
using DBusSink = org::deepin::daemon::audio1::Sink;
|
2022-05-17 20:57:09 +08:00
|
|
|
|
2022-05-12 17:35:50 +08:00
|
|
|
class QDBusMessage;
|
|
|
|
class AudioSink;
|
|
|
|
class AudioPorts;
|
|
|
|
|
|
|
|
class VolumeModel : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit VolumeModel(QObject *parent);
|
|
|
|
~VolumeModel();
|
|
|
|
|
|
|
|
void setActivePort(AudioPorts *port);
|
|
|
|
|
|
|
|
QList<AudioSink *> sinks() const;
|
|
|
|
QList<AudioPorts *> ports() const;
|
|
|
|
|
|
|
|
AudioSink *defaultSink() const;
|
|
|
|
|
|
|
|
void setVolume(int volume);
|
|
|
|
void setMute(bool value);
|
|
|
|
|
|
|
|
int volume();
|
|
|
|
bool isMute();
|
|
|
|
bool existActiveOutputDevice();
|
|
|
|
|
2022-05-17 20:57:09 +08:00
|
|
|
Q_SIGNALS:
|
|
|
|
void defaultSinkChanged(AudioSink *);
|
|
|
|
void volumeChanged(int);
|
|
|
|
void muteChanged(bool);
|
|
|
|
void checkPortChanged();
|
|
|
|
|
2022-05-12 17:35:50 +08:00
|
|
|
private Q_SLOTS:
|
2022-05-17 20:57:09 +08:00
|
|
|
void onDefaultSinkChanged(const QDBusObjectPath & value);
|
2022-05-12 17:35:50 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
void reloadSinks();
|
|
|
|
void reloadPorts();
|
|
|
|
void clearSinks();
|
|
|
|
void clearPorts();
|
|
|
|
|
|
|
|
private:
|
|
|
|
QList<AudioSink *> m_sinks;
|
|
|
|
QList<AudioPorts *> m_ports;
|
2022-05-17 20:57:09 +08:00
|
|
|
|
|
|
|
DBusAudio *m_audio;
|
2022-05-12 17:35:50 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class AudioSink : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
friend class VolumeModel;
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void volumeChanged(int);
|
|
|
|
void muteChanged(bool);
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool isDefault();
|
|
|
|
bool isHeadPhone();
|
|
|
|
|
|
|
|
void setBalance(double value, bool isPlay);
|
|
|
|
void setFade(double value);
|
|
|
|
void setMute(bool mute);
|
|
|
|
void setPort(QString name);
|
2022-05-17 20:57:09 +08:00
|
|
|
void setVolume(int value, bool isPlay);
|
2022-05-12 17:35:50 +08:00
|
|
|
|
|
|
|
bool isMute();
|
|
|
|
bool supportBalance();
|
|
|
|
bool suoportFade();
|
|
|
|
double balance();
|
|
|
|
double baseVolume();
|
|
|
|
double fade();
|
|
|
|
int volume();
|
|
|
|
QString description();
|
|
|
|
QString name();
|
2022-05-17 20:57:09 +08:00
|
|
|
uint cardId();
|
2022-05-12 17:35:50 +08:00
|
|
|
|
|
|
|
protected:
|
2022-05-17 20:57:09 +08:00
|
|
|
explicit AudioSink(QString path, bool isDefault, QObject *parent = nullptr);
|
2022-05-12 17:35:50 +08:00
|
|
|
~AudioSink();
|
2022-05-17 20:57:09 +08:00
|
|
|
void setDefault(bool isDefaultSink);
|
2022-05-12 17:35:50 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
QString m_devicePath;
|
2022-05-17 20:57:09 +08:00
|
|
|
DBusSink *m_sink;
|
|
|
|
bool m_isDefault;
|
2022-05-12 17:35:50 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class AudioPorts : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
friend class VolumeModel;
|
|
|
|
|
|
|
|
public:
|
2022-05-17 20:57:09 +08:00
|
|
|
uint cardId() const;
|
2022-05-12 17:35:50 +08:00
|
|
|
QString cardName() const;
|
|
|
|
QString name() const;
|
|
|
|
QString description() const;
|
|
|
|
int direction() const;
|
|
|
|
bool isChecked() const;
|
|
|
|
bool isHeadPhone() const;
|
|
|
|
|
|
|
|
protected:
|
2022-05-17 20:57:09 +08:00
|
|
|
AudioPorts(uint cardId, QString cardName);
|
2022-05-12 17:35:50 +08:00
|
|
|
~AudioPorts();
|
|
|
|
void setName(const QString &name);
|
|
|
|
void setDescription(const QString &desc);
|
|
|
|
void setDirection(int dir);
|
|
|
|
void setIsChecked(bool isChecked);
|
|
|
|
|
|
|
|
private:
|
2022-05-17 20:57:09 +08:00
|
|
|
uint m_cardId;
|
2022-05-12 17:35:50 +08:00
|
|
|
QString m_cardName;
|
|
|
|
QString m_portName;
|
|
|
|
QString m_description;
|
|
|
|
int m_direction;
|
|
|
|
bool m_isCheck;
|
|
|
|
bool m_isHeadPhone;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VOLUMNMODEL_H
|