X-Git-Url: http://cgit.sxemacs.org/?p=harmattan%2Fcameraplus;a=blobdiff_plain;f=qml%2FMainPage.qml;h=c4f5de4a5cda6b179b9f44c4fe4fd79aff201889;hp=5598c0b1366487983b5f804a2223be9252e633dc;hb=c54bd1327085d9e1d8a9ff3236aa805842545a3e;hpb=669262fa107a2c43534a2e51a058fad2121143b2 diff --git a/qml/MainPage.qml b/qml/MainPage.qml index 5598c0b..c4f5de4 100644 --- a/qml/MainPage.qml +++ b/qml/MainPage.qml @@ -25,12 +25,13 @@ import QtCamera 1.0 import CameraPlus 1.0 // TODO: flash not ready (battery low or flash not ready message) -// TODO: rotate post capture image -// TODO: front camera +// TODO: front camera night mode CameraPage { id: root + property bool deviceChangeInProgress: false + CameraTheme { id: cameraTheme } @@ -72,8 +73,7 @@ CameraPage { Component.onCompleted: { platformSettings.init() - // TODO: hardcoding device id - root.resetCamera(0, settings.mode) + root.resetCamera(settings.device, settings.mode) } PlatformSettings { @@ -82,6 +82,33 @@ CameraPage { 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 { @@ -93,7 +120,17 @@ CameraPage { 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) { @@ -165,11 +202,13 @@ CameraPage { 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 { @@ -179,10 +218,6 @@ CameraPage { model: deviceInfo.model } - function checkDiskSpace() { - return fileSystem.hasFreeSpace(fileNaming.path) - } - ImageSettings { id: imageSettings camera: viewfinder.camera @@ -192,12 +227,6 @@ CameraPage { showError(qsTr("Failed to set required resolution")) } } - - onReadyChanged: { - if (ready) { - imageSettings.setImageResolution() - } - } } VideoSettings { @@ -209,28 +238,6 @@ CameraPage { 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 {