28
28
m_pOutputDeviceModel(nullptr)
30
30
m_pRingtoneDeviceModel = new RingtoneDeviceModel (this);
31
ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance();
32
connect(&configurationManager,SIGNAL(volumeChanged(QString,double)),this,SLOT(slotVolumeChanged(QString,double)));
166
168
return DBus::ConfigurationManager::instance().isCaptureMuted();
171
///Set where the call recordings will be saved
172
void AudioSettingsModel::setRecordPath(const QUrl& path)
174
ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance();
175
configurationManager.setRecordPath(path.toString());
178
///Return the path where recordings are going to be saved
179
QUrl AudioSettingsModel::recordPath() const
181
ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance();
182
return QUrl(configurationManager.getRecordPath());
185
///are all calls recorded by default
186
bool AudioSettingsModel::isAlwaysRecording() const
188
ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance();
189
return configurationManager.getIsAlwaysRecording();
192
///Set if all calls needs to be recorded
193
void AudioSettingsModel::setAlwaysRecording(bool record)
195
ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance();
196
configurationManager.setIsAlwaysRecording ( record );
169
199
int AudioSettingsModel::playbackVolume() const
171
201
ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance();
204
234
return DBus::ConfigurationManager::instance().isDtmfMuted();
237
///Called when the volume change for external reasons
238
void AudioSettingsModel::slotVolumeChanged(const QString& str, double volume)
240
if (str == AudioSettingsModel::DeviceKey::CAPTURE)
241
emit captureVolumeChanged(static_cast<int>(volume*100));
242
else if (str == AudioSettingsModel::DeviceKey::PLAYBACK)
243
emit playbackVolumeChanged(static_cast<int>(volume*100));
245
qDebug() << "Unknown audio device" << str;
207
249
/****************************************************************
209
251
* AlsaPluginModel *
356
398
ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance();
357
399
const QStringList currentDevices = configurationManager.getCurrentAudioDevicesIndex();
358
const int idx = currentDevices[AudioSettingsModel::DeviceIndex::INPUT].toInt();
400
const int idx = currentDevices[static_cast<int>(AudioSettingsModel::DeviceIndex::INPUT)].toInt();
359
401
if (idx >= m_lDeviceList.size())
360
402
return QModelIndex();
361
403
return index(idx,0);
447
489
ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance();
448
490
const QStringList currentDevices = configurationManager.getCurrentAudioDevicesIndex();
449
const int idx = currentDevices[AudioSettingsModel::DeviceIndex::OUTPUT].toInt();
491
const int idx = currentDevices[static_cast<int>(AudioSettingsModel::DeviceIndex::OUTPUT)].toInt();
451
493
if (idx >= m_lDeviceList.size())
452
494
return QModelIndex();
487
529
AudioManagerModel::AudioManagerModel(QObject* parent) : QAbstractListModel(parent)
489
m_lDeviceList << "ALSA" << "Pulse Audio";
531
ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance();
532
const QStringList managers = configurationManager.getSupportedAudioManagers();
533
foreach(const QString& m,managers) {
534
if (m == ManagerName::PULSEAUDIO) {
535
m_lSupportedManagers << Manager::PULSE;
536
m_lDeviceList << "Pulse Audio";
538
else if (m == ManagerName::ALSA) {
539
m_lSupportedManagers << Manager::ALSA;
540
m_lDeviceList<< "ALSA";
542
else if (m == ManagerName::JACK) {
543
m_lSupportedManagers << Manager::JACK;
544
m_lDeviceList<< "Jack";
547
qDebug() << "Unsupported audio manager" << m;
535
594
* Return the current audio manager
536
595
* @warning Changes to the current index model will invalid Input/Output/Ringtone devices models
538
QModelIndex AudioManagerModel::currentManager() const
597
QModelIndex AudioManagerModel::currentManagerIndex() const
540
599
ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance();
541
600
const QString manager = configurationManager.getAudioManager();
543
602
return index((int)Manager::PULSE,0);
544
603
else if (manager == ManagerName::ALSA)
545
604
return index((int)Manager::ALSA,0);
605
else if (manager == ManagerName::JACK)
606
return index((int)Manager::JACK,0);
546
607
return QModelIndex();
610
AudioManagerModel::Manager AudioManagerModel::currentManager() const
612
return m_lSupportedManagers[currentManagerIndex().row()];
549
615
///Set current audio manager
550
void AudioManagerModel::setCurrentManager(const QModelIndex& idx)
616
bool AudioManagerModel::setCurrentManager(const QModelIndex& idx)
552
618
if (!idx.isValid())
555
622
ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance();
556
switch (static_cast<Manager>(idx.row())) {
623
switch (m_lSupportedManagers[idx.row()]) {
557
624
case Manager::PULSE:
558
configurationManager.setAudioManager(ManagerName::PULSEAUDIO);
625
ret = configurationManager.setAudioManager(ManagerName::PULSEAUDIO);
559
626
AudioSettingsModel::instance()->reload();
561
628
case Manager::ALSA:
562
configurationManager.setAudioManager(ManagerName::ALSA);
629
ret = configurationManager.setAudioManager(ManagerName::ALSA);
630
AudioSettingsModel::instance()->reload();
633
ret = configurationManager.setAudioManager(ManagerName::JACK);
563
634
AudioSettingsModel::instance()->reload();
638
const QModelIndex& newIdx = currentManagerIndex();
639
emit currentManagerChanged(currentManager());
640
emit currentManagerChanged(newIdx);
641
emit currentManagerChanged(newIdx.row());
568
646
///QCombobox -> QModelIndex shim
569
void AudioManagerModel::setCurrentManager(int idx)
647
bool AudioManagerModel::setCurrentManager(int idx)
571
setCurrentManager(index(idx,0));
649
return setCurrentManager(index(idx,0));
574
652
/****************************************************************
632
710
ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance();
633
711
const QStringList currentDevices = configurationManager.getCurrentAudioDevicesIndex();
634
const int idx = currentDevices[AudioSettingsModel::DeviceIndex::RINGTONE].toInt();
712
const int idx = currentDevices[static_cast<int>(AudioSettingsModel::DeviceIndex::RINGTONE)].toInt();
635
713
if (idx >= m_lDeviceList.size())
636
714
return QModelIndex();
637
715
return index(idx,0);