Commit 773a8c76 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(ui/views/App/Settings/SettingsAudio): supports devices selection

parent 86eb025c
......@@ -663,6 +663,25 @@ Server url not configured.</translation>
<translation type="vanished">Search contact or enter SIP address</translation>
</message>
</context>
<context>
<name>SettingsAudio</name>
<message>
<source>audioTitle</source>
<translation>Audio parameters</translation>
</message>
<message>
<source>playbackDeviceLabel</source>
<translation>Playback device</translation>
</message>
<message>
<source>captureDeviceLabel</source>
<translation>Capture device</translation>
</message>
<message>
<source>ringerDeviceLabel</source>
<translation>Ringer device</translation>
</message>
</context>
<context>
<name>SettingsCallsChat</name>
<message>
......
......@@ -673,6 +673,25 @@ Url du serveur non configurée.</translation>
<translation type="vanished">Rechercher un contact ou entrer une adresse SIP</translation>
</message>
</context>
<context>
<name>SettingsAudio</name>
<message>
<source>audioTitle</source>
<translation>Paramètres audio</translation>
</message>
<message>
<source>playbackDeviceLabel</source>
<translation>Périphérique d&apos;écoute</translation>
</message>
<message>
<source>captureDeviceLabel</source>
<translation>Périphérique de capture</translation>
</message>
<message>
<source>ringerDeviceLabel</source>
<translation>Périphérique de sonnerie</translation>
</message>
</context>
<context>
<name>SettingsCallsChat</name>
<message>
......
......@@ -38,6 +38,89 @@ SettingsModel::SettingsModel (QObject *parent) : QObject(parent) {
m_config = CoreManager::getInstance()->getCore()->getConfig();
}
// =============================================================================
// Audio.
// =============================================================================
QVariantList SettingsModel::getAudioCodecs () const {
QVariantList list;
for (const auto &codec : CoreManager::getInstance()->getCore()->getAudioCodecs()) {
QVariantMap map;
map["mime"] = ::Utils::linphoneStringToQString(codec->getMimeType());
map["channels"] = codec->getChannels();
map["bitrate"] = codec->getNormalBitrate();
map["type"] = codec->getType();
map["isVbr"] = codec->isVbr();
list << map;
}
return list;
}
void SettingsModel::setAudioCodecs (const QVariantList &codecs) {
// TODO
emit audioCodecsChanged(codecs);
}
// -----------------------------------------------------------------------------
QStringList SettingsModel::getAudioDevices () const {
QStringList list;
for (const auto &device : CoreManager::getInstance()->getCore()->getSoundDevices())
list << ::Utils::linphoneStringToQString(device);
return list;
}
// -----------------------------------------------------------------------------
QString SettingsModel::getCaptureDevice () const {
return ::Utils::linphoneStringToQString(
CoreManager::getInstance()->getCore()->getCaptureDevice()
);
}
void SettingsModel::setCaptureDevice (const QString &device) {
CoreManager::getInstance()->getCore()->setCaptureDevice(
::Utils::qStringToLinphoneString(device)
);
emit captureDeviceChanged(device);
}
// -----------------------------------------------------------------------------
QString SettingsModel::getPlaybackDevice () const {
return ::Utils::linphoneStringToQString(
CoreManager::getInstance()->getCore()->getPlaybackDevice()
);
}
void SettingsModel::setPlaybackDevice (const QString &device) {
CoreManager::getInstance()->getCore()->setPlaybackDevice(
::Utils::qStringToLinphoneString(device)
);
emit playbackDeviceChanged(device);
}
// -----------------------------------------------------------------------------
QString SettingsModel::getRingerDevice () const {
return ::Utils::linphoneStringToQString(
CoreManager::getInstance()->getCore()->getRingerDevice()
);
}
void SettingsModel::setRingerDevice (const QString &device) {
CoreManager::getInstance()->getCore()->setRingerDevice(
::Utils::qStringToLinphoneString(device)
);
emit ringerDeviceChanged(device);
}
// =============================================================================
// Chat & calls.
// =============================================================================
......
......@@ -35,6 +35,16 @@ class SettingsModel : public QObject {
// PROPERTIES.
// ===========================================================================
// Audio. --------------------------------------------------------------------
Q_PROPERTY(QVariantList audioCodecs READ getAudioCodecs WRITE setAudioCodecs NOTIFY audioCodecsChanged);
Q_PROPERTY(QStringList audioDevices READ getAudioDevices CONSTANT);
Q_PROPERTY(QString captureDevice READ getCaptureDevice WRITE setCaptureDevice NOTIFY captureDeviceChanged);
Q_PROPERTY(QString playbackDevice READ getPlaybackDevice WRITE setPlaybackDevice NOTIFY playbackDeviceChanged);
Q_PROPERTY(QString ringerDevice READ getRingerDevice WRITE setRingerDevice NOTIFY ringerDeviceChanged);
// Chat & calls. -------------------------------------------------------------
Q_PROPERTY(bool autoAnswerStatus READ getAutoAnswerStatus WRITE setAutoAnswerStatus NOTIFY autoAnswerStatusChanged);
......@@ -111,6 +121,22 @@ public:
// METHODS.
// ===========================================================================
// Audio. --------------------------------------------------------------------
QVariantList getAudioCodecs () const;
void setAudioCodecs (const QVariantList &codecs);
QStringList getAudioDevices () const;
QString getCaptureDevice () const;
void setCaptureDevice (const QString &device);
QString getPlaybackDevice () const;
void setPlaybackDevice (const QString &device);
QString getRingerDevice () const;
void setRingerDevice (const QString &device);
// Chat & calls. -------------------------------------------------------------
bool getAutoAnswerStatus () const;
......@@ -201,6 +227,14 @@ public:
// ===========================================================================
signals:
// Audio. --------------------------------------------------------------------
void audioCodecsChanged (const QVariantList &codecs);
void captureDeviceChanged (const QString &device);
void playbackDeviceChanged (const QString &device);
void ringerDeviceChanged (const QString &device);
// Chat & calls. -------------------------------------------------------------
void autoAnswerStatusChanged (bool status);
......
import QtQuick 2.7
import Common 1.0
import Linphone 1.0
import Utils 1.0
// =============================================================================
TabContainer {
Form {
title: qsTr('audioTitle')
width: parent.width
FormLine {
FormGroup {
label: qsTr('playbackDeviceLabel')
ComboBox {
model: SettingsModel.audioDevices
Component.onCompleted: currentIndex = Utils.findIndex(model, function (device) {
return device === SettingsModel.playbackDevice
})
onActivated: SettingsModel.playbackDevice = model[index]
}
}
}
FormLine {
FormGroup {
label: qsTr('captureDeviceLabel')
ComboBox {
model: SettingsModel.audioDevices
Component.onCompleted: currentIndex = Utils.findIndex(model, function (device) {
return device === SettingsModel.captureDevice
})
onActivated: SettingsModel.captureDevice = model[index]
}
}
}
FormLine {
FormGroup {
label: qsTr('ringerDeviceLabel')
ComboBox {
model: SettingsModel.audioDevices
Component.onCompleted: currentIndex = Utils.findIndex(model, function (device) {
return device === SettingsModel.ringerDevice
})
onActivated: SettingsModel.ringerDevice = model[index]
}
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment