X-Git-Url: http://cgit.sxemacs.org/?a=blobdiff_plain;f=qml%2FMainPage.qml;h=1201f8c3a92259e09729d5e892c3ad3c7089a4bb;hb=bf922c4aa3164bf3a50b904126b77a350dafdb71;hp=1b0f5d46820b626024e26d4f5ae6fd7b06a3da7b;hpb=7961e69b8f38ed0e08fedf542fc4001801a9aebc;p=harmattan%2Fcameraplus diff --git a/qml/MainPage.qml b/qml/MainPage.qml index 1b0f5d4..1201f8c 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 CameraPage { id: root + property bool deviceChangeInProgress: false + property bool inCaptureMode: mainView.currentIndex == 1 + CameraTheme { id: cameraTheme } @@ -71,8 +73,7 @@ CameraPage { Component.onCompleted: { platformSettings.init() - // TODO: hardcoding device id - root.resetCamera(0, settings.mode) + root.resetCamera(settings.device, settings.mode) } PlatformSettings { @@ -81,6 +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 { @@ -92,7 +132,17 @@ CameraPage { function resetCamera(deviceId, mode) { if (!viewfinder.camera.reset(deviceId, mode)) { showError(qsTr("Failed to set camera device and mode. Please restart the application.")) + return false } + + if (mode == Camera.ImageMode) { + imageSettings.setImageResolution() + } + else if (mode == Camera.VideoMode) { + videoSettings.setVideoResolution() + } + + return true } function showError(msg) { @@ -101,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) } @@ -145,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 { @@ -164,11 +221,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 { @@ -178,10 +238,6 @@ CameraPage { model: deviceInfo.model } - function checkDiskSpace() { - return fileSystem.hasFreeSpace(fileNaming.path) - } - ImageSettings { id: imageSettings camera: viewfinder.camera @@ -191,12 +247,6 @@ CameraPage { showError(qsTr("Failed to set required resolution")) } } - - onReadyChanged: { - if (ready) { - imageSettings.setImageResolution() - } - } } VideoSettings { @@ -208,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 { @@ -252,13 +280,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) } }