Prevent changing any camera properties while device change is in progress
[harmattan/cameraplus] / qml / MainPage.qml
index 5598c0b..bf98add 100644 (file)
@@ -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,21 @@ 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()
+            }
+        }
     }
 
     PipelineManager {
@@ -93,7 +108,10 @@ 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
         }
+
+        return true
     }
 
     function showError(msg) {
@@ -165,11 +183,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 +199,6 @@ CameraPage {
         model: deviceInfo.model
     }
 
-    function checkDiskSpace() {
-        return fileSystem.hasFreeSpace(fileNaming.path)
-    }
-
     ImageSettings {
         id: imageSettings
         camera: viewfinder.camera