Don't disable all interactions when standby is visible
[harmattan/cameraplus] / qml / MainPage.qml
index 811ba31..731b334 100644 (file)
@@ -25,11 +25,13 @@ import QtCamera 1.0
 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
+    property bool inCaptureMode: mainView.currentIndex == 1
+
     CameraTheme {
         id: cameraTheme
     }
@@ -80,14 +82,45 @@ 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: {
+            if (!root.deviceChangeInProgress) {
+                imageSettings.setImageResolution()
+            }
+        }
+
+        onImageResolutionChanged: {
+            if (!root.deviceChangeInProgress) {
+                imageSettings.setImageResolution()
+            }
+        }
+
+        onVideoResolutionChanged: {
+            if (!root.deviceChangeInProgress) {
+                videoSettings.setVideoResolution()
+            }
+        }
+
+        onVideoAspectRatioChanged: {
+            if (!root.deviceChangeInProgress) {
+                videoSettings.setVideoResolution()
+            }
+        }
     }
 
     PipelineManager {
@@ -102,6 +135,13 @@ CameraPage {
             return false
         }
 
+        if (mode == Camera.ImageMode) {
+            imageSettings.setImageResolution()
+        }
+        else if (mode == Camera.VideoMode) {
+            videoSettings.setVideoResolution()
+        }
+
         return true
     }
 
@@ -174,11 +214,14 @@ CameraPage {
         id: fileNaming
         imageSuffix: viewfinder.camera.imageSuffix
         videoSuffix: viewfinder.camera.videoSuffix
+        imagePath: platformSettings.imagePath
+        videoPath: platformSettings.videoPath
+        temporaryVideoPath: platformSettings.temporaryVideoPath
+        settings: settings
     }
 
     MountProtector {
         id: mountProtector
-        path: fileNaming.path
     }
 
     TrackerStore {
@@ -188,28 +231,15 @@ 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"))
             }
         }
-
-        onReadyChanged: {
-            if (ready) {
-                imageSettings.setImageResolution()
-            }
-        }
     }
 
     VideoSettings {
@@ -217,33 +247,10 @@ 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"))
             }
         }
-
-        onReadyChanged: {
-            if (ready) {
-                videoSettings.setVideoResolution()
-            }
-        }
-    }
-
-    Connections {
-        target: settings
-
-        onPrimaryImageResolutionChanged: imageSettings.setImageResolution()
-        onPrimaryImageAspectRatioChanged: imageSettings.setImageResolution()
-        onSecondaryImageResolutionChanged: imageSettings.setImageResolution()
-        onSecondaryImageAspectRatioChanged: imageSettings.setImageResolution()
-
-        onPrimaryVideoResolutionChanged: videoSettings.setVideoResolution()
-        onPrimaryVideoAspectRatioChanged: videoSettings.setVideoResolution()
-        onSecondaryVideoResolutionChanged: videoSettings.setVideoResolution()
-        onSecondaryVideoAspectRatioChanged: videoSettings.setVideoResolution()
     }
 
     ModeController {
@@ -266,13 +273,18 @@ CameraPage {
 
     DeviceKeys {
         id: keys
-        active: Qt.application.active && pipelineManager.scaleAcquired
+        active: Qt.application.active && pipelineManager.scaleAcquired && root.inCaptureMode && !mainView.moving
         repeat: !settings.zoomAsShutter
     }
 
+    CameraProximitySensor {
+        id: proximitySensor
+        active: Qt.application.active && viewfinder.camera.running && settings.proximityAsShutter && root.inCaptureMode && !mainView.moving
+    }
+
     Standby {
         policyLost: pipelineManager.state == "policyLost"
         show: !Qt.application.active || pipelineManager.showStandBy ||
-            (mainView.currentIndex == 1 && !viewfinder.camera.running)
+            (inCaptureMode && !viewfinder.camera.running)
     }
 }