diff options
author | Michael Goddard <michael.goddard@nokia.com> | 2011-06-29 13:38:46 +1000 |
---|---|---|
committer | Michael Goddard <michael.goddard@nokia.com> | 2011-06-29 13:38:46 +1000 |
commit | 2a34e88c1e1ced28e75c487cd13402e1c9cf9fa3 (patch) | |
tree | e6c1b770c5c47212792a1f9344fa034ea3e54c44 /examples/declarative-camera |
Initial copy of QtMultimediaKit.
Comes from original repo, with SHA1:
2c82d5611655e5967f5c5095af50c0991c4378b2
Diffstat (limited to 'examples/declarative-camera')
29 files changed, 1480 insertions, 0 deletions
diff --git a/examples/declarative-camera/CameraButton.qml b/examples/declarative-camera/CameraButton.qml new file mode 100644 index 000000000..cc0b1e787 --- /dev/null +++ b/examples/declarative-camera/CameraButton.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Mobility Components. +** +** $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 Qt 4.7 + +Item { + id: button + + signal clicked + + property string text + property color color: "white" + + width : 144 + height: 70 + + BorderImage { + id: buttonImage + source: "images/toolbutton.sci" + width: button.width; height: button.height + } + MouseArea { + id: mouseRegion + anchors.fill: buttonImage + onClicked: { button.clicked(); } + } + Text { + id: btnText + color: button.color + anchors.centerIn: buttonImage; font.bold: true + text: button.text; style: Text.Raised; styleColor: "black" + font.pixelSize: 14 + } +} diff --git a/examples/declarative-camera/CameraPropertyButton.qml b/examples/declarative-camera/CameraPropertyButton.qml new file mode 100644 index 000000000..8787ecbe2 --- /dev/null +++ b/examples/declarative-camera/CameraPropertyButton.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Mobility Components. +** +** $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 Qt 4.7 +import QtMultimediaKit 1.1 + +Item { + id: propertyButton + property alias value : popup.currentValue + property alias model : popup.model + + width : 144 + height: 70 + + BorderImage { + id: buttonImage + source: "images/toolbutton.sci" + width: propertyButton.width; height: propertyButton.height + } + + CameraButton { + anchors.fill: parent + Image { + anchors.centerIn: parent + source: popup.currentItem.icon + } + + onClicked: popup.toggle() + } + + CameraPropertyPopup { + id: popup + anchors.right: parent.left + anchors.rightMargin: 16 + anchors.top: parent.top + state: "invisible" + visible: opacity > 0 + + currentValue: propertyButton.value + + states: [ + State { + name: "invisible" + PropertyChanges { target: popup; opacity: 0 } + PropertyChanges { target: camera; focus: true } + }, + + State { + name: "visible" + PropertyChanges { target: popup; opacity: 1.0 } + } + ] + + transitions: Transition { + NumberAnimation { properties: "opacity"; duration: 100 } + } + + function toggle() { + if (state == "visible") + state = "invisible"; + else + state = "visible"; + } + + onSelected: { + popup.state = "invisible" + } + } +} + diff --git a/examples/declarative-camera/CameraPropertyPopup.qml b/examples/declarative-camera/CameraPropertyPopup.qml new file mode 100644 index 000000000..4d49bb904 --- /dev/null +++ b/examples/declarative-camera/CameraPropertyPopup.qml @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Mobility Components. +** +** $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 Qt 4.7 + +Rectangle { + id: propertyPopup + + property alias model : view.model + property variant currentValue + property variant currentItem : model.get(view.currentIndex) + + property int itemWidth : 100 + property int itemHeight : 70 + property int columns : 2 + + width: columns*itemWidth + view.anchors.margins*2 + height: Math.ceil(model.count/columns)*itemHeight + view.anchors.margins*2 + 25 + + radius: 5 + border.color: "#000000" + border.width: 2 + smooth: true + color: "#5e5e5e" + + signal selected + + function indexForValue(value) { + for (var i = 0; i < view.count; i++) { + if (model.get(i).value == value) { + return i; + } + } + + return 0; + } + + GridView { + id: view + anchors.fill: parent + anchors.margins: 5 + cellWidth: propertyPopup.itemWidth + cellHeight: propertyPopup.itemHeight + snapMode: ListView.SnapOneItem + highlightFollowsCurrentItem: true + highlight: Rectangle { color: "gray"; radius: 5 } + currentIndex: indexForValue(propertyPopup.currentValue) + + onCurrentIndexChanged: { + propertyPopup.currentValue = model.get(view.currentIndex).value + } + + delegate: Item { + width: propertyPopup.itemWidth + height: 70 + + Image { + anchors.centerIn: parent + source: icon + } + MouseArea { + anchors.fill: parent + onClicked: { + propertyPopup.currentValue = value + propertyPopup.selected(value) + } + } + } + } + + Text { + anchors.bottom: parent.bottom + anchors.bottomMargin: 8 + anchors.left: parent.left + anchors.leftMargin: 16 + + color: "#ffffff" + font.bold: true + style: Text.Raised; + styleColor: "black" + font.pixelSize: 14 + + text: view.model.get(view.currentIndex).text + } +} diff --git a/examples/declarative-camera/CaptureControls.qml b/examples/declarative-camera/CaptureControls.qml new file mode 100644 index 000000000..e431b73b5 --- /dev/null +++ b/examples/declarative-camera/CaptureControls.qml @@ -0,0 +1,237 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Mobility Components. +** +** $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 Qt 4.7 +import QtMultimediaKit 1.1 + +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.WhiteBalanceIncandescent + text: "Incandescent" + } + 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/ExposureCompensationButton.qml b/examples/declarative-camera/ExposureCompensationButton.qml new file mode 100644 index 000000000..98e038b8a --- /dev/null +++ b/examples/declarative-camera/ExposureCompensationButton.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Mobility Components. +** +** $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 Qt 4.7 + +Item { + id: exposureCompensation + property real value : flickableList.items[flickableList.index] + signal clicked + + width : 144 + height: 70 + + BorderImage { + id: buttonImage + source: "images/toolbutton.sci" + width: exposureCompensation.width; height: exposureCompensation.height + } + + Text { + text: "Ev:" + x: 8 + y: 8 + font.pixelSize: 18 + color: "white" + } + + 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] + } + } +} + diff --git a/examples/declarative-camera/FlickableList.qml b/examples/declarative-camera/FlickableList.qml new file mode 100644 index 000000000..f33c45311 --- /dev/null +++ b/examples/declarative-camera/FlickableList.qml @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Mobility Components. +** +** $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 Qt 4.7 + +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/FocusButton.qml b/examples/declarative-camera/FocusButton.qml new file mode 100644 index 000000000..39848c043 --- /dev/null +++ b/examples/declarative-camera/FocusButton.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Mobility Components. +** +** $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 Qt 4.7 +import QtMultimediaKit 1.1 + +CameraButton { + property Camera camera + + onClicked: { + if (camera.lockStatus == Camera.Unlocked) + camera.searchAndLock(); + else + camera.unlock(); + } + + text: { + if (camera.lockStatus == Camera.Unlocked) + "Focus"; + else if (camera.lockStatus == Camera.Searching) + "Focusing" + else + "Unlock" + } +} diff --git a/examples/declarative-camera/PhotoPreview.qml b/examples/declarative-camera/PhotoPreview.qml new file mode 100644 index 000000000..c161d7f1c --- /dev/null +++ b/examples/declarative-camera/PhotoPreview.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Mobility Components. +** +** $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 Qt 4.7 +import QtMultimediaKit 1.1 + +Item { + property alias source : preview.source + signal closed + + Image { + id: preview + anchors.fill : parent + fillMode: Image.PreserveAspectFit + smooth: true + } + + MouseArea { + anchors.fill: parent + onClicked: { + parent.closed(); + } + } +} + diff --git a/examples/declarative-camera/ZoomControl.qml b/examples/declarative-camera/ZoomControl.qml new file mode 100644 index 000000000..681f63bd5 --- /dev/null +++ b/examples/declarative-camera/ZoomControl.qml @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Mobility Components. +** +** $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 Qt 4.7 +import QtMultimediaKit 1.1 + +Item { + id : zoomControl + property real currentZoom : 1 + property real maximumZoom : 1 + signal zoomTo(real value) + + MouseArea { + id : mouseArea + anchors.fill: parent + + property real initialZoom : 0 + property real initialPos : 0 + + onPressed: { + initialPos = mouseY + initialZoom = zoomControl.currentZoom + } + + onMousePositionChanged: { + if (pressed) { + var target = initialZoom * Math.pow(2, (initialPos-mouseY)/zoomControl.height); + target = Math.max(1, Math.min(target, zoomControl.maximumZoom)) + zoomControl.zoomTo(target) + } + } + } + + Item { + id : bar + x : 16 + y : parent.height/4 + width : 24 + height : parent.height/2 + opacity : 0 + + Rectangle { + anchors.fill: parent + + smooth: true + radius: 8 + border.color: "black" + border.width: 2 + color: "white" + opacity: 0.3 + } + + Rectangle { + x : 0 + y : parent.height * (1.0 - (zoomControl.currentZoom-1.0) / (zoomControl.maximumZoom-1.0)) + width: parent.width + height: parent.height - y + smooth: true + radius: 8 + color: "black" + opacity: 0.5 + } + + states: State { + name: "ShowBar" + when: mouseArea.pressed || zoomControl.currentZoom > 1.0 + PropertyChanges { target: bar; opacity: 1 } + } + + transitions: [ + Transition { + to : "ShowBar" + NumberAnimation { properties: "opacity"; duration: 100 } + }, + Transition { + from : "ShowBar" + NumberAnimation { properties: "opacity"; duration: 500 } + } + ] + } +} diff --git a/examples/declarative-camera/camerakeyevent_symbian/camerakeyevent_symbian.cpp b/examples/declarative-camera/camerakeyevent_symbian/camerakeyevent_symbian.cpp new file mode 100644 index 000000000..30723af40 --- /dev/null +++ b/examples/declarative-camera/camerakeyevent_symbian/camerakeyevent_symbian.cpp @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Mobility Components. +** +** $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$ +** +****************************************************************************/ + +#include "camerakeyevent_symbian.h" + +#include <QtGui/QWidget> // WId +#include <eikon.hrh> // EKeyCamera +#include <coecntrl.h> // CCoeControl (WId) +#include <w32std.h> // RWindowbase, RWindowGroup, RWsSession + +QSymbianCameraKeyListener::QSymbianCameraKeyListener(QWidget *widget): + QObject(widget), + m_widget(widget) +{ + if (!m_widget) + return; + + // Get view's native Symbian window + WId windowId = 0; + if (m_widget->internalWinId()) + windowId = m_widget->internalWinId(); + else if (m_widget->parentWidget() && m_widget->effectiveWinId()) + windowId = m_widget->effectiveWinId(); + RWindowBase *window = windowId ? static_cast<RWindowBase*>(windowId->DrawableWindow()) : 0; + + // Get hold of the window group + TInt wGroupId = window ? window->WindowGroupId() : 0; + if (!wGroupId) + return; + RWsSession &wsSession = CCoeEnv::Static()->WsSession(); + TUint wGroupHandle = wsSession.GetWindowGroupHandle(wGroupId); + if (wGroupHandle) { + RWindowGroup wGroup(wsSession); + wGroup.Construct(wGroupHandle); + if (wGroup.CaptureKey(EKeyCamera, 0, 0, 100) < 0) + qWarning("Unable to register for camera capture key events, SwEvent capability may be missing"); + } +} + +QSymbianCameraKeyListener::~QSymbianCameraKeyListener() +{ + if (!m_widget) + return; + + // Get view's native Symbian window + WId windowId = 0; + if (m_widget->internalWinId()) + windowId = m_widget->internalWinId(); + else if (m_widget->parentWidget() && m_widget->effectiveWinId()) + windowId = m_widget->effectiveWinId(); + RWindowBase *window = windowId ? static_cast<RWindowBase*>(windowId->DrawableWindow()) : 0; + + // Get hold of the window group + TInt wGroupId = window ? window->WindowGroupId() : 0; + if (!wGroupId) + return; + RWsSession &wsSession = CCoeEnv::Static()->WsSession(); + TUint wGroupHandle = wsSession.GetWindowGroupHandle(wGroupId); + if (wGroupHandle) { + RWindowGroup wGroup(wsSession); + wGroup.Construct(wGroupHandle); + wGroup.CancelCaptureKey(EKeyCamera); + } +} diff --git a/examples/declarative-camera/camerakeyevent_symbian/camerakeyevent_symbian.h b/examples/declarative-camera/camerakeyevent_symbian/camerakeyevent_symbian.h new file mode 100644 index 000000000..4cd5701b9 --- /dev/null +++ b/examples/declarative-camera/camerakeyevent_symbian/camerakeyevent_symbian.h @@ -0,0 +1,87 @@ +#ifndef CAMERAKEYEVENT_SYMBIAN_H +#define CAMERAKEYEVENT_SYMBIAN_H + +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Mobility Components. +** +** $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$ +** +****************************************************************************/ + +/* + * Description: + * This header can be used to register application on Symbian platforms + * for the Camera capture button key events. Application can avoid native + * camera application from starting by not forwarding the key event. + * + * Usage: + * Application needs to include this header and include the needed Symbian + * libraries. Optionally application can include camerakeyevent_symbian.pri + * file. Application can register and unregister for the Camera capture + * key events by creating/destructing the QSymbianCameraKeyListener helper + * object. The widget needs to be shown before it registers for the + * Camera key event. + * + * Libraries needed: + * User needs to define following in the .pro file (or optionally include + * the camerakeyevent_symbian.pri): + * LIBS += -lcone -lws32 + * + * Symbian Capabilities needed: + * To use this header user needs to have SwEvent capability (included in + * the camerakeyevent_symbian.pri): + * TARGET.CAPABILITY += SwEvent + */ + +#include <QtCore/QObject> + +QT_BEGIN_NAMESPACE +QT_FORWARD_DECLARE_CLASS(QWidget) +QT_END_NAMESPACE + +QT_USE_NAMESPACE + +class QSymbianCameraKeyListener : public QObject +{ + Q_OBJECT +public: + QSymbianCameraKeyListener(QWidget *parent = 0); + ~QSymbianCameraKeyListener(); +private: + QWidget *m_widget; +}; + +#endif // CAMERAKEYEVENT_SYMBIAN_H diff --git a/examples/declarative-camera/camerakeyevent_symbian/camerakeyevent_symbian.pri b/examples/declarative-camera/camerakeyevent_symbian/camerakeyevent_symbian.pri new file mode 100644 index 000000000..097c3b245 --- /dev/null +++ b/examples/declarative-camera/camerakeyevent_symbian/camerakeyevent_symbian.pri @@ -0,0 +1,7 @@ +message("camerakeyevent_symbian: Including Symbian camera capture key event register methods") + +HEADERS += $$PWD/camerakeyevent_symbian.h +SOURCES += $$PWD/camerakeyevent_symbian.cpp +INCLUDEPATH += $$PWD +LIBS *= -lcone -lws32 +TARGET.CAPABILITY *= SwEvent diff --git a/examples/declarative-camera/declarative-camera.pro b/examples/declarative-camera/declarative-camera.pro new file mode 100644 index 000000000..297361cf3 --- /dev/null +++ b/examples/declarative-camera/declarative-camera.pro @@ -0,0 +1,31 @@ +include (../mobility_examples.pri) + +TEMPLATE=app + +QT += declarative network + +!maemo5 { + contains(QT_CONFIG, opengl) { + QT += opengl + } +} + +win32 { + #required by Qt SDK to resolve Mobility libraries + CONFIG+=mobility + MOBILITY+=multimedia +} + +SOURCES += $$PWD/qmlcamera.cpp +!mac:TARGET = qml_camera +else:TARGET = QmlCamera + +RESOURCES += declarative-camera.qrc + +symbian { + include(camerakeyevent_symbian/camerakeyevent_symbian.pri) + load(data_caging_paths) + TARGET.CAPABILITY += UserEnvironment NetworkServices Location ReadUserData WriteUserData + TARGET.EPOCHEAPSIZE = 0x20000 0x3000000 +} + diff --git a/examples/declarative-camera/declarative-camera.qml b/examples/declarative-camera/declarative-camera.qml new file mode 100644 index 000000000..0d9f984de --- /dev/null +++ b/examples/declarative-camera/declarative-camera.qml @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Mobility Components. +** +** $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 Qt 4.7 +import QtMultimediaKit 1.1 + +Rectangle { + id : cameraUI + color: "black" + state: "PhotoCapture" + + states: [ + State { + name: "PhotoCapture" + StateChangeScript { + script: { + camera.visible = true + camera.focus = true + stillControls.visible = true + photoPreview.visible = false + } + } + }, + State { + name: "PhotoPreview" + StateChangeScript { + script: { + camera.visible = false + stillControls.visible = false + photoPreview.visible = true + photoPreview.focus = true + } + } + } + ] + + PhotoPreview { + id : photoPreview + anchors.fill : parent + onClosed: cameraUI.state = "PhotoCapture" + 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; + } + } + } + + Camera { + id: camera + 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" + } + } + + CaptureControls { + id: stillControls + anchors.fill: parent + camera: camera + onPreviewSelected: cameraUI.state = "PhotoPreview" + } + +} diff --git a/examples/declarative-camera/declarative-camera.qmlproject b/examples/declarative-camera/declarative-camera.qmlproject new file mode 100644 index 000000000..53f5ecb8d --- /dev/null +++ b/examples/declarative-camera/declarative-camera.qmlproject @@ -0,0 +1,18 @@ +/* File generated by QtCreator */ + +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ "../exampleplugin" ] +} diff --git a/examples/declarative-camera/declarative-camera.qrc b/examples/declarative-camera/declarative-camera.qrc new file mode 100644 index 000000000..f8ce52784 --- /dev/null +++ b/examples/declarative-camera/declarative-camera.qrc @@ -0,0 +1,28 @@ +<!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/images/camera_auto_mode.png b/examples/declarative-camera/images/camera_auto_mode.png Binary files differnew file mode 100644 index 000000000..f168296cf --- /dev/null +++ b/examples/declarative-camera/images/camera_auto_mode.png diff --git a/examples/declarative-camera/images/camera_camera_setting.png b/examples/declarative-camera/images/camera_camera_setting.png Binary files differnew file mode 100644 index 000000000..7b993eee9 --- /dev/null +++ b/examples/declarative-camera/images/camera_camera_setting.png diff --git a/examples/declarative-camera/images/camera_flash_auto.png b/examples/declarative-camera/images/camera_flash_auto.png Binary files differnew file mode 100644 index 000000000..fb5cc40ec --- /dev/null +++ b/examples/declarative-camera/images/camera_flash_auto.png diff --git a/examples/declarative-camera/images/camera_flash_fill.png b/examples/declarative-camera/images/camera_flash_fill.png Binary files differnew file mode 100644 index 000000000..7bc5949ac --- /dev/null +++ b/examples/declarative-camera/images/camera_flash_fill.png diff --git a/examples/declarative-camera/images/camera_flash_off.png b/examples/declarative-camera/images/camera_flash_off.png Binary files differnew file mode 100644 index 000000000..3c5db10cc --- /dev/null +++ b/examples/declarative-camera/images/camera_flash_off.png diff --git a/examples/declarative-camera/images/camera_flash_redeye.png b/examples/declarative-camera/images/camera_flash_redeye.png Binary files differnew file mode 100644 index 000000000..534a087df --- /dev/null +++ b/examples/declarative-camera/images/camera_flash_redeye.png diff --git a/examples/declarative-camera/images/camera_white_balance_cloudy.png b/examples/declarative-camera/images/camera_white_balance_cloudy.png Binary files differnew file mode 100644 index 000000000..243b699e7 --- /dev/null +++ b/examples/declarative-camera/images/camera_white_balance_cloudy.png diff --git a/examples/declarative-camera/images/camera_white_balance_flourescent.png b/examples/declarative-camera/images/camera_white_balance_flourescent.png Binary files differnew file mode 100644 index 000000000..032efe1d1 --- /dev/null +++ b/examples/declarative-camera/images/camera_white_balance_flourescent.png diff --git a/examples/declarative-camera/images/camera_white_balance_incandescent.png b/examples/declarative-camera/images/camera_white_balance_incandescent.png Binary files differnew file mode 100644 index 000000000..98f906741 --- /dev/null +++ b/examples/declarative-camera/images/camera_white_balance_incandescent.png diff --git a/examples/declarative-camera/images/camera_white_balance_sunny.png b/examples/declarative-camera/images/camera_white_balance_sunny.png Binary files differnew file mode 100644 index 000000000..d7d5c9a36 --- /dev/null +++ b/examples/declarative-camera/images/camera_white_balance_sunny.png diff --git a/examples/declarative-camera/images/toolbutton.png b/examples/declarative-camera/images/toolbutton.png Binary files differnew file mode 100644 index 000000000..11310013e --- /dev/null +++ b/examples/declarative-camera/images/toolbutton.png diff --git a/examples/declarative-camera/images/toolbutton.sci b/examples/declarative-camera/images/toolbutton.sci new file mode 100644 index 000000000..9e4f96530 --- /dev/null +++ b/examples/declarative-camera/images/toolbutton.sci @@ -0,0 +1,5 @@ +border.left: 15 +border.top: 4 +border.bottom: 4 +border.right: 15 +source: toolbutton.png diff --git a/examples/declarative-camera/qmlcamera.cpp b/examples/declarative-camera/qmlcamera.cpp new file mode 100644 index 000000000..f6d3e9c36 --- /dev/null +++ b/examples/declarative-camera/qmlcamera.cpp @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Mobility Components. +** +** $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$ +** +****************************************************************************/ + +#include <QtGui/QApplication> +#include <QtGui/QDesktopWidget> +#include <QtDeclarative/QDeclarativeView> +#include <QtDeclarative/QDeclarativeEngine> + +#if !defined(QT_NO_OPENGL) +#include <QtOpenGL/QGLWidget> +#endif + +#ifdef Q_OS_SYMBIAN +#include "camerakeyevent_symbian.h" +#endif // Q_OS_SYMBIAN + +int main(int argc, char *argv[]) +{ + +#if defined (Q_WS_X11) || defined (Q_WS_MAC) || defined (Q_OS_SYMBIAN) + //### 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"); + QDeclarativeView view; +#if !defined(QT_NO_OPENGL) && !defined(Q_WS_MAEMO_5) && !defined(Q_WS_S60) + view.setViewport(new QGLWidget); +#endif + view.setSource(QUrl(mainQmlApp)); + view.setResizeMode(QDeclarativeView::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_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) + view.setGeometry(application.desktop()->screenGeometry()); + view.showFullScreen(); +#ifdef Q_OS_SYMBIAN + new QSymbianCameraKeyListener(&view); +#endif // Q_OS_SYMBIAN +#else + view.setGeometry(QRect(100, 100, 800, 480)); + view.show(); +#endif + return application.exec(); +} + |