Skip to content
Snippets Groups Projects
Commit 28aa5aab authored by Andreas Traczyk's avatar Andreas Traczyk
Browse files

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
parent 215f4349
Branches
Tags
No related merge requests found
...@@ -58,9 +58,8 @@ set(COMMON_SOURCES ...@@ -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 ...@@ -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
......
...@@ -200,9 +200,8 @@ HEADERS += \ ...@@ -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 += \ ...@@ -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 \
......
/* /*
* 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
...@@ -16,73 +16,73 @@ ...@@ -16,73 +16,73 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "audioinputdevicemodel.h" #include "audiodevicemodel.h"
AudioInputDeviceModel::AudioInputDeviceModel(QObject* parent) #include "lrcinstance.h"
: QAbstractListModel(parent)
{}
AudioInputDeviceModel::~AudioInputDeviceModel() {} AudioDeviceModel::AudioDeviceModel(QObject* parent)
: QAbstractListModel(parent)
{
connect(this, &AudioDeviceModel::typeChanged, this, &AudioDeviceModel::reset);
}
int int
AudioInputDeviceModel::rowCount(const QModelIndex& parent) const AudioDeviceModel::rowCount(const QModelIndex& parent) const
{ {
if (!parent.isValid()) { if (!parent.isValid()) {
/* return devices_.size();
* Count.
*/
return LRCInstance::avModel().getAudioInputDevices().size();
} }
/*
* A valid QModelIndex returns 0 as no entry has sub-elements.
*/
return 0; return 0;
} }
int int
AudioInputDeviceModel::columnCount(const QModelIndex& parent) const AudioDeviceModel::columnCount(const QModelIndex& parent) const
{ {
Q_UNUSED(parent); Q_UNUSED(parent);
/*
* Only need one column.
*/
return 1; return 1;
} }
QVariant QVariant
AudioInputDeviceModel::data(const QModelIndex& index, int role) const AudioDeviceModel::data(const QModelIndex& index, int role) const
{ {
auto deviceList = LRCInstance::avModel().getAudioInputDevices(); if (!index.isValid() || devices_.size() <= index.row()) {
if (!index.isValid() || deviceList.size() <= index.row()) {
return QVariant(); return QVariant();
} }
switch (role) { switch (role) {
case Role::Device_ID: case Qt::DisplayRole:
return QVariant(deviceList.at(index.row())); case Role::DeviceName: {
case Role::ID_UTF8: auto deviceName = devices_.at(index.row());
return QVariant(deviceList.at(index.row()).toUtf8()); 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(); return QVariant();
} }
QHash<int, QByteArray> QHash<int, QByteArray>
AudioInputDeviceModel::roleNames() const AudioDeviceModel::roleNames() const
{ {
QHash<int, QByteArray> roles; QHash<int, QByteArray> roles;
roles[Device_ID] = "Device_ID"; roles[DeviceName] = "DeviceName";
roles[ID_UTF8] = "ID_UTF8"; roles[RawDeviceName] = "RawDeviceName";
return roles; return roles;
} }
QModelIndex QModelIndex
AudioInputDeviceModel::index(int row, int column, const QModelIndex& parent) const AudioDeviceModel::index(int row, int column, const QModelIndex&) const
{ {
Q_UNUSED(parent);
if (column != 0) { if (column != 0) {
return QModelIndex(); return QModelIndex();
} }
if (row >= 0 && row < rowCount()) { if (row >= 0 && row < rowCount()) {
return createIndex(row, column); return createIndex(row, column);
} }
...@@ -90,14 +90,13 @@ AudioInputDeviceModel::index(int row, int column, const QModelIndex& parent) con ...@@ -90,14 +90,13 @@ AudioInputDeviceModel::index(int row, int column, const QModelIndex& parent) con
} }
QModelIndex QModelIndex
AudioInputDeviceModel::parent(const QModelIndex& child) const AudioDeviceModel::parent(const QModelIndex&) const
{ {
Q_UNUSED(child);
return QModelIndex(); return QModelIndex();
} }
Qt::ItemFlags Qt::ItemFlags
AudioInputDeviceModel::flags(const QModelIndex& index) const AudioDeviceModel::flags(const QModelIndex& index) const
{ {
auto flags = QAbstractItemModel::flags(index) | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable; auto flags = QAbstractItemModel::flags(index) | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable;
if (!index.isValid()) { if (!index.isValid()) {
...@@ -107,22 +106,18 @@ AudioInputDeviceModel::flags(const QModelIndex& index) const ...@@ -107,22 +106,18 @@ AudioInputDeviceModel::flags(const QModelIndex& index) const
} }
void void
AudioInputDeviceModel::reset() AudioDeviceModel::reset()
{ {
beginResetModel(); beginResetModel();
devices_ = type_ == Type::Record ? LRCInstance::avModel().getAudioInputDevices()
: LRCInstance::avModel().getAudioOutputDevices();
endResetModel(); endResetModel();
} }
int int
AudioInputDeviceModel::getCurrentSettingIndex() AudioDeviceModel::getCurrentIndex()
{ {
QString currentId = LRCInstance::avModel().getInputDevice(); QString currentId = LRCInstance::avModel().getInputDevice();
auto resultList = match(index(0, 0), Device_ID, QVariant(currentId)); auto resultList = match(index(0, 0), Qt::DisplayRole, QVariant(currentId));
return resultList.size() > 0 ? resultList[0].row() : 0;
int resultRowIndex = 0;
if (resultList.size() > 0) {
resultRowIndex = resultList[0].row();
}
return resultRowIndex;
} }
/* /*
* 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 @@ ...@@ -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: ...@@ -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};
}; };
/*
* 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;
}
/*
* 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();
};
...@@ -22,6 +22,7 @@ import QtQuick.Controls.Universal 2.14 ...@@ -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 { ...@@ -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()
} }
......
...@@ -21,9 +21,8 @@ ...@@ -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() ...@@ -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);
......
...@@ -17,12 +17,8 @@ ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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)
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment