import CameraPlus 1.0
// TODO: flash not ready (battery low or flash not ready message)
+// TODO: front camera night mode
CameraPage {
id: root
+ property bool deviceChangeInProgress: false
+
CameraTheme {
id: cameraTheme
}
Component.onCompleted: {
platformSettings.init()
- // TODO: hardcoding device id
- root.resetCamera(0, settings.mode)
+ root.resetCamera(settings.device, settings.mode)
}
PlatformSettings {
Settings {
id: settings
+ onDeviceAboutToChange: {
+ root.deviceChangeInProgress = true
+ }
+
+ onDeviceChanged: {
+ viewfinder.cameraDeviceChanged()
+
+ // Reset pipeline manager error
+ pipelineManager.error = false
+
+ if (root.resetCamera(settings.device, settings.mode)) {
+ root.deviceChangeInProgress = false
+ pipelineManager.startCamera()
+ }
+ }
+
+ onImageAspectRatioChanged: {
+ imageSettings.setImageResolution()
+ }
+
+ onImageResolutionChanged: {
+ imageSettings.setImageResolution()
+ }
+
+ onVideoResolutionChanged: {
+ videoSettings.setVideoResolution()
+ }
}
PipelineManager {
function resetCamera(deviceId, mode) {
if (!viewfinder.camera.reset(deviceId, mode)) {
showError(qsTr("Failed to set camera device and mode. Please restart the application."))
+ return false
+ }
+
+ if (mode == Camera.ImageMode) {
+ imageSettings.setImageResolution()
+ }
+ else if (mode == Camera.VideoMode) {
+ videoSettings.setVideoResolution()
}
+
+ return true
}
function showError(msg) {
id: fileNaming
imageSuffix: viewfinder.camera.imageSuffix
videoSuffix: viewfinder.camera.videoSuffix
+ imagePath: platformSettings.imagePath
+ videoPath: platformSettings.videoPath
+ temporaryVideoPath: platformSettings.temporaryVideoPath
}
MountProtector {
id: mountProtector
- path: fileNaming.path
}
TrackerStore {
model: deviceInfo.model
}
- function checkDiskSpace() {
- return fileSystem.hasFreeSpace(fileNaming.path)
- }
-
ImageSettings {
id: imageSettings
camera: viewfinder.camera
showError(qsTr("Failed to set required resolution"))
}
}
-
- onReadyChanged: {
- if (ready) {
- imageSettings.setImageResolution()
- }
- }
}
VideoSettings {
showError(qsTr("Failed to set required resolution"))
}
}
-
- onReadyChanged: {
- if (ready) {
- videoSettings.setVideoResolution()
- }
- }
- }
-
- Connections {
- target: settings
-
- onImageAspectRatioChanged: {
- imageSettings.setImageResolution()
- }
-
- onImageResolutionChanged: {
- imageSettings.setImageResolution()
- }
-
- onVideoResolutionChanged: {
- videoSettings.setVideoResolution()
- }
}
ModeController {