1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2025-09-05 14:43:39 +02:00

settings: use default audio devices

Refactors audio settings to avoid list model code duplication. This code
could be greatly simplified by using string lists, however the combo-box
component design is highly dependent on QAbstractItemModel based models.

Also translates the handlebarred strings upon presentation, which is
currently used to translate the "Default" prefix for the first device
item.

Gitlab: #346
Change-Id: I5ed282d29cc4ec6a090a9cdf47b0459f0db2a99b
This commit is contained in:
Andreas Traczyk 2021-03-18 16:10:09 -04:00
parent 215f43492c
commit 28aa5aab6d
10 changed files with 177 additions and 410 deletions

View file

@ -58,9 +58,8 @@ set(COMMON_SOURCES
${SRC_DIR}/preferenceitemlistmodel.cpp ${SRC_DIR}/preferenceitemlistmodel.cpp
${SRC_DIR}/mediacodeclistmodel.cpp ${SRC_DIR}/mediacodeclistmodel.cpp
${SRC_DIR}/accountstomigratelistmodel.cpp ${SRC_DIR}/accountstomigratelistmodel.cpp
${SRC_DIR}/audioinputdevicemodel.cpp ${SRC_DIR}/audiodevicemodel.cpp
${SRC_DIR}/videoinputdevicemodel.cpp ${SRC_DIR}/videoinputdevicemodel.cpp
${SRC_DIR}/audiooutputdevicemodel.cpp
${SRC_DIR}/pluginlistpreferencemodel.cpp ${SRC_DIR}/pluginlistpreferencemodel.cpp
${SRC_DIR}/videoformatfpsmodel.cpp ${SRC_DIR}/videoformatfpsmodel.cpp
${SRC_DIR}/videoformatresolutionmodel.cpp ${SRC_DIR}/videoformatresolutionmodel.cpp
@ -109,9 +108,8 @@ set(COMMON_HEADERS
${SRC_DIR}/preferenceitemlistmodel.h ${SRC_DIR}/preferenceitemlistmodel.h
${SRC_DIR}/mediacodeclistmodel.h ${SRC_DIR}/mediacodeclistmodel.h
${SRC_DIR}/accountstomigratelistmodel.h ${SRC_DIR}/accountstomigratelistmodel.h
${SRC_DIR}/audioinputdevicemodel.h ${SRC_DIR}/audiodevicemodel.h
${SRC_DIR}/videoinputdevicemodel.h ${SRC_DIR}/videoinputdevicemodel.h
${SRC_DIR}/audiooutputdevicemodel.h
${SRC_DIR}/pluginlistpreferencemodel.h ${SRC_DIR}/pluginlistpreferencemodel.h
${SRC_DIR}/videoformatfpsmodel.h ${SRC_DIR}/videoformatfpsmodel.h
${SRC_DIR}/videoformatresolutionmodel.h ${SRC_DIR}/videoformatresolutionmodel.h

View file

@ -200,9 +200,8 @@ HEADERS += \
src/preferenceitemlistmodel.h \ src/preferenceitemlistmodel.h \
src/mediacodeclistmodel.h \ src/mediacodeclistmodel.h \
src/accountstomigratelistmodel.h \ src/accountstomigratelistmodel.h \
src/audioinputdevicemodel.h \ src/audiodevicemodel.h \
src/videoinputdevicemodel.h \ src/videoinputdevicemodel.h \
src/audiooutputdevicemodel.h \
src/pluginlistpreferencemodel.h \ src/pluginlistpreferencemodel.h \
src/videoformatfpsmodel.h \ src/videoformatfpsmodel.h \
src/videoformatresolutionmodel.h \ src/videoformatresolutionmodel.h \
@ -242,9 +241,8 @@ SOURCES += \
src/preferenceitemlistmodel.cpp \ src/preferenceitemlistmodel.cpp \
src/mediacodeclistmodel.cpp \ src/mediacodeclistmodel.cpp \
src/accountstomigratelistmodel.cpp \ src/accountstomigratelistmodel.cpp \
src/audioinputdevicemodel.cpp \ src/audiodevicemodel.cpp \
src/videoinputdevicemodel.cpp \ src/videoinputdevicemodel.cpp \
src/audiooutputdevicemodel.cpp \
src/pluginlistpreferencemodel.cpp \ src/pluginlistpreferencemodel.cpp \
src/videoformatfpsmodel.cpp \ src/videoformatfpsmodel.cpp \
src/videoformatresolutionmodel.cpp \ src/videoformatresolutionmodel.cpp \

123
src/audiodevicemodel.cpp Normal file
View file

@ -0,0 +1,123 @@
/*
* Copyright (C) 2021 by Savoir-faire Linux
* Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 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 "audiodevicemodel.h"
#include "lrcinstance.h"
AudioDeviceModel::AudioDeviceModel(QObject* parent)
: QAbstractListModel(parent)
{
connect(this, &AudioDeviceModel::typeChanged, this, &AudioDeviceModel::reset);
}
int
AudioDeviceModel::rowCount(const QModelIndex& parent) const
{
if (!parent.isValid()) {
return devices_.size();
}
return 0;
}
int
AudioDeviceModel::columnCount(const QModelIndex& parent) const
{
Q_UNUSED(parent);
return 1;
}
QVariant
AudioDeviceModel::data(const QModelIndex& index, int role) const
{
if (!index.isValid() || devices_.size() <= index.row()) {
return QVariant();
}
switch (role) {
case Qt::DisplayRole:
case Role::DeviceName: {
auto deviceName = devices_.at(index.row());
QRegularExpression re("{{(.*?)}}");
QRegularExpressionMatch match = re.match(deviceName);
if (match.hasMatch() && re.captureCount() > 0) {
deviceName.replace(match.captured(0), QObject::tr(match.captured(1).toUtf8()));
}
return QVariant(deviceName.toUtf8());
}
case Role::RawDeviceName:
return QVariant(devices_.at(index.row()));
default:
break;
}
return QVariant();
}
QHash<int, QByteArray>
AudioDeviceModel::roleNames() const
{
QHash<int, QByteArray> roles;
roles[DeviceName] = "DeviceName";
roles[RawDeviceName] = "RawDeviceName";
return roles;
}
QModelIndex
AudioDeviceModel::index(int row, int column, const QModelIndex&) const
{
if (column != 0) {
return QModelIndex();
}
if (row >= 0 && row < rowCount()) {
return createIndex(row, column);
}
return QModelIndex();
}
QModelIndex
AudioDeviceModel::parent(const QModelIndex&) const
{
return QModelIndex();
}
Qt::ItemFlags
AudioDeviceModel::flags(const QModelIndex& index) const
{
auto flags = QAbstractItemModel::flags(index) | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable;
if (!index.isValid()) {
return QAbstractItemModel::flags(index);
}
return flags;
}
void
AudioDeviceModel::reset()
{
beginResetModel();
devices_ = type_ == Type::Record ? LRCInstance::avModel().getAudioInputDevices()
: LRCInstance::avModel().getAudioOutputDevices();
endResetModel();
}
int
AudioDeviceModel::getCurrentIndex()
{
QString currentId = LRCInstance::avModel().getInputDevice();
auto resultList = match(index(0, 0), Qt::DisplayRole, QVariant(currentId));
return resultList.size() > 0 ? resultList[0].row() : 0;
}

View file

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2019-2020 by Savoir-faire Linux * Copyright (C) 2021 by Savoir-faire Linux
* Author: Yang Wang <yang.wang@savoirfairelinux.com> * Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -20,22 +20,23 @@
#include <QAbstractItemModel> #include <QAbstractItemModel>
#include "api/account.h" class AudioDeviceModel : public QAbstractListModel
#include "api/contact.h"
#include "api/conversation.h"
#include "api/newdevicemodel.h"
#include "lrcinstance.h"
class AudioInputDeviceModel : public QAbstractListModel
{ {
Q_OBJECT Q_OBJECT
public: public:
enum Role { Device_ID = Qt::UserRole + 1, ID_UTF8 }; enum class Type { Invalid, Record, Playback, Ringtone };
Q_ENUM(Type)
Q_PROPERTY(Type type MEMBER type_ NOTIFY typeChanged)
enum Role { DeviceName = Qt::UserRole + 1, RawDeviceName };
Q_ENUM(Role) Q_ENUM(Role)
explicit AudioInputDeviceModel(QObject* parent = 0); signals:
~AudioInputDeviceModel(); void typeChanged();
public:
explicit AudioDeviceModel(QObject* parent = 0);
~AudioDeviceModel() = default;
/* /*
* QAbstractListModel override. * QAbstractListModel override.
@ -43,20 +44,22 @@ public:
int rowCount(const QModelIndex& parent = QModelIndex()) const override; int rowCount(const QModelIndex& parent = QModelIndex()) const override;
int columnCount(const QModelIndex& parent) const override; int columnCount(const QModelIndex& parent) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
/* /*
* Override role name as access point in qml. * Override role name as access point in qml.
*/ */
QHash<int, QByteArray> roleNames() const override; QHash<int, QByteArray> roleNames() const override;
QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const; QModelIndex index(int row,
QModelIndex parent(const QModelIndex& child) const; int column = 0,
Qt::ItemFlags flags(const QModelIndex& index) const; const QModelIndex& parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex& child) const override;
Qt::ItemFlags flags(const QModelIndex& index) const override;
/*
* This function is to reset the model when there's new account added.
*/
Q_INVOKABLE void reset(); Q_INVOKABLE void reset();
/* Q_INVOKABLE int getCurrentIndex();
* This function is to get the current device id in the demon.
*/ private:
Q_INVOKABLE int getCurrentSettingIndex(); QVector<QString> devices_;
Type type_ {Type::Invalid};
}; };

View file

@ -1,128 +0,0 @@
/*
* Copyright (C) 2019-2020 by Savoir-faire Linux
* Author: Yang Wang <yang.wang@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 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 "audioinputdevicemodel.h"
AudioInputDeviceModel::AudioInputDeviceModel(QObject* parent)
: QAbstractListModel(parent)
{}
AudioInputDeviceModel::~AudioInputDeviceModel() {}
int
AudioInputDeviceModel::rowCount(const QModelIndex& parent) const
{
if (!parent.isValid()) {
/*
* Count.
*/
return LRCInstance::avModel().getAudioInputDevices().size();
}
/*
* A valid QModelIndex returns 0 as no entry has sub-elements.
*/
return 0;
}
int
AudioInputDeviceModel::columnCount(const QModelIndex& parent) const
{
Q_UNUSED(parent);
/*
* Only need one column.
*/
return 1;
}
QVariant
AudioInputDeviceModel::data(const QModelIndex& index, int role) const
{
auto deviceList = LRCInstance::avModel().getAudioInputDevices();
if (!index.isValid() || deviceList.size() <= index.row()) {
return QVariant();
}
switch (role) {
case Role::Device_ID:
return QVariant(deviceList.at(index.row()));
case Role::ID_UTF8:
return QVariant(deviceList.at(index.row()).toUtf8());
}
return QVariant();
}
QHash<int, QByteArray>
AudioInputDeviceModel::roleNames() const
{
QHash<int, QByteArray> roles;
roles[Device_ID] = "Device_ID";
roles[ID_UTF8] = "ID_UTF8";
return roles;
}
QModelIndex
AudioInputDeviceModel::index(int row, int column, const QModelIndex& parent) const
{
Q_UNUSED(parent);
if (column != 0) {
return QModelIndex();
}
if (row >= 0 && row < rowCount()) {
return createIndex(row, column);
}
return QModelIndex();
}
QModelIndex
AudioInputDeviceModel::parent(const QModelIndex& child) const
{
Q_UNUSED(child);
return QModelIndex();
}
Qt::ItemFlags
AudioInputDeviceModel::flags(const QModelIndex& index) const
{
auto flags = QAbstractItemModel::flags(index) | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable;
if (!index.isValid()) {
return QAbstractItemModel::flags(index);
}
return flags;
}
void
AudioInputDeviceModel::reset()
{
beginResetModel();
endResetModel();
}
int
AudioInputDeviceModel::getCurrentSettingIndex()
{
QString currentId = LRCInstance::avModel().getInputDevice();
auto resultList = match(index(0, 0), Device_ID, QVariant(currentId));
int resultRowIndex = 0;
if (resultList.size() > 0) {
resultRowIndex = resultList[0].row();
}
return resultRowIndex;
}

View file

@ -1,142 +0,0 @@
/*
* Copyright (C) 2019-2020 by Savoir-faire Linux
* Author: Yang Wang <yang.wang@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 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 "audiooutputdevicemodel.h"
AudioOutputDeviceModel::AudioOutputDeviceModel(QObject* parent)
: QAbstractListModel(parent)
{}
AudioOutputDeviceModel::~AudioOutputDeviceModel() {}
int
AudioOutputDeviceModel::rowCount(const QModelIndex& parent) const
{
if (!parent.isValid()) {
/*
* Count.
*/
return LRCInstance::avModel().getAudioOutputDevices().size();
}
/*
* A valid QModelIndex returns 0 as no entry has sub-elements.
*/
return 0;
}
int
AudioOutputDeviceModel::columnCount(const QModelIndex& parent) const
{
Q_UNUSED(parent);
/*
* Only need one column.
*/
return 1;
}
QVariant
AudioOutputDeviceModel::data(const QModelIndex& index, int role) const
{
auto deviceList = LRCInstance::avModel().getAudioOutputDevices();
if (!index.isValid() || deviceList.size() <= index.row()) {
return QVariant();
}
switch (role) {
case Role::Device_ID:
return QVariant(deviceList.at(index.row()));
case Role::ID_UTF8:
return QVariant(deviceList.at(index.row()).toUtf8());
}
return QVariant();
}
QHash<int, QByteArray>
AudioOutputDeviceModel::roleNames() const
{
QHash<int, QByteArray> roles;
roles[Device_ID] = "Device_ID";
roles[ID_UTF8] = "ID_UTF8";
return roles;
}
QModelIndex
AudioOutputDeviceModel::index(int row, int column, const QModelIndex& parent) const
{
Q_UNUSED(parent);
if (column != 0) {
return QModelIndex();
}
if (row >= 0 && row < rowCount()) {
return createIndex(row, column);
}
return QModelIndex();
}
QModelIndex
AudioOutputDeviceModel::parent(const QModelIndex& child) const
{
Q_UNUSED(child);
return QModelIndex();
}
Qt::ItemFlags
AudioOutputDeviceModel::flags(const QModelIndex& index) const
{
auto flags = QAbstractItemModel::flags(index) | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable;
if (!index.isValid()) {
return QAbstractItemModel::flags(index);
}
return flags;
}
void
AudioOutputDeviceModel::reset()
{
beginResetModel();
endResetModel();
}
int
AudioOutputDeviceModel::getCurrentSettingIndex()
{
QString currentId = LRCInstance::avModel().getOutputDevice();
auto resultList = match(index(0, 0), Device_ID, QVariant(currentId));
int resultRowIndex = 0;
if (resultList.size() > 0) {
resultRowIndex = resultList[0].row();
}
return resultRowIndex;
}
int
AudioOutputDeviceModel::getCurrentRingtoneDeviceIndex()
{
QString currentId = LRCInstance::avModel().getRingtoneDevice();
auto resultList = match(index(0, 0), Device_ID, QVariant(currentId));
int resultRowIndex = 0;
if (resultList.size() > 0) {
resultRowIndex = resultList[0].row();
}
return resultRowIndex;
}

View file

@ -1,66 +0,0 @@
/*
* Copyright (C) 2019-2020 by Savoir-faire Linux
* Author: Yang Wang <yang.wang@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 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/>.
*/
#pragma once
#include <QAbstractItemModel>
#include "api/account.h"
#include "api/contact.h"
#include "api/conversation.h"
#include "api/newdevicemodel.h"
#include "lrcinstance.h"
class AudioOutputDeviceModel : public QAbstractListModel
{
Q_OBJECT
public:
enum Role { Device_ID = Qt::UserRole + 1, ID_UTF8 };
Q_ENUM(Role)
explicit AudioOutputDeviceModel(QObject* parent = 0);
~AudioOutputDeviceModel();
/*
* QAbstractListModel override.
*/
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
int columnCount(const QModelIndex& parent) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
/*
* Override role name as access point in qml.
*/
QHash<int, QByteArray> roleNames() const override;
QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex& child) const;
Qt::ItemFlags flags(const QModelIndex& index) const;
/*
* This function is to reset the model when there's new account added.
*/
Q_INVOKABLE void reset();
/*
* This function is to get the current device id in the demon.
*/
Q_INVOKABLE int getCurrentSettingIndex();
/*
* This function is to get the current ringtone device id in the demon.
*/
Q_INVOKABLE int getCurrentRingtoneDeviceIndex();
};

View file

@ -22,6 +22,7 @@ import QtQuick.Controls.Universal 2.14
import QtQuick.Layouts 1.14 import QtQuick.Layouts 1.14
import QtGraphicalEffects 1.14 import QtGraphicalEffects 1.14
import QtQuick.Controls.Styles 1.4 import QtQuick.Controls.Styles 1.4
import net.jami.Constants 1.0 import net.jami.Constants 1.0
ComboBox { ComboBox {
@ -37,8 +38,6 @@ ComboBox {
width: root.width width: root.width
contentItem: Text { contentItem: Text {
text: { text: {
if (index < 0)
return qsTr("")
var currentItem = root.delegateModel.items.get(index) var currentItem = root.delegateModel.items.get(index)
return currentItem.model[root.textRole].toString() return currentItem.model[root.textRole].toString()
} }

View file

@ -21,9 +21,8 @@
#include "accountadapter.h" #include "accountadapter.h"
#include "accountstomigratelistmodel.h" #include "accountstomigratelistmodel.h"
#include "mediacodeclistmodel.h" #include "mediacodeclistmodel.h"
#include "audioinputdevicemodel.h" #include "audiodevicemodel.h"
#include "audiomanagerlistmodel.h" #include "audiomanagerlistmodel.h"
#include "audiooutputdevicemodel.h"
#include "avadapter.h" #include "avadapter.h"
#include "bannedlistmodel.h" #include "bannedlistmodel.h"
#include "moderatorlistmodel.h" #include "moderatorlistmodel.h"
@ -107,8 +106,7 @@ registerTypes()
QML_REGISTERTYPE("net.jami.Models", ModeratorListModel, 1, 0); QML_REGISTERTYPE("net.jami.Models", ModeratorListModel, 1, 0);
QML_REGISTERTYPE("net.jami.Models", MediaCodecListModel, 1, 0); QML_REGISTERTYPE("net.jami.Models", MediaCodecListModel, 1, 0);
QML_REGISTERTYPE("net.jami.Models", AccountsToMigrateListModel, 1, 0); QML_REGISTERTYPE("net.jami.Models", AccountsToMigrateListModel, 1, 0);
QML_REGISTERTYPE("net.jami.Models", AudioInputDeviceModel, 1, 0); QML_REGISTERTYPE("net.jami.Models", AudioDeviceModel, 1, 0);
QML_REGISTERTYPE("net.jami.Models", AudioOutputDeviceModel, 1, 0);
QML_REGISTERTYPE("net.jami.Models", AudioManagerListModel, 1, 0); QML_REGISTERTYPE("net.jami.Models", AudioManagerListModel, 1, 0);
QML_REGISTERTYPE("net.jami.Models", VideoInputDeviceModel, 1, 0); QML_REGISTERTYPE("net.jami.Models", VideoInputDeviceModel, 1, 0);
QML_REGISTERTYPE("net.jami.Models", VideoFormatResolutionModel, 1, 0); QML_REGISTERTYPE("net.jami.Models", VideoFormatResolutionModel, 1, 0);

View file

@ -17,12 +17,8 @@
*/ */
import QtQuick 2.14 import QtQuick 2.14
import QtQuick.Controls 2.14
import QtQuick.Controls.Universal 2.14
import QtQuick.Layouts 1.14 import QtQuick.Layouts 1.14
import QtGraphicalEffects 1.14
import QtQuick.Controls.Styles 1.4
import Qt.labs.platform 1.1
import net.jami.Models 1.0 import net.jami.Models 1.0
import net.jami.Adapters 1.0 import net.jami.Adapters 1.0
import net.jami.Enums 1.0 import net.jami.Enums 1.0
@ -43,24 +39,15 @@ ColumnLayout {
} }
function populateAudioSettings() { function populateAudioSettings() {
inputComboBoxSetting.comboModel.reset() inputComboBoxSetting.setCurrentIndex(inputComboBoxSetting.comboModel.getCurrentIndex())
audioOutputDeviceModel.reset() outputComboBoxSetting.setCurrentIndex(outputComboBoxSetting.comboModel.getCurrentIndex())
audioManagerComboBoxSetting.comboModel.reset() ringtoneComboBoxSetting.setCurrentIndex(outputComboBoxSetting.comboModel.getCurrentIndex())
inputComboBoxSetting.setCurrentIndex(inputComboBoxSetting.comboModel.getCurrentSettingIndex())
outputComboBoxSetting.setCurrentIndex(audioOutputDeviceModel.getCurrentSettingIndex())
ringtoneDeviceComboBoxSetting.setCurrentIndex(audioOutputDeviceModel.getCurrentRingtoneDeviceIndex())
if(audioManagerComboBoxSetting.comboModel.rowCount() > 0) { if(audioManagerComboBoxSetting.comboModel.rowCount() > 0) {
audioManagerComboBoxSetting.setCurrentIndex(audioManagerComboBoxSetting.comboModel.getCurrentSettingIndex()) audioManagerComboBoxSetting.setCurrentIndex(audioManagerComboBoxSetting.comboModel.getCurrentSettingIndex())
} }
audioManagerComboBoxSetting.visible = (audioManagerComboBoxSetting.comboModel.rowCount() > 0) audioManagerComboBoxSetting.visible = (audioManagerComboBoxSetting.comboModel.rowCount() > 0)
} }
AudioOutputDeviceModel{
id: audioOutputDeviceModel
}
ElidedTextLabel { ElidedTextLabel {
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: JamiTheme.preferredFieldHeight Layout.preferredHeight: JamiTheme.preferredFieldHeight
@ -79,17 +66,16 @@ ColumnLayout {
labelText: JamiStrings.microphone labelText: JamiStrings.microphone
fontPointSize: JamiTheme.settingsFontSize fontPointSize: JamiTheme.settingsFontSize
comboModel: AudioInputDeviceModel {} comboModel: AudioDeviceModel { type: AudioDeviceModel.Type.Record }
widthOfComboBox: itemWidth widthOfComboBox: itemWidth
tipText: JamiStrings.selectAudioInputDevice tipText: JamiStrings.selectAudioInputDevice
role: "ID_UTF8" role: "DeviceName"
onIndexChanged: { onIndexChanged: {
AvAdapter.stopAudioMeter(false) AvAdapter.stopAudioMeter(false)
var selectedInputDeviceName = comboModel.data( AVModel.setInputDevice(comboModel.data(
comboModel.index(modelIndex, 0), comboModel.index(modelIndex, 0),
AudioInputDeviceModel.Device_ID) AudioDeviceModel.RawDeviceName))
AVModel.setInputDevice(selectedInputDeviceName)
AvAdapter.startAudioMeter(false) AvAdapter.startAudioMeter(false)
} }
} }
@ -116,23 +102,22 @@ ColumnLayout {
labelText: JamiStrings.outputDevice labelText: JamiStrings.outputDevice
fontPointSize: JamiTheme.settingsFontSize fontPointSize: JamiTheme.settingsFontSize
comboModel: audioOutputDeviceModel comboModel: AudioDeviceModel { type: AudioDeviceModel.Type.Playback }
widthOfComboBox: itemWidth widthOfComboBox: itemWidth
tipText: JamiStrings.selectAudioOutputDevice tipText: JamiStrings.selectAudioOutputDevice
role: "ID_UTF8" role: "DeviceName"
onIndexChanged: { onIndexChanged: {
AvAdapter.stopAudioMeter(false) AvAdapter.stopAudioMeter(false)
var selectedOutputDeviceName = audioOutputDeviceModel.data( AVModel.setOutputDevice(comboModel.data(
audioOutputDeviceModel.index(modelIndex, 0), comboModel.index(modelIndex, 0),
AudioOutputDeviceModel.Device_ID) AudioDeviceModel.RawDeviceName))
AVModel.setOutputDevice(selectedOutputDeviceName)
AvAdapter.startAudioMeter(false) AvAdapter.startAudioMeter(false)
} }
} }
SettingsComboBox { SettingsComboBox {
id: ringtoneDeviceComboBoxSetting id: ringtoneComboBoxSetting
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: JamiTheme.preferredFieldHeight Layout.preferredHeight: JamiTheme.preferredFieldHeight
@ -140,17 +125,16 @@ ColumnLayout {
labelText: JamiStrings.ringtoneDevice labelText: JamiStrings.ringtoneDevice
fontPointSize: JamiTheme.settingsFontSize fontPointSize: JamiTheme.settingsFontSize
comboModel: audioOutputDeviceModel comboModel: AudioDeviceModel { type: AudioDeviceModel.Type.Ringtone }
widthOfComboBox: itemWidth widthOfComboBox: itemWidth
tipText: JamiStrings.selectRingtoneOutputDevice tipText: JamiStrings.selectRingtoneOutputDevice
role: "ID_UTF8" role: "DeviceName"
onIndexChanged: { onIndexChanged: {
AvAdapter.stopAudioMeter(false) AvAdapter.stopAudioMeter(false)
var selectedRingtoneDeviceName = audioOutputDeviceModel.data( AVModel.setRingtoneDevice(comboModel.data(
audioOutputDeviceModel.index(modelIndex, 0), comboModel.index(modelIndex, 0),
AudioOutputDeviceModel.Device_ID) AudioDeviceModel.RawDeviceName))
AVModel.setRingtoneDevice(selectedRingtoneDeviceName)
AvAdapter.startAudioMeter(false) AvAdapter.startAudioMeter(false)
} }
} }