summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDmytro Poplavskiy <dmytro.poplavskiy@nokia.com>2012-07-16 16:40:57 +1000
committerQt by Nokia <qt-info@nokia.com>2012-07-19 09:08:52 +0200
commit0d0e89b1e89589812a91ee8d202de2576d6ae89f (patch)
tree6e954afb33ef63233773b00a2e561e37a23a9c59 /examples
parentf844d6d9da0fff8f1eaad1ad7f3d73e85560b735 (diff)
downloadqtmultimedia-0d0e89b1e89589812a91ee8d202de2576d6ae89f.tar.gz
Ported QML camera example to QtQuick 2.0 and QtMultimedia 5.0
Removed controls not currently supported on Qt5 platforms and added basic video capture mode Change-Id: I1f188d31af770cfb6ebb65ab5ee4a5467abcfbeb Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/declarative-camera/CameraPropertyButton.qml1
-rw-r--r--examples/declarative-camera/CaptureControls.qml237
-rw-r--r--examples/declarative-camera/FlickableList.qml128
-rw-r--r--examples/declarative-camera/PhotoCaptureControls.qml159
-rw-r--r--examples/declarative-camera/VideoCaptureControls.qml132
-rw-r--r--examples/declarative-camera/VideoPreview.qml (renamed from examples/declarative-camera/ExposureCompensationButton.qml)51
-rw-r--r--examples/declarative-camera/ZoomControl.qml2
-rw-r--r--examples/declarative-camera/declarative-camera.pro32
-rw-r--r--examples/declarative-camera/declarative-camera.qml93
-rw-r--r--examples/declarative-camera/declarative-camera.qrc28
-rw-r--r--examples/declarative-camera/qmlcamera.cpp48
11 files changed, 401 insertions, 510 deletions
diff --git a/examples/declarative-camera/CameraPropertyButton.qml b/examples/declarative-camera/CameraPropertyButton.qml
index 71732d2bc..257ceefc5 100644
--- a/examples/declarative-camera/CameraPropertyButton.qml
+++ b/examples/declarative-camera/CameraPropertyButton.qml
@@ -79,7 +79,6 @@ Item {
State {
name: "invisible"
PropertyChanges { target: popup; opacity: 0 }
- PropertyChanges { target: camera; focus: true }
},
State {
diff --git a/examples/declarative-camera/CaptureControls.qml b/examples/declarative-camera/CaptureControls.qml
deleted file mode 100644
index 6a0e88ce0..000000000
--- a/examples/declarative-camera/CaptureControls.qml
+++ /dev/null
@@ -1,237 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** 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 Nokia Corporation 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
-
-FocusScope {
- property Camera camera
- property bool previewAvailable : false
-
- property alias whiteBalance : wbModesButton.value
- property alias flashMode : flashModesButton.value
- property alias exposureCompensation : exposureCompensationButton.value
-
- property int buttonsPanelWidth: buttonPaneShadow.width
-
- signal previewSelected
- id : captureControls
-
- Rectangle {
- id: buttonPaneShadow
- width: buttonPanningPane.width + 16
- height: parent.height
- anchors.top: parent.top
- anchors.right: parent.right
- color: Qt.rgba(0.08, 0.08, 0.08, 1)
-
- Flickable {
- id: buttonPanningPane
- anchors {
- right: parent.right
- top: parent.top
- bottom: parent.bottom
- margins: 8
- }
- width: buttonsColumn.width
-
- contentWidth: buttonsColumn.width
- contentHeight: buttonsColumn.height
-
- Column {
- id: buttonsColumn
- spacing: 8
-
- FocusButton {
- camera: captureControls.camera
- }
-
- CameraButton {
- text: "Capture"
- onClicked: camera.captureImage()
- }
-
- CameraPropertyButton {
- id : flashModesButton
- value: Camera.FlashOff
- model: ListModel {
- ListElement {
- icon: "images/camera_flash_auto.png"
- value: Camera.FlashAuto
- text: "Auto"
- }
- ListElement {
- icon: "images/camera_flash_off.png"
- value: Camera.FlashOff
- text: "Off"
- }
- ListElement {
- icon: "images/camera_flash_fill.png"
- value: Camera.FlashOn
- text: "On"
- }
- ListElement {
- icon: "images/camera_flash_redeye.png"
- value: Camera.FlashRedEyeReduction
- text: "Red Eye Reduction"
- }
- }
- }
-
- CameraPropertyButton {
- id : wbModesButton
- value: Camera.WhiteBalanceAuto
- model: ListModel {
- ListElement {
- icon: "images/camera_auto_mode.png"
- value: Camera.WhiteBalanceAuto
- text: "Auto"
- }
- ListElement {
- icon: "images/camera_white_balance_sunny.png"
- value: Camera.WhiteBalanceSunlight
- text: "Sunlight"
- }
- ListElement {
- icon: "images/camera_white_balance_cloudy.png"
- value: Camera.WhiteBalanceCloudy
- text: "Cloudy"
- }
- ListElement {
- icon: "images/camera_white_balance_incandescent.png"
- value: Camera.WhiteBalanceTungsten
- text: "Tungsten"
- }
- ListElement {
- icon: "images/camera_white_balance_flourescent.png"
- value: Camera.WhiteBalanceFluorescent
- text: "Fluorescent"
- }
- }
- }
-
- ExposureCompensationButton {
- id : exposureCompensationButton
- }
-
- CameraButton {
- text: "View"
- onClicked: captureControls.previewSelected()
- visible: captureControls.previewAvailable
- }
-
- CameraButton {
- id: quitButton
- text: "Quit"
- onClicked: Qt.quit()
- }
-
- }
- }
- }
-
-
- Item {
- id: exposureDetails
- anchors.bottom : parent.bottom
- anchors.left : parent.left
- anchors.bottomMargin: 16
- anchors.leftMargin: 16
- height: childrenRect.height
- width: childrenRect.width
-
- visible : camera.lockStatus == Camera.Locked
-
- Rectangle {
- opacity: 0.4
- color: "black"
- anchors.fill: parent
- }
-
- Row {
- spacing : 16
-
- Text {
- text: "Av: "+camera.aperture.toFixed(1)
- font.pixelSize: 18
- color: "white"
- visible: camera.aperture > 0
- }
-
- Text {
- font.pixelSize: 18
- color: "white"
- visible: camera.shutterSpped > 0
- text: "Tv: "+printableExposureTime(camera.shutterSpeed)
-
- function printableExposureTime(t) {
- if (t > 3.9)
- return "Tv: "+t.toFixed() + "\"";
-
- if (t > 0.24 )
- return "Tv: "+t.toFixed(1) + "\"";
-
- if (t > 0)
- return "Tv: 1/"+(1/t).toFixed();
-
- return "";
- }
- }
-
- Text {
- text: "ISO: "+camera.iso.toFixed()
- font.pixelSize: 18
- color: "white"
- visible: camera.iso > 0
- }
- }
- }
-
- ZoomControl {
- x : 0
- y : 0
- width : 100
- height: parent.height
-
- currentZoom: camera.digitalZoom
- maximumZoom: Math.min(4.0, camera.maximumDigitalZoom)
- onZoomTo: camera.setDigitalZoom(value)
- }
-}
diff --git a/examples/declarative-camera/FlickableList.qml b/examples/declarative-camera/FlickableList.qml
deleted file mode 100644
index 1aae66302..000000000
--- a/examples/declarative-camera/FlickableList.qml
+++ /dev/null
@@ -1,128 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** 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 Nokia Corporation 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: flickableList
- clip: true
-
- signal clicked
-
- property alias delegate : repeater.delegate
-
- property variant items: []
- property int index: 0
- property int itemWidth : flickableList.width
-
- function scrollTo(id) {
- var x = id*flickableList.itemWidth
- if (flickArea.contentX != x) {
- centeringAnimation.stop();
- flickArea.newX = id*flickableList.itemWidth
- centeringAnimation.start();
- }
- }
-
- onIndexChanged: scrollTo(index)
- onWidthChanged: scrollTo(index)
-
- Flickable {
- id: flickArea
- property int newX: 0
-
- MouseArea {
- anchors.fill: parent
- onClicked: {
- var x = mapToItem(flickableList, mouseX, mouseY).x
-
- if (x < flickableList.width/3) {
- if (flickableList.index > 0)
- flickableList.scrollTo(flickableList.index-1);
- } else if (x > flickableList.width*2/3) {
- if (flickableList.index < flickableList.items.length-1)
- flickableList.scrollTo(flickableList.index+1);
- } else {
- flickableList.clicked()
- }
-
- }
- }
-
- PropertyAnimation {
- id: centeringAnimation
- target: flickArea
- properties: "contentX"
- easing.type: Easing.OutQuad
- from: flickArea.contentX
- to: flickArea.newX
-
- onCompleted: {
- flickableList.index = flickArea.newX / flickableList.itemWidth
- }
- }
-
- onMovementStarted: {
- centeringAnimation.stop();
- }
-
- onMovementEnded: {
- var modulo = flickArea.contentX % flickableList.itemWidth;
- var offset = flickableList.itemWidth / 2;
- flickArea.newX = modulo < offset ? flickArea.contentX - modulo : flickArea.contentX + (flickableList.itemWidth - modulo);
- centeringAnimation.start();
- }
-
-
- width: flickableList.width
- height: flickableList.height
- contentWidth: items.width
- contentHeight: items.height
- flickDeceleration: 4000
-
- Row {
- id: items
- Repeater {
- id: repeater
- model: flickableList.items.length
- }
- }
- }
-}
diff --git a/examples/declarative-camera/PhotoCaptureControls.qml b/examples/declarative-camera/PhotoCaptureControls.qml
new file mode 100644
index 000000000..d378d9456
--- /dev/null
+++ b/examples/declarative-camera/PhotoCaptureControls.qml
@@ -0,0 +1,159 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 Nokia Corporation 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
+
+FocusScope {
+ property Camera camera
+ property bool previewAvailable : false
+
+ property int buttonsPanelWidth: buttonPaneShadow.width
+
+ signal previewSelected
+ signal videoModeSelected
+ id : captureControls
+
+ Rectangle {
+ id: buttonPaneShadow
+ width: buttonsColumn.width + 16
+ height: parent.height
+ anchors.top: parent.top
+ anchors.right: parent.right
+ color: Qt.rgba(0.08, 0.08, 0.08, 1)
+
+ Column {
+ anchors {
+ right: parent.right
+ top: parent.top
+ margins: 8
+ }
+
+ id: buttonsColumn
+ spacing: 8
+
+ FocusButton {
+ camera: captureControls.camera
+ visible: camera.cameraStatus == Camera.ActiveStatus && camera.focus.isFocusModeSupported(Camera.FocusAuto)
+ }
+
+ CameraButton {
+ text: "Capture"
+ visible: camera.imageCapture.ready
+ onClicked: camera.imageCapture.capture()
+ }
+
+ CameraPropertyButton {
+ id : wbModesButton
+ value: CameraImageProcessing.WhiteBalanceAuto
+ model: ListModel {
+ ListElement {
+ icon: "images/camera_auto_mode.png"
+ value: CameraImageProcessing.WhiteBalanceAuto
+ text: "Auto"
+ }
+ ListElement {
+ icon: "images/camera_white_balance_sunny.png"
+ value: CameraImageProcessing.WhiteBalanceSunlight
+ text: "Sunlight"
+ }
+ ListElement {
+ icon: "images/camera_white_balance_cloudy.png"
+ value: CameraImageProcessing.WhiteBalanceCloudy
+ text: "Cloudy"
+ }
+ ListElement {
+ icon: "images/camera_white_balance_incandescent.png"
+ value: CameraImageProcessing.WhiteBalanceTungsten
+ text: "Tungsten"
+ }
+ ListElement {
+ icon: "images/camera_white_balance_flourescent.png"
+ value: CameraImageProcessing.WhiteBalanceFluorescent
+ text: "Fluorescent"
+ }
+ }
+ }
+
+ CameraButton {
+ text: "View"
+ onClicked: captureControls.previewSelected()
+ visible: captureControls.previewAvailable
+ }
+ }
+
+ Column {
+ anchors {
+ bottom: parent.bottom
+ right: parent.right
+ margins: 8
+ }
+
+ id: bottomColumn
+ spacing: 8
+
+ CameraButton {
+ text: "Switch to Video"
+ onClicked: captureControls.videoModeSelected()
+ }
+
+
+ CameraButton {
+ id: quitButton
+ text: "Quit"
+ onClicked: Qt.quit()
+ }
+ }
+
+
+ }
+
+
+ ZoomControl {
+ x : 0
+ y : 0
+ width : 100
+ height: parent.height
+
+ currentZoom: camera.digitalZoom
+ maximumZoom: Math.min(4.0, camera.maximumDigitalZoom)
+ onZoomTo: camera.setDigitalZoom(value)
+ }
+}
diff --git a/examples/declarative-camera/VideoCaptureControls.qml b/examples/declarative-camera/VideoCaptureControls.qml
new file mode 100644
index 000000000..0809b24ce
--- /dev/null
+++ b/examples/declarative-camera/VideoCaptureControls.qml
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 Nokia Corporation 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
+
+FocusScope {
+ property Camera camera
+ property bool previewAvailable : false
+
+ property int buttonsPanelWidth: buttonPaneShadow.width
+
+ signal previewSelected
+ signal photoModeSelected
+ id : captureControls
+
+ Rectangle {
+ id: buttonPaneShadow
+ width: buttonsColumn.width + 16
+ height: parent.height
+ anchors.top: parent.top
+ anchors.right: parent.right
+ color: Qt.rgba(0.08, 0.08, 0.08, 1)
+
+ Column {
+ anchors {
+ right: parent.right
+ top: parent.top
+ margins: 8
+ }
+
+ id: buttonsColumn
+ spacing: 8
+
+ FocusButton {
+ camera: captureControls.camera
+ visible: camera.cameraStatus == Camera.ActiveStatus && camera.focus.isFocusModeSupported(Camera.FocusAuto)
+ }
+
+ CameraButton {
+ text: "Record"
+ visible: camera.videoRecorder.recorderStatus == CameraRecorder.LoadedStatus
+ onClicked: camera.videoRecorder.record()
+ }
+
+ CameraButton {
+ id: stopButton
+ text: "Stop"
+ visible: camera.videoRecorder.recorderStatus == CameraRecorder.RecordingStatus
+ onClicked: camera.videoRecorder.stop()
+ }
+
+ CameraButton {
+ text: "View"
+ onClicked: captureControls.previewSelected()
+ //don't show View button during recording
+ visible: camera.videoRecorder.actualLocation && !stopButton.visible
+ }
+ }
+
+ Column {
+ anchors {
+ bottom: parent.bottom
+ right: parent.right
+ margins: 8
+ }
+
+ id: bottomColumn
+ spacing: 8
+
+ CameraButton {
+ text: "Switch to Photo"
+ onClicked: captureControls.photoModeSelected()
+ }
+
+ CameraButton {
+ id: quitButton
+ text: "Quit"
+ onClicked: Qt.quit()
+ }
+ }
+ }
+
+
+ ZoomControl {
+ x : 0
+ y : 0
+ width : 100
+ height: parent.height
+
+ currentZoom: camera.digitalZoom
+ maximumZoom: Math.min(4.0, camera.maximumDigitalZoom)
+ onZoomTo: camera.setDigitalZoom(value)
+ }
+}
diff --git a/examples/declarative-camera/ExposureCompensationButton.qml b/examples/declarative-camera/VideoPreview.qml
index 811722c46..267de7b8e 100644
--- a/examples/declarative-camera/ExposureCompensationButton.qml
+++ b/examples/declarative-camera/VideoPreview.qml
@@ -39,46 +39,33 @@
****************************************************************************/
import QtQuick 2.0
+import QtMultimedia 5.0
Item {
- id: exposureCompensation
- property real value : flickableList.items[flickableList.index]
- signal clicked
+ id: videoPreview
+ property alias source : player.source
+ signal closed
- width : 144
- height: 70
+ MediaPlayer {
+ id: player
+ autoPlay: true
- BorderImage {
- id: buttonImage
- source: "images/toolbutton.sci"
- width: exposureCompensation.width; height: exposureCompensation.height
+ //switch back to viewfinder after playback finished
+ onStatusChanged: {
+ if (status == MediaPlayer.EndOfMedia)
+ videoPreview.closed();
+ }
}
- Text {
- text: "Ev:"
- x: 8
- y: 8
- font.pixelSize: 18
- color: "white"
+ VideoOutput {
+ source: player
+ anchors.fill : parent
}
- FlickableList {
- anchors.fill: buttonImage
- id: flickableList
- items: ["-2", "-1.5", "-1", "-0.5", "0", "+0.5", "+1", "+1.5", "+2"]
- index: 4
-
- onClicked: exposureCompensation.clicked()
-
- delegate: Text {
- font.pixelSize: 22
- color: "white"
- styleColor: "black"
- width: flickableList.width
- height: flickableList.height
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- text: flickableList.items[index]
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ videoPreview.closed();
}
}
}
diff --git a/examples/declarative-camera/ZoomControl.qml b/examples/declarative-camera/ZoomControl.qml
index 0b48c40eb..3f9b6e406 100644
--- a/examples/declarative-camera/ZoomControl.qml
+++ b/examples/declarative-camera/ZoomControl.qml
@@ -59,7 +59,7 @@ Item {
initialZoom = zoomControl.currentZoom
}
- onMousePositionChanged: {
+ onPositionChanged: {
if (pressed) {
var target = initialZoom * Math.pow(2, (initialPos-mouseY)/zoomControl.height);
target = Math.max(1, Math.min(target, zoomControl.maximumZoom))
diff --git a/examples/declarative-camera/declarative-camera.pro b/examples/declarative-camera/declarative-camera.pro
index 6ca62f0f9..a32ee127f 100644
--- a/examples/declarative-camera/declarative-camera.pro
+++ b/examples/declarative-camera/declarative-camera.pro
@@ -1,22 +1,24 @@
-
TEMPLATE=app
+TARGET=declarative-camera
-QT += qtquick1 network multimedia
-
-contains(QT_CONFIG, opengl) {
- QT += opengl
-}
+QT += quick qml multimedia
-SOURCES += $$PWD/qmlcamera.cpp
-!mac:TARGET = qml_camera
-else:TARGET = QmlCamera
+SOURCES += qmlcamera.cpp
-RESOURCES += declarative-camera.qrc
+target.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/declarative-camera
-target.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/qml_camera
-sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/qml_camera
+qml.files = declarative-camera.qml \
+ CameraButton.qml \
+ CameraPropertyButton.qml \
+ CameraPropertyPopup.qml \
+ FocusButton.qml \
+ PhotoCaptureControls.qml \
+ PhotoPreview.qml \
+ VideoCaptureControls.qml \
+ VideoPreview.qml \
+ ZoomControl.qml \
+ images
-INSTALLS += target sources
+qml.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/declarative-camera
-QT+=widgets
+INSTALLS += target qml
diff --git a/examples/declarative-camera/declarative-camera.qml b/examples/declarative-camera/declarative-camera.qml
index 54935b326..8ab6604b4 100644
--- a/examples/declarative-camera/declarative-camera.qml
+++ b/examples/declarative-camera/declarative-camera.qml
@@ -43,6 +43,10 @@ import QtMultimedia 5.0
Rectangle {
id : cameraUI
+
+ width: 800
+ height: 480
+
color: "black"
state: "PhotoCapture"
@@ -51,66 +55,97 @@ Rectangle {
name: "PhotoCapture"
StateChangeScript {
script: {
- camera.visible = true
- camera.focus = true
- stillControls.visible = true
- photoPreview.visible = false
+ camera.captureMode = Camera.CaptureStillImage
+ camera.start()
}
}
},
State {
name: "PhotoPreview"
+ },
+ State {
+ name: "VideoCapture"
StateChangeScript {
script: {
- camera.visible = false
- stillControls.visible = false
- photoPreview.visible = true
- photoPreview.focus = true
+ camera.captureMode = Camera.CaptureVideo
+ camera.start()
+ }
+ }
+ },
+ State {
+ name: "VideoPreview"
+ StateChangeScript {
+ script: {
+ camera.stop()
}
}
}
]
+ Camera {
+ id: camera
+ captureMode: Camera.CaptureStillImage
+
+ imageCapture {
+ onImageCaptured: {
+ photoPreview.source = preview
+ stillControls.previewAvailable = true
+ cameraUI.state = "PhotoPreview"
+ }
+ }
+
+ videoRecorder {
+ resolution: "640x480"
+ frameRate: 15
+ }
+ }
+
PhotoPreview {
id : photoPreview
anchors.fill : parent
onClosed: cameraUI.state = "PhotoCapture"
+ visible: cameraUI.state == "PhotoPreview"
focus: visible
+ }
- Keys.onPressed : {
- //return to capture mode if the shutter button is touched
- if (event.key == Qt.Key_CameraFocus && !event.isAutoRepeat) {
- cameraUI.state = "PhotoCapture"
- event.accepted = true;
- }
- }
+ VideoPreview {
+ id : videoPreview
+ anchors.fill : parent
+ onClosed: cameraUI.state = "VideoCapture"
+ visible: cameraUI.state == "VideoPreview"
+ focus: visible
+
+ //don't load recorded video if preview is invisible
+ source: visible ? camera.videoRecorder.actualLocation : ""
}
- Camera {
- id: camera
+ VideoOutput {
+ id: viewfinder
+ visible: cameraUI.state == "PhotoCapture" || cameraUI.state == "VideoCapture"
+
x: 0
y: 0
width: parent.width - stillControls.buttonsPanelWidth
height: parent.height
- focus: visible //to receive focus and capture key events
- //captureResolution : "640x480"
-
- flashMode: stillControls.flashMode
- whiteBalanceMode: stillControls.whiteBalance
- exposureCompensation: stillControls.exposureCompensation
- onImageCaptured : {
- photoPreview.source = preview
- stillControls.previewAvailable = true
- cameraUI.state = "PhotoPreview"
- }
+ source: camera
}
- CaptureControls {
+ PhotoCaptureControls {
id: stillControls
anchors.fill: parent
camera: camera
+ visible: cameraUI.state == "PhotoCapture"
onPreviewSelected: cameraUI.state = "PhotoPreview"
+ onVideoModeSelected: cameraUI.state = "VideoCapture"
}
+ VideoCaptureControls {
+ id: videoControls
+ anchors.fill: parent
+ camera: camera
+ visible: cameraUI.state == "VideoCapture"
+ onPreviewSelected: cameraUI.state = "VideoPreview"
+ onPhotoModeSelected: cameraUI.state = "PhotoCapture"
+ }
}
diff --git a/examples/declarative-camera/declarative-camera.qrc b/examples/declarative-camera/declarative-camera.qrc
deleted file mode 100644
index f8ce52784..000000000
--- a/examples/declarative-camera/declarative-camera.qrc
+++ /dev/null
@@ -1,28 +0,0 @@
-<!DOCTYPE RCC>
- <RCC version="1.0">
-
- <qresource prefix="/">
- <file>declarative-camera.qml</file>
- <file>CameraButton.qml</file>
- <file>CameraPropertyPopup.qml</file>
- <file>CameraPropertyButton.qml</file>
- <file>CaptureControls.qml</file>
- <file>ExposureCompensationButton.qml</file>
- <file>FlickableList.qml</file>
- <file>FocusButton.qml</file>
- <file>PhotoPreview.qml</file>
- <file>ZoomControl.qml</file>
- <file>images/camera_auto_mode.png</file>
- <file>images/camera_camera_setting.png</file>
- <file>images/camera_flash_auto.png</file>
- <file>images/camera_flash_fill.png</file>
- <file>images/camera_flash_off.png</file>
- <file>images/camera_flash_redeye.png</file>
- <file>images/camera_white_balance_cloudy.png</file>
- <file>images/camera_white_balance_flourescent.png</file>
- <file>images/camera_white_balance_incandescent.png</file>
- <file>images/camera_white_balance_sunny.png</file>
- <file>images/toolbutton.png</file>
- <file>images/toolbutton.sci</file>
- </qresource>
- </RCC>
diff --git a/examples/declarative-camera/qmlcamera.cpp b/examples/declarative-camera/qmlcamera.cpp
index 85bd9c9d2..e7918a019 100644
--- a/examples/declarative-camera/qmlcamera.cpp
+++ b/examples/declarative-camera/qmlcamera.cpp
@@ -38,51 +38,21 @@
**
****************************************************************************/
-#include <QtWidgets/QApplication>
-#include <QtWidgets/QDesktopWidget>
-#include <QtQuick1/qdeclarativeview.h>
-#include <QtQml/QQmlEngine>
+#include <QGuiApplication>
+#include <QQuickView>
+#include <QQmlEngine>
-#if !defined(QT_NO_OPENGL)
-#include <QtOpenGL/QGLWidget>
-#endif
-
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
{
-
-#if defined (Q_WS_X11) || defined (Q_WS_MAC)
- //### default to using raster graphics backend for now
- bool gsSpecified = false;
- for (int i = 0; i < argc; ++i) {
- QString arg = argv[i];
- if (arg == "-graphicssystem") {
- gsSpecified = true;
- break;
- }
- }
-
- if (!gsSpecified)
- QApplication::setGraphicsSystem("raster");
-#endif
-
- QApplication application(argc, argv);
- const QString mainQmlApp = QLatin1String("qrc:/declarative-camera.qml");
+ QGuiApplication app(argc,argv);
QQuickView view;
-#if !defined(QT_NO_OPENGL)
- view.setViewport(new QGLWidget);
-#endif
- view.setSource(QUrl(mainQmlApp));
view.setResizeMode(QQuickView::SizeRootObjectToView);
// Qt.quit() called in embedded .qml by default only emits
// quit() signal, so do this (optionally use Qt.exit()).
QObject::connect(view.engine(), SIGNAL(quit()), qApp, SLOT(quit()));
-#if defined(Q_WS_MAEMO_6)
- view.setGeometry(application.desktop()->screenGeometry());
- view.showFullScreen();
-#else
- view.setGeometry(QRect(100, 100, 800, 480));
+ view.setSource(QUrl::fromLocalFile(QCoreApplication::applicationDirPath() +
+ QLatin1String("/declarative-camera.qml")));
+ view.resize(800, 480);
view.show();
-#endif
- return application.exec();
+ return app.exec();
}
-