diff --git a/qml/Application.qml b/qml/Application.qml index d9d6093a..7c80b9e7 100644 --- a/qml/Application.qml +++ b/qml/Application.qml @@ -80,6 +80,7 @@ ApplicationWindow { height: parent.height width: parent.width collageMenu.printer : printer + libcamera: libcamera settingsMenu.switchPrinter.onCheckedChanged: { diff --git a/qml/ApplicationFlowForm.ui.qml b/qml/ApplicationFlowForm.ui.qml index b8f7553c..f97cb617 100644 --- a/qml/ApplicationFlowForm.ui.qml +++ b/qml/ApplicationFlowForm.ui.qml @@ -11,6 +11,7 @@ Item { property alias collageMenu: collageMenu property alias galleryMenu: galleryMenu property alias settingsMenu: settingsMenu + property var libcamera property real slideValueCollageSelection: 0.0 property real slideValueSnapshotMenu: 1.0 @@ -36,6 +37,7 @@ Item { width: root.width height: root.height state: "deactivated" + libcamera: root.libcamera } ImagePreview { @@ -73,6 +75,7 @@ Item { z: 0 width: root.width height: root.height + libcamera: root.libcamera } states: [ diff --git a/qml/SettingsMenu.qml b/qml/SettingsMenu.qml index 696a1bf6..90e69ca9 100644 --- a/qml/SettingsMenu.qml +++ b/qml/SettingsMenu.qml @@ -33,11 +33,13 @@ SettingsMenuForm { { listModel.push(gphotoCameras[i]) } - var libcameras = libcamera.availableCameras(); - console.log("Libcamera Camera Count: " + Number(libcameras.length).toString()) - for(i = 0; i < libcameras.length; i++) - { - listModel.push(libcameras[i]) + if (form.libcamera) { + var libcameras = form.libcamera.availableCameras(); + console.log("Libcamera Camera Count: " + Number(libcameras.length).toString()) + for(i = 0; i < libcameras.length; i++) + { + listModel.push(libcameras[i]) + } } return listModel; } diff --git a/qml/SettingsMenuForm.ui.qml b/qml/SettingsMenuForm.ui.qml index b4aba3d8..03496fc8 100644 --- a/qml/SettingsMenuForm.ui.qml +++ b/qml/SettingsMenuForm.ui.qml @@ -30,6 +30,7 @@ Item { property alias comboBoxCameraOrientation: comboBoxCameraOrientation property alias comboBoxNeuralNetworkRuntime: comboBoxNeuralNetworkRuntime property alias buttonSelectPhotoDirectory: buttonSelectPhotoDirectory + property var libcamera ColumnLayout { anchors.fill: parent diff --git a/qml/SnapshotMenuForm.ui.qml b/qml/SnapshotMenuForm.ui.qml index 1879108e..b0a4d8b2 100644 --- a/qml/SnapshotMenuForm.ui.qml +++ b/qml/SnapshotMenuForm.ui.qml @@ -14,10 +14,12 @@ Item { property alias shutterButton: shutterButton property alias countdown: shutterButton.countDownTime property bool hideSnapshotSettingsPane: false + property var libcamera CameraRenderer { id: cameraRenderer anchors.fill: parent + libcamera: element.libcamera Text { id: failureText diff --git a/qml/content/CameraRenderer.qml b/qml/content/CameraRenderer.qml index d4963f17..8ebfd49f 100644 --- a/qml/content/CameraRenderer.qml +++ b/qml/content/CameraRenderer.qml @@ -18,6 +18,7 @@ Item { property alias backgroundFilter: backgroundFilter property bool backgroundFilterEnabled: false property url backgroundImage: "" + property var libcamera onCameraNameChanged: { @@ -54,6 +55,7 @@ Item { anchors.fill: parent cameraName: renderer.cameraName + libcamera: renderer.libcamera onImageCaptured: function(image) { whiteOverlay.state = "released" diff --git a/qml/content/CameraSource.qml b/qml/content/CameraSource.qml index 40954766..8ad7df81 100644 --- a/qml/content/CameraSource.qml +++ b/qml/content/CameraSource.qml @@ -12,6 +12,7 @@ Item property alias output: output property string cameraName: "" property bool readyForCapture: ((cameraSession.imageCapture.readyForCapture) || (cameraSource.state === "GPhotoCamera") || (cameraSource.state === "Libcamera")) + property var libcamera signal imageCaptured(var image) signal errorOccurred(var errorString) @@ -37,12 +38,14 @@ Item return } } - var libcameras = libcamera.availableCameras() - for (var j = 0; j < libcameras.length; j++) { - if (libcameras[j] === cameraName) { - cameraSource.state = "Libcamera" - console.log("CameraSource using Libcamera camera device: " + cameraName) - return + if (cameraSource.libcamera) { + var libcameras = cameraSource.libcamera.availableCameras() + for (var j = 0; j < libcameras.length; j++) { + if (libcameras[j] === cameraName) { + cameraSource.state = "Libcamera" + console.log("CameraSource using Libcamera camera device: " + cameraName) + return + } } } @@ -62,7 +65,9 @@ Item } else if(state === "Libcamera") { - libcamera.startCamera(cameraName) + if (cameraSource.libcamera) { + cameraSource.libcamera.startCamera(cameraName) + } } else { @@ -82,7 +87,9 @@ Item } else if(state === "Libcamera") { - libcamera.stopCamera() + if (cameraSource.libcamera) { + cameraSource.libcamera.stopCamera() + } } else { @@ -100,7 +107,9 @@ Item else if(state === "Libcamera") { console.log("Libcamera capture") - libcamera.captureImage() + if (cameraSource.libcamera) { + cameraSource.libcamera.captureImage() + } } else if(state === "GPhotoCamera") { @@ -118,7 +127,7 @@ Item } Connections { - target: libcamera + target: cameraSource.libcamera function onErrorOccurred(errorString) { if(state === "Libcamera") { @@ -129,7 +138,7 @@ Item Connections { - target: libcamera + target: cameraSource.libcamera function onImageCaptured(image) { cameraSource.imageCaptured(image) } @@ -262,7 +271,7 @@ Item name: "Libcamera" PropertyChanges { target: cameraSession - videoFrameInput: libcamera + videoFrameInput: cameraSource.libcamera } }, State {