summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorNicholas Bennett <nicholas.bennett@qt.io>2023-03-27 14:10:18 +0300
committerNicholas Bennett <nicholas.bennett@qt.io>2023-03-30 07:50:32 +0000
commit5163c78690d31401d2883630878c489ff94bf773 (patch)
treec16c1d41048a143f10a43fa52314b18e07f6eb4e /examples
parent8ffad74e143afbdead0ad1f6da60ccd69315fea2 (diff)
downloadqtmultimedia-5163c78690d31401d2883630878c489ff94bf773.tar.gz
Fix AudioInputSelect combobox list in qml recorder example
Copied the implementation of the listmodel used in VideoSourceSelect. Fixes: QTBUG-110466 Pick-to: 6.5 Change-Id: I9e10c9404800820881ebdd23716ef512700f497e Reviewed-by: Rami Potinkara <rami.potinkara@qt.io> Reviewed-by: Samuel Mira <samuel.mira@qt.io> Reviewed-by: Artem Dyomin <artem.dyomin@qt.io> Reviewed-by: Lars Knoll <lars@knoll.priv.no>
Diffstat (limited to 'examples')
-rw-r--r--examples/multimedia/video/recorder/AudioInputSelect.qml26
1 files changed, 22 insertions, 4 deletions
diff --git a/examples/multimedia/video/recorder/AudioInputSelect.qml b/examples/multimedia/video/recorder/AudioInputSelect.qml
index 9e2e0ed98..4b572862d 100644
--- a/examples/multimedia/video/recorder/AudioInputSelect.qml
+++ b/examples/multimedia/video/recorder/AudioInputSelect.qml
@@ -7,10 +7,15 @@ import QtMultimedia
Row {
id: root
-
+ height: Style.height
property AudioInput selected: available ? audioInput : null
property bool available: (typeof comboBox.currentValue !== 'undefined') && audioSwitch.checked
+ Component.onCompleted: {
+ audioInputModel.populate()
+ comboBox.currentIndex = 0
+ }
+
MediaDevices { id: mediaDevices }
AudioInput { id: audioInput; muted: !audioSwitch.checked }
@@ -21,15 +26,28 @@ Row {
checked: true
}
+ ListModel {
+ id: audioInputModel
+ property var audioInputs: mediaDevices.audioInputs
+
+ function populate() {
+ audioInputModel.clear()
+
+ for (var audioInput of audioInputs)
+ audioInputModel.append({ text: audioInput.description, value:
+ { type: 'audioInput', audioInput: audioInput } })
+ }
+ }
ComboBox {
id: comboBox
width: Style.widthLong
height: Style.height
background: StyleRectangle { anchors.fill: parent }
- model: mediaDevices.audioInputs
- textRole: "description"
+ model: audioInputModel
+ textRole: "text"
font.pointSize: Style.fontSize
- displayText: typeof currentValue === 'undefined' ? "unavailable" : currentValue.description
+ displayText: typeof currentValue === 'undefined' ? "unavailable" : currentText
+ valueRole: "value"
onCurrentValueChanged: if (typeof comboBox.currentValue !== 'undefined') audioInput.device = currentValue
}
}