* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-import QtQuick 1.1
+import QtQuick 2.0
import QtCamera 1.0
import CameraPlus 1.0
-// TODO: reset reticle and roi when we stop camera or change mode
-Camera {
- id: cam
-
- property bool pressed: loader.item ? loader.item.pressed : false
+Viewfinder {
+ id: viewfinder
+ property bool pressed: focusReticle.locked || preview.animationRunning
+ || (loader.item ? loader.item.pressed : false)
property int policyMode: loader.item ? loader.item.policyMode : CameraResources.None
- renderingEnabled: mainView.currentItem == cam
+ camera: cam
+ cameraConfig: cam.cameraConfig
+ renderingEnabled: mainView.currentItem == viewfinder
- function policyLost() {
- if (loader.item) {
- loader.item.policyLost()
- }
+ Component.onDestruction: cam.stop()
+
+ GridLines {
+ x: viewfinder.renderArea.x
+ y: viewfinder.renderArea.y
+ width: viewfinder.renderArea.width
+ height: viewfinder.renderArea.height
+ visible: settings.gridEnabled
}
- function checkBattery() {
- // We are fine if we are connected to the charger:
- if (batteryMonitor.charging) {
- return true
+ PhoneProfile {
+ id: phoneProfile
+ }
+
+ Camera {
+ id: cam
+ sounds: Sounds {
+ id: sounds
+ mute: !settings.soundEnabled || phoneProfile.isSilent
+ volume: volumeControl.fullVolume ? Sounds.VolumeHigh : Sounds.VolumeLow
+ imageCaptureStart: platformSettings.imageCaptureStartedSound
+ imageCaptureEnd: platformSettings.imageCaptureEndedSound
+ videoRecordingStart: platformSettings.videoRecordingStartedSound
+ videoRecordingEnd: platformSettings.videoRecordingEndedSound
+ autoFocusAcquired: platformSettings.autoFocusAcquiredSound
}
- // If we have enough battery then we are fine:
- if (!batteryMonitor.critical) {
- return true
+ onFocusChanged: focus.value = Focus.ContinuousNormal
+ onRoiChanged: roi.normalize = false
+
+ onRunningChanged: {
+ if (!cam.running) {
+ mountProtector.unlockAll()
+ }
}
- return false
- }
+ onError: {
+ if (pipelineManager.error) {
+ // Ignore any subsequent errors.
+ // Killing pulseaudio while recording will lead to an
+ // infinite supply of errors which will break the UI
+ // if we show a banner for each.
+ return
+ }
- Component.onDestruction: cam.stop()
+ pipelineManager.error = true
+ if (loader.item) {
+ loader.item.cameraError()
+ }
- onRunningChanged: {
- if (!cam.running) {
- mountProtector.unlock()
+ console.log("Camera error (" + code + "): " + message + " " + debug)
+ showError(qsTr("Camera error. Please restart the application."))
+ // We cannot stop camera here. Seems there is a race condition somewhere
+ // which leads to a freeze if we do so.
}
+
}
- notifications: Sounds {
- id: sounds
- mute: !settings.soundEnabled
+ SoundVolumeControl {
+ id: volumeControl
}
BatteryInfo {
id: preview
}
+ FocusReticle {
+ id: focusReticle
+ cam: cam
+ videoResolution: viewfinder.videoResolution
+ renderArea: viewfinder.renderArea
+
+ visible: loader.item != null && loader.item.controlsVisible &&
+ cam.autoFocus.canFocus(cam.scene.value)
+ cafStatus: cam ? cam.autoFocus.cafStatus : -1
+ status: cam ? cam.autoFocus.status : -1
+ }
+
+ Loader {
+ id: loader
+ property string src: cam.mode == Camera.VideoMode ? "VideoOverlay.qml" : "ImageOverlay.qml"
+ anchors.fill: parent
+ source: Qt.resolvedUrl(src)
+ }
+
Connections {
target: loader.item
onPreviewAvailable: preview.setPreview(uri)
when: loader.item != null
}
- onRoiChanged: roi.normalize = false
-
- GridLines {
- x: cam.renderArea.x
- y: cam.renderArea.y
- width: cam.renderArea.width
- height: cam.renderArea.height
- visible: settings.gridEnabled
- }
-
- FocusReticle {
- id: focusReticle
- cam: cam
- visible: loader.item != null && loader.item.controlsVisible &&
- cam.autoFocus.canFocus(cam.scene.value)
- cafStatus: cam ? cam.autoFocus.cafStatus : -1
- status: cam ? cam.autoFocus.status : -1
- }
-
- Loader {
- id: loader
- property string src: mode == Camera.VideoMode ? "VideoOverlay.qml" : "ImageOverlay.qml"
- anchors.fill: parent
- source: Qt.resolvedUrl(src)
- }
-
+ /* Camera bindings */
Binding {
target: cam.flash
property: "value"
- when: cam.mode == Camera.ImageMode
+ when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
value: settings.imageFlashMode
}
Binding {
target: settings
property: "imageFlashMode"
- when: cam.mode == Camera.ImageMode
+ when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
value: cam.flash.value
}
Binding {
target: cam.scene
property: "value"
- when: cam.mode == Camera.VideoMode
+ when: cam.mode == Camera.VideoMode && !root.deviceChangeInProgress
value: settings.videoSceneMode
}
Binding {
target: cam.scene
property: "value"
- when: cam.mode == Camera.ImageMode
+ when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
value: settings.imageSceneMode
}
Binding {
target: cam.evComp
property: "value"
- when: cam.mode == Camera.ImageMode
+ when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
value: settings.imageEvComp
}
Binding {
target: cam.evComp
property: "value"
- when: cam.mode == Camera.VideoMode
+ when: cam.mode == Camera.VideoMode && !root.deviceChangeInProgress
value: settings.videoEvComp
}
Binding {
target: settings
property: "imageEvComp"
- when: cam.mode == Camera.ImageMode
+ when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
value: cam.evComp.value
}
Binding {
target: settings
property: "videoEvComp"
- when: cam.mode == Camera.VideoMode
+ when: cam.mode == Camera.VideoMode && !root.deviceChangeInProgress
value: cam.evComp.value
}
Binding {
target: cam.whiteBalance
property: "value"
- when: cam.mode == Camera.ImageMode
+ when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
value: settings.imageWhiteBalance
}
Binding {
target: cam.whiteBalance
property: "value"
- when: cam.mode == Camera.VideoMode
+ when: cam.mode == Camera.VideoMode && !root.deviceChangeInProgress
value: settings.videoWhiteBalance
}
Binding {
target: cam.colorTone
property: "value"
- when: cam.mode == Camera.ImageMode
+ when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
value: settings.imageColorFilter
}
Binding {
target: cam.colorTone
property: "value"
- when: cam.mode == Camera.VideoMode
+ when: cam.mode == Camera.VideoMode && !root.deviceChangeInProgress
value: settings.videoColorFilter
}
Binding {
target: cam.iso
property: "value"
- when: cam.mode == Camera.ImageMode
+ when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
value: settings.imageIso
}
Binding {
target: settings
property: "imageIso"
- when: cam.mode == Camera.ImageMode
+ when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
value: cam.iso.value
}
value: settings.faceDetectionEnabled && !focusReticle.pressed && !focusReticle.touchMode && cam.mode == Camera.ImageMode
}
- onError: {
- if (pipelineManager.error) {
- // Ignore any subsequent errors.
- // Killing pulseaudio while recording will lead to an
- // infinite supply of errors which will break the UI
- // if we show a banner for each.
- return
+ function policyLost() {
+ if (loader.item) {
+ loader.item.policyLost()
}
+ }
- pipelineManager.error = true
- if (loader.item) {
- loader.item.cameraError()
+ function checkBattery() {
+ // We are fine if we are connected to the charger:
+ if (batteryMonitor.charging) {
+ return true
+ }
+
+ // If we have enough battery then we are fine:
+ if (!batteryMonitor.critical) {
+ return true
}
- console.log("Camera error (" + code + "): " + message + " " + debug)
- showError(qsTr("Camera error. Please restart the application."))
- // We cannot stop camera here. Seems there is a race condition somewhere
- // which leads to a freeze if we do so.
+ return false
}
+ function cameraDeviceChanged() {
+ if (loader.item) {
+ loader.item.cameraDeviceChanged()
+ }
+ }
}