X-Git-Url: http://cgit.sxemacs.org/?p=harmattan%2Fcameraplus;a=blobdiff_plain;f=qml%2FMainPage.qml;h=82d914e7735b097eb2f35e9dfb451c3078c617c7;hp=863a58caae9b9465b005d1efdc71fb973730d548;hb=b12f938a7e89a6fd7d363def86c9390da0e47b17;hpb=9546aadb83f80d8d2b7bfbdf95672d385ddf4416;ds=sidebyside diff --git a/qml/MainPage.qml b/qml/MainPage.qml index 863a58c..82d914e 100644 --- a/qml/MainPage.qml +++ b/qml/MainPage.qml @@ -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,6 +82,10 @@ CameraPage { Settings { id: settings + onDeviceAboutToChange: { + root.deviceChangeInProgress = true + } + onDeviceChanged: { viewfinder.cameraDeviceChanged() @@ -87,9 +93,34 @@ CameraPage { 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 { @@ -104,6 +135,13 @@ CameraPage { return false } + if (mode == Camera.ImageMode) { + imageSettings.setImageResolution() + } + else if (mode == Camera.VideoMode) { + videoSettings.setVideoResolution() + } + return true } @@ -113,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) } @@ -157,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 { @@ -179,6 +224,7 @@ CameraPage { imagePath: platformSettings.imagePath videoPath: platformSettings.videoPath temporaryVideoPath: platformSettings.temporaryVideoPath + settings: settings } MountProtector { @@ -197,19 +243,10 @@ CameraPage { 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 +254,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 +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) } }