blob: e6900b6abe75cac3d7f9dba1f4acd22f51310fab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
// Copyright (C) 2025 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
pragma ComponentBehavior: Bound
import QtQuick
import QtMultimedia
import QtQuick.Layouts
import QtQuick.Controls
ColumnLayout {
id: top
required property CameraHelper camera
required property MediaDevicesHelper mediaDevices
Label {
text: "Media devices (" + mediaDevices.videoInputs.length + ")"
font.bold: true
}
ListView {
id: videoInputsListView
clip: true
Layout.preferredWidth: 400
Layout.preferredHeight: 100
model: mediaDevices.videoInputs
delegate: ItemDelegate {
required property var modelData
required property int index
highlighted: ListView.isCurrentItem
// Item is QCameraDevice
function buildString(item) {
let string = ""
if (String(item.id) === String(top.camera.cameraDevice.id))
string += "(Active) "
if (item.description === "")
string += "No description"
else
string += item.description
if (item.isDefault)
string += " (Default)"
return string
}
text: buildString(modelData)
onClicked: videoInputsListView.currentIndex = index
}
}
Label {
readonly property var defaultCount:
mediaDevices.videoInputs
.reduce((count, item) => { return count + Number(item.isDefault) }, 0)
color: "red"
text: defaultCount > 1 ? "Multiple default devices" : "No default device"
visible: defaultCount > 1 || defaultCount === 0
}
Label {
// video-input might be undefined, in which case we get errors when dereferencing.
text:
videoInputsListView.model[videoInputsListView.currentIndex]
? ("Formats for "
+ videoInputsListView.model[videoInputsListView.currentIndex].description
+ "("
+ videoFormatsListView.model.length
+ ")")
: "Formats"
font.bold: true
}
ListView {
id: videoFormatsListView
clip: true
Layout.fillWidth: true
Layout.preferredHeight: 100
// Chosen video input can be undefined if there is no device, in which case we get errors
// when dereferencing.
model:
videoInputsListView.model[videoInputsListView.currentIndex]
? (videoInputsListView.model[videoInputsListView.currentIndex].videoFormats
.slice()
.sort((a, b) => top.camera.customCameraFormatSortDelegate(a, b)))
: []
delegate: Label {
required property int index
readonly property var item: videoFormatsListView.model[index]
text: item !== undefined ? top.camera.cameraFormatToString(item) : ""
}
}
Label {
text: "Supported features (" + top.camera.supportedFeaturesList.length + ")"
font.bold: true
}
ListView {
id: supportedFeaturesListView
clip: true
Layout.preferredWidth: 250
Layout.preferredHeight: 200
model: top.camera.allFeatureFlags
delegate: CheckBox {
required property int index
readonly property var item: supportedFeaturesListView.model[index]
function buildString() {
return top.camera.featureFlagToString(item)
}
text: buildString()
checked: top.camera.supportedFeatures & item
onClicked: () => {
checked = top.camera.supportedFeatures & item
}
}
}
}
|