diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 865b1bf0ba9194c6044b7ce71266868a133e0d5f..09a39d121d0bf1d4aed1cec0bd5c67476fc626c8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -66,7 +66,6 @@ set( qtsflphone_LIB_SRCS historymodel.cpp abstractbookmarkmodel.cpp credentialmodel.cpp - audiocodecmodel.cpp instantmessagingmodel.cpp contactproxymodel.cpp useractionmodel.cpp @@ -78,7 +77,6 @@ set( qtsflphone_LIB_SRCS tlsmethodmodel.cpp numbercompletionmodel.cpp categorizedaccountmodel.cpp - audiosettingsmodel.cpp ringtonemodel.cpp lastusednumbermodel.cpp securityvalidationmodel.cpp @@ -91,6 +89,14 @@ set( qtsflphone_LIB_SRCS video/videoresolution.cpp video/videorate.cpp video/videomodel.cpp + audio/alsapluginmodel.cpp + audio/codecmodel.cpp + audio/inputdevicemodel.cpp + audio/managermodel.cpp + audio/outputdevicemodel.cpp + audio/ringtonedevicemodel.cpp + audio/settings.cpp + #Data backends transitionalcontactbackend.cpp @@ -131,7 +137,6 @@ set( qtsflphone_LIB_HDRS abstractitembackend.h abstractbookmarkmodel.h credentialmodel.h - audiocodecmodel.h instantmessagingmodel.h contactproxymodel.h useractionmodel.h @@ -145,7 +150,6 @@ set( qtsflphone_LIB_HDRS numbercompletionmodel.h categorizedaccountmodel.h numbercategory.h - audiosettingsmodel.h ringtonemodel.h lastusednumbermodel.h securityvalidationmodel.h @@ -166,6 +170,14 @@ set( qtsflphone_LIB_HDRS video/videoresolution.h video/videochannel.h video/videorate.h + audio/alsapluginmodel.h + audio/codecmodel.h + audio/inputdevicemodel.h + audio/managermodel.h + audio/outputdevicemodel.h + audio/ringtonedevicemodel.h + audio/settings.h + extensions/presenceitembackendmodelextension.h #commonbackendmanagerinterface.h ) diff --git a/src/account.cpp b/src/account.cpp index d8df102a08dd4479bcfc3ab5e4b3ebead4a2288e..1350a03177d23e9621c190c8ad304c772e53e30c 100644 --- a/src/account.cpp +++ b/src/account.cpp @@ -36,7 +36,7 @@ #include "certificate.h" #include "accountmodel.h" #include "credentialmodel.h" -#include "audiocodecmodel.h" +#include "audio/codecmodel.h" #include "video/videocodecmodel.h" #include "ringtonemodel.h" #include "phonenumber.h" @@ -88,7 +88,7 @@ public: void reloadMod() {reload();modify();}; CredentialModel* m_pCredentials ; - AudioCodecModel* m_pAudioCodecs ; + Audio::CodecModel* m_pAudioCodecs ; VideoCodecModel* m_pVideoCodecs ; RingToneModel* m_pRingToneModel ; KeyExchangeModel* m_pKeyExchangeModel; @@ -380,7 +380,7 @@ CredentialModel* Account::credentialsModel() const } ///Create and return the audio codec model -AudioCodecModel* Account::audioCodecModel() const +Audio::CodecModel* Account::audioCodecModel() const { if (!d_ptr->m_pAudioCodecs) const_cast<Account*>(this)->reloadAudioCodecs(); @@ -1436,11 +1436,11 @@ void AccountPrivate::save() const QVector<int> codecIdList = configurationManager.getAudioCodecList(); foreach (const int aCodec, codecIdList) { const QStringList codec = configurationManager.getAudioCodecDetails(aCodec); - const QModelIndex idx = m_pAudioCodecs->addAudioCodec(); - m_pAudioCodecs->setData(idx,codec[0],AudioCodecModel::Role::NAME ); - m_pAudioCodecs->setData(idx,codec[1],AudioCodecModel::Role::SAMPLERATE ); - m_pAudioCodecs->setData(idx,codec[2],AudioCodecModel::Role::BITRATE ); - m_pAudioCodecs->setData(idx,aCodec ,AudioCodecModel::Role::ID ); + const QModelIndex idx = m_pAudioCodecs->add(); + m_pAudioCodecs->setData(idx,codec[0],Audio::CodecModel::Role::NAME ); + m_pAudioCodecs->setData(idx,codec[1],Audio::CodecModel::Role::SAMPLERATE ); + m_pAudioCodecs->setData(idx,codec[2],Audio::CodecModel::Role::BITRATE ); + m_pAudioCodecs->setData(idx,aCodec ,Audio::CodecModel::Role::ID ); m_pAudioCodecs->setData(idx, Qt::Checked ,Qt::CheckStateRole); } q_ptr->saveAudioCodecs(); @@ -1571,7 +1571,7 @@ void Account::saveCredentials() { void Account::reloadAudioCodecs() { if (!d_ptr->m_pAudioCodecs) { - d_ptr->m_pAudioCodecs = new AudioCodecModel(this); + d_ptr->m_pAudioCodecs = new Audio::CodecModel(this); } d_ptr->m_pAudioCodecs->reload(); } diff --git a/src/account.h b/src/account.h index 6712ea5461a0774b99cf3760abe86bbcdcd763b6..1cda3f70fdf763a6733c8440f9cbc9a2751de892 100644 --- a/src/account.h +++ b/src/account.h @@ -32,13 +32,16 @@ class QString; #include "sflphone_const.h" #include "typedefs.h" class CredentialModel; -class AudioCodecModel; class VideoCodecModel; class RingToneModel ; class PhoneNumber ; class SecurityValidationModel; class Certificate ; +namespace Audio { + class CodecModel; +} + //Private class AccountPrivate; @@ -329,11 +332,11 @@ class LIB_EXPORT Account : public QObject { QString stateColorName() const; QVariant stateColor() const; - Q_INVOKABLE CredentialModel* credentialsModel() const; - Q_INVOKABLE AudioCodecModel* audioCodecModel () const; - Q_INVOKABLE VideoCodecModel* videoCodecModel () const; - Q_INVOKABLE RingToneModel* ringToneModel () const; - Q_INVOKABLE KeyExchangeModel* keyExchangeModel() const; + Q_INVOKABLE CredentialModel* credentialsModel() const; + Q_INVOKABLE Audio::CodecModel* audioCodecModel () const; + Q_INVOKABLE VideoCodecModel* videoCodecModel () const; + Q_INVOKABLE RingToneModel* ringToneModel () const; + Q_INVOKABLE KeyExchangeModel* keyExchangeModel() const; Q_INVOKABLE SecurityValidationModel* securityValidationModel() const; //Getters diff --git a/src/audio/alsapluginmodel.cpp b/src/audio/alsapluginmodel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cb3f81a5802edd4a85aa1c1517569880f5dd6f24 --- /dev/null +++ b/src/audio/alsapluginmodel.cpp @@ -0,0 +1,106 @@ +/**************************************************************************** + * Copyright (C) 2012-2014 by Savoir-Faire Linux * + * Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see <http://www.gnu.org/licenses/>. * + ***************************************************************************/ +#include "alsapluginmodel.h" + +//SFLPhone +#include "dbus/configurationmanager.h" + +///Constructor +Audio::AlsaPluginModel::AlsaPluginModel(const QObject* parent) : QAbstractListModel(const_cast<QObject*>(parent)) +{ + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); + m_lDeviceList = configurationManager.getAudioPluginList(); +} + +///Destructor +Audio::AlsaPluginModel::~AlsaPluginModel() +{ + +} + +///Re-implement QAbstractListModel data +QVariant Audio::AlsaPluginModel::data( const QModelIndex& index, int role) const +{ + if (!index.isValid()) + return QVariant(); + switch(role) { + case Qt::DisplayRole: + return m_lDeviceList[index.row()]; + }; + return QVariant(); +} + +///Re-implement QAbstractListModel rowCount +int Audio::AlsaPluginModel::rowCount( const QModelIndex& parent ) const +{ + if (parent.isValid()) + return 0; + return m_lDeviceList.size(); +} + +///Re-implement QAbstractListModel flags +Qt::ItemFlags Audio::AlsaPluginModel::flags( const QModelIndex& index ) const +{ + Q_UNUSED(index) + return Qt::ItemIsEnabled | Qt::ItemIsSelectable; +} + +///Setting data is disabled +bool Audio::AlsaPluginModel::setData( const QModelIndex& index, const QVariant &value, int role) +{ + Q_UNUSED(index) + Q_UNUSED(value) + Q_UNUSED(role) + return false; +} + +///Return the current index +QModelIndex Audio::AlsaPluginModel::currentPlugin() const +{ + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); + const int idx = m_lDeviceList.indexOf(configurationManager.getCurrentAudioOutputPlugin()); + qDebug() << "Invalid current audio plugin"; + if (idx == -1) + return QModelIndex(); + else + return index(idx,0,QModelIndex()); +} + +///Set the current index +void Audio::AlsaPluginModel::setCurrentPlugin(const QModelIndex& idx) +{ + if (!idx.isValid()) + return; + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); + configurationManager.setAudioPlugin(m_lDeviceList[idx.row()]); +} + +///Set the current index (qcombobox compatibility shim) +void Audio::AlsaPluginModel::setCurrentPlugin(int idx) +{ + setCurrentPlugin(index(idx,0)); +} + +///Reload to current daemon state +void Audio::AlsaPluginModel::reload() +{ + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); + m_lDeviceList = configurationManager.getAudioPluginList(); + emit layoutChanged(); + emit dataChanged(index(0,0),index(m_lDeviceList.size()-1,0)); +} \ No newline at end of file diff --git a/src/audio/alsapluginmodel.h b/src/audio/alsapluginmodel.h new file mode 100644 index 0000000000000000000000000000000000000000..ee82dd6b199c4605523f9f0de46989aad2130010 --- /dev/null +++ b/src/audio/alsapluginmodel.h @@ -0,0 +1,59 @@ +/**************************************************************************** + * Copyright (C) 2013-2014 by Savoir-Faire Linux * + * Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see <http://www.gnu.org/licenses/>. * + ***************************************************************************/ +#ifndef ALSAPLUGINMODEL_H +#define ALSAPLUGINMODEL_H + +#include <QtCore/QAbstractListModel> + +//Qt +#include <QtCore/QStringList> + +//SFLPhone +#include "../typedefs.h" + +namespace Audio { + +class LIB_EXPORT AlsaPluginModel : public QAbstractListModel { + Q_OBJECT +public: + explicit AlsaPluginModel(const QObject* parent); + virtual ~AlsaPluginModel(); + + //Models function + virtual QVariant data ( const QModelIndex& index, int role = Qt::DisplayRole ) const override; + virtual int rowCount( const QModelIndex& parent = QModelIndex() ) const override; + virtual Qt::ItemFlags flags ( const QModelIndex& index ) const override; + virtual bool setData ( const QModelIndex& index, const QVariant &value, int role) override; + + //Getters + QModelIndex currentPlugin() const; + + //Setters + void setCurrentPlugin(const QModelIndex& idx); + void setCurrentPlugin(int idx); + + //Mutator + void reload(); + +private: + QStringList m_lDeviceList; +}; + +} + +#endif \ No newline at end of file diff --git a/src/audiocodecmodel.cpp b/src/audio/codecmodel.cpp similarity index 71% rename from src/audiocodecmodel.cpp rename to src/audio/codecmodel.cpp index bfb5f7eb3a7a96e7a5085d2583c89adb12ebfc6e..7a51ddbeb14ce44a03a08668abe7d28fec78de7c 100644 --- a/src/audiocodecmodel.cpp +++ b/src/audio/codecmodel.cpp @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * * along with this program. If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#include "audiocodecmodel.h" +#include "codecmodel.h" //Qt #include <QtCore/QDebug> @@ -26,19 +26,19 @@ #include "dbus/configurationmanager.h" ///Constructor -AudioCodecModel::AudioCodecModel(Account* account) : +Audio::CodecModel::CodecModel(Account* account) : QAbstractListModel(account?(QObject*)account:(QObject*)QCoreApplication::instance()),m_pAccount(account) { - setObjectName("AudioCodecModel: "+(account?account->id():"Unknown")); + setObjectName("CodecModel: "+(account?account->id():"Unknown")); QHash<int, QByteArray> roles = roleNames(); - roles.insert(AudioCodecModel::Role::ID ,QByteArray("id")); - roles.insert(AudioCodecModel::Role::NAME ,QByteArray("name")); - roles.insert(AudioCodecModel::Role::BITRATE ,QByteArray("bitrate")); - roles.insert(AudioCodecModel::Role::SAMPLERATE,QByteArray("samplerate")); + roles.insert(Audio::CodecModel::Role::ID ,QByteArray("id")); + roles.insert(Audio::CodecModel::Role::NAME ,QByteArray("name")); + roles.insert(Audio::CodecModel::Role::BITRATE ,QByteArray("bitrate")); + roles.insert(Audio::CodecModel::Role::SAMPLERATE,QByteArray("samplerate")); setRoleNames(roles); } -AudioCodecModel::~AudioCodecModel() +Audio::CodecModel::~CodecModel() { while (m_lAudioCodecs.size()) { AudioCodecData* c = m_lAudioCodecs[0]; @@ -48,49 +48,49 @@ AudioCodecModel::~AudioCodecModel() } ///Model data -QVariant AudioCodecModel::data(const QModelIndex& idx, int role) const { +QVariant Audio::CodecModel::data(const QModelIndex& idx, int role) const { if(idx.column() == 0 && role == Qt::DisplayRole ) { return QVariant(m_lAudioCodecs[idx.row()]->name); } else if(idx.column() == 0 && role == Qt::CheckStateRole ) { return QVariant(m_lEnabledCodecs[m_lAudioCodecs[idx.row()]->id] ? Qt::Checked : Qt::Unchecked); } - else if (idx.column() == 0 && role == AudioCodecModel::Role::NAME ) { + else if (idx.column() == 0 && role == Audio::CodecModel::Role::NAME ) { return m_lAudioCodecs[idx.row()]->name; } - else if (idx.column() == 0 && role == AudioCodecModel::Role::BITRATE ) { + else if (idx.column() == 0 && role == Audio::CodecModel::Role::BITRATE ) { return m_lAudioCodecs[idx.row()]->bitrate; } - else if (idx.column() == 0 && role == AudioCodecModel::Role::SAMPLERATE ) { + else if (idx.column() == 0 && role == Audio::CodecModel::Role::SAMPLERATE ) { return m_lAudioCodecs[idx.row()]->samplerate; } - else if (idx.column() == 0 && role == AudioCodecModel::Role::ID ) { + else if (idx.column() == 0 && role == Audio::CodecModel::Role::ID ) { return m_lAudioCodecs[idx.row()]->id; } return QVariant(); } ///Number of audio codecs -int AudioCodecModel::rowCount(const QModelIndex& par) const { +int Audio::CodecModel::rowCount(const QModelIndex& par) const { Q_UNUSED(par) return m_lAudioCodecs.size(); } ///Model flags -Qt::ItemFlags AudioCodecModel::flags(const QModelIndex& idx) const { +Qt::ItemFlags Audio::CodecModel::flags(const QModelIndex& idx) const { if (idx.column() == 0) return QAbstractItemModel::flags(idx) | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable; return QAbstractItemModel::flags(idx); } ///Set audio codec data -bool AudioCodecModel::setData( const QModelIndex& idx, const QVariant &value, int role) { - if (idx.column() == 0 && role == AudioCodecModel::NAME) { +bool Audio::CodecModel::setData( const QModelIndex& idx, const QVariant &value, int role) { + if (idx.column() == 0 && role == Audio::CodecModel::NAME) { m_lAudioCodecs[idx.row()]->name = value.toString(); emit dataChanged(idx, idx); return true; } - else if (idx.column() == 0 && role == AudioCodecModel::BITRATE) { + else if (idx.column() == 0 && role == Audio::CodecModel::BITRATE) { m_lAudioCodecs[idx.row()]->bitrate = value.toString(); emit dataChanged(idx, idx); return true; @@ -100,12 +100,12 @@ bool AudioCodecModel::setData( const QModelIndex& idx, const QVariant &value, in emit dataChanged(idx, idx); return true; } - else if (idx.column() == 0 && role == AudioCodecModel::SAMPLERATE) { + else if (idx.column() == 0 && role == Audio::CodecModel::SAMPLERATE) { m_lAudioCodecs[idx.row()]->samplerate = value.toString(); emit dataChanged(idx, idx); return true; } - else if (idx.column() == 0 && role == AudioCodecModel::ID) { + else if (idx.column() == 0 && role == Audio::CodecModel::ID) { m_lAudioCodecs[idx.row()]->id = value.toInt(); emit dataChanged(idx, idx); return true; @@ -114,14 +114,14 @@ bool AudioCodecModel::setData( const QModelIndex& idx, const QVariant &value, in } ///Add a new audio codec -QModelIndex AudioCodecModel::addAudioCodec() { +QModelIndex Audio::CodecModel::add() { m_lAudioCodecs << new AudioCodecData; emit dataChanged(index(m_lAudioCodecs.size()-1,0), index(m_lAudioCodecs.size()-1,0)); return index(m_lAudioCodecs.size()-1,0); } ///Remove audio codec at 'idx' -void AudioCodecModel::removeAudioCodec(QModelIndex idx) { +void Audio::CodecModel::remove(const QModelIndex& idx) { if (idx.isValid()) { AudioCodecData* d = m_lAudioCodecs[idx.row()]; m_lAudioCodecs.removeAt(idx.row()); @@ -134,7 +134,7 @@ void AudioCodecModel::removeAudioCodec(QModelIndex idx) { } ///Remove everything -void AudioCodecModel::clear() +void Audio::CodecModel::clear() { while(m_lAudioCodecs.size()) { AudioCodecData* d = m_lAudioCodecs[0]; @@ -146,7 +146,7 @@ void AudioCodecModel::clear() } ///Increase codec priority -bool AudioCodecModel::moveUp(QModelIndex idx) +bool Audio::CodecModel::moveUp(const QModelIndex& idx) { if(idx.row() > 0 && idx.row() <= rowCount()) { AudioCodecData* data2 = m_lAudioCodecs[idx.row()]; @@ -159,7 +159,7 @@ bool AudioCodecModel::moveUp(QModelIndex idx) } ///Decrease codec priority -bool AudioCodecModel::moveDown(QModelIndex idx) +bool Audio::CodecModel::moveDown(const QModelIndex& idx) { if(idx.row() >= 0 && idx.row() < rowCount()) { AudioCodecData* data2 = m_lAudioCodecs[idx.row()]; @@ -172,7 +172,7 @@ bool AudioCodecModel::moveDown(QModelIndex idx) } ///Reload the codeclist -void AudioCodecModel::reload() +void Audio::CodecModel::reload() { ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); QVector<int> codecIdList = configurationManager.getAudioCodecList(); @@ -183,11 +183,11 @@ void AudioCodecModel::reload() foreach (const int aCodec, activeCodecList) { if (!findCodec(aCodec)) { QStringList codec = configurationManager.getAudioCodecDetails(aCodec); - QModelIndex idx = addAudioCodec(); - setData(idx,codec[0] ,AudioCodecModel::Role::NAME ); - setData(idx,codec[1] ,AudioCodecModel::Role::SAMPLERATE ); - setData(idx,codec[2] ,AudioCodecModel::Role::BITRATE ); - setData(idx,aCodec ,AudioCodecModel::Role::ID ); + QModelIndex idx = add(); + setData(idx,codec[0] ,Audio::CodecModel::Role::NAME ); + setData(idx,codec[1] ,Audio::CodecModel::Role::SAMPLERATE ); + setData(idx,codec[2] ,Audio::CodecModel::Role::BITRATE ); + setData(idx,aCodec ,Audio::CodecModel::Role::ID ); setData(idx, Qt::Checked ,Qt::CheckStateRole ); if (codecIdList.indexOf(aCodec)!=-1) codecIdList.remove(codecIdList.indexOf(aCodec)); @@ -198,33 +198,33 @@ void AudioCodecModel::reload() foreach (const int aCodec, codecIdList) { if (!findCodec(aCodec)) { const QStringList codec = configurationManager.getAudioCodecDetails(aCodec); - QModelIndex idx = addAudioCodec(); - setData(idx,codec[0],AudioCodecModel::Role::NAME ); - setData(idx,codec[1],AudioCodecModel::Role::SAMPLERATE ); - setData(idx,codec[2],AudioCodecModel::Role::BITRATE ); - setData(idx,aCodec ,AudioCodecModel::Role::ID ); + QModelIndex idx = add(); + setData(idx,codec[0],Audio::CodecModel::Role::NAME ); + setData(idx,codec[1],Audio::CodecModel::Role::SAMPLERATE ); + setData(idx,codec[2],Audio::CodecModel::Role::BITRATE ); + setData(idx,aCodec ,Audio::CodecModel::Role::ID ); setData(idx, Qt::Unchecked ,Qt::CheckStateRole); } } } ///Save details -void AudioCodecModel::save() +void Audio::CodecModel::save() { QStringList _codecList; for (int i=0; i < rowCount();i++) { QModelIndex idx = index(i,0); if (data(idx,Qt::CheckStateRole) == Qt::Checked) { - _codecList << data(idx,AudioCodecModel::Role::ID).toString(); + _codecList << data(idx,Audio::CodecModel::Role::ID).toString(); } } - ConfigurationManagerInterface & configurationManager = DBus::ConfigurationManager::instance(); + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); configurationManager.setActiveAudioCodecList(_codecList, m_pAccount->id()); } ///Check is a codec is already in the list -bool AudioCodecModel::findCodec(int id) +bool Audio::CodecModel::findCodec(int id) { foreach(AudioCodecData* data, m_lAudioCodecs) { if (data->id == id) diff --git a/src/audiocodecmodel.h b/src/audio/codecmodel.h similarity index 76% rename from src/audiocodecmodel.h rename to src/audio/codecmodel.h index 29c88ee8fb248df97cc3216dd7d6e4869b89d545..212c24fd39ffcd91671b9f640e69152314117c3b 100644 --- a/src/audiocodecmodel.h +++ b/src/audio/codecmodel.h @@ -15,17 +15,23 @@ * You should have received a copy of the GNU General Public License * * along with this program. If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#ifndef AUDIO_CODEC_MODEL_H -#define AUDIO_CODEC_MODEL_H +#ifndef CODEC_MODEL_H +#define CODEC_MODEL_H -#include <QtCore/QString> #include <QtCore/QAbstractListModel> -#include "typedefs.h" + +//Qt +#include <QtCore/QString> + +//SFLPhone +#include "../typedefs.h" class Account; +namespace Audio { + ///AudioCodecModel: A model for account audio codec -class LIB_EXPORT AudioCodecModel : public QAbstractListModel { +class LIB_EXPORT CodecModel : public QAbstractListModel { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" Q_OBJECT @@ -41,23 +47,23 @@ public: }; //Constructor - explicit AudioCodecModel(Account* account); - virtual ~AudioCodecModel(); + explicit CodecModel(Account* account); + virtual ~CodecModel(); //Abstract model member - QVariant data (const QModelIndex& index, int role = Qt::DisplayRole ) const; - int rowCount (const QModelIndex& parent = QModelIndex() ) const; - Qt::ItemFlags flags (const QModelIndex& index ) const; - virtual bool setData (const QModelIndex& index, const QVariant &value, int role ); + QVariant data (const QModelIndex& index, int role = Qt::DisplayRole ) const override; + int rowCount (const QModelIndex& parent = QModelIndex() ) const override; + Qt::ItemFlags flags (const QModelIndex& index ) const override; + virtual bool setData (const QModelIndex& index, const QVariant &value, int role ) override; //Mutator - QModelIndex addAudioCodec(); - Q_INVOKABLE void removeAudioCodec ( QModelIndex idx ); - Q_INVOKABLE bool moveUp ( QModelIndex idx ); - Q_INVOKABLE bool moveDown ( QModelIndex idx ); - Q_INVOKABLE void clear ( ); - Q_INVOKABLE void reload ( ); - Q_INVOKABLE void save ( ); + QModelIndex add(); + Q_INVOKABLE void remove ( const QModelIndex& idx ); + Q_INVOKABLE bool moveUp ( const QModelIndex& idx ); + Q_INVOKABLE bool moveDown ( const QModelIndex& idx ); + Q_INVOKABLE void clear ( ); + Q_INVOKABLE void reload ( ); + Q_INVOKABLE void save ( ); private: ///@struct AudioCodecData store audio codec information @@ -76,6 +82,8 @@ private: //Helpers bool findCodec(int id); }; -Q_DECLARE_METATYPE(AudioCodecModel*) + +} +Q_DECLARE_METATYPE(Audio::CodecModel*) #endif diff --git a/src/audio/inputdevicemodel.cpp b/src/audio/inputdevicemodel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6715a90bf67c27ba42c94abccd037acee602f862 --- /dev/null +++ b/src/audio/inputdevicemodel.cpp @@ -0,0 +1,106 @@ +/**************************************************************************** + * Copyright (C) 2012-2014 by Savoir-Faire Linux * + * Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see <http://www.gnu.org/licenses/>. * + ***************************************************************************/ +#include "inputdevicemodel.h" + +//SFLPhone +#include "dbus/configurationmanager.h" +#include "settings.h" + +///Constructor +Audio::InputDeviceModel::InputDeviceModel(const QObject* parent) : QAbstractListModel(const_cast<QObject*>(parent)) +{ + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); + m_lDeviceList = configurationManager.getAudioInputDeviceList (); +} + +///Destructor +Audio::InputDeviceModel::~InputDeviceModel() +{ + +} + +///Re-implement QAbstractListModel data +QVariant Audio::InputDeviceModel::data( const QModelIndex& index, int role) const +{ + if (!index.isValid()) + return QVariant(); + switch(role) { + case Qt::DisplayRole: + return m_lDeviceList[index.row()]; + }; + return QVariant(); +} + +///Re-implement QAbstractListModel rowCount +int Audio::InputDeviceModel::rowCount( const QModelIndex& parent ) const +{ + if (parent.isValid()) + return 0; + return m_lDeviceList.size(); +} + +///Re-implement QAbstractListModel flags +Qt::ItemFlags Audio::InputDeviceModel::flags( const QModelIndex& index ) const +{ + Q_UNUSED(index) + return Qt::ItemIsEnabled | Qt::ItemIsSelectable; +} + +///This model does not support setting data +bool Audio::InputDeviceModel::setData( const QModelIndex& index, const QVariant &value, int role) +{ + Q_UNUSED(index) + Q_UNUSED(value) + Q_UNUSED(role) + return false; +} + +///Return the current input device index +QModelIndex Audio::InputDeviceModel::currentDevice() const +{ + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); + const QStringList currentDevices = configurationManager.getCurrentAudioDevicesIndex(); + const int idx = currentDevices[static_cast<int>(Settings::DeviceIndex::INPUT)].toInt(); + if (idx >= m_lDeviceList.size()) + return QModelIndex(); + return index(idx,0); +} + +///Set the current input device +void Audio::InputDeviceModel::setCurrentDevice(const QModelIndex& index) +{ + if (index.isValid()) { + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); + configurationManager.setAudioInputDevice(index.row()); + } +} + +///QCombobox signals -> QModelIndex shim +void Audio::InputDeviceModel::setCurrentDevice(int idx) +{ + setCurrentDevice(index(idx,0)); +} + +///Reload input device list +void Audio::InputDeviceModel::reload() +{ + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); + m_lDeviceList = configurationManager.getAudioInputDeviceList (); + emit layoutChanged(); + emit dataChanged(index(0,0),index(m_lDeviceList.size()-1,0)); +} \ No newline at end of file diff --git a/src/audio/inputdevicemodel.h b/src/audio/inputdevicemodel.h new file mode 100644 index 0000000000000000000000000000000000000000..18c96127d4ea1fc51367c60cb4e8cc7099d9fd2b --- /dev/null +++ b/src/audio/inputdevicemodel.h @@ -0,0 +1,59 @@ +/**************************************************************************** + * Copyright (C) 2013-2014 by Savoir-Faire Linux * + * Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see <http://www.gnu.org/licenses/>. * + ***************************************************************************/ +#ifndef INPUTDEVICEMODEL_H +#define INPUTDEVICEMODEL_H + +#include <QtCore/QAbstractListModel> + +//Qt +#include <QtCore/QStringList> + +//SFLPhone +#include "../typedefs.h" + +namespace Audio { + +class LIB_EXPORT InputDeviceModel : public QAbstractListModel { + Q_OBJECT +public: + explicit InputDeviceModel(const QObject* parent); + virtual ~InputDeviceModel(); + + //Models function + virtual QVariant data ( const QModelIndex& index, int role = Qt::DisplayRole ) const override; + virtual int rowCount( const QModelIndex& parent = QModelIndex() ) const override; + virtual Qt::ItemFlags flags ( const QModelIndex& index ) const override; + virtual bool setData ( const QModelIndex& index, const QVariant &value, int role) override; + + //Getters + QModelIndex currentDevice() const; + + //Setters + void setCurrentDevice(const QModelIndex& index); + void setCurrentDevice(int idx); + + //Mutator + void reload(); + +private: + QStringList m_lDeviceList; +}; + +} + +#endif \ No newline at end of file diff --git a/src/audio/managermodel.cpp b/src/audio/managermodel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0f360bf4c1ed3e91c8f44f01e3edaff9b4e40381 --- /dev/null +++ b/src/audio/managermodel.cpp @@ -0,0 +1,146 @@ +/**************************************************************************** + * Copyright (C) 2012-2014 by Savoir-Faire Linux * + * Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see <http://www.gnu.org/licenses/>. * + ***************************************************************************/ +#include "managermodel.h" + +//SFLPhone +#include "dbus/configurationmanager.h" +#include "settings.h" + +///Constructor +Audio::ManagerModel::ManagerModel(const QObject* parent) : QAbstractListModel(const_cast<QObject*>(parent)) +{ + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); + const QStringList managers = configurationManager.getSupportedAudioManagers(); + foreach(const QString& m,managers) { + if (m == ManagerName::PULSEAUDIO) { + m_lSupportedManagers << Manager::PULSE; + m_lDeviceList << "Pulse Audio"; + } + else if (m == ManagerName::ALSA) { + m_lSupportedManagers << Manager::ALSA; + m_lDeviceList<< "ALSA"; + } + else if (m == ManagerName::JACK) { + m_lSupportedManagers << Manager::JACK; + m_lDeviceList<< "Jack"; + } + else + qDebug() << "Unsupported audio manager" << m; + } +} + +///Destructor +Audio::ManagerModel::~ManagerModel() +{ + m_lDeviceList.clear(); +} + +///Re-implement QAbstractListModel data +QVariant Audio::ManagerModel::data( const QModelIndex& index, int role) const +{ + if (!index.isValid()) + return QVariant(); + switch(role) { + case Qt::DisplayRole: + return m_lDeviceList[index.row()]; + }; + return QVariant(); +} + +///Re-implement QAbstractListModel rowCount +int Audio::ManagerModel::rowCount( const QModelIndex& parent ) const +{ + if (parent.isValid()) + return 0; + return m_lDeviceList.size(); +} + +///Re-implement QAbstractListModel flags +Qt::ItemFlags Audio::ManagerModel::flags( const QModelIndex& index ) const +{ + Q_UNUSED(index) + return Qt::ItemIsEnabled | Qt::ItemIsSelectable; +} + +///This model is read only +bool Audio::ManagerModel::setData( const QModelIndex& index, const QVariant &value, int role) +{ + Q_UNUSED(index) + Q_UNUSED(value) + Q_UNUSED(role) + return false; +} + +/** + * Return the current audio manager + * @warning Changes to the current index model will invalid Input/Output/Ringtone devices models + */ +QModelIndex Audio::ManagerModel::currentManagerIndex() const +{ + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); + const QString manager = configurationManager.getAudioManager(); + if (manager == ManagerName::PULSEAUDIO) + return index((int)Manager::PULSE,0); + else if (manager == ManagerName::ALSA) + return index((int)Manager::ALSA,0); + else if (manager == ManagerName::JACK) + return index((int)Manager::JACK,0); + return QModelIndex(); +} + +Audio::ManagerModel::Manager Audio::ManagerModel::currentManager() const +{ + return m_lSupportedManagers[currentManagerIndex().row()]; +} + +///Set current audio manager +bool Audio::ManagerModel::setCurrentManager(const QModelIndex& idx) +{ + if (!idx.isValid()) + return false; + + bool ret = true; + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); + switch (m_lSupportedManagers[idx.row()]) { + case Manager::PULSE: + ret = configurationManager.setAudioManager(ManagerName::PULSEAUDIO); + Audio::Settings::instance()->reload(); + break; + case Manager::ALSA: + ret = configurationManager.setAudioManager(ManagerName::ALSA); + Audio::Settings::instance()->reload(); + break; + case Manager::JACK: + ret = configurationManager.setAudioManager(ManagerName::JACK); + Audio::Settings::instance()->reload(); + break; + }; + if (!ret) { + const QModelIndex& newIdx = currentManagerIndex(); + emit currentManagerChanged(currentManager()); + emit currentManagerChanged(newIdx); + emit currentManagerChanged(newIdx.row()); + } + return ret; +} + +///QCombobox -> QModelIndex shim +bool Audio::ManagerModel::setCurrentManager(int idx) +{ + return setCurrentManager(index(idx,0)); +} \ No newline at end of file diff --git a/src/audio/managermodel.h b/src/audio/managermodel.h new file mode 100644 index 0000000000000000000000000000000000000000..444f5f43f8a6063bdd36d1abc0f05621db085c9f --- /dev/null +++ b/src/audio/managermodel.h @@ -0,0 +1,78 @@ +/**************************************************************************** + * Copyright (C) 2013-2014 by Savoir-Faire Linux * + * Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see <http://www.gnu.org/licenses/>. * + ***************************************************************************/ +#ifndef MANAGERMODEL_H +#define MANAGERMODEL_H + +#include <QtCore/QAbstractListModel> + +//Qt +#include <QtCore/QStringList> + +//SFLPhone +#include "../typedefs.h" + +namespace Audio { + +class LIB_EXPORT ManagerModel : public QAbstractListModel { + Q_OBJECT +public: + + enum class Manager { + ALSA =0, + PULSE=1, + JACK =2, + }; + explicit ManagerModel(const QObject* parent); + virtual ~ManagerModel(); + + //Models function + virtual QVariant data ( const QModelIndex& index, int role = Qt::DisplayRole ) const override; + virtual int rowCount( const QModelIndex& parent = QModelIndex() ) const override; + virtual Qt::ItemFlags flags ( const QModelIndex& index ) const override; + virtual bool setData ( const QModelIndex& index, const QVariant &value, int role) override; + + //Getters + QModelIndex currentManagerIndex() const; + Manager currentManager() const; + + //Setters + bool setCurrentManager(const QModelIndex& index); + +public Q_SLOTS: + bool setCurrentManager(int idx); + +Q_SIGNALS: + void currentManagerChanged(Manager); + void currentManagerChanged(int); + void currentManagerChanged(const QModelIndex&); + +private: + class ManagerName { + public: + constexpr static const char* PULSEAUDIO = "pulseaudio"; + constexpr static const char* ALSA = "alsa" ; + constexpr static const char* JACK = "jack" ; + }; + + QStringList m_lDeviceList; + QList<Manager> m_lSupportedManagers; +}; + +} + +#endif \ No newline at end of file diff --git a/src/audio/outputdevicemodel.cpp b/src/audio/outputdevicemodel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..83c1179804f76b0c1d68005c18a54fb0c0adafb1 --- /dev/null +++ b/src/audio/outputdevicemodel.cpp @@ -0,0 +1,107 @@ +/**************************************************************************** + * Copyright (C) 2012-2014 by Savoir-Faire Linux * + * Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see <http://www.gnu.org/licenses/>. * + ***************************************************************************/ +#include "outputdevicemodel.h" + +//SFLPhone +#include "dbus/configurationmanager.h" +#include "settings.h" + +///Constructor +Audio::OutputDeviceModel::OutputDeviceModel(const QObject* parent) : QAbstractListModel(const_cast<QObject*>(parent)) +{ + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); + m_lDeviceList = configurationManager.getAudioOutputDeviceList(); +} + +///Destructor +Audio::OutputDeviceModel::~OutputDeviceModel() +{ + +} + +///Re-implement QAbstractListModel data +QVariant Audio::OutputDeviceModel::data( const QModelIndex& index, int role) const +{ + if (!index.isValid()) + return QVariant(); + switch(role) { + case Qt::DisplayRole: + return m_lDeviceList[index.row()]; + }; + return QVariant(); +} + +///Re-implement QAbstractListModel rowCount +int Audio::OutputDeviceModel::rowCount( const QModelIndex& parent ) const +{ + if (parent.isValid()) + return 0; + return m_lDeviceList.size(); +} + +///Re-implement QAbstractListModel flags +Qt::ItemFlags Audio::OutputDeviceModel::flags( const QModelIndex& index ) const +{ + Q_UNUSED(index) + return Qt::ItemIsEnabled | Qt::ItemIsSelectable; +} + +///This model is read only +bool Audio::OutputDeviceModel::setData( const QModelIndex& index, const QVariant &value, int role) +{ + Q_UNUSED(index) + Q_UNUSED(value) + Q_UNUSED(role) + return false; +} + +///Return the current output device +QModelIndex Audio::OutputDeviceModel::currentDevice() const +{ + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); + const QStringList currentDevices = configurationManager.getCurrentAudioDevicesIndex(); + const int idx = currentDevices[static_cast<int>(Audio::Settings::DeviceIndex::OUTPUT)].toInt(); + + if (idx >= m_lDeviceList.size()) + return QModelIndex(); + return index(idx,0); +} + +///Set the current output device +void Audio::OutputDeviceModel::setCurrentDevice(const QModelIndex& index) +{ + if (index.isValid()) { + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); + configurationManager.setAudioOutputDevice(index.row()); + } +} + +///QCombobox index -> QModelIndex shim +void Audio::OutputDeviceModel::setCurrentDevice(int idx) +{ + setCurrentDevice(index(idx,0)); +} + +///reload output devices list +void Audio::OutputDeviceModel::reload() +{ + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); + m_lDeviceList = configurationManager.getAudioOutputDeviceList(); + emit layoutChanged(); + emit dataChanged(index(0,0),index(m_lDeviceList.size()-1,0)); +} \ No newline at end of file diff --git a/src/audio/outputdevicemodel.h b/src/audio/outputdevicemodel.h new file mode 100644 index 0000000000000000000000000000000000000000..0aa5fea82dd442221b7aaf5b518041010f4e7737 --- /dev/null +++ b/src/audio/outputdevicemodel.h @@ -0,0 +1,59 @@ +/**************************************************************************** + * Copyright (C) 2013-2014 by Savoir-Faire Linux * + * Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see <http://www.gnu.org/licenses/>. * + ***************************************************************************/ +#ifndef OUTPUTDEVICEMODEL_H +#define OUTPUTDEVICEMODEL_H + +#include <QtCore/QAbstractListModel> + +//Qt +#include <QtCore/QStringList> + +//SFLPhone +#include "../typedefs.h" + +namespace Audio { + +class LIB_EXPORT OutputDeviceModel : public QAbstractListModel { + Q_OBJECT +public: + explicit OutputDeviceModel(const QObject* parent); + virtual ~OutputDeviceModel(); + + //Models function + virtual QVariant data ( const QModelIndex& index, int role = Qt::DisplayRole ) const override; + virtual int rowCount( const QModelIndex& parent = QModelIndex() ) const override; + virtual Qt::ItemFlags flags ( const QModelIndex& index ) const override; + virtual bool setData ( const QModelIndex& index, const QVariant &value, int role) override; + + //Getters + QModelIndex currentDevice() const; + + //Setters + void setCurrentDevice(const QModelIndex& index); + void setCurrentDevice(int idx); + + //Mutator + void reload(); + +private: + QStringList m_lDeviceList; +}; + +} + +#endif \ No newline at end of file diff --git a/src/audio/ringtonedevicemodel.cpp b/src/audio/ringtonedevicemodel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..462cf260ae847787223ab8bc5c85e5d5bce09500 --- /dev/null +++ b/src/audio/ringtonedevicemodel.cpp @@ -0,0 +1,106 @@ +/**************************************************************************** + * Copyright (C) 2012-2014 by Savoir-Faire Linux * + * Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see <http://www.gnu.org/licenses/>. * + ***************************************************************************/ +#include "ringtonedevicemodel.h" + +//SFLPhone +#include "dbus/configurationmanager.h" +#include "settings.h" + +///Constructor +Audio::RingtoneDeviceModel::RingtoneDeviceModel(const QObject* parent) : QAbstractListModel(const_cast<QObject*>(parent)) +{ + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); + m_lDeviceList = configurationManager.getAudioOutputDeviceList(); +} + +///Destructor +Audio::RingtoneDeviceModel::~RingtoneDeviceModel() +{ + +} + +///Re-implement QAbstractListModel data +QVariant Audio::RingtoneDeviceModel::data( const QModelIndex& index, int role) const +{ + if (!index.isValid()) + return QVariant(); + switch(role) { + case Qt::DisplayRole: + return m_lDeviceList[index.row()]; + }; + return QVariant(); +} + +///Re-implement QAbstractListModel rowCount +int Audio::RingtoneDeviceModel::rowCount( const QModelIndex& parent ) const +{ + if (parent.isValid()) + return 0; + return m_lDeviceList.size(); +} + +///Re-implement QAbstractListModel flags +Qt::ItemFlags Audio::RingtoneDeviceModel::flags( const QModelIndex& index ) const +{ + Q_UNUSED(index) + return Qt::ItemIsEnabled | Qt::ItemIsSelectable; +} + +///RingtoneDeviceModel is read only +bool Audio::RingtoneDeviceModel::setData( const QModelIndex& index, const QVariant &value, int role) +{ + Q_UNUSED(index) + Q_UNUSED(value) + Q_UNUSED(role) + return false; +} + +///Return the current ringtone device +QModelIndex Audio::RingtoneDeviceModel::currentDevice() const +{ + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); + const QStringList currentDevices = configurationManager.getCurrentAudioDevicesIndex(); + const int idx = currentDevices[static_cast<int>(Audio::Settings::DeviceIndex::RINGTONE)].toInt(); + if (idx >= m_lDeviceList.size()) + return QModelIndex(); + return index(idx,0); +} + +///Set the current ringtone device +void Audio::RingtoneDeviceModel::setCurrentDevice(const QModelIndex& index) +{ + if (index.isValid()) { + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); + configurationManager.setAudioRingtoneDevice(index.row()); + } +} + +///QCombobox -> QModelIndex shim +void Audio::RingtoneDeviceModel::setCurrentDevice(int idx) +{ + setCurrentDevice(index(idx,0)); +} + +///Reload ringtone device list +void Audio::RingtoneDeviceModel::reload() +{ + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); + m_lDeviceList = configurationManager.getAudioOutputDeviceList(); + emit layoutChanged(); + emit dataChanged(index(0,0),index(m_lDeviceList.size()-1,0)); +} diff --git a/src/audio/ringtonedevicemodel.h b/src/audio/ringtonedevicemodel.h new file mode 100644 index 0000000000000000000000000000000000000000..c79d65afed90fb5b9dd4273b00e0b28c701ac3c0 --- /dev/null +++ b/src/audio/ringtonedevicemodel.h @@ -0,0 +1,59 @@ +/**************************************************************************** + * Copyright (C) 2013-2014 by Savoir-Faire Linux * + * Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see <http://www.gnu.org/licenses/>. * + ***************************************************************************/ +#ifndef RINGTONEDEVICEMODEL_H +#define RINGTONEDEVICEMODEL_H + +#include <QtCore/QAbstractListModel> + +//Qt +#include <QtCore/QStringList> + +//SFLPhone +#include "../typedefs.h" + +namespace Audio { + +class LIB_EXPORT RingtoneDeviceModel: public QAbstractListModel { + Q_OBJECT +public: + explicit RingtoneDeviceModel(const QObject* parent); + virtual ~RingtoneDeviceModel(); + + //Models function + virtual QVariant data ( const QModelIndex& index, int role = Qt::DisplayRole ) const override; + virtual int rowCount( const QModelIndex& parent = QModelIndex() ) const override; + virtual Qt::ItemFlags flags ( const QModelIndex& index ) const override; + virtual bool setData ( const QModelIndex& index, const QVariant &value, int role) override; + + //Getters + QModelIndex currentDevice() const; + + //Setters + void setCurrentDevice(const QModelIndex& index); + void setCurrentDevice(int idx); + + //Mutator + void reload(); + +private: + QStringList m_lDeviceList; +}; + +} + +#endif \ No newline at end of file diff --git a/src/audio/settings.cpp b/src/audio/settings.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9a55702de3e84d78372baf5efec89ded88109598 --- /dev/null +++ b/src/audio/settings.cpp @@ -0,0 +1,256 @@ +/**************************************************************************** + * Copyright (C) 2012-2014 by Savoir-Faire Linux * + * Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see <http://www.gnu.org/licenses/>. * + ***************************************************************************/ +#include "settings.h" + +//SFLPhone +#include "dbus/configurationmanager.h" +#include "dbus/callmanager.h" +#include "ringtonedevicemodel.h" +#include "alsapluginmodel.h" +#include "managermodel.h" +#include "outputdevicemodel.h" +#include "inputdevicemodel.h" + +Audio::Settings* Audio::Settings::m_spInstance = nullptr; + +///Constructor +Audio::Settings::Settings() : QObject(),m_EnableRoomTone(false), + m_pAlsaPluginModel (nullptr), m_pInputDeviceModel (nullptr), + m_pAudioManagerModel(nullptr), m_pRingtoneDeviceModel(nullptr), + m_pOutputDeviceModel(nullptr) +{ + m_pRingtoneDeviceModel = new RingtoneDeviceModel (this); + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); + connect(&configurationManager,SIGNAL(volumeChanged(QString,double)),this,SLOT(slotVolumeChanged(QString,double))); +} + +///Destructor +Audio::Settings::~Settings() +{ + delete m_pAlsaPluginModel ; + delete m_pInputDeviceModel ; + delete m_pOutputDeviceModel ; + delete m_pAudioManagerModel ; + delete m_pRingtoneDeviceModel; +} + +///Singleton +Audio::Settings* Audio::Settings::instance() +{ + if (!m_spInstance) + m_spInstance = new Settings(); + return m_spInstance; +} + + +///Return plugin model (alsa only for the time being) +Audio::AlsaPluginModel* Audio::Settings::alsaPluginModel() const +{ + if (!m_pAlsaPluginModel) + m_pAlsaPluginModel = new Audio::AlsaPluginModel(this); + return m_pAlsaPluginModel; +} + + +///Return the input device model +Audio::InputDeviceModel* Audio::Settings::inputDeviceModel() const +{ + if (!m_pInputDeviceModel) + m_pInputDeviceModel = new Audio::InputDeviceModel(this); + return m_pInputDeviceModel; +} + +///Return the output device model +Audio::OutputDeviceModel* Audio::Settings::outputDeviceModel() const +{ + if (!m_pOutputDeviceModel) + m_pOutputDeviceModel = new Audio::OutputDeviceModel(this); + return m_pOutputDeviceModel; +} + +///Return audio manager +Audio::ManagerModel* Audio::Settings::managerModel() const +{ + if (!m_pAudioManagerModel) + m_pAudioManagerModel = new Audio::ManagerModel(this); + return m_pAudioManagerModel; +} + +///Return the ringtone device model +Audio::RingtoneDeviceModel* Audio::Settings::ringtoneDeviceModel() const +{ + if (!m_pRingtoneDeviceModel) + m_pRingtoneDeviceModel = new Audio::RingtoneDeviceModel (this); + return m_pRingtoneDeviceModel; +} + +///Is the room tone (globally) enabled +bool Audio::Settings::isRoomToneEnabled() +{ + return m_EnableRoomTone; +} + +///Reload everything +void Audio::Settings::reload() +{ + m_pAlsaPluginModel->reload(); + m_pInputDeviceModel->reload(); + m_pOutputDeviceModel->reload(); +// m_pAudioManagerModel->reload(); + m_pRingtoneDeviceModel->reload(); +} + +///Play room tone +Audio::Settings::ToneType Audio::Settings::playRoomTone() const +{ + CallManagerInterface& callManager = DBus::CallManager::instance(); + callManager.startTone(true,static_cast<int>(Audio::Settings::ToneType::WITHOUT_MESSAGE)); + //TODO support voicemail + return Audio::Settings::ToneType::WITHOUT_MESSAGE; +} + +///Stop room tone if it is playing +void Audio::Settings::stopRoomTone() const +{ + CallManagerInterface& callManager = DBus::CallManager::instance(); + callManager.startTone(false,0); +} + +///Set if the roomtone is (globally) enabled +void Audio::Settings::setEnableRoomTone(bool enable) +{ + m_EnableRoomTone = enable; +} + +///Enable noise suppress code, may make things worst +void Audio::Settings::setNoiseSuppressState(bool enabled) +{ + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); + configurationManager.setNoiseSuppressState(enabled); +} + +///Enable noise suppress code, may make things worst +bool Audio::Settings::isNoiseSuppressEnabled() const +{ + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); + return configurationManager.getNoiseSuppressState(); +} + +///Mute playback +void Audio::Settings::mutePlayback(bool m) +{ + DBus::ConfigurationManager::instance().mutePlayback(m); + emit playbackMuted(m); +} + +///Mute capture +void Audio::Settings::muteCapture(bool m) +{ + DBus::ConfigurationManager::instance().muteCapture(m); + emit captureMuted(m); +} + +///is mute playback +bool Audio::Settings::isPlaybackMuted() const +{ + return DBus::ConfigurationManager::instance().isPlaybackMuted(); +} + +///is mute capture +bool Audio::Settings::isCaptureMuted() const +{ + return DBus::ConfigurationManager::instance().isCaptureMuted(); +} + +///Set where the call recordings will be saved +void Audio::Settings::setRecordPath(const QUrl& path) +{ + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); + configurationManager.setRecordPath(path.toString()); +} + +///Return the path where recordings are going to be saved +QUrl Audio::Settings::recordPath() const +{ + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); + return QUrl(configurationManager.getRecordPath()); +} + +///are all calls recorded by default +bool Audio::Settings::isAlwaysRecording() const +{ + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); + return configurationManager.getIsAlwaysRecording(); +} + +///Set if all calls needs to be recorded +void Audio::Settings::setAlwaysRecording(bool record) +{ + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); + configurationManager.setIsAlwaysRecording ( record ); +} + +int Audio::Settings::playbackVolume() const +{ + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); + return configurationManager.getVolume(DeviceKey::PLAYBACK)*100; +} + +int Audio::Settings::captureVolume() const +{ + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); + return configurationManager.getVolume(DeviceKey::CAPTURE)*100; +} + +void Audio::Settings::setPlaybackVolume(int volume) +{ + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); + configurationManager.setVolume(DeviceKey::PLAYBACK,volume/100.0f); + emit playbackVolumeChanged(volume); +} + +void Audio::Settings::setCaptureVolume(int volume) +{ + ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); + configurationManager.setVolume(DeviceKey::CAPTURE,volume/100.0f); + emit captureVolumeChanged(volume); +} + +void Audio::Settings::setDTMFMuted(bool muted) +{ + //TODO + DBus::ConfigurationManager::instance().muteDtmf(muted); + emit DTMFMutedChanged(muted); +} + +bool Audio::Settings::areDTMFMuted() const +{ + return DBus::ConfigurationManager::instance().isDtmfMuted(); +} + +///Called when the volume change for external reasons +void Audio::Settings::slotVolumeChanged(const QString& str, double volume) +{ + if (str == Audio::Settings::DeviceKey::CAPTURE) + emit captureVolumeChanged(static_cast<int>(volume*100)); + else if (str == Audio::Settings::DeviceKey::PLAYBACK) + emit playbackVolumeChanged(static_cast<int>(volume*100)); + else + qDebug() << "Unknown audio device" << str; +} + diff --git a/src/audio/settings.h b/src/audio/settings.h new file mode 100644 index 0000000000000000000000000000000000000000..be36ce4a06a453f024c5c9fe5b8aa92d2303a36d --- /dev/null +++ b/src/audio/settings.h @@ -0,0 +1,124 @@ +/**************************************************************************** + * Copyright (C) 2013-2014 by Savoir-Faire Linux * + * Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see <http://www.gnu.org/licenses/>. * + ***************************************************************************/ +#ifndef SETTINGS_H +#define SETTINGS_H + +#include <QtCore/QAbstractListModel> + +//SFLPhone +#include "../typedefs.h" + +namespace Audio { + +class AlsaPluginModel ; +class InputDeviceModel ; +class OutputDeviceModel ; +class ManagerModel ; +class RingtoneDeviceModel; + +/** + * This class group all ComboBox models used by audio settings dialogs + */ +class LIB_EXPORT Settings : public QObject { + Q_OBJECT +public: + + enum class DeviceIndex { + OUTPUT = 0, + INPUT = 1, + RINGTONE = 2, + }; + + virtual ~Settings(); + static Settings* instance(); + + //Getters + Audio::AlsaPluginModel* alsaPluginModel () const; + Audio::InputDeviceModel* inputDeviceModel () const; + Audio::OutputDeviceModel* outputDeviceModel () const; + Audio::ManagerModel* managerModel () const; + Audio::RingtoneDeviceModel* ringtoneDeviceModel() const; + bool isRoomToneEnabled (); + bool isNoiseSuppressEnabled () const; + bool isPlaybackMuted () const; + bool isCaptureMuted () const; + bool isAlwaysRecording() const; + bool areDTMFMuted () const; + int playbackVolume () const; + int captureVolume () const; + QUrl recordPath () const; + + //Setters + void setEnableRoomTone ( bool enable ); + void setNoiseSuppressState( bool enabled ); + void setRecordPath ( const QUrl& path ); + void setAlwaysRecording ( bool record ); + + //Room tone type + enum class ToneType { + WITHOUT_MESSAGE = 0, + WITH_MESSAGE = 1, + }; + + class DeviceKey { + public: + constexpr static const char* CAPTURE = "mic" ; + constexpr static const char* PLAYBACK = "speaker"; + }; + + //Mutator + ToneType playRoomTone() const; + void stopRoomTone() const; + +public Q_SLOTS: + void reload ( ); + void mutePlayback ( bool m ); + void muteCapture ( bool m ); + void setPlaybackVolume( int volume ); + void setCaptureVolume ( int volume ); + void setDTMFMuted ( bool muted ); + +Q_SIGNALS: + void captureMuted(bool); + void playbackMuted(bool); + void playbackVolumeChanged(int); + void captureVolumeChanged(int); + void DTMFMutedChanged(bool); + +private Q_SLOTS: + void slotVolumeChanged(const QString& str, double volume); + +private: + //Constructor + explicit Settings(); + + //Attributes + mutable AlsaPluginModel* m_pAlsaPluginModel ; + mutable InputDeviceModel* m_pInputDeviceModel ; + mutable OutputDeviceModel* m_pOutputDeviceModel ; + mutable ManagerModel* m_pAudioManagerModel ; + mutable RingtoneDeviceModel* m_pRingtoneDeviceModel; + bool m_EnableRoomTone ; + + //Singleton + static Settings* m_spInstance; +}; + +} + +#endif \ No newline at end of file diff --git a/src/audiosettingsmodel.cpp b/src/audiosettingsmodel.cpp deleted file mode 100644 index dda273314d904310920e22b4cd300bd55df098fc..0000000000000000000000000000000000000000 --- a/src/audiosettingsmodel.cpp +++ /dev/null @@ -1,740 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2013-2014 by Savoir-Faire Linux * - * Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2.1 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * - * Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see <http://www.gnu.org/licenses/>. * - ***************************************************************************/ -#include "audiosettingsmodel.h" -#include "dbus/configurationmanager.h" -#include "dbus/callmanager.h" - -AudioSettingsModel* AudioSettingsModel::m_spInstance = nullptr; - -///Constructor -AudioSettingsModel::AudioSettingsModel() : QObject(),m_EnableRoomTone(false), - m_pAlsaPluginModel (nullptr), m_pInputDeviceModel (nullptr), - m_pAudioManagerModel(nullptr), m_pRingtoneDeviceModel(nullptr), - m_pOutputDeviceModel(nullptr) -{ - m_pRingtoneDeviceModel = new RingtoneDeviceModel (this); - ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - connect(&configurationManager,SIGNAL(volumeChanged(QString,double)),this,SLOT(slotVolumeChanged(QString,double))); -} - -///Destructor -AudioSettingsModel::~AudioSettingsModel() -{ - delete m_pAlsaPluginModel ; - delete m_pInputDeviceModel ; - delete m_pOutputDeviceModel ; - delete m_pAudioManagerModel ; - delete m_pRingtoneDeviceModel; -} - -///Singleton -AudioSettingsModel* AudioSettingsModel::instance() -{ - if (!m_spInstance) - m_spInstance = new AudioSettingsModel(); - return m_spInstance; -} - -///Return plugin model (alsa only for the time being) -AlsaPluginModel* AudioSettingsModel::alsaPluginModel() -{ - if (!m_pAlsaPluginModel) - m_pAlsaPluginModel = new AlsaPluginModel(this); - return m_pAlsaPluginModel; -} - -///Return the input device model -InputDeviceModel* AudioSettingsModel::inputDeviceModel() -{ - if (!m_pInputDeviceModel) - m_pInputDeviceModel = new InputDeviceModel(this); - return m_pInputDeviceModel; -} - -///Return the output device model -OutputDeviceModel* AudioSettingsModel::outputDeviceModel() -{ - if (!m_pOutputDeviceModel) - m_pOutputDeviceModel = new OutputDeviceModel(this); - return m_pOutputDeviceModel; -} - -///Return audio manager -AudioManagerModel* AudioSettingsModel::audioManagerModel() -{ - if (!m_pAudioManagerModel) - m_pAudioManagerModel = new AudioManagerModel(this); - return m_pAudioManagerModel; -} - -///Return the ringtone device model -RingtoneDeviceModel* AudioSettingsModel::ringtoneDeviceModel() -{ - if (!m_pRingtoneDeviceModel) - m_pRingtoneDeviceModel = new RingtoneDeviceModel (this); - return m_pRingtoneDeviceModel; -} - -///Is the room tone (globally) enabled -bool AudioSettingsModel::isRoomToneEnabled() -{ - return m_EnableRoomTone; -} - -///Reload everything -void AudioSettingsModel::reload() -{ - m_pAlsaPluginModel->reload(); - m_pInputDeviceModel->reload(); - m_pOutputDeviceModel->reload(); -// m_pAudioManagerModel->reload(); - m_pRingtoneDeviceModel->reload(); -} - -///Play room tone -AudioSettingsModel::ToneType AudioSettingsModel::playRoomTone() const -{ - CallManagerInterface& callManager = DBus::CallManager::instance(); - callManager.startTone(true,static_cast<int>(AudioSettingsModel::ToneType::WITHOUT_MESSAGE)); - //TODO support voicemail - return AudioSettingsModel::ToneType::WITHOUT_MESSAGE; -} - -///Stop room tone if it is playing -void AudioSettingsModel::stopRoomTone() const -{ - CallManagerInterface& callManager = DBus::CallManager::instance(); - callManager.startTone(false,0); -} - -///Set if the roomtone is (globally) enabled -void AudioSettingsModel::setEnableRoomTone(bool enable) -{ - m_EnableRoomTone = enable; -} - -///Enable noise suppress code, may make things worst -void AudioSettingsModel::setNoiseSuppressState(bool enabled) -{ - ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - configurationManager.setNoiseSuppressState(enabled); -} - -///Enable noise suppress code, may make things worst -bool AudioSettingsModel::isNoiseSuppressEnabled() const -{ - ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - return configurationManager.getNoiseSuppressState(); -} - -///Mute playback -void AudioSettingsModel::mutePlayback(bool m) -{ - DBus::ConfigurationManager::instance().mutePlayback(m); - emit playbackMuted(m); -} - -///Mute capture -void AudioSettingsModel::muteCapture(bool m) -{ - DBus::ConfigurationManager::instance().muteCapture(m); - emit captureMuted(m); -} - -///is mute playback -bool AudioSettingsModel::isPlaybackMuted() const -{ - return DBus::ConfigurationManager::instance().isPlaybackMuted(); -} - -///is mute capture -bool AudioSettingsModel::isCaptureMuted() const -{ - return DBus::ConfigurationManager::instance().isCaptureMuted(); -} - -///Set where the call recordings will be saved -void AudioSettingsModel::setRecordPath(const QUrl& path) -{ - ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - configurationManager.setRecordPath(path.toString()); -} - -///Return the path where recordings are going to be saved -QUrl AudioSettingsModel::recordPath() const -{ - ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - return QUrl(configurationManager.getRecordPath()); -} - -///are all calls recorded by default -bool AudioSettingsModel::isAlwaysRecording() const -{ - ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - return configurationManager.getIsAlwaysRecording(); -} - -///Set if all calls needs to be recorded -void AudioSettingsModel::setAlwaysRecording(bool record) -{ - ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - configurationManager.setIsAlwaysRecording ( record ); -} - -int AudioSettingsModel::playbackVolume() const -{ - ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - return configurationManager.getVolume(DeviceKey::PLAYBACK)*100; -} - -int AudioSettingsModel::captureVolume() const -{ - ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - return configurationManager.getVolume(DeviceKey::CAPTURE)*100; -} - -void AudioSettingsModel::setPlaybackVolume(int volume) -{ - ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - configurationManager.setVolume(DeviceKey::PLAYBACK,volume/100.0f); - emit playbackVolumeChanged(volume); -} - -void AudioSettingsModel::setCaptureVolume(int volume) -{ - ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - configurationManager.setVolume(DeviceKey::CAPTURE,volume/100.0f); - emit captureVolumeChanged(volume); -} - -void AudioSettingsModel::setDTMFMuted(bool muted) -{ - //TODO - DBus::ConfigurationManager::instance().muteDtmf(muted); - emit DTMFMutedChanged(muted); -} - -bool AudioSettingsModel::areDTMFMuted() const -{ - return DBus::ConfigurationManager::instance().isDtmfMuted(); -} - -///Called when the volume change for external reasons -void AudioSettingsModel::slotVolumeChanged(const QString& str, double volume) -{ - if (str == AudioSettingsModel::DeviceKey::CAPTURE) - emit captureVolumeChanged(static_cast<int>(volume*100)); - else if (str == AudioSettingsModel::DeviceKey::PLAYBACK) - emit playbackVolumeChanged(static_cast<int>(volume*100)); - else - qDebug() << "Unknown audio device" << str; -} - - -/**************************************************************** - * * - * AlsaPluginModel * - * * - ***************************************************************/ -///Constructor -AlsaPluginModel::AlsaPluginModel(QObject* parent) : QAbstractListModel(parent) -{ - ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - m_lDeviceList = configurationManager.getAudioPluginList(); -} - -///Destructor -AlsaPluginModel::~AlsaPluginModel() -{ - -} - -///Re-implement QAbstractListModel data -QVariant AlsaPluginModel::data( const QModelIndex& index, int role) const -{ - if (!index.isValid()) - return QVariant(); - switch(role) { - case Qt::DisplayRole: - return m_lDeviceList[index.row()]; - }; - return QVariant(); -} - -///Re-implement QAbstractListModel rowCount -int AlsaPluginModel::rowCount( const QModelIndex& parent ) const -{ - if (parent.isValid()) - return 0; - return m_lDeviceList.size(); -} - -///Re-implement QAbstractListModel flags -Qt::ItemFlags AlsaPluginModel::flags( const QModelIndex& index ) const -{ - Q_UNUSED(index) - return Qt::ItemIsEnabled | Qt::ItemIsSelectable; -} - -///Setting data is disabled -bool AlsaPluginModel::setData( const QModelIndex& index, const QVariant &value, int role) -{ - Q_UNUSED(index) - Q_UNUSED(value) - Q_UNUSED(role) - return false; -} - -///Return the current index -QModelIndex AlsaPluginModel::currentPlugin() const -{ - ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - const int idx = m_lDeviceList.indexOf(configurationManager.getCurrentAudioOutputPlugin()); - qDebug() << "Invalid current audio plugin"; - if (idx == -1) - return QModelIndex(); - else - return index(idx,0,QModelIndex()); -} - -///Set the current index -void AlsaPluginModel::setCurrentPlugin(const QModelIndex& idx) -{ - if (!idx.isValid()) - return; - ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - configurationManager.setAudioPlugin(m_lDeviceList[idx.row()]); -} - -///Set the current index (qcombobox compatibility shim) -void AlsaPluginModel::setCurrentPlugin(int idx) -{ - setCurrentPlugin(index(idx,0)); -} - -///Reload to current daemon state -void AlsaPluginModel::reload() -{ - ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - m_lDeviceList = configurationManager.getAudioPluginList(); - emit layoutChanged(); - emit dataChanged(index(0,0),index(m_lDeviceList.size()-1,0)); -} - - -/**************************************************************** - * * - * InputDeviceModel * - * * - ***************************************************************/ - -///Constructor -InputDeviceModel::InputDeviceModel(QObject* parent) : QAbstractListModel(parent) -{ - ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - m_lDeviceList = configurationManager.getAudioInputDeviceList (); -} - -///Destructor -InputDeviceModel::~InputDeviceModel() -{ - -} - -///Re-implement QAbstractListModel data -QVariant InputDeviceModel::data( const QModelIndex& index, int role) const -{ - if (!index.isValid()) - return QVariant(); - switch(role) { - case Qt::DisplayRole: - return m_lDeviceList[index.row()]; - }; - return QVariant(); -} - -///Re-implement QAbstractListModel rowCount -int InputDeviceModel::rowCount( const QModelIndex& parent ) const -{ - if (parent.isValid()) - return 0; - return m_lDeviceList.size(); -} - -///Re-implement QAbstractListModel flags -Qt::ItemFlags InputDeviceModel::flags( const QModelIndex& index ) const -{ - Q_UNUSED(index) - return Qt::ItemIsEnabled | Qt::ItemIsSelectable; -} - -///This model does not support setting data -bool InputDeviceModel::setData( const QModelIndex& index, const QVariant &value, int role) -{ - Q_UNUSED(index) - Q_UNUSED(value) - Q_UNUSED(role) - return false; -} - -///Return the current input device index -QModelIndex InputDeviceModel::currentDevice() const -{ - ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - const QStringList currentDevices = configurationManager.getCurrentAudioDevicesIndex(); - const int idx = currentDevices[static_cast<int>(AudioSettingsModel::DeviceIndex::INPUT)].toInt(); - if (idx >= m_lDeviceList.size()) - return QModelIndex(); - return index(idx,0); -} - -///Set the current input device -void InputDeviceModel::setCurrentDevice(const QModelIndex& index) -{ - if (index.isValid()) { - ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - configurationManager.setAudioInputDevice(index.row()); - } -} - -///QCombobox signals -> QModelIndex shim -void InputDeviceModel::setCurrentDevice(int idx) -{ - setCurrentDevice(index(idx,0)); -} - -///Reload input device list -void InputDeviceModel::reload() -{ - ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - m_lDeviceList = configurationManager.getAudioInputDeviceList (); - emit layoutChanged(); - emit dataChanged(index(0,0),index(m_lDeviceList.size()-1,0)); -} - - -/**************************************************************** - * * - * OutputDeviceModel * - * * - ***************************************************************/ - -///Constructor -OutputDeviceModel::OutputDeviceModel(QObject* parent) : QAbstractListModel(parent) -{ - ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - m_lDeviceList = configurationManager.getAudioOutputDeviceList(); -} - -///Destructor -OutputDeviceModel::~OutputDeviceModel() -{ - -} - -///Re-implement QAbstractListModel data -QVariant OutputDeviceModel::data( const QModelIndex& index, int role) const -{ - if (!index.isValid()) - return QVariant(); - switch(role) { - case Qt::DisplayRole: - return m_lDeviceList[index.row()]; - }; - return QVariant(); -} - -///Re-implement QAbstractListModel rowCount -int OutputDeviceModel::rowCount( const QModelIndex& parent ) const -{ - if (parent.isValid()) - return 0; - return m_lDeviceList.size(); -} - -///Re-implement QAbstractListModel flags -Qt::ItemFlags OutputDeviceModel::flags( const QModelIndex& index ) const -{ - Q_UNUSED(index) - return Qt::ItemIsEnabled | Qt::ItemIsSelectable; -} - -///This model is read only -bool OutputDeviceModel::setData( const QModelIndex& index, const QVariant &value, int role) -{ - Q_UNUSED(index) - Q_UNUSED(value) - Q_UNUSED(role) - return false; -} - -///Return the current output device -QModelIndex OutputDeviceModel::currentDevice() const -{ - ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - const QStringList currentDevices = configurationManager.getCurrentAudioDevicesIndex(); - const int idx = currentDevices[static_cast<int>(AudioSettingsModel::DeviceIndex::OUTPUT)].toInt(); - - if (idx >= m_lDeviceList.size()) - return QModelIndex(); - return index(idx,0); -} - -///Set the current output device -void OutputDeviceModel::setCurrentDevice(const QModelIndex& index) -{ - if (index.isValid()) { - ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - configurationManager.setAudioOutputDevice(index.row()); - } -} - -///QCombobox index -> QModelIndex shim -void OutputDeviceModel::setCurrentDevice(int idx) -{ - setCurrentDevice(index(idx,0)); -} - -///reload output devices list -void OutputDeviceModel::reload() -{ - ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - m_lDeviceList = configurationManager.getAudioOutputDeviceList(); - emit layoutChanged(); - emit dataChanged(index(0,0),index(m_lDeviceList.size()-1,0)); -} - -/**************************************************************** - * * - * AudioManagerModel * - * * - ***************************************************************/ - -///Constructor -AudioManagerModel::AudioManagerModel(QObject* parent) : QAbstractListModel(parent) -{ - ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - const QStringList managers = configurationManager.getSupportedAudioManagers(); - foreach(const QString& m,managers) { - if (m == ManagerName::PULSEAUDIO) { - m_lSupportedManagers << Manager::PULSE; - m_lDeviceList << "Pulse Audio"; - } - else if (m == ManagerName::ALSA) { - m_lSupportedManagers << Manager::ALSA; - m_lDeviceList<< "ALSA"; - } - else if (m == ManagerName::JACK) { - m_lSupportedManagers << Manager::JACK; - m_lDeviceList<< "Jack"; - } - else - qDebug() << "Unsupported audio manager" << m; - } -} - -///Destructor -AudioManagerModel::~AudioManagerModel() -{ - m_lDeviceList.clear(); -} - -///Re-implement QAbstractListModel data -QVariant AudioManagerModel::data( const QModelIndex& index, int role) const -{ - if (!index.isValid()) - return QVariant(); - switch(role) { - case Qt::DisplayRole: - return m_lDeviceList[index.row()]; - }; - return QVariant(); -} - -///Re-implement QAbstractListModel rowCount -int AudioManagerModel::rowCount( const QModelIndex& parent ) const -{ - if (parent.isValid()) - return 0; - return m_lDeviceList.size(); -} - -///Re-implement QAbstractListModel flags -Qt::ItemFlags AudioManagerModel::flags( const QModelIndex& index ) const -{ - Q_UNUSED(index) - return Qt::ItemIsEnabled | Qt::ItemIsSelectable; -} - -///This model is read only -bool AudioManagerModel::setData( const QModelIndex& index, const QVariant &value, int role) -{ - Q_UNUSED(index) - Q_UNUSED(value) - Q_UNUSED(role) - return false; -} - -/** - * Return the current audio manager - * @warning Changes to the current index model will invalid Input/Output/Ringtone devices models - */ -QModelIndex AudioManagerModel::currentManagerIndex() const -{ - ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - const QString manager = configurationManager.getAudioManager(); - if (manager == ManagerName::PULSEAUDIO) - return index((int)Manager::PULSE,0); - else if (manager == ManagerName::ALSA) - return index((int)Manager::ALSA,0); - else if (manager == ManagerName::JACK) - return index((int)Manager::JACK,0); - return QModelIndex(); -} - -AudioManagerModel::Manager AudioManagerModel::currentManager() const -{ - return m_lSupportedManagers[currentManagerIndex().row()]; -} - -///Set current audio manager -bool AudioManagerModel::setCurrentManager(const QModelIndex& idx) -{ - if (!idx.isValid()) - return false; - - bool ret = true; - ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - switch (m_lSupportedManagers[idx.row()]) { - case Manager::PULSE: - ret = configurationManager.setAudioManager(ManagerName::PULSEAUDIO); - AudioSettingsModel::instance()->reload(); - break; - case Manager::ALSA: - ret = configurationManager.setAudioManager(ManagerName::ALSA); - AudioSettingsModel::instance()->reload(); - break; - case Manager::JACK: - ret = configurationManager.setAudioManager(ManagerName::JACK); - AudioSettingsModel::instance()->reload(); - break; - }; - if (!ret) { - const QModelIndex& newIdx = currentManagerIndex(); - emit currentManagerChanged(currentManager()); - emit currentManagerChanged(newIdx); - emit currentManagerChanged(newIdx.row()); - } - return ret; -} - -///QCombobox -> QModelIndex shim -bool AudioManagerModel::setCurrentManager(int idx) -{ - return setCurrentManager(index(idx,0)); -} - -/**************************************************************** - * * - * RingtoneDeviceModel * - * * - ***************************************************************/ - -///Constructor -RingtoneDeviceModel::RingtoneDeviceModel(QObject* parent) : QAbstractListModel(parent) -{ - ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - m_lDeviceList = configurationManager.getAudioOutputDeviceList(); -} - -///Destructor -RingtoneDeviceModel::~RingtoneDeviceModel() -{ - -} - -///Re-implement QAbstractListModel data -QVariant RingtoneDeviceModel::data( const QModelIndex& index, int role) const -{ - if (!index.isValid()) - return QVariant(); - switch(role) { - case Qt::DisplayRole: - return m_lDeviceList[index.row()]; - }; - return QVariant(); -} - -///Re-implement QAbstractListModel rowCount -int RingtoneDeviceModel::rowCount( const QModelIndex& parent ) const -{ - if (parent.isValid()) - return 0; - return m_lDeviceList.size(); -} - -///Re-implement QAbstractListModel flags -Qt::ItemFlags RingtoneDeviceModel::flags( const QModelIndex& index ) const -{ - Q_UNUSED(index) - return Qt::ItemIsEnabled | Qt::ItemIsSelectable; -} - -///RingtoneDeviceModel is read only -bool RingtoneDeviceModel::setData( const QModelIndex& index, const QVariant &value, int role) -{ - Q_UNUSED(index) - Q_UNUSED(value) - Q_UNUSED(role) - return false; -} - -///Return the current ringtone device -QModelIndex RingtoneDeviceModel::currentDevice() const -{ - ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - const QStringList currentDevices = configurationManager.getCurrentAudioDevicesIndex(); - const int idx = currentDevices[static_cast<int>(AudioSettingsModel::DeviceIndex::RINGTONE)].toInt(); - if (idx >= m_lDeviceList.size()) - return QModelIndex(); - return index(idx,0); -} - -///Set the current ringtone device -void RingtoneDeviceModel::setCurrentDevice(const QModelIndex& index) -{ - if (index.isValid()) { - ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - configurationManager.setAudioRingtoneDevice(index.row()); - } -} - -///QCombobox -> QModelIndex shim -void RingtoneDeviceModel::setCurrentDevice(int idx) -{ - setCurrentDevice(index(idx,0)); -} - -///Reload ringtone device list -void RingtoneDeviceModel::reload() -{ - ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance(); - m_lDeviceList = configurationManager.getAudioOutputDeviceList(); - emit layoutChanged(); - emit dataChanged(index(0,0),index(m_lDeviceList.size()-1,0)); -} diff --git a/src/audiosettingsmodel.h b/src/audiosettingsmodel.h deleted file mode 100644 index 72db9daf9a8b0114b1d6fb92a20a836add601e65..0000000000000000000000000000000000000000 --- a/src/audiosettingsmodel.h +++ /dev/null @@ -1,270 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2013-2014 by Savoir-Faire Linux * - * Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2.1 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * - * Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see <http://www.gnu.org/licenses/>. * - ***************************************************************************/ -#ifndef AUDIOSETTINGSMODEL_H -#define AUDIOSETTINGSMODEL_H - -#include <QtCore/QObject> -#include <QtCore/QStringList> -#include <QtCore/QAbstractListModel> - -#include "typedefs.h" - -class AlsaPluginModel ; -class InputDeviceModel ; -class OutputDeviceModel ; -class AudioManagerModel ; -class RingtoneDeviceModel; - -/** - * This class group all ComboBox models used by audio settings dialogs - */ -class LIB_EXPORT AudioSettingsModel : public QObject { - Q_OBJECT -public: - - enum class DeviceIndex { - OUTPUT = 0, - INPUT = 1, - RINGTONE = 2, - }; - - virtual ~AudioSettingsModel(); - static AudioSettingsModel* instance(); - - //Getters - AlsaPluginModel* alsaPluginModel (); - InputDeviceModel* inputDeviceModel (); - OutputDeviceModel* outputDeviceModel (); - AudioManagerModel* audioManagerModel (); - RingtoneDeviceModel* ringtoneDeviceModel(); - bool isRoomToneEnabled (); - bool isNoiseSuppressEnabled () const; - bool isPlaybackMuted () const; - bool isCaptureMuted () const; - bool isAlwaysRecording() const; - bool areDTMFMuted () const; - int playbackVolume () const; - int captureVolume () const; - QUrl recordPath () const; - - //Setters - void setEnableRoomTone ( bool enable ); - void setNoiseSuppressState( bool enabled ); - void setRecordPath ( const QUrl& path ); - void setAlwaysRecording ( bool record ); - - //Room tone type - enum class ToneType { - WITHOUT_MESSAGE = 0, - WITH_MESSAGE = 1, - }; - - class DeviceKey { - public: - constexpr static const char* CAPTURE = "mic" ; - constexpr static const char* PLAYBACK = "speaker"; - }; - - //Mutator - ToneType playRoomTone() const; - void stopRoomTone() const; - -public Q_SLOTS: - void reload ( ); - void mutePlayback ( bool m ); - void muteCapture ( bool m ); - void setPlaybackVolume( int volume ); - void setCaptureVolume ( int volume ); - void setDTMFMuted ( bool muted ); - -Q_SIGNALS: - void captureMuted(bool); - void playbackMuted(bool); - void playbackVolumeChanged(int); - void captureVolumeChanged(int); - void DTMFMutedChanged(bool); - -private Q_SLOTS: - void slotVolumeChanged(const QString& str, double volume); - -private: - //Constructor - explicit AudioSettingsModel(); - - //Attributes - AlsaPluginModel* m_pAlsaPluginModel ; - InputDeviceModel* m_pInputDeviceModel ; - OutputDeviceModel* m_pOutputDeviceModel ; - AudioManagerModel* m_pAudioManagerModel ; - RingtoneDeviceModel* m_pRingtoneDeviceModel; - bool m_EnableRoomTone ; - - //Singleton - static AudioSettingsModel* m_spInstance; -}; - -class LIB_EXPORT AlsaPluginModel : public QAbstractListModel { - Q_OBJECT -public: - explicit AlsaPluginModel(QObject* parent); - virtual ~AlsaPluginModel(); - - //Models function - virtual QVariant data ( const QModelIndex& index, int role = Qt::DisplayRole ) const; - virtual int rowCount( const QModelIndex& parent = QModelIndex() ) const; - virtual Qt::ItemFlags flags ( const QModelIndex& index ) const; - virtual bool setData ( const QModelIndex& index, const QVariant &value, int role); - - //Getters - QModelIndex currentPlugin() const; - - //Setters - void setCurrentPlugin(const QModelIndex& idx); - void setCurrentPlugin(int idx); - - //Mutator - void reload(); - -private: - QStringList m_lDeviceList; -}; - -class LIB_EXPORT InputDeviceModel : public QAbstractListModel { - Q_OBJECT -public: - explicit InputDeviceModel(QObject* parent); - virtual ~InputDeviceModel(); - - //Models function - virtual QVariant data ( const QModelIndex& index, int role = Qt::DisplayRole ) const; - virtual int rowCount( const QModelIndex& parent = QModelIndex() ) const; - virtual Qt::ItemFlags flags ( const QModelIndex& index ) const; - virtual bool setData ( const QModelIndex& index, const QVariant &value, int role); - - //Getters - QModelIndex currentDevice() const; - - //Setters - void setCurrentDevice(const QModelIndex& index); - void setCurrentDevice(int idx); - - //Mutator - void reload(); - -private: - QStringList m_lDeviceList; -}; - -class LIB_EXPORT OutputDeviceModel : public QAbstractListModel { - Q_OBJECT -public: - explicit OutputDeviceModel(QObject* parent); - virtual ~OutputDeviceModel(); - - //Models function - virtual QVariant data ( const QModelIndex& index, int role = Qt::DisplayRole ) const; - virtual int rowCount( const QModelIndex& parent = QModelIndex() ) const; - virtual Qt::ItemFlags flags ( const QModelIndex& index ) const; - virtual bool setData ( const QModelIndex& index, const QVariant &value, int role); - - //Getters - QModelIndex currentDevice() const; - - //Setters - void setCurrentDevice(const QModelIndex& index); - void setCurrentDevice(int idx); - - //Mutator - void reload(); - -private: - QStringList m_lDeviceList; -}; - -class LIB_EXPORT AudioManagerModel : public QAbstractListModel { - Q_OBJECT -public: - - enum class Manager { - ALSA =0, - PULSE=1, - JACK =2, - }; - explicit AudioManagerModel(QObject* parent); - virtual ~AudioManagerModel(); - - //Models function - virtual QVariant data ( const QModelIndex& index, int role = Qt::DisplayRole ) const; - virtual int rowCount( const QModelIndex& parent = QModelIndex() ) const; - virtual Qt::ItemFlags flags ( const QModelIndex& index ) const; - virtual bool setData ( const QModelIndex& index, const QVariant &value, int role); - - //Getters - QModelIndex currentManagerIndex() const; - Manager currentManager() const; - - //Setters - bool setCurrentManager(const QModelIndex& index); - -public Q_SLOTS: - bool setCurrentManager(int idx); - -Q_SIGNALS: - void currentManagerChanged(Manager); - void currentManagerChanged(int); - void currentManagerChanged(const QModelIndex&); - -private: - class ManagerName { - public: - constexpr static const char* PULSEAUDIO = "pulseaudio"; - constexpr static const char* ALSA = "alsa" ; - constexpr static const char* JACK = "jack" ; - }; - - QStringList m_lDeviceList; - QList<Manager> m_lSupportedManagers; -}; - -class LIB_EXPORT RingtoneDeviceModel: public QAbstractListModel { - Q_OBJECT -public: - explicit RingtoneDeviceModel(QObject* parent); - virtual ~RingtoneDeviceModel(); - - //Models function - virtual QVariant data ( const QModelIndex& index, int role = Qt::DisplayRole ) const; - virtual int rowCount( const QModelIndex& parent = QModelIndex() ) const; - virtual Qt::ItemFlags flags ( const QModelIndex& index ) const; - virtual bool setData ( const QModelIndex& index, const QVariant &value, int role); - - //Getters - QModelIndex currentDevice() const; - - //Setters - void setCurrentDevice(const QModelIndex& index); - void setCurrentDevice(int idx); - - //Mutator - void reload(); - -private: - QStringList m_lDeviceList; -}; - -#endif //AUDIOSETTINGSMODEL_H diff --git a/src/call.cpp b/src/call.cpp index 80e35e86577d7520eca6129a6f6c248f983e4e81..ef4413da19cde386e2b82c564f02fb6131272afb 100644 --- a/src/call.cpp +++ b/src/call.cpp @@ -46,7 +46,7 @@ #include "phonenumber.h" #include "video/videorenderer.h" #include "tlsmethodmodel.h" -#include "audiosettingsmodel.h" +#include "audio/settings.h" #include "contactmodel.h" //Track where state changes are performed on finished (over, error, failed) calls @@ -325,8 +325,8 @@ Call* Call::buildDialingCall(const QString& callId, const QString & peerName, Ac Call* call = new Call(Call::State::DIALING, callId, peerName, nullptr, account); call->d_ptr->m_HistoryState = Call::LegacyHistoryState::NONE; call->d_ptr->m_Direction = Call::Direction::OUTGOING; - if (AudioSettingsModel::instance()->isRoomToneEnabled()) { - AudioSettingsModel::instance()->playRoomTone(); + if (Audio::Settings::instance()->isRoomToneEnabled()) { + Audio::Settings::instance()->playRoomTone(); } qDebug() << "Created dialing call" << call; return call;