Don't disable GPS when we are obscured by location-ui or conndlgs
[harmattan/cameraplus] / qml / MainPage.qml
index bf98add..82d914e 100644 (file)
@@ -25,12 +25,12 @@ 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
@@ -97,6 +97,30 @@ CameraPage {
                 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 {
@@ -111,6 +135,13 @@ CameraPage {
             return false
         }
 
+        if (mode == Camera.ImageMode) {
+            imageSettings.setImageResolution()
+        }
+        else if (mode == Camera.VideoMode) {
+            videoSettings.setVideoResolution()
+        }
+
         return true
     }
 
@@ -120,12 +151,19 @@ CameraPage {
     }
 
     property alias dimmer: camDimmer
+
+    PlatformQuirks {
+        id: platformQuirks
+    }
+
+    DisplayState {
+        id: displayState
+        inhibitDim: mainView.currentItem != null ? mainView.currentItem.inhibitDim : false
+    }
+
     CameraPositionSource {
         id: positionSource
-        active: settings.useGps
-        // TODO: we cannot bind to cam.running because camera will stop
-        // when the connection dialog pops up and we end up with an infinite loop
-        // active: cam.running && settings.useGps
+        active: (viewfinder.camera.running || platformQuirks.forceOn) && settings.useGps && displayState.isOn
         onPositionChanged: geocode.search(position.coordinate.longitude, position.coordinate.latitude)
     }
 
@@ -164,7 +202,7 @@ CameraPage {
 
     ReverseGeocode {
         id: geocode
-        active: viewfinder.camera.running && settings.useGps && settings.useGeotags
+        active: (viewfinder.camera.running || platformQuirks.forceOn) && settings.useGps && settings.useGeotags && displayState.isOn
     }
 
     DeviceInfo {
@@ -186,6 +224,7 @@ CameraPage {
         imagePath: platformSettings.imagePath
         videoPath: platformSettings.videoPath
         temporaryVideoPath: platformSettings.temporaryVideoPath
+        settings: settings
     }
 
     MountProtector {
@@ -208,12 +247,6 @@ CameraPage {
                 showError(qsTr("Failed to set required resolution"))
             }
         }
-
-        onReadyChanged: {
-            if (ready) {
-                imageSettings.setImageResolution()
-            }
-        }
     }
 
     VideoSettings {
@@ -225,28 +258,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 {
@@ -269,13 +280,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)
     }
 }