Use Component as the type for initialPage in harmattan CameraWindow
[harmattan/cameraplus] / qml / MainPage.qml
index 37f80c5..58ef4f4 100644 (file)
@@ -25,11 +25,15 @@ import QtCamera 1.0
 import CameraPlus 1.0
 
 // TODO: flash not ready (battery low or flash not ready message)
+// TODO: Sounds
+// TODO: N950 conf
 
 CameraPage {
     id: root
 
     property bool deviceChangeInProgress: false
+    property bool inCaptureMode: mainView.currentIndex == 1
+    property Item dimmer: camDimmer
 
     CameraTheme {
         id: cameraTheme
@@ -149,13 +153,18 @@ CameraPage {
         error.show()
     }
 
-    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)
     }
 
@@ -194,7 +203,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 {
@@ -272,13 +281,37 @@ CameraPage {
 
     DeviceKeys {
         id: keys
-        active: Qt.application.active && pipelineManager.scaleAcquired
+        active: Qt.application.active && pipelineManager.scaleAcquired && root.inCaptureMode && !mainView.moving
         repeat: !settings.zoomAsShutter
     }
 
+    Timer {
+        id: proximityTimer
+        running: proximitySensor.close
+        repeat: false
+        interval: 500
+        onTriggered: {
+            if (proximitySensor.close) {
+                proximitySensor.sensorClosed = true
+            }
+        }
+    }
+
+    CameraProximitySensor {
+        id: proximitySensor
+        property bool sensorClosed: false
+
+        active: Qt.application.active && viewfinder.camera.running && settings.proximityAsShutter && root.inCaptureMode && !mainView.moving
+        onCloseChanged: {
+            if (!close) {
+                sensorClosed = false
+            }
+        }
+    }
+
     Standby {
         policyLost: pipelineManager.state == "policyLost"
         show: !Qt.application.active || pipelineManager.showStandBy ||
-            (mainView.currentIndex == 1 && !viewfinder.camera.running)
+            (inCaptureMode && !viewfinder.camera.running)
     }
 }