blob: 4ea3535757f7a63320e7a66310a506ea67e82975 (
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
|
// Copyright (C) 2025 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtCore
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import QtQml
import QtMultimedia
GridLayout {
id: top
required property bool useLandscapeLayout
Layout.fillWidth: true
columns: useLandscapeLayout === true ? 2 : 1
ScreenCapture {
id: screenCapture
onActiveChanged: () => {
console.log("QScreenCapture active changed: " + active)
// CheckBox has a weird behavior where it will remove our bindings when activated.
// Update the value manually here
if (active === true)
screenCaptureActiveCheckBox.checkState = Qt.Checked
else
screenCaptureActiveCheckBox.checkState = Qt.Unchecked
}
onErrorChanged: () => {
console.log("QScreenCapture error changed: " + error)
}
onErrorStringChanged: (msg) => {
console.log("QScreenCapture error string changed: " + errorString)
}
}
CaptureSession {
screenCapture: screenCapture
videoOutput: screenCaptureVideoOutput
}
ColumnLayout {
Layout.alignment: Qt.AlignTop
CheckBox {
id: screenCaptureActiveCheckBox
text: "Active"
onClicked: () => {
if (checkState === Qt.Checked)
screenCapture.start()
else
screenCapture.stop()
checkState = screenCapture.active === true ? Qt.Checked : Qt.Unchecked
}
}
Label {
text: "Screens:"
}
Frame {
Layout.preferredWidth: 200
Layout.preferredHeight: screensListView.model.length > 0 ? 200 : 50
ListView {
id: screensListView
anchors.fill: parent
clip: true
model: Qt.application.screens
currentIndex: model
.findIndex((item) => item === screenCapture.screen)
delegate: ItemDelegate {
required property var modelData
required property int index
highlighted: ListView.isCurrentItem
text: modelData.name
onClicked: () => {
screenCapture.screen = modelData
}
}
}
}
}
Frame {
Layout.alignment: Qt.AlignTop
Layout.fillWidth: true
Layout.preferredHeight: 400
VideoOutput {
anchors.fill: parent
id: screenCaptureVideoOutput
}
}
}
|