summaryrefslogtreecommitdiffstats
path: root/basicsuite/Camera
diff options
context:
space:
mode:
Diffstat (limited to 'basicsuite/Camera')
-rw-r--r--basicsuite/Camera/Camera.pro4
-rw-r--r--basicsuite/Camera/CameraControlButton.qml54
-rw-r--r--basicsuite/Camera/CameraSetting.qml28
-rw-r--r--basicsuite/Camera/CaptureControl.qml40
-rw-r--r--basicsuite/Camera/CapturePreview.qml45
-rw-r--r--basicsuite/Camera/Controls.qml159
-rw-r--r--basicsuite/Camera/FocusControl.qml111
-rw-r--r--basicsuite/Camera/Picker.qml89
-rw-r--r--basicsuite/Camera/README2
-rw-r--r--basicsuite/Camera/RecordingTime.qml70
-rw-r--r--basicsuite/Camera/Slider.qml93
-rw-r--r--basicsuite/Camera/ZoomControl.qml40
-rw-r--r--basicsuite/Camera/camerautils/camerautils.cpp189
-rw-r--r--basicsuite/Camera/camerautils/camerautils.h87
-rw-r--r--basicsuite/Camera/camerautils/camerautils.pro19
-rw-r--r--basicsuite/Camera/camerautils/plugin.cpp60
-rw-r--r--basicsuite/Camera/camerautils/qmldir2
-rw-r--r--basicsuite/Camera/description.txt5
-rw-r--r--basicsuite/Camera/main.qml223
19 files changed, 1320 insertions, 0 deletions
diff --git a/basicsuite/Camera/Camera.pro b/basicsuite/Camera/Camera.pro
new file mode 100644
index 0000000..d8e46c6
--- /dev/null
+++ b/basicsuite/Camera/Camera.pro
@@ -0,0 +1,4 @@
+TEMPLATE = subdirs
+SUBDIRS += \
+ camerautils
+
diff --git a/basicsuite/Camera/CameraControlButton.qml b/basicsuite/Camera/CameraControlButton.qml
new file mode 100644
index 0000000..dc82435
--- /dev/null
+++ b/basicsuite/Camera/CameraControlButton.qml
@@ -0,0 +1,54 @@
+import QtQuick 2.0
+
+MouseArea {
+ id: buttonRoot
+ property alias title: titleTxt.text
+ property alias subtitle: valueTxt.text
+ property bool toggled: false
+
+ width: 78 * root.contentScale
+ height: 78 * root.contentScale
+ opacity: pressed ? 0.3 : 1.0
+ rotation: root.contentRotation
+ Behavior on rotation { NumberAnimation { } }
+
+ Rectangle {
+ anchors.fill: parent
+ color: toggled ? "#8898c66c" : "#77333333"
+ radius: 5 * root.contentScale
+ }
+
+ Column {
+ id: expModeControls
+ spacing: 2 * root.contentScale
+ anchors.centerIn: parent
+
+ Text {
+ id: titleTxt
+ anchors.horizontalCenter: expModeControls.horizontalCenter
+ font.pixelSize: 22 * root.contentScale
+ font.letterSpacing: -1
+ color: "white"
+ font.bold: true
+ }
+
+ Text {
+ id: valueTxt
+ anchors.horizontalCenter: expModeControls.horizontalCenter
+ height: 22 * root.contentScale
+ verticalAlignment: Text.AlignVCenter
+ color: "white"
+
+ Connections {
+ target: root
+ onContentScaleChanged: valueTxt.font.pixelSize = Math.round(18 * root.contentScale)
+ }
+
+ onTextChanged: font.pixelSize = Math.round(18 * root.contentScale)
+ onPaintedWidthChanged: {
+ if (paintedWidth > buttonRoot.width - (8 * root.contentScale))
+ font.pixelSize -= Math.round(2 * root.contentScale);
+ }
+ }
+ }
+}
diff --git a/basicsuite/Camera/CameraSetting.qml b/basicsuite/Camera/CameraSetting.qml
new file mode 100644
index 0000000..224c70c
--- /dev/null
+++ b/basicsuite/Camera/CameraSetting.qml
@@ -0,0 +1,28 @@
+import QtQuick 2.0
+
+Item {
+ width: button.width
+ height: button.height
+ visible: enabled && picker.count > 1
+
+ property alias title: button.title
+ property alias selectedValue: picker.value
+ property alias currentIndex: picker.currentIndex
+ property alias model: picker.model
+ property alias count: picker.count
+
+ CameraControlButton {
+ id: button
+ anchors.centerIn: parent
+
+ subtitle: picker.name
+ toggled: picker.visible
+
+ onClicked: picker.visible = true
+ }
+
+ Picker {
+ id: picker
+ }
+
+}
diff --git a/basicsuite/Camera/CaptureControl.qml b/basicsuite/Camera/CaptureControl.qml
new file mode 100644
index 0000000..b8180f9
--- /dev/null
+++ b/basicsuite/Camera/CaptureControl.qml
@@ -0,0 +1,40 @@
+import QtQuick 2.0
+import QtMultimedia 5.0
+
+Rectangle {
+ id: controlRoot
+
+ signal clicked
+
+ property bool videoMode: camera.captureMode === Camera.CaptureVideo
+
+ width: 180 * root.contentScale
+ height: width
+ radius: width / 2
+ color: mouser.pressed ? (controlRoot.videoMode ? "#77fa334f" : "#7798c66c") : "#77333333"
+ visible: enabled
+
+ Rectangle {
+ id: center
+ anchors.centerIn: parent
+ width: parent.width * 0.45
+ height: width
+ radius: width / 2
+ opacity: mouser.pressed ? 0.7 : 1
+ color: controlRoot.videoMode ? "#fa334f" : "#98c66c"
+ }
+
+ Rectangle {
+ anchors.centerIn: parent
+ color: "white"
+ visible: camera.videoRecorder.recorderStatus === CameraRecorder.RecordingStatus
+ width: center.width * 0.3
+ height: width
+ }
+
+ MouseArea {
+ id: mouser
+ anchors.fill: parent
+ onClicked: controlRoot.clicked()
+ }
+}
diff --git a/basicsuite/Camera/CapturePreview.qml b/basicsuite/Camera/CapturePreview.qml
new file mode 100644
index 0000000..611fa53
--- /dev/null
+++ b/basicsuite/Camera/CapturePreview.qml
@@ -0,0 +1,45 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ anchors.fill: parent
+ color: "black"
+ opacity: 0
+ enabled: opacity !== 0
+
+ property string previewSrc: ""
+
+ onOpacityChanged: {
+ if (opacity === 1 && previewSrc !== "") {
+ previewImage.source = previewSrc;
+ previewSrc = "";
+ }
+ }
+
+ Behavior on opacity { NumberAnimation { duration: 100 } }
+
+ function show() {
+ previewImage.source = "";
+ opacity = 1;
+ }
+
+ function setPreview(preview) {
+ if (root.opacity === 1)
+ previewImage.source = preview;
+ else
+ root.previewSrc = preview;
+ }
+
+ Image {
+ id: previewImage
+ anchors.fill: parent
+ fillMode: Image.PreserveAspectFit
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ root.opacity = 0;
+ }
+ }
+}
diff --git a/basicsuite/Camera/Controls.qml b/basicsuite/Camera/Controls.qml
new file mode 100644
index 0000000..63f750b
--- /dev/null
+++ b/basicsuite/Camera/Controls.qml
@@ -0,0 +1,159 @@
+import QtQuick 2.0
+import QtMultimedia 5.0
+
+Item {
+ id: controlsRoot
+ anchors.fill: parent
+
+ property alias cameraMode: cameraModeControl.selectedValue
+
+ property alias requestedZoom: zoomControl.requestedZoom
+ property alias actualZoom: zoomControl.actualZoom
+ property alias maximumZoom: zoomControl.maximumZoom
+
+ property alias flashMode: flashControl.selectedValue
+ property alias focusMode: focusModeControl.selectedValue
+ property alias exposureMode: expModeControl.selectedValue
+ property alias exposureCompensation: expCompControl.selectedValue
+ property alias whiteBalanceMode: wbControl.selectedValue
+ property alias resolution: resControl.selectedValue
+
+ property bool captureReady: false
+
+ signal capture
+ signal searchAndLock
+
+ FocusControl {
+ id: focusControl
+ anchors.fill: parent
+ onSearchAndLock: controlsRoot.searchAndLock()
+ enabled: camera.captureMode === Camera.CaptureStillImage
+ }
+
+ ZoomControl {
+ id: zoomControl
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 50
+ }
+
+ CameraSetting {
+ id: cameraModeControl
+ anchors.right: parent.right
+ anchors.rightMargin: 20
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 20
+ title: "MODE"
+ model: ListModel {
+ ListElement {
+ name: "Picture"
+ value: Camera.CaptureStillImage
+ }
+ ListElement {
+ name: "Video"
+ value: Camera.CaptureVideo
+ }
+ }
+ onCountChanged: currentIndex = 0
+ enabled: controlsRoot.captureReady
+ }
+
+ RecordingTime {
+ anchors.right: parent.right
+ anchors.rightMargin: 40
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 60 * root.contentScale
+ visible: camera.videoRecorder.recorderStatus === CameraRecorder.RecordingStatus
+ }
+
+ Row {
+ anchors.left: parent.left
+ anchors.leftMargin: 20
+ anchors.top: parent.top
+ anchors.topMargin: 20
+ height: 84
+ spacing: 20
+
+ CameraSetting {
+ id: flashControl
+ title: "FLASH"
+ model: cameraUtils.supportedFlashModes
+ }
+
+ CameraSetting {
+ id: focusModeControl
+ title: "FOCUS"
+ model: cameraUtils.supportedFocusModes
+ enabled: camera.captureMode === Camera.CaptureStillImage
+ }
+
+ CameraSetting {
+ id: expModeControl
+ title: "SCENE"
+ model: cameraUtils.supportedSceneModes
+ }
+
+ CameraSetting {
+ id: expCompControl
+ title: "EV"
+ model: ListModel {
+ ListElement {
+ name: "+2"
+ value: 2
+ }
+ ListElement {
+ name: "+1"
+ value: 1
+ }
+ ListElement {
+ name: "0"
+ value: 0
+ }
+ ListElement {
+ name: "-1"
+ value: -1
+ }
+ ListElement {
+ name: "-2"
+ value: -2
+ }
+ }
+ }
+
+ CameraSetting {
+ id: wbControl
+ title: "WB"
+ model: cameraUtils.supportedWhiteBalanceModes
+ }
+
+ CameraSetting {
+ id: resControl
+ title: "SIZE"
+ model: cameraUtils.supportedCaptureResolutions
+// onCountChanged: currentIndex = 1
+
+ Component.onCompleted: currentIndex = 1
+
+ Connections {
+ target: camera
+ onCaptureModeChanged: {
+ if (camera.captureMode === Camera.CaptureStillImage) {
+ resControl.model = cameraUtils.supportedCaptureResolutions;
+ } else {
+ resControl.model = cameraUtils.supportedVideoResolutions;
+ }
+ }
+ }
+ }
+ }
+
+ CaptureControl {
+ id: captureControl
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.right: parent.right
+ anchors.rightMargin: -30
+ enabled: controlsRoot.captureReady || camera.videoRecorder.recorderStatus === CameraRecorder.RecordingStatus
+
+ onClicked: controlsRoot.capture()
+ }
+}
diff --git a/basicsuite/Camera/FocusControl.qml b/basicsuite/Camera/FocusControl.qml
new file mode 100644
index 0000000..f9b2f29
--- /dev/null
+++ b/basicsuite/Camera/FocusControl.qml
@@ -0,0 +1,111 @@
+import QtQuick 2.0
+import QtMultimedia 5.0
+
+MouseArea {
+ id: focusRoot
+
+ signal searchAndLock
+
+ onClicked: {
+ camera.focus.focusPointMode = Camera.FocusPointCustom
+ camera.focus.customFocusPoint = viewfinder.mapPointToSourceNormalized(Qt.point(mouse.x, mouse.y))
+ focusRoot.searchAndLock()
+ }
+
+ Item {
+ id: zones
+ anchors.fill: parent
+
+ property color focusAreaColor
+ property real focusAreaScale: 1
+
+ Repeater {
+ model: camera.focus.focusZones
+
+ Rectangle {
+ border {
+ width: Math.round(2 * root.contentScale)
+ color: zones.focusAreaColor
+ }
+ radius: 8 * root.contentScale
+ color: "transparent"
+ scale: zones.focusAreaScale
+
+ // Map from the relative, normalized frame coordinates
+ property rect mappedRect: viewfinder.mapNormalizedRectToItem(area);
+
+ Connections {
+ target: viewfinder
+ onContentRectChanged: {
+ mappedRect = viewfinder.mapNormalizedRectToItem(area);
+ }
+ }
+
+ x: mappedRect.x - (width - mappedRect.width) / 2
+ y: mappedRect.y - (height - mappedRect.height) / 2
+ width: Math.round(120 * root.contentScale)
+ height: width
+
+ Rectangle {
+ anchors.fill: parent
+ anchors.margins: -1.5
+ color: "transparent"
+ border.width: 1
+ border.color: "black"
+ radius: parent.radius + 2
+ }
+
+ Rectangle {
+ anchors.fill: parent
+ anchors.margins: 1 + parent.border.width / 2 + 0.5
+ color: "transparent"
+ border.width: 1
+ border.color: "black"
+ radius: parent.radius - 3
+ }
+ }
+ }
+
+ states: [
+ State {
+ name: "unlocked"; when: camera.lockStatus === Camera.Unlocked
+ PropertyChanges { target: zones; opacity: 0; focusAreaColor: "red" }
+ },
+ State {
+ name: "searching"; when: camera.lockStatus === Camera.Searching
+ PropertyChanges { target: zones; opacity: 1; focusAreaColor: "white" }
+ },
+ State {
+ name: "locked"; when: camera.lockStatus === Camera.Locked
+ PropertyChanges { target: zones; opacity: 0; focusAreaColor: "green" }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ to: "searching"
+ NumberAnimation { properties: "opacity"; duration: 60 }
+ SequentialAnimation {
+ NumberAnimation {
+ target: zones; property: "focusAreaScale"; from: 1; to: 1.3; duration: 150
+ }
+ PauseAnimation { duration: 20 }
+ NumberAnimation {
+ target: zones; property: "focusAreaScale"; easing.period: 1; easing.amplitude: 1.4
+ easing.type: Easing.OutElastic; from: 1.3; to: 1
+ duration: 450
+ }
+ }
+ },
+ Transition {
+ from: "searching"
+ SequentialAnimation {
+ PauseAnimation { duration: 1500 }
+ NumberAnimation { properties: "opacity"; duration: 60 }
+ }
+ }
+
+ ]
+ }
+
+}
diff --git a/basicsuite/Camera/Picker.qml b/basicsuite/Camera/Picker.qml
new file mode 100644
index 0000000..364fed7
--- /dev/null
+++ b/basicsuite/Camera/Picker.qml
@@ -0,0 +1,89 @@
+import QtQuick 2.0
+
+MouseArea {
+ id: pickerRoot
+
+ parent: root
+ anchors.fill: parent
+
+ onClicked: visible = false
+ visible: false
+
+ property alias contentWidth: back.width
+ property real contentHeight: 350 * root.contentScale
+ property alias model: list.model
+ property variant value: null
+ property string name: ""
+ property alias currentIndex: list.currentIndex
+ property alias count: list.count
+
+ onValueChanged: {
+ for (var i = 0; i < list.count; ++i) {
+ var data = list.model[i];
+ if (data === undefined)
+ data = list.model.get(i);
+ if (data.value === pickerRoot.value) {
+ list.currentIndex = i;
+ return;
+ }
+ }
+ list.currentIndex = -1;
+ }
+
+ Rectangle {
+ id: back
+ color: "#77333333"
+ width: 200 * root.contentScale
+ height: Math.min(pickerRoot.contentHeight, list.contentHeight + list.anchors.margins * 2)
+ anchors.centerIn: parent
+ property int itemHeight: 25 * root.contentScale
+ rotation: root.contentRotation
+ Behavior on rotation { NumberAnimation { } }
+
+ ListView {
+ id: list
+ anchors.fill: parent
+ clip: true
+ anchors.margins: 14 * root.contentScale
+
+ currentIndex: -1
+
+ onCurrentIndexChanged: {
+ if (list.currentIndex >= 0) {
+ var data = list.model[list.currentIndex];
+ if (data === undefined)
+ data = list.model.get(list.currentIndex);
+ pickerRoot.value = data.value;
+ pickerRoot.name = data.name;
+ } else {
+ pickerRoot.value = null
+ pickerRoot.name = ""
+ }
+ }
+
+ delegate: Item {
+ height: 40 * root.contentScale
+ width: parent.width
+ Rectangle {
+ anchors.fill: parent
+ border.color: index == list.currentIndex ? "#44ffffff" : "transparent"
+ color: index == list.currentIndex ? "#22ffffff" : "transparent"
+ radius: 3 * root.contentScale
+ Text {
+ color: "white"
+ text: (typeof modelData === 'undefined' ? name : modelData.name)
+ anchors.centerIn: parent
+ font.pixelSize: Math.round(20 * root.contentScale)
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ list.currentIndex = index;
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
diff --git a/basicsuite/Camera/README b/basicsuite/Camera/README
new file mode 100644
index 0000000..e249fae
--- /dev/null
+++ b/basicsuite/Camera/README
@@ -0,0 +1,2 @@
+You need to compile and intall the included qml plugin for this demo to work.
+
diff --git a/basicsuite/Camera/RecordingTime.qml b/basicsuite/Camera/RecordingTime.qml
new file mode 100644
index 0000000..504d232
--- /dev/null
+++ b/basicsuite/Camera/RecordingTime.qml
@@ -0,0 +1,70 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: recRoot
+ width: row.width + 14 * root.contentScale
+ height: circle.height + 14 * root.contentScale
+ color: "#77333333"
+ radius: 5 * root.contentScale
+ rotation: root.contentRotation
+ Behavior on rotation { NumberAnimation { } }
+
+ Row {
+ id: row
+ anchors.centerIn: parent
+ spacing: 10 * root.contentScale
+
+ Item {
+ anchors.verticalCenter: timeText.verticalCenter
+ width: 18 * root.contentScale
+ height: width
+
+ Rectangle {
+ id: circle
+ width: parent.width
+ height: parent.height
+ radius: width / 2
+ color: "#fa334f"
+
+ SequentialAnimation {
+ loops: Animation.Infinite
+ running: recRoot.visible
+ PropertyAction { target: circle; property: "visible"; value: true }
+ PauseAnimation { duration: 1000 }
+ PropertyAction { target: circle; property: "visible"; value: false }
+ PauseAnimation { duration: 1000 }
+ }
+ }
+ }
+
+ Text {
+ id: timeText
+ color: "white"
+ font.pixelSize: 24 * root.contentScale
+ text: formatTime(camera.videoRecorder.duration)
+ }
+ }
+
+ function formatTime(time) {
+ time = time / 1000
+ var hours = Math.floor(time / 3600);
+ time = time - hours * 3600;
+ var minutes = Math.floor(time / 60);
+ var seconds = Math.floor(time - minutes * 60);
+
+ if (hours > 0)
+ return formatTimeBlock(hours) + ":" + formatTimeBlock(minutes) + ":" + formatTimeBlock(seconds);
+ else
+ return formatTimeBlock(minutes) + ":" + formatTimeBlock(seconds);
+
+ }
+
+ function formatTimeBlock(time) {
+ if (time === 0)
+ return "00"
+ if (time < 10)
+ return "0" + time;
+ else
+ return time.toString();
+ }
+}
diff --git a/basicsuite/Camera/Slider.qml b/basicsuite/Camera/Slider.qml
new file mode 100644
index 0000000..025d521
--- /dev/null
+++ b/basicsuite/Camera/Slider.qml
@@ -0,0 +1,93 @@
+import QtQuick 2.0
+
+Item {
+ id: slider
+
+ height: handleBack.height
+ // value is read/write.
+ property real value: 0
+ property real maximum: 1
+ property real minimum: 0
+ property int xMax: width - handle.width
+ onXMaxChanged: updatePos()
+ onMinimumChanged: updatePos()
+ onValueChanged: if (!pressed) updatePos()
+ property bool mutable: true
+ property alias pressed : backgroundMouse.pressed
+
+ signal valueChangedByHandle(int newValue)
+
+ function updatePos() {
+ if (maximum > minimum) {
+ var pos = 0 + (value - minimum) * slider.xMax / (maximum - minimum);
+ pos = Math.min(pos, width - handle.width - 0);
+ pos = Math.max(pos, 0);
+ handle.x = pos;
+ } else {
+ handle.x = 0;
+ }
+ }
+
+ Rectangle {
+ id: background
+ width: slider.width
+ anchors.verticalCenter: slider.verticalCenter
+ height: 4 * root.contentScale
+ color: "#666666"
+
+ MouseArea {
+ id: backgroundMouse
+ anchors.fill: parent
+ anchors.topMargin: -24 * root.contentScale
+ anchors.bottomMargin: -24 * root.contentScale
+ enabled: slider.mutable
+ drag.target: handle
+ drag.axis: Drag.XAxis
+ drag.minimumX: 0
+ drag.maximumX: slider.xMax
+ onPressedChanged: {
+ value = Math.max(minimum, Math.min(maximum, (maximum - minimum) * (mouseX - handle.width/2) / slider.xMax + minimum));
+ valueChangedByHandle(value);
+ updatePos();
+ }
+ onPositionChanged: {
+ value = Math.max(minimum, Math.min(maximum, (maximum - minimum) * (mouseX - handle.width/2) / slider.xMax + minimum));
+ valueChangedByHandle(value);
+ }
+ }
+ }
+
+ Rectangle {
+ id: progress
+ height: 8 * root.contentScale
+ anchors.verticalCenter: background.verticalCenter
+ anchors.left: background.left
+ anchors.right: handle.right
+ anchors.rightMargin: handle.width / 2
+ visible: slider.enabled
+ color: "#98c66c"
+ }
+
+ Rectangle {
+ id: handleBack
+ width: 40 * root.contentScale
+ height: width
+ radius: width / 2
+ color: "#8898c66c"
+ antialiasing: true
+ anchors.centerIn: handle
+ visible: handle.visible
+ }
+
+ Rectangle {
+ id: handle
+ width: 14 * root.contentScale
+ height: width
+ radius: width / 2
+ antialiasing: true
+ color: "#98c66c"
+ anchors.verticalCenter: background.verticalCenter
+ visible: slider.enabled
+ }
+}
+
diff --git a/basicsuite/Camera/ZoomControl.qml b/basicsuite/Camera/ZoomControl.qml
new file mode 100644
index 0000000..493defe
--- /dev/null
+++ b/basicsuite/Camera/ZoomControl.qml
@@ -0,0 +1,40 @@
+import QtQuick 2.0
+
+Column {
+ width: 400 * root.contentScale
+ spacing: 20 * root.contentScale
+ visible: maximumZoom > 1
+
+ property alias maximumZoom: zoomSlider.maximum
+ property alias requestedZoom: zoomSlider.value
+ property real actualZoom: 1
+
+ Rectangle {
+ anchors.horizontalCenter: zoomSlider.horizontalCenter
+ width: zoomText.width + 10 * root.contentScale
+ height: zoomText.height + 10 * root.contentScale
+ color: "#77333333"
+ radius: 5 * root.contentScale
+ rotation: root.contentRotation
+ Behavior on rotation { NumberAnimation { } }
+
+ Text {
+ id: zoomText
+ anchors.centerIn: parent
+ font.pixelSize: Math.round(24 * root.contentScale)
+ color: "white"
+ font.bold: true
+ text: (Math.round(actualZoom * 100) / 100) + "x"
+ }
+ }
+
+ Slider {
+ id: zoomSlider
+ width: parent.width
+ rotation: root.contentRotation === -90 ? 180 : (root.contentRotation === 90 ? 0 : root.contentRotation)
+
+ minimum: 1
+ maximum: 1
+ value: 1
+ }
+}
diff --git a/basicsuite/Camera/camerautils/camerautils.cpp b/basicsuite/Camera/camerautils/camerautils.cpp
new file mode 100644
index 0000000..608bfaa
--- /dev/null
+++ b/basicsuite/Camera/camerautils/camerautils.cpp
@@ -0,0 +1,189 @@
+#include "camerautils.h"
+
+#include <QCamera>
+#include <QCameraImageCapture>
+#include <QCameraImageProcessing>
+#include <QCameraExposure>
+#include <QCameraFocus>
+#include <QMediaRecorder>
+
+static QList<CameraSettingsValue*> g_commonResolutions;
+static QList<CameraSettingsValue*> g_commonVideoResolutions;
+static QList<CameraSettingsValue*> g_whiteBalanceModes;
+static QList<CameraSettingsValue*> g_sceneModes;
+static QList<CameraSettingsValue*> g_flashModes;
+static QList<CameraSettingsValue*> g_focusModes;
+
+QDebug operator<<(QDebug dbg, const CameraSettingsValue &r) {
+ dbg.nospace() << "CameraSettingsValue(" << r.name() << ", " << r.value() << ')';
+ return dbg.space();
+}
+
+CameraUtils::CameraUtils(QObject *parent)
+ : QObject(parent)
+ , m_camera(0)
+{
+ if (g_commonResolutions.isEmpty()) {
+ g_commonResolutions << new CameraSettingsValue(QStringLiteral("QVGA"), QSize(320, 240))
+ << new CameraSettingsValue(QStringLiteral("0.3M"), QSize(640, 480))
+ << new CameraSettingsValue(QStringLiteral("0.8M"), QSize(1024, 768))
+ << new CameraSettingsValue(QStringLiteral("1.2M"), QSize(1280, 960))
+ << new CameraSettingsValue(QStringLiteral("2M"), QSize(1600, 1200))
+ << new CameraSettingsValue(QStringLiteral("5M"), QSize(2560, 1920))
+ << new CameraSettingsValue(QStringLiteral("8M"), QSize(3264, 2448));
+
+ g_commonVideoResolutions << new CameraSettingsValue(QStringLiteral("1080p (16:9)"), QSize(1920, 1080))
+ << new CameraSettingsValue(QStringLiteral("1080p (16:9)"), QSize(1920, 1088))
+ << new CameraSettingsValue(QStringLiteral("1080p (4:3)"), QSize(1440, 1080))
+ << new CameraSettingsValue(QStringLiteral("1080p (4:3)"), QSize(1440, 1088))
+ << new CameraSettingsValue(QStringLiteral("720p (16:9)"), QSize(1280, 720))
+ << new CameraSettingsValue(QStringLiteral("720p (4:3)"), QSize(960, 720))
+ << new CameraSettingsValue(QStringLiteral("480p (16:9)"), QSize(720, 480))
+ << new CameraSettingsValue(QStringLiteral("480p (4:3)"), QSize(640, 480))
+ << new CameraSettingsValue(QStringLiteral("QVGA"), QSize(320, 240));
+
+ g_whiteBalanceModes << new CameraSettingsValue(QStringLiteral("Auto"), QCameraImageProcessing::WhiteBalanceAuto)
+ << new CameraSettingsValue(QStringLiteral("Manual"), QCameraImageProcessing::WhiteBalanceManual)
+ << new CameraSettingsValue(QStringLiteral("Sunlight"), QCameraImageProcessing::WhiteBalanceSunlight)
+ << new CameraSettingsValue(QStringLiteral("Cloudy"), QCameraImageProcessing::WhiteBalanceCloudy)
+ << new CameraSettingsValue(QStringLiteral("Shade"), QCameraImageProcessing::WhiteBalanceShade)
+ << new CameraSettingsValue(QStringLiteral("Tungsten"), QCameraImageProcessing::WhiteBalanceTungsten)
+ << new CameraSettingsValue(QStringLiteral("Fluorescent"), QCameraImageProcessing::WhiteBalanceFluorescent)
+ << new CameraSettingsValue(QStringLiteral("Flash"), QCameraImageProcessing::WhiteBalanceFlash)
+ << new CameraSettingsValue(QStringLiteral("Sunset"), QCameraImageProcessing::WhiteBalanceSunset);
+
+ g_sceneModes << new CameraSettingsValue(QStringLiteral("Auto"), QCameraExposure::ExposureAuto)
+ << new CameraSettingsValue(QStringLiteral("Manual"), QCameraExposure::ExposureManual)
+ << new CameraSettingsValue(QStringLiteral("Portrait"), QCameraExposure::ExposurePortrait)
+ << new CameraSettingsValue(QStringLiteral("Night"), QCameraExposure::ExposureNight)
+ << new CameraSettingsValue(QStringLiteral("Backlight"), QCameraExposure::ExposureBacklight)
+ << new CameraSettingsValue(QStringLiteral("Spotlight"), QCameraExposure::ExposureSpotlight)
+ << new CameraSettingsValue(QStringLiteral("Sports"), QCameraExposure::ExposureSports)
+ << new CameraSettingsValue(QStringLiteral("Snow"), QCameraExposure::ExposureSnow)
+ << new CameraSettingsValue(QStringLiteral("Beach"), QCameraExposure::ExposureBeach)
+ << new CameraSettingsValue(QStringLiteral("Large Aperture"), QCameraExposure::ExposureLargeAperture)
+ << new CameraSettingsValue(QStringLiteral("Small Aperture"), QCameraExposure::ExposureSmallAperture);
+
+ g_flashModes << new CameraSettingsValue(QStringLiteral("Auto"), QCameraExposure::FlashAuto)
+ << new CameraSettingsValue(QStringLiteral("Off"), QCameraExposure::FlashOff)
+ << new CameraSettingsValue(QStringLiteral("On"), QCameraExposure::FlashOn)
+ << new CameraSettingsValue(QStringLiteral("Red-Eye"), QCameraExposure::FlashRedEyeReduction)
+ << new CameraSettingsValue(QStringLiteral("Torch"), QCameraExposure::FlashVideoLight);
+
+ g_focusModes << new CameraSettingsValue(QStringLiteral("Auto"), QCameraFocus::AutoFocus)
+ << new CameraSettingsValue(QStringLiteral("Continuous"), QCameraFocus::ContinuousFocus)
+ << new CameraSettingsValue(QStringLiteral("Hyperfocal"), QCameraFocus::HyperfocalFocus)
+ << new CameraSettingsValue(QStringLiteral("Infinity"), QCameraFocus::InfinityFocus)
+ << new CameraSettingsValue(QStringLiteral("Macro"), QCameraFocus::MacroFocus)
+ << new CameraSettingsValue(QStringLiteral("Off"), QCameraFocus::ManualFocus);
+ }
+
+}
+
+CameraUtils::~CameraUtils()
+{
+}
+
+void CameraUtils::init()
+{
+ m_camera = new QCamera;
+ connect(m_camera, SIGNAL(statusChanged(QCamera::Status)), this, SLOT(onCameraStatusChanged()));
+ connect(m_camera, SIGNAL(error(QCamera::Error)), this, SLOT(onError()));
+ m_camera->load();
+}
+
+void CameraUtils::setCamera(QObject *obj)
+{
+ QObject *mediaObject = qvariant_cast<QObject*>(obj->property("mediaObject"));
+ if (!mediaObject)
+ return;
+
+ m_camera = qobject_cast<QCamera*>(mediaObject);
+ if (!m_camera)
+ return;
+
+ if (m_camera->status() >= QCamera::LoadedStatus)
+ onCameraStatusChanged();
+ else
+ connect(m_camera, SIGNAL(statusChanged(QCamera::Status)), this, SLOT(onCameraStatusChanged()));
+}
+
+void CameraUtils::onError()
+{
+ if (m_camera && m_camera->status() == QCamera::UnavailableStatus) {
+ delete m_camera;
+ m_camera = 0;
+
+ emit done();
+ }
+}
+
+void CameraUtils::onCameraStatusChanged()
+{
+ if (!m_camera || m_camera->status() < QCamera::LoadedStatus)
+ return;
+
+ disconnect(m_camera, SIGNAL(statusChanged(QCamera::Status)), this, SLOT(onCameraStatusChanged()));
+
+ QCameraImageCapture *imageCapture = new QCameraImageCapture(m_camera);
+ QCameraImageProcessing *imageProc = m_camera->imageProcessing();
+ QCameraExposure *exposure = m_camera->exposure();
+ QCameraFocus *focus = m_camera->focus();
+ QMediaRecorder rec(m_camera);
+
+ // Supported image resolutions
+ QList<QSize> resolutions = imageCapture->supportedResolutions();
+ for (int i = resolutions.size() - 1; i >= 0; --i) {
+ QSize reso = resolutions.at(i);
+ int mp = reso.width() * reso.height();
+ CameraSettingsValue *r = new CameraSettingsValue(QString::number(mp / double(1000000), 'f', 1) + QLatin1String("M"), reso);
+ m_supportedResolutions.append(r);
+ }
+
+ // Supported video resolutions
+ QList<QSize> suppRes = rec.supportedResolutions();
+ for (int i = 0; i < g_commonVideoResolutions.size(); ++i) {
+ CameraSettingsValue *r = g_commonVideoResolutions.at(i);
+ if (suppRes.contains(r->value().toSize()))
+ m_supportedVideoResolutions.append(r);
+ }
+
+
+ // Supported white balance modes
+ for (int i = 0; i < g_whiteBalanceModes.size(); ++i) {
+ CameraSettingsValue *m = g_whiteBalanceModes.at(i);
+ if (imageProc->isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceMode(m->value().toInt())))
+ m_supportedWhiteBalanceModes.append(m);
+ }
+
+ // Supported scene modes
+ for (int i = 0; i < g_sceneModes.size(); ++i) {
+ CameraSettingsValue *sm = g_sceneModes.at(i);
+ if (exposure->isExposureModeSupported(QCameraExposure::ExposureMode(sm->value().toInt())))
+ m_supportedSceneModes.append(sm);
+ }
+
+ // Supported flash modes
+ for (int i = 0; i < g_flashModes.size(); ++i) {
+ CameraSettingsValue *sm = g_flashModes.at(i);
+ if (exposure->isFlashModeSupported(QCameraExposure::FlashModes(sm->value().toInt())))
+ m_supportedFlashModes.append(sm);
+ }
+
+ // Supported focus modes
+ for (int i = 0; i < g_focusModes.size(); ++i) {
+ CameraSettingsValue *sm = g_focusModes.at(i);
+ if (focus->isFocusModeSupported(QCameraFocus::FocusModes(sm->value().toInt())))
+ m_supportedFocusModes.append(sm);
+ }
+
+ delete imageCapture;
+
+ emit supportedCaptureResolutionsChanged();
+ emit supportedVideoResolutionsChanged();
+ emit supportedWhiteBalanceModesChanged();
+ emit supportedSceneModesChanged();
+ emit supportedFlashModesChanged();
+}
+
+
diff --git a/basicsuite/Camera/camerautils/camerautils.h b/basicsuite/Camera/camerautils/camerautils.h
new file mode 100644
index 0000000..562b675
--- /dev/null
+++ b/basicsuite/Camera/camerautils/camerautils.h
@@ -0,0 +1,87 @@
+#ifndef CAMERAUTILS_H
+#define CAMERAUTILS_H
+
+#include <QObject>
+#include <QVariant>
+
+class QCamera;
+
+class CameraSettingsValue : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
+ Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
+
+public:
+ CameraSettingsValue(const QString &n, const QVariant &v)
+ : QObject()
+ , m_name(n)
+ , m_value(v)
+ { }
+
+ QString name() const { return m_name; }
+ void setName(const QString &n) { m_name = n; emit nameChanged(); }
+
+ QVariant value() const { return m_value; }
+ void setValue(const QVariant &v) { m_value = v; emit valueChanged(); }
+
+Q_SIGNALS:
+ void nameChanged();
+ void valueChanged();
+
+private:
+ QString m_name;
+ QVariant m_value;
+};
+
+QDebug operator<<(QDebug, const CameraSettingsValue &);
+
+class CameraUtils : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QList<QObject*> supportedCaptureResolutions READ supportedCaptureResolutions NOTIFY supportedCaptureResolutionsChanged)
+ Q_PROPERTY(QList<QObject*> supportedWhiteBalanceModes READ supportedWhiteBalanceModes NOTIFY supportedWhiteBalanceModesChanged)
+ Q_PROPERTY(QList<QObject*> supportedSceneModes READ supportedSceneModes NOTIFY supportedSceneModesChanged)
+ Q_PROPERTY(QList<QObject*> supportedFlashModes READ supportedFlashModes NOTIFY supportedFlashModesChanged)
+ Q_PROPERTY(QList<QObject*> supportedFocusModes READ supportedFocusModes NOTIFY supportedFocusModesChanged)
+ Q_PROPERTY(QList<QObject*> supportedVideoResolutions READ supportedVideoResolutions NOTIFY supportedVideoResolutionsChanged)
+public:
+ explicit CameraUtils(QObject *parent = 0);
+ ~CameraUtils();
+
+ Q_INVOKABLE void init();
+ Q_INVOKABLE void setCamera(QObject *cam);
+
+ QList<QObject*> supportedCaptureResolutions() const { return m_supportedResolutions; }
+ QList<QObject*> supportedVideoResolutions() const { return m_supportedVideoResolutions; }
+ QList<QObject*> supportedWhiteBalanceModes() const { return m_supportedWhiteBalanceModes; }
+ QList<QObject*> supportedSceneModes() const { return m_supportedSceneModes; }
+ QList<QObject*> supportedFlashModes() const { return m_supportedFlashModes; }
+ QList<QObject*> supportedFocusModes() const { return m_supportedFocusModes; }
+
+Q_SIGNALS:
+ void supportedCaptureResolutionsChanged();
+ void supportedWhiteBalanceModesChanged();
+ void supportedSceneModesChanged();
+ void supportedFlashModesChanged();
+ void supportedFocusModesChanged();
+ void supportedVideoResolutionsChanged();
+
+ void done();
+
+private Q_SLOTS:
+ void onCameraStatusChanged();
+ void onError();
+
+private:
+ QCamera *m_camera;
+
+ QList<QObject*> m_supportedResolutions;
+ QList<QObject*> m_supportedVideoResolutions;
+ QList<QObject*> m_supportedWhiteBalanceModes;
+ QList<QObject*> m_supportedSceneModes;
+ QList<QObject*> m_supportedFlashModes;
+ QList<QObject*> m_supportedFocusModes;
+};
+
+#endif // CAMERAUTILS_H
diff --git a/basicsuite/Camera/camerautils/camerautils.pro b/basicsuite/Camera/camerautils/camerautils.pro
new file mode 100644
index 0000000..938a0a9
--- /dev/null
+++ b/basicsuite/Camera/camerautils/camerautils.pro
@@ -0,0 +1,19 @@
+TEMPLATE = lib
+CONFIG += plugin
+QT += qml multimedia
+
+TARGET = camerautilsplugin
+
+SOURCES += plugin.cpp \
+ camerautils.cpp
+
+HEADERS += camerautils.h
+
+pluginfiles.files += \
+ qmldir \
+
+target.path += $$[QT_INSTALL_QML]/CameraUtils
+pluginfiles.path += $$[QT_INSTALL_QML]/CameraUtils
+
+INSTALLS += target pluginfiles
+
diff --git a/basicsuite/Camera/camerautils/plugin.cpp b/basicsuite/Camera/camerautils/plugin.cpp
new file mode 100644
index 0000000..2a8c3ea
--- /dev/null
+++ b/basicsuite/Camera/camerautils/plugin.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtQml/QQmlExtensionPlugin>
+#include <QtQml/qqml.h>
+#include <qdebug.h>
+
+#include "camerautils.h"
+
+class QExampleQmlPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
+
+public:
+ void registerTypes(const char *uri)
+ {
+ qmlRegisterType<CameraUtils>(uri, 1, 0, "CameraUtils");
+ }
+};
+
+
+#include "plugin.moc"
diff --git a/basicsuite/Camera/camerautils/qmldir b/basicsuite/Camera/camerautils/qmldir
new file mode 100644
index 0000000..a5ab412
--- /dev/null
+++ b/basicsuite/Camera/camerautils/qmldir
@@ -0,0 +1,2 @@
+module CameraUtils
+plugin camerautilsplugin
diff --git a/basicsuite/Camera/description.txt b/basicsuite/Camera/description.txt
new file mode 100644
index 0000000..7e94e89
--- /dev/null
+++ b/basicsuite/Camera/description.txt
@@ -0,0 +1,5 @@
+This example demonstrates the use of the camera features of Qt Multimedia with Qt Quick.
+
+It can take pictures and record videos. Files are saved inside the 'DCIM' folder on the external storage.
+
+Camera parameters such as flash mode, scene mode or white balance can be changed. The availability of parameters depends on what the camera driver provides.
diff --git a/basicsuite/Camera/main.qml b/basicsuite/Camera/main.qml
new file mode 100644
index 0000000..a1cc89c
--- /dev/null
+++ b/basicsuite/Camera/main.qml
@@ -0,0 +1,223 @@
+import QtQuick 2.0
+import QtMultimedia 5.0
+//import QtSensors 5.0
+import CameraUtils 1.0
+
+Rectangle {
+ id: root
+ color: "black"
+
+ property real contentScale: root.width / 1280
+ property int contentRotation: 0
+
+ Text {
+ anchors.centerIn: parent
+ color: "white"
+ font.pixelSize: 30
+ text: "Camera service is not available..."
+ visible: camera.cameraStatus === Camera.UnavailableStatus
+ }
+
+ CameraUtils {
+ id: cameraUtils
+ }
+
+ Camera {
+ id: camera
+ property bool updateFocusPointMode: true
+ property bool captureWhenLocked: false
+
+ Component.onCompleted: cameraUtils.setCamera(camera)
+
+ digitalZoom: controls.requestedZoom
+ captureMode: Camera.CaptureStillImage
+
+ onCaptureModeChanged: {
+ if (camera.captureMode === Camera.CaptureVideo) {
+ controls.focusMode = Camera.FocusContinuous;
+ camera.unlock();
+ } else {
+ controls.focusMode = Camera.FocusAuto;
+ }
+ }
+
+ onLockStatusChanged: {
+ if (camera.lockStatus === Camera.Locked && captureWhenLocked) {
+ camera.imageCapture.capture();
+ captureWhenLocked = false;
+ }
+ }
+
+ focus {
+ onFocusModeChanged: {
+ camera.unlock();
+ if (camera.updateFocusPointMode)
+ camera.focus.focusPointMode = Camera.FocusPointAuto
+ }
+ onCustomFocusPointChanged: {
+ if (camera.focus.focusPointMode === Camera.FocusPointCustom
+ && camera.focus.focusMode !== Camera.FocusAuto
+ && camera.focus.focusMode !== Camera.FocusMacro) {
+ camera.updateFocusPointMode = false;
+ camera.focus.focusMode = Camera.FocusAuto
+ controls.focusMode = Camera.FocusAuto
+ camera.updateFocusPointMode = true;
+ }
+ }
+ }
+
+ onCameraStatusChanged: {
+ if (cameraStatus === Camera.ActiveStatus) {
+ controls.exposureMode = camera.exposure.exposureMode
+ controls.exposureCompensation = camera.exposure.exposureCompensation
+ controls.whiteBalanceMode = camera.imageProcessing.whiteBalanceMode
+ controls.flashMode = Camera.FlashAuto
+ if (camera.captureMode === Camera.CaptureStillImage)
+ controls.focusMode = camera.focus.focusMode
+ else
+ camera.focus.focusMode = Camera.FocusContinuous
+ }
+ }
+
+ imageCapture {
+ onImageExposed: capturePreview.show()
+ onImageCaptured: {
+ camera.unlock();
+ capturePreview.setPreview(preview);
+ }
+ onCaptureFailed: print(requestId + " " + message)
+ }
+
+ videoRecorder {
+ // mediaContainer: "mp4"
+ // audioCodec: "aac"
+ // audioSampleRate: 48000
+ // audioBitRate: 192000
+ // audioChannels: 2
+ // videoCodec: "h264"
+ // resolution: Qt.size(960, 720)
+ onResolutionChanged: {
+ if (camera.videoRecorder.resolution == Qt.size(1920, 1080))
+ camera.videoRecorder.videoBitRate = 20000000;
+ else if (camera.videoRecorderresolution == Qt.size(1280, 720))
+ camera.videoRecorder.videoBitRate = 10000000;
+ else
+ camera.videoRecorder.videoBitRate = 5000000;
+ }
+ }
+
+ }
+
+ VideoOutput {
+ id: viewfinder
+ source: camera
+ anchors.fill: parent
+ fillMode: VideoOutput.PreserveAspectFit
+ }
+
+ // OrientationSensor {
+ // active: true
+ // onReadingChanged: {
+ // if (reading.orientation === OrientationReading.TopUp)
+ // root.contentRotation = -90;
+ // else if (reading.orientation === OrientationReading.RightUp)
+ // root.contentRotation = 0;
+ // else if (reading.orientation === OrientationReading.LeftUp)
+ // root.contentRotation = 180;
+ // else if (reading.orientation === OrientationReading.TopDown)
+ // root.contentRotation = 90;
+ // }
+ // }
+
+ // RotationSensor {
+ // active: (camera.cameraStatus === Camera.ActiveStatus)
+ // dataRate: 20
+ // property real lastxvalue: 0
+ // property real lastyvalue: 0
+ // property real lastzvalue: 0
+
+ // onActiveChanged: {
+ // lastxvalue = 0
+ // lastyvalue = 0
+ // lastzvalue = 0
+ // }
+
+ // onReadingChanged: {
+ // if (lastxvalue != 0 && camera.focus.focusMode === Camera.FocusContinuous && camera.lockStatus === Camera.Locked && camera.imageCapture.ready) {
+ // if (Math.abs(reading.x - lastxvalue) > 3 || Math.abs(reading.y - lastyvalue) > 3 || Math.abs(reading.z - lastzvalue) > 3)
+ // camera.unlock();
+ // }
+ // lastxvalue = reading.x;
+ // lastyvalue = reading.y;
+ // lastzvalue = reading.z;
+ // }
+ // }
+
+ Controls {
+ id: controls
+ visible: camera.cameraStatus === Camera.ActiveStatus
+
+ actualZoom: camera.digitalZoom
+ maximumZoom: camera.maximumDigitalZoom
+
+ onCameraModeChanged: camera.captureMode = controls.cameraMode
+
+ onFlashModeChanged: if (visible) camera.flash.mode = controls.flashMode
+ onFocusModeChanged: if (visible) camera.focus.focusMode = controls.focusMode
+ onExposureModeChanged: if (visible) camera.exposure.exposureMode = controls.exposureMode
+ onExposureCompensationChanged: if (visible) camera.exposure.exposureCompensation = controls.exposureCompensation
+ onWhiteBalanceModeChanged: if (visible) camera.imageProcessing.whiteBalanceMode = controls.whiteBalanceMode
+ onResolutionChanged: {
+ if (controls.resolution != null) {
+ if (camera.captureMode === Camera.CaptureStillImage)
+ camera.imageCapture.resolution = controls.resolution;
+ else
+ camera.videoRecorder.resolution = controls.resolution;
+ }
+ }
+
+ onSearchAndLock: {
+ camera.searchAndLock();
+ }
+
+ captureReady: camera.imageCapture.ready
+ onCapture: {
+ if (camera.captureMode === Camera.CaptureVideo) {
+ if (camera.videoRecorder.recorderState === CameraRecorder.RecordingState) {
+ camera.videoRecorder.stop();
+ } else {
+ camera.videoRecorder.record();
+ }
+ } else {
+ if ((camera.focus.focusMode === Camera.FocusAuto || camera.focus.focusMode === Camera.FocusMacro)
+ && camera.focus.focusPointMode === Camera.FocusPointAuto
+ && camera.lockStatus === Camera.Unlocked) {
+ camera.captureWhenLocked = true;
+ camera.searchAndLock();
+ } else {
+ camera.imageCapture.capture();
+ }
+ }
+ }
+ }
+
+ // CameraControlButton {
+ // anchors.left: parent.left
+ // anchors.leftMargin: 30
+ // anchors.bottom: parent.bottom
+ // anchors.bottomMargin: 20
+ // title: camera.cameraStatus === Camera.ActiveStatus ? "Stop" : "Start"
+
+ // onClicked: {
+ // if (camera.cameraStatus === Camera.ActiveStatus)
+ // camera.cameraState = Camera.UnloadedState
+ // else
+ // camera.start();
+ // }
+ // }
+
+ CapturePreview {
+ id: capturePreview
+ }
+
+}