diff options
author | Kalle Viironen <kalle.viironen@digia.com> | 2014-02-21 12:03:35 +0200 |
---|---|---|
committer | Kalle Viironen <kalle.viironen@digia.com> | 2014-02-21 12:04:13 +0200 |
commit | b1f9ebae32c44ff0dc2315a1c1c363ad98aaf145 (patch) | |
tree | bad33c0a01cc4274dee43c8370a0bdcd08d6fc7f /basicsuite/camera | |
parent | 9c48ce0535c7a89e32a4b0f932dc3f61e973018a (diff) | |
parent | 0325d7b4156098ef064f04208905712c5bf0174e (diff) |
Merge branch 'stable' into release
* stable: (50 commits)
Fix deployment of QML import plugins when building in Qt Creator
Add QtWidgets dependecy to shared.pri
Update title and description for Text Input demo
Update content for About Boot to Qt demo
Fix QML GroupBox: Binding loop detected for property
[controls-touch] Deploy images
Remove Sensors demo from the Qt Creator's list of examples
Remove Sensor Explorer and Particles demos from launcher
Fix layout issues with Qt-Everywhere (touchgallery)
[qt5-launchpresentation] Don't crop the description text on nexus
[launcher settings] improve visual appearance
[qt5-everywhere] update preview image
Fix vkb import path
Fix issues in qt5-launcher presentation
Remove Raspberry Pi logo from demo
Fix Canvas2D error
Qt5-Everywhere: show network error message
fix glsl syntax in graphical effects demo
Update copyright year
Limit camera & mediaplayer demos to working devices
...
Change-Id: I1ed9233a89ea989013b398c8480e1932949fff19
Diffstat (limited to 'basicsuite/camera')
23 files changed, 1866 insertions, 0 deletions
diff --git a/basicsuite/camera/CameraControlButton.qml b/basicsuite/camera/CameraControlButton.qml new file mode 100644 index 0000000..f0dc438 --- /dev/null +++ b/basicsuite/camera/CameraControlButton.qml @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: For any questions to Digia, please use the contact form at +** http://qt.digia.com/ +** +** This file is part of the examples of the Qt Enterprise Embedded. +** +** $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$ +** +****************************************************************************/ +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..bf8fb6b --- /dev/null +++ b/basicsuite/camera/CameraSetting.qml @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: For any questions to Digia, please use the contact form at +** http://qt.digia.com/ +** +** This file is part of the examples of the Qt Enterprise Embedded. +** +** $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$ +** +****************************************************************************/ +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..5a14e4e --- /dev/null +++ b/basicsuite/camera/CaptureControl.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: For any questions to Digia, please use the contact form at +** http://qt.digia.com/ +** +** This file is part of the examples of the Qt Enterprise Embedded. +** +** $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$ +** +****************************************************************************/ +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..db01ca4 --- /dev/null +++ b/basicsuite/camera/CapturePreview.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: For any questions to Digia, please use the contact form at +** http://qt.digia.com/ +** +** This file is part of the examples of the Qt Enterprise Embedded. +** +** $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$ +** +****************************************************************************/ +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..cc1e1ad --- /dev/null +++ b/basicsuite/camera/Controls.qml @@ -0,0 +1,199 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: For any questions to Digia, please use the contact form at +** http://qt.digia.com/ +** +** This file is part of the examples of the Qt Enterprise Embedded. +** +** $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$ +** +****************************************************************************/ +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..83fd2fe --- /dev/null +++ b/basicsuite/camera/FocusControl.qml @@ -0,0 +1,151 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: For any questions to Digia, please use the contact form at +** http://qt.digia.com/ +** +** This file is part of the examples of the Qt Enterprise Embedded. +** +** $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$ +** +****************************************************************************/ +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..e29d70f --- /dev/null +++ b/basicsuite/camera/Picker.qml @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: For any questions to Digia, please use the contact form at +** http://qt.digia.com/ +** +** This file is part of the examples of the Qt Enterprise Embedded. +** +** $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$ +** +****************************************************************************/ +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..941f76a --- /dev/null +++ b/basicsuite/camera/RecordingTime.qml @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: For any questions to Digia, please use the contact form at +** http://qt.digia.com/ +** +** This file is part of the examples of the Qt Enterprise Embedded. +** +** $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$ +** +****************************************************************************/ +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..18853ad --- /dev/null +++ b/basicsuite/camera/Slider.qml @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: For any questions to Digia, please use the contact form at +** http://qt.digia.com/ +** +** This file is part of the examples of the Qt Enterprise Embedded. +** +** $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$ +** +****************************************************************************/ +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..0c1cbdd --- /dev/null +++ b/basicsuite/camera/ZoomControl.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: For any questions to Digia, please use the contact form at +** http://qt.digia.com/ +** +** This file is part of the examples of the Qt Enterprise Embedded. +** +** $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$ +** +****************************************************************************/ +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/app.pro b/basicsuite/camera/app.pro new file mode 100644 index 0000000..b588a0d --- /dev/null +++ b/basicsuite/camera/app.pro @@ -0,0 +1,13 @@ +TARGET = camera + +include(../shared/shared.pri) +b2qtdemo_deploy_defaults() + +content.files = \ + *.qml \ + *.png +content.path = $$DESTPATH + +OTHER_FILES += $${content.files} + +INSTALLS += target content diff --git a/basicsuite/camera/camera.pro b/basicsuite/camera/camera.pro new file mode 100644 index 0000000..7d9c9f1 --- /dev/null +++ b/basicsuite/camera/camera.pro @@ -0,0 +1,7 @@ +TEMPLATE = subdirs +CONFIG += ordered + +SUBDIRS += \ + camerautils \ + app.pro + diff --git a/basicsuite/camera/camerautils/camerautils.cpp b/basicsuite/camera/camerautils/camerautils.cpp new file mode 100644 index 0000000..9e890d5 --- /dev/null +++ b/basicsuite/camera/camerautils/camerautils.cpp @@ -0,0 +1,229 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: For any questions to Digia, please use the contact form at +** http://qt.digia.com/ +** +** This file is part of the examples of the Qt Enterprise Embedded. +** +** $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 "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..67c5b0d --- /dev/null +++ b/basicsuite/camera/camerautils/camerautils.h @@ -0,0 +1,127 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: For any questions to Digia, please use the contact form at +** http://qt.digia.com/ +** +** This file is part of the examples of the Qt Enterprise Embedded. +** +** $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$ +** +****************************************************************************/ +#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..7e5864e --- /dev/null +++ b/basicsuite/camera/camerautils/camerautils.pro @@ -0,0 +1,20 @@ +TEMPLATE = lib +CONFIG += plugin +QT += qml multimedia + +TARGET = camerautilsplugin + +SOURCES += plugin.cpp \ + camerautils.cpp + +HEADERS += camerautils.h + +pluginfiles.files += \ + qmldir \ + +B2QT_DEPLOYPATH = /data/user/qt/qmlplugins/CameraUtils +target.path += $$B2QT_DEPLOYPATH +pluginfiles.path += $$B2QT_DEPLOYPATH + +INSTALLS += target pluginfiles + diff --git a/basicsuite/camera/camerautils/plugin.cpp b/basicsuite/camera/camerautils/plugin.cpp new file mode 100644 index 0000000..5e74e71 --- /dev/null +++ b/basicsuite/camera/camerautils/plugin.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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..71c3c44 --- /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. + +Demo can be used to take pictures. Files are saved inside the /data/images/ folder and can be viewed with the "Photo Gallery" application. + +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/exclude.txt b/basicsuite/camera/exclude.txt new file mode 100644 index 0000000..b481e58 --- /dev/null +++ b/basicsuite/camera/exclude.txt @@ -0,0 +1,8 @@ +android-beaglebone +android-iMX6 +android-emulator +linux-beagleboard +linux-beaglebone +linux-iMX6 +linux-raspberrypi +linux-emulator diff --git a/basicsuite/camera/main.qml b/basicsuite/camera/main.qml new file mode 100644 index 0000000..a0cf449 --- /dev/null +++ b/basicsuite/camera/main.qml @@ -0,0 +1,263 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: For any questions to Digia, please use the contact form at +** http://qt.digia.com/ +** +** This file is part of the examples of the Qt Enterprise Embedded. +** +** $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$ +** +****************************************************************************/ +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.captureToLocation("/data/images/"); + 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.captureToLocation("/data/images/"); + } + } + } + } + + // 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 + } + +} diff --git a/basicsuite/camera/preview_l.jpg b/basicsuite/camera/preview_l.jpg Binary files differnew file mode 100644 index 0000000..3f15310 --- /dev/null +++ b/basicsuite/camera/preview_l.jpg diff --git a/basicsuite/camera/title.txt b/basicsuite/camera/title.txt new file mode 100644 index 0000000..10a226d --- /dev/null +++ b/basicsuite/camera/title.txt @@ -0,0 +1 @@ +Camera |