Prevent changing any camera properties while device change is in progress
[harmattan/cameraplus] / qml / MainPage.qml
index 811ba31..bf98add 100644 (file)
@@ -30,6 +30,8 @@ import CameraPlus 1.0
 CameraPage {
     id: root
 
+    property bool deviceChangeInProgress: false
+
     CameraTheme {
         id: cameraTheme
     }
@@ -80,11 +82,18 @@ 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()
             }
         }
@@ -174,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 {
@@ -188,19 +199,12 @@ CameraPage {
         model: deviceInfo.model
     }
 
-    function checkDiskSpace() {
-        return fileSystem.hasFreeSpace(fileNaming.path)
-    }
-
     ImageSettings {
         id: imageSettings
         camera: viewfinder.camera
 
         function setImageResolution() {
-            var aspectRatio = settings.device == 1 ? settings.secondaryImageAspectRatio : settings.primaryImageAspectRatio
-            var resolution = settings.device == 1 ? settings.secondaryImageResolution : settings.primaryImageResolution
-
-            if (!imageSettings.setResolution(aspectRatio, resolution)) {
+            if (!imageSettings.setResolution(settings.imageAspectRatio, settings.imageResolution)) {
                 showError(qsTr("Failed to set required resolution"))
             }
         }
@@ -217,10 +221,7 @@ CameraPage {
         camera: viewfinder.camera
 
         function setVideoResolution() {
-            var aspectRatio = settings.device == 1 ? settings.secondaryVideoAspectRatio : settings.primaryVideoAspectRatio
-            var resolution = settings.device == 1 ? settings.secondaryVideoResolution : settings.primaryVideoResolution
-
-            if (!videoSettings.setResolution(aspectRatio, resolution)) {
+            if (!videoSettings.setResolution(settings.videoAspectRatio, settings.videoResolution)) {
                 showError(qsTr("Failed to set required resolution"))
             }
         }
@@ -235,15 +236,17 @@ CameraPage {
     Connections {
         target: settings
 
-        onPrimaryImageResolutionChanged: imageSettings.setImageResolution()
-        onPrimaryImageAspectRatioChanged: imageSettings.setImageResolution()
-        onSecondaryImageResolutionChanged: imageSettings.setImageResolution()
-        onSecondaryImageAspectRatioChanged: imageSettings.setImageResolution()
+        onImageAspectRatioChanged: {
+            imageSettings.setImageResolution()
+        }
+
+        onImageResolutionChanged: {
+            imageSettings.setImageResolution()
+        }
 
-        onPrimaryVideoResolutionChanged: videoSettings.setVideoResolution()
-        onPrimaryVideoAspectRatioChanged: videoSettings.setVideoResolution()
-        onSecondaryVideoResolutionChanged: videoSettings.setVideoResolution()
-        onSecondaryVideoAspectRatioChanged: videoSettings.setVideoResolution()
+        onVideoResolutionChanged: {
+            videoSettings.setVideoResolution()
+        }
     }
 
     ModeController {