diff --git a/src/avadapter.cpp b/src/avadapter.cpp index c24a1e5c8239f29983210aa6814f5073486bdd68..acb8644bdaf289581b83b10a94447998a00c02b2 100644 --- a/src/avadapter.cpp +++ b/src/avadapter.cpp @@ -36,7 +36,8 @@ AvAdapter::AvAdapter(LRCInstance* instance, QObject* parent) auto& avModel = lrcInstance_->avModel(); deviceListSize_ = avModel.getDevices().size(); - connect(&avModel, &lrc::api::AVModel::deviceEvent, this, &AvAdapter::slotDeviceEvent); + connect(&avModel, &lrc::api::AVModel::audioDeviceEvent, this, &AvAdapter::onAudioDeviceEvent); + connect(&avModel, &lrc::api::AVModel::deviceEvent, this, &AvAdapter::onVideoDeviceEvent); connect(lrcInstance_->renderer(), &RenderManager::previewFrameStarted, [this]() { // TODO: listen to the correct signals that are needed to be added in daemon or lrc auto callId = getCurrentCallId(); @@ -235,21 +236,17 @@ AvAdapter::stopAudioMeter(bool async) lrcInstance_->stopAudioMeter(async); } -QString -AvAdapter::getCurrentCallId() +void +AvAdapter::onAudioDeviceEvent() { - try { - const auto& convInfo = lrcInstance_->getConversationFromConvUid( - lrcInstance_->get_selectedConvUid()); - auto call = lrcInstance_->getCallInfoForConversation(convInfo); - return call ? call->id : QString(); - } catch (...) { - return QString(); - } + auto& avModel = lrcInstance_->avModel(); + auto inputs = avModel.getAudioInputDevices().size(); + auto outputs = avModel.getAudioOutputDevices().size(); + Q_EMIT audioDeviceListChanged(inputs, outputs); } void -AvAdapter::slotDeviceEvent() +AvAdapter::onVideoDeviceEvent() { auto& avModel = lrcInstance_->avModel(); auto defaultDevice = avModel.getDefaultDevice(); @@ -305,11 +302,24 @@ AvAdapter::slotDeviceEvent() } } - Q_EMIT videoDeviceListChanged(currentDeviceListSize == 0); + Q_EMIT videoDeviceListChanged(currentDeviceListSize); deviceListSize_ = currentDeviceListSize; } +QString +AvAdapter::getCurrentCallId() +{ + try { + const auto& convInfo = lrcInstance_->getConversationFromConvUid( + lrcInstance_->get_selectedConvUid()); + auto call = lrcInstance_->getCallInfoForConversation(convInfo); + return call ? call->id : QString(); + } catch (...) { + return QString(); + } +} + int AvAdapter::getScreenNumber() const { diff --git a/src/avadapter.h b/src/avadapter.h index fc4b699be046d95e755a6d2153dd5c0dae0965b9..79d1e0949b0a65a23e598505bbf06e82bb5bf330 100644 --- a/src/avadapter.h +++ b/src/avadapter.h @@ -37,8 +37,8 @@ public: Q_SIGNALS: - // Emitted when the size of the video capture device list changes. - void videoDeviceListChanged(bool listIsEmpty); + void audioDeviceListChanged(int inputs, int outputs); + void videoDeviceListChanged(int inputs); void screenCaptured(int screenNumber, QString source); @@ -75,6 +75,10 @@ protected: Q_INVOKABLE void startAudioMeter(bool async); Q_INVOKABLE void stopAudioMeter(bool async); +private Q_SLOTS: + void onAudioDeviceEvent(); + void onVideoDeviceEvent(); + private: // Get screens arrangement rect relative to primary screen. const QRect getAllScreensBoundingRect(); @@ -88,9 +92,6 @@ private: // Used to track the capture device count. int deviceListSize_; - // Device changed slot. - void slotDeviceEvent(); - // Get the screen number int getScreenNumber() const; }; diff --git a/src/commoncomponents/SettingParaCombobox.qml b/src/commoncomponents/SettingParaCombobox.qml index b0ab191ee8076e347b1d9d65033a25d26f71f4c1..3a93ad7b5bb08c2cf0e5e3e9ebfdc3f67825362c 100644 --- a/src/commoncomponents/SettingParaCombobox.qml +++ b/src/commoncomponents/SettingParaCombobox.qml @@ -28,8 +28,15 @@ import net.jami.Constants 1.0 ComboBox { id: root - property string tooltipText:"" + property string tooltipText property string comboBoxBackgroundColor: JamiTheme.editBackgroundColor + property string placeholderText + + displayText: currentIndex !== -1 ? + currentText : + (placeholderText !== "" ? + placeholderText : + JamiStrings.notAvailable) ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval ToolTip.visible: hovered && (tooltipText.length > 0) @@ -39,8 +46,11 @@ ComboBox { width: root.width contentItem: Text { text: { - var currentItem = root.delegateModel.items.get(index) - return currentItem.model[root.textRole].toString() + if (index >= 0) { + var currentItem = root.delegateModel.items.get(index) + return currentItem.model[root.textRole].toString() + } + return "" } color: JamiTheme.textColor font: root.font @@ -106,9 +116,10 @@ ComboBox { padding: 1 contentItem: ListView { + id: listView clip: true implicitHeight: contentHeight - model: root.delegateModel + model: root.delegateModel currentIndex: root.highlightedIndex ScrollIndicator.vertical: ScrollIndicator { } diff --git a/src/constant/JamiStrings.qml b/src/constant/JamiStrings.qml index 6e29cec22b1164d58580d2525bf3a6485e63930f..1f8c7d3a6638eacb982d0e4a9e5ce7f33cfd5893 100644 --- a/src/constant/JamiStrings.qml +++ b/src/constant/JamiStrings.qml @@ -226,6 +226,7 @@ Item { property string shareFile: qsTr("Share file") property string viewPlugin: qsTr("View plugin") property string noVideoDevice: qsTr("No video device") + property string notAvailable: qsTr("N/A") // Chatview header property string hideChatView: qsTr("Hide chat view") diff --git a/src/mainview/components/CallActionBar.qml b/src/mainview/components/CallActionBar.qml index ca6778e68b717b6a9c9184f9aa983522c29c47e8..ef4d5574791e5cb492a2ee2f474d7d3c790b816f 100644 --- a/src/mainview/components/CallActionBar.qml +++ b/src/mainview/components/CallActionBar.qml @@ -58,9 +58,16 @@ Control { Connections { target: AvAdapter - // TODO: audio device list updates - function onVideoDeviceListChanged(listIsEmpty) { + function onAudioDeviceListChanged(inputs, outputs) { + audioInputDeviceListModel.reset(); + audioInputMenuAction.enabled = inputs + audioOutputDeviceListModel.reset(); + audioOutputMenuAction.enabled = outputs + } + + function onVideoDeviceListChanged(inputs) { videoInputDeviceListModel.reset(); + videoInputMenuAction.enabled = inputs } } @@ -68,6 +75,7 @@ Control { Action { id: audioInputMenuAction text: JamiStrings.selectAudioInputDevice + Component.onCompleted: enabled = audioInputDeviceListModel.rowCount() property var listModel: AudioDeviceModel { id: audioInputDeviceListModel lrcInstance: LRCInstance @@ -84,6 +92,7 @@ Control { Action { id: audioOutputMenuAction text: JamiStrings.selectAudioOutputDevice + Component.onCompleted: enabled = audioOutputDeviceListModel.rowCount() property var listModel: AudioDeviceModel { id: audioOutputDeviceListModel lrcInstance: LRCInstance @@ -100,6 +109,7 @@ Control { Action { id: videoInputMenuAction text: JamiStrings.selectVideoDevice + Component.onCompleted: enabled = videoInputDeviceListModel.rowCount() property var listModel: VideoInputDeviceModel { id: videoInputDeviceListModel lrcInstance: LRCInstance diff --git a/src/mainview/components/CallButtonDelegate.qml b/src/mainview/components/CallButtonDelegate.qml index b8de758ef915436cb7a3761182b88f850e0de2f1..115f944491a6b9887204c90dc35e2b9bc73fc8a3 100644 --- a/src/mainview/components/CallButtonDelegate.qml +++ b/src/mainview/components/CallButtonDelegate.qml @@ -159,7 +159,7 @@ ItemDelegate { indicator: null - visible: menuAction !== undefined && !UrgentCount + visible: menuAction !== undefined && !UrgentCount && menuAction.enabled y: isVertical ? 0 : -4 x: isVertical ? -4 : 0 diff --git a/src/mainview/components/OngoingCallPage.qml b/src/mainview/components/OngoingCallPage.qml index deb268d81b08f83373abb8a10cb6ea438e34138d..5f87dbc115fb84849e692e0673fcb9039f5645eb 100644 --- a/src/mainview/components/OngoingCallPage.qml +++ b/src/mainview/components/OngoingCallPage.qml @@ -215,8 +215,8 @@ Rectangle { Connections { target: AvAdapter - function onVideoDeviceListChanged(listIsEmpty) { - previewRenderer.visible = !listIsEmpty + function onVideoDeviceListChanged(inputs) { + previewRenderer.visible = (inputs !== 0) } } diff --git a/src/settingsview/components/AvSettingPage.qml b/src/settingsview/components/AvSettingPage.qml index 352d110809eeca21801740cfd453346dfeeda542..cd6555019de9b126a1e1506642989e3dd64bddcf 100644 --- a/src/settingsview/components/AvSettingPage.qml +++ b/src/settingsview/components/AvSettingPage.qml @@ -49,7 +49,6 @@ Rectangle { width: Math.min(JamiTheme.maximumWidthSettingsView, root.width) - // Audio AudioSettings { id: audioSettings @@ -60,7 +59,6 @@ Rectangle { itemWidth: preferredColumnWidth } - // Video VideoSettings { id: videoSettings diff --git a/src/settingsview/components/SettingsComboBox.qml b/src/settingsview/components/SettingsComboBox.qml index 5b95b24ccd09136b2f5ce673bfaa616c09eefab8..39dea8825b0e28f544c02f63fe8aefcd19c030ca 100644 --- a/src/settingsview/components/SettingsComboBox.qml +++ b/src/settingsview/components/SettingsComboBox.qml @@ -39,6 +39,8 @@ RowLayout { property string tipText: "" property string role: "" + property alias placeholderText: comboBoxOfLayout.placeholderText + signal indexChanged function setCurrentIndex(index, emitIndexChanged = false) { diff --git a/src/settingsview/components/VideoSettings.qml b/src/settingsview/components/VideoSettings.qml index 4343d39f85e62d69230361d9eef5d587711aa978..6740a6f7d80ec3f9f4115325ce81f193cd783d72 100644 --- a/src/settingsview/components/VideoSettings.qml +++ b/src/settingsview/components/VideoSettings.qml @@ -50,20 +50,19 @@ ColumnLayout { deviceComboBoxSetting.comboModel.reset() var count = deviceComboBoxSetting.comboModel.deviceCount() - var deviceListIsEmpty = count === 0 previewWidget.visible = count > 0 deviceComboBoxSetting.setEnabled(count > 0) resolutionComboBoxSetting.setEnabled(count > 0) fpsComboBoxSetting.setEnabled(count > 0) - if (deviceListIsEmpty) { + if (count === 0) { resolutionComboBoxSetting.comboModel.reset() fpsComboBoxSetting.comboModel.reset() + } else { + deviceComboBoxSetting.setCurrentIndex( + deviceComboBoxSetting.comboModel.getCurrentIndex(), true) } - - deviceComboBoxSetting.setCurrentIndex( - deviceComboBoxSetting.comboModel.getCurrentIndex(), true) hardwareAccelControl.checked = AVModel.getHardwareAcceleration() } @@ -132,8 +131,8 @@ ColumnLayout { } try { - SettingsAdapter.set_Video_Settings_Rate_And_Resolution( - AVModel.getCurrentVideoCaptureDevice(),rate, resolution) + SettingsAdapter.set_Video_Settings_Rate_And_Resolution( + AVModel.getCurrentVideoCaptureDevice(),rate, resolution) updatePreviewRatio(resolution) } catch(error){ console.warn(error.message) } } @@ -176,6 +175,8 @@ ColumnLayout { onIndexChanged: { slotDeviceBoxCurrentIndexChanged(modelIndex) } + + placeholderText: JamiStrings.noVideoDevice } SettingsComboBox { @@ -220,7 +221,6 @@ ColumnLayout { } } - // Toggle switch to enable hardware acceleration ToggleSwitch { id: hardwareAccelControl diff --git a/src/videoinputdevicemodel.cpp b/src/videoinputdevicemodel.cpp index 694becbfd246351b733d85d5bc4a809a6273223a..49d639390dab0ecc96b9155563a59d6693be627b 100644 --- a/src/videoinputdevicemodel.cpp +++ b/src/videoinputdevicemodel.cpp @@ -20,9 +20,6 @@ #include "lrcinstance.h" -#include "api/account.h" -#include "api/contact.h" -#include "api/conversation.h" #include "api/newdevicemodel.h" VideoInputDeviceModel::VideoInputDeviceModel(QObject* parent) @@ -35,32 +32,11 @@ int VideoInputDeviceModel::rowCount(const QModelIndex& parent) const { if (!parent.isValid() && lrcInstance_) { - /* - * Count. - */ - int deviceListSize = lrcInstance_->avModel().getDevices().size(); - if (deviceListSize > 0) { - return deviceListSize; - } else { - return 1; - } + return lrcInstance_->avModel().getDevices().size(); } - /* - * A valid QModelIndex returns 0 as no entry has sub-elements. - */ return 0; } -int -VideoInputDeviceModel::columnCount(const QModelIndex& parent) const -{ - Q_UNUSED(parent); - /* - * Only need one column. - */ - return 1; -} - QVariant VideoInputDeviceModel::data(const QModelIndex& index, int role) const { @@ -69,15 +45,6 @@ VideoInputDeviceModel::data(const QModelIndex& index, int role) const return QVariant(); } - if (deviceList.size() == 0 && index.row() == 0) { - switch (role) { - case Role::DeviceName: - return QVariant(QObject::tr("No device")); - case Role::DeviceName_UTF8: - return QVariant(QObject::tr("No device").toUtf8()); - } - } - if (deviceList.size() <= index.row()) { return QVariant(); } @@ -117,37 +84,6 @@ VideoInputDeviceModel::roleNames() const return roles; } -QModelIndex -VideoInputDeviceModel::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 -VideoInputDeviceModel::parent(const QModelIndex& child) const -{ - Q_UNUSED(child); - return QModelIndex(); -} - -Qt::ItemFlags -VideoInputDeviceModel::flags(const QModelIndex& index) const -{ - auto flags = QAbstractItemModel::flags(index) | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable; - if (!index.isValid()) { - return QAbstractItemModel::flags(index); - } - return flags; -} - void VideoInputDeviceModel::reset() { diff --git a/src/videoinputdevicemodel.h b/src/videoinputdevicemodel.h index ed9d42d263bedeb4e4f1eee8a66058bc8f6d6ffd..63a1a1d88f8d3e7766cdb7c7efdca8fb68c79e61 100644 --- a/src/videoinputdevicemodel.h +++ b/src/videoinputdevicemodel.h @@ -38,27 +38,11 @@ public: explicit VideoInputDeviceModel(QObject* parent = nullptr); ~VideoInputDeviceModel(); - /* - * 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 reset the model when there's new account added. - */ Q_INVOKABLE int deviceCount(); // get model index of the current device