Skip to content
Snippets Groups Projects
Unverified Commit 81934737 authored by Aline Gondim Santos's avatar Aline Gondim Santos Committed by Sébastien Blin
Browse files

video: fix camera preview opening

 - Camera preview in av settings now opens after inserting USB camera on a device with `No video device`;
 - Same for recording video message window.

Change-Id: I34ad9b6900865fdc7c4acf861527e4bf8e336123
GitLab: #610
parent afcee374
Branches
Tags
No related merge requests found
...@@ -84,7 +84,7 @@ Rectangle { ...@@ -84,7 +84,7 @@ Rectangle {
} }
} }
RecordBox{ RecordBox {
id: recordBox id: recordBox
visible: false visible: false
......
...@@ -41,7 +41,6 @@ Rectangle { ...@@ -41,7 +41,6 @@ Rectangle {
property int duration: 0 property int duration: 0
property int state: RecordBox.States.INIT property int state: RecordBox.States.INIT
property bool isVideo: false property bool isVideo: false
property bool previewAvailable: false
property int preferredWidth: 320 property int preferredWidth: 320
property int preferredHeight: 240 property int preferredHeight: 240
property int btnSize: 40 property int btnSize: 40
...@@ -61,7 +60,6 @@ Rectangle { ...@@ -61,7 +60,6 @@ Rectangle {
if (isVideo) { if (isVideo) {
previewWidget.deviceId = VideoDevices.getDefaultDevice() previewWidget.deviceId = VideoDevices.getDefaultDevice()
previewWidget.rendererId = VideoDevices.startDevice(previewWidget.deviceId) previewWidget.rendererId = VideoDevices.startDevice(previewWidget.deviceId)
previewAvailable = true
} }
} }
...@@ -243,7 +241,7 @@ Rectangle { ...@@ -243,7 +241,7 @@ Rectangle {
anchors.fill: parent anchors.fill: parent
visible: (isVideo && previewAvailable) visible: (isVideo && VideoDevices.listSize !== 0)
color: JamiTheme.blackColor color: JamiTheme.blackColor
radius: 5 radius: 5
...@@ -262,6 +260,14 @@ Rectangle { ...@@ -262,6 +260,14 @@ Rectangle {
maskSource: rectBox maskSource: rectBox
} }
} }
onVisibleChanged: {
if (visible) {
previewWidget.deviceId = VideoDevices.getDefaultDevice()
previewWidget.rendererId = VideoDevices.startDevice(previewWidget.deviceId)
} else
VideoDevices.stopDevice(previewWidget.deviceId)
}
} }
Label { Label {
...@@ -269,7 +275,13 @@ Rectangle { ...@@ -269,7 +275,13 @@ Rectangle {
width: root.width width: root.width
visible: (isVideo && !previewAvailable) visible: (isVideo && VideoDevices.listSize === 0)
onVisibleChanged: {
if (visible) {
closeRecorder()
}
}
text: JamiStrings.previewUnavailable text: JamiStrings.previewUnavailable
font.pointSize: JamiTheme.settingsFontSize font.pointSize: JamiTheme.settingsFontSize
......
...@@ -32,14 +32,12 @@ ColumnLayout { ...@@ -32,14 +32,12 @@ ColumnLayout {
id: root id: root
property real aspectRatio: 0.75 property real aspectRatio: 0.75
property bool previewAvailable: false
property int itemWidth property int itemWidth
function startPreviewing(force = false) { function startPreviewing(force = false) {
if (root.visible) { if (root.visible) {
previewWidget.deviceId = VideoDevices.getDefaultDevice() previewWidget.deviceId = VideoDevices.getDefaultDevice()
previewWidget.rendererId = VideoDevices.startDevice(previewWidget.deviceId, force) previewWidget.rendererId = VideoDevices.startDevice(previewWidget.deviceId, force)
previewAvailable = true
} }
} }
...@@ -230,11 +228,18 @@ ColumnLayout { ...@@ -230,11 +228,18 @@ ColumnLayout {
maskSource: rectBox maskSource: rectBox
} }
} }
onVisibleChanged: {
if (visible) {
VideoDevices.stopDevice(previewWidget.deviceId)
startPreviewing(true)
} else
VideoDevices.stopDevice(previewWidget.deviceId)
}
} }
Label { Label {
// TODO: proper use of previewAvailable visible: VideoDevices.listSize === 0
visible: !previewAvailable
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: JamiTheme.preferredFieldHeight Layout.preferredHeight: JamiTheme.preferredFieldHeight
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment