summaryrefslogtreecommitdiffstats
path: root/examples/multimedia/declarative-camera
diff options
context:
space:
mode:
Diffstat (limited to 'examples/multimedia/declarative-camera')
-rw-r--r--examples/multimedia/declarative-camera/CMakeLists.txt4
-rw-r--r--examples/multimedia/declarative-camera/CameraButton.qml51
-rw-r--r--examples/multimedia/declarative-camera/CameraListButton.qml68
-rw-r--r--examples/multimedia/declarative-camera/CameraListPopup.qml69
-rw-r--r--examples/multimedia/declarative-camera/CameraPropertyButton.qml69
-rw-r--r--examples/multimedia/declarative-camera/CameraPropertyPopup.qml69
-rw-r--r--examples/multimedia/declarative-camera/FlashControl.qml65
-rw-r--r--examples/multimedia/declarative-camera/Info.plist2
-rw-r--r--examples/multimedia/declarative-camera/PhotoCaptureControls.qml200
-rw-r--r--examples/multimedia/declarative-camera/PhotoPreview.qml52
-rw-r--r--examples/multimedia/declarative-camera/Popup.qml55
-rw-r--r--examples/multimedia/declarative-camera/VideoCaptureControls.qml220
-rw-r--r--examples/multimedia/declarative-camera/VideoPreview.qml53
-rw-r--r--examples/multimedia/declarative-camera/ZoomControl.qml54
-rw-r--r--examples/multimedia/declarative-camera/declarative-camera.qml114
-rw-r--r--examples/multimedia/declarative-camera/declarative-camera.qrc1
-rw-r--r--examples/multimedia/declarative-camera/doc/images/CaptureControls.pngbin0 -> 41278 bytes
-rw-r--r--examples/multimedia/declarative-camera/doc/images/FlashControls.pngbin0 -> 69725 bytes
-rw-r--r--examples/multimedia/declarative-camera/doc/images/VideoCaptureControls.pngbin0 -> 35913 bytes
-rw-r--r--examples/multimedia/declarative-camera/doc/images/ZoomControl.pngbin0 -> 28291 bytes
-rw-r--r--examples/multimedia/declarative-camera/doc/images/qml-camera.pngbin28409 -> 51620 bytes
-rw-r--r--examples/multimedia/declarative-camera/doc/images/qml-declarative-portrait.pngbin0 -> 49057 bytes
-rw-r--r--examples/multimedia/declarative-camera/doc/src/declarative-camera.qdoc183
-rw-r--r--examples/multimedia/declarative-camera/permission-denied.qml20
-rw-r--r--examples/multimedia/declarative-camera/qmlcamera.cpp89
25 files changed, 548 insertions, 890 deletions
diff --git a/examples/multimedia/declarative-camera/CMakeLists.txt b/examples/multimedia/declarative-camera/CMakeLists.txt
index 7bc0ff7b3..50b0ba48d 100644
--- a/examples/multimedia/declarative-camera/CMakeLists.txt
+++ b/examples/multimedia/declarative-camera/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
cmake_minimum_required(VERSION 3.16)
project(declarative-camera LANGUAGES CXX)
@@ -40,6 +43,7 @@ set(declarative-camera_resource_files
"CameraListPopup.qml"
"CameraPropertyButton.qml"
"CameraPropertyPopup.qml"
+ "FlashControl.qml"
"PhotoCaptureControls.qml"
"PhotoPreview.qml"
"Popup.qml"
diff --git a/examples/multimedia/declarative-camera/CameraButton.qml b/examples/multimedia/declarative-camera/CameraButton.qml
index 1547e015f..43837bcb3 100644
--- a/examples/multimedia/declarative-camera/CameraButton.qml
+++ b/examples/multimedia/declarative-camera/CameraButton.qml
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
diff --git a/examples/multimedia/declarative-camera/CameraListButton.qml b/examples/multimedia/declarative-camera/CameraListButton.qml
index 2b2716eb7..b6361eac2 100644
--- a/examples/multimedia/declarative-camera/CameraListButton.qml
+++ b/examples/multimedia/declarative-camera/CameraListButton.qml
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtMultimedia
@@ -91,23 +44,30 @@ Item {
name: "MobilePortrait"
AnchorChanges {
target: popup
- anchors.bottom: parent.top;
+ // qmllint disable incompatible-type
+ anchors.bottom: cameraListButton.top
+ anchors.left: cameraListButton.left
+ // qmllint enable incompatible-type
}
},
State {
name: "MobileLandscape"
AnchorChanges {
target: popup
- anchors.top: parent.top;
- anchors.right: parent.left;
+ // qmllint disable incompatible-type
+ anchors.top: cameraListButton.top
+ anchors.right: cameraListButton.left
+ // qmllint enable incompatible-type
}
},
State {
name: "Other"
AnchorChanges {
target: popup
- anchors.top: parent.top;
- anchors.right: parent.left;
+ // qmllint disable incompatible-type
+ anchors.top: cameraListButton.top
+ anchors.right: cameraListButton.left
+ // qmllint enable incompatible-type
}
}
]
diff --git a/examples/multimedia/declarative-camera/CameraListPopup.qml b/examples/multimedia/declarative-camera/CameraListPopup.qml
index a9ccb6275..83c9843ee 100644
--- a/examples/multimedia/declarative-camera/CameraListPopup.qml
+++ b/examples/multimedia/declarative-camera/CameraListPopup.qml
@@ -1,61 +1,16 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+pragma ComponentBehavior: Bound
import QtQuick
+import QtMultimedia
Popup {
id: cameraListPopup
property alias model : view.model
- property variant currentValue
- property variant currentItem : model[view.currentIndex]
+ property cameraDevice currentValue
+ property cameraDevice currentItem : model[view.currentIndex]
property int itemWidth : 200
property int itemHeight : 50
@@ -76,11 +31,16 @@ Popup {
clip: true
delegate: Item {
+ id: cameraListItem
+
+ required property int index
+ required property cameraDevice modelData
+
width: cameraListPopup.itemWidth
height: cameraListPopup.itemHeight
Text {
- text: modelData.description
+ text: cameraListItem.modelData.description
anchors.fill: parent
anchors.margins: 5
@@ -96,8 +56,9 @@ Popup {
MouseArea {
anchors.fill: parent
onClicked: {
- view.currentIndex = index
- cameraListPopup.currentValue = modelData
+ view.currentIndex = cameraListItem.index
+ cameraListPopup.currentValue = cameraListItem.modelData
+ cameraListPopup.selected()
}
}
}
diff --git a/examples/multimedia/declarative-camera/CameraPropertyButton.qml b/examples/multimedia/declarative-camera/CameraPropertyButton.qml
index 91961ebf0..3a9e60a98 100644
--- a/examples/multimedia/declarative-camera/CameraPropertyButton.qml
+++ b/examples/multimedia/declarative-camera/CameraPropertyButton.qml
@@ -1,55 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
-import QtMultimedia
Item {
id: propertyButton
@@ -90,23 +42,30 @@ Item {
name: "MobilePortrait"
AnchorChanges {
target: popup
- anchors.bottom: parent.top;
+ // qmllint disable incompatible-type
+ anchors.bottom: propertyButton.top
+ anchors.left: propertyButton.left
+ // qmllint enable incompatible-type
}
},
State {
name: "MobileLandscape"
AnchorChanges {
target: popup
- anchors.verticalCenter: parent.top;
- anchors.right: parent.left;
+ // qmllint disable incompatible-type
+ anchors.verticalCenter: propertyButton.top
+ anchors.right: propertyButton.left
+ // qmllint enable incompatible-type
}
},
State {
name: "Other"
AnchorChanges {
target: popup
- anchors.top: parent.top;
- anchors.right: parent.left;
+ // qmllint disable incompatible-type
+ anchors.top: propertyButton.top
+ anchors.right: propertyButton.left
+ // qmllint enable incompatible-type
}
}
]
diff --git a/examples/multimedia/declarative-camera/CameraPropertyPopup.qml b/examples/multimedia/declarative-camera/CameraPropertyPopup.qml
index 6fc125144..774775a5b 100644
--- a/examples/multimedia/declarative-camera/CameraPropertyPopup.qml
+++ b/examples/multimedia/declarative-camera/CameraPropertyPopup.qml
@@ -1,61 +1,15 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+pragma ComponentBehavior: Bound
import QtQuick
Popup {
id: propertyPopup
property alias model : view.model
- property variant currentValue
- property variant currentItem : model.get(view.currentIndex)
+ property var currentValue
+ property var currentItem : model.get(view.currentIndex)
property int itemWidth : 100
property int itemHeight : 70
@@ -85,21 +39,26 @@ Popup {
snapMode: ListView.SnapOneItem
highlightFollowsCurrentItem: true
highlight: Rectangle { color: "gray"; radius: 5 }
- currentIndex: indexForValue(propertyPopup.currentValue)
+ currentIndex: propertyPopup.indexForValue(propertyPopup.currentValue)
delegate: Item {
+ id: propertyItem
+
+ required property url icon
+ required property var value
+
width: propertyPopup.itemWidth
height: 70
Image {
anchors.centerIn: parent
- source: icon
+ source: propertyItem.icon
}
MouseArea {
anchors.fill: parent
onClicked: {
- propertyPopup.currentValue = value
- propertyPopup.selected(value)
+ propertyPopup.currentValue = propertyItem.value
+ propertyPopup.selected()
}
}
}
diff --git a/examples/multimedia/declarative-camera/FlashControl.qml b/examples/multimedia/declarative-camera/FlashControl.qml
new file mode 100644
index 000000000..61550f098
--- /dev/null
+++ b/examples/multimedia/declarative-camera/FlashControl.qml
@@ -0,0 +1,65 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+import QtMultimedia
+
+Item {
+ id: flashControl
+
+ height: column.height
+
+ property Camera cameraDevice
+ property bool mIsFlashSupported: (cameraDevice && cameraDevice.active) ? cameraDevice.isFlashModeSupported(Camera.FlashOn) : false
+ property bool mIsTorchSupported: (cameraDevice && cameraDevice.active) ? cameraDevice.isTorchModeSupported(Camera.TorchOn) : false
+
+ Column {
+ id: column
+
+ Switch {
+ id: flashModeControl
+ visible: flashControl.mIsFlashSupported
+ opacity: checked ? 0.75 : 0.25
+ text: "Flash"
+ contentItem: Text {
+ text: flashModeControl.text
+ color: "white"
+ leftPadding: flashModeControl.indicator.width + flashModeControl.spacing
+ }
+
+ onPositionChanged: {
+ if (position) {
+ if (torchModeControl.checked)
+ torchModeControl.toggle();
+ flashControl.cameraDevice.flashMode = Camera.FlashOn
+
+ } else {
+ flashControl.cameraDevice.flashMode = Camera.FlashOff
+ }
+ }
+ }
+
+ Switch {
+ id: torchModeControl
+ visible: flashControl.mIsTorchSupported
+ opacity: checked ? 0.75 : 0.25
+ text: "Torch"
+ contentItem: Text {
+ text: torchModeControl.text
+ color: "white"
+ leftPadding: torchModeControl.indicator.width + torchModeControl.spacing
+ }
+
+ onPositionChanged: {
+ if (position) {
+ if (flashModeControl.checked)
+ flashModeControl.toggle();
+ flashControl.cameraDevice.torchMode = Camera.TorchOn
+ } else {
+ flashControl.cameraDevice.torchMode = Camera.TorchOff
+ }
+ }
+ }
+ }
+}
diff --git a/examples/multimedia/declarative-camera/Info.plist b/examples/multimedia/declarative-camera/Info.plist
index d664a2460..7a1b26e1e 100644
--- a/examples/multimedia/declarative-camera/Info.plist
+++ b/examples/multimedia/declarative-camera/Info.plist
@@ -13,7 +13,7 @@
<key>CFBundleExecutable</key>
<string>declarative-camera</string>
<key>CFBundleIdentifier</key>
- <string>com.digia.${PRODUCT_NAME:rfc1034identifier}</string>
+ <string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundleDisplayName</key>
<string>declarative-camera</string>
<key>CFBundleName</key>
diff --git a/examples/multimedia/declarative-camera/PhotoCaptureControls.qml b/examples/multimedia/declarative-camera/PhotoCaptureControls.qml
index 0f2745665..f4ecee37b 100644
--- a/examples/multimedia/declarative-camera/PhotoCaptureControls.qml
+++ b/examples/multimedia/declarative-camera/PhotoCaptureControls.qml
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtMultimedia
@@ -71,19 +24,19 @@ FocusScope {
GridLayout {
id: buttonsColumn
- anchors.margins: buttonsmargin
+ anchors.margins: captureControls.buttonsmargin
flow: captureControls.state === "MobilePortrait"
? GridLayout.LeftToRight : GridLayout.TopToBottom
CameraButton {
text: "Capture"
- implicitWidth: buttonsWidth
- visible: captureSession.imageCapture.readyForCapture
- onClicked: captureSession.imageCapture.captureToFile("")
+ implicitWidth: captureControls.buttonsWidth
+ visible: captureControls.captureSession.imageCapture.readyForCapture
+ onClicked: captureControls.captureSession.imageCapture.captureToFile("")
}
CameraPropertyButton {
id : wbModesButton
- implicitWidth: buttonsWidth
+ implicitWidth: captureControls.buttonsWidth
state: captureControls.state
value: Camera.WhiteBalanceAuto
model: ListModel {
@@ -117,12 +70,12 @@ FocusScope {
}
Item {
- implicitWidth: buttonsWidth
- height: 70
+ implicitWidth: captureControls.buttonsWidth
+ implicitHeight: 70
CameraButton {
text: "View"
anchors.fill: parent
- onClicked:state = captureControls.previewSelected()
+ onClicked: captureControls.previewSelected()
visible: captureControls.previewAvailable
}
}
@@ -130,25 +83,25 @@ FocusScope {
GridLayout {
id: bottomColumn
- anchors.margins: buttonsmargin
+ anchors.margins: captureControls.buttonsmargin
flow: captureControls.state === "MobilePortrait"
? GridLayout.LeftToRight : GridLayout.TopToBottom
CameraListButton {
- implicitWidth: buttonsWidth
+ implicitWidth: captureControls.buttonsWidth
state: captureControls.state
- onValueChanged: captureSession.camera.cameraDevice = value
+ onValueChanged: captureControls.captureSession.camera.cameraDevice = value
}
CameraButton {
text: "Switch to Video"
- implicitWidth: buttonsWidth
+ implicitWidth: captureControls.buttonsWidth
onClicked: captureControls.videoModeSelected()
}
CameraButton {
id: quitButton
- implicitWidth: buttonsWidth
+ implicitWidth: captureControls.buttonsWidth
text: "Quit"
onClicked: Qt.quit()
}
@@ -156,107 +109,120 @@ FocusScope {
}
ZoomControl {
+ id: zoomControl
x : 0
- y : captureControls.state === "MobilePortrait" ? -buttonPaneShadow.height : 0
+ y : captureControls.state === "MobilePortrait" ? -buttonPaneShadow.height/2 : 0
width : 100
- height: parent.height
+ height: parent.height - (flashControl.visible * flashControl.height)
- currentZoom: camera.zoomFactor
- maximumZoom: camera.maximumZoomFactor
- onZoomTo: camera.setDigitalZoom(value)
+ currentZoom: captureControls.captureSession.camera.zoomFactor
+ maximumZoom: captureControls.captureSession.camera.maximumZoomFactor
+ onZoomTo: (target) => captureControls.captureSession.camera.zoomFactor = target
+ }
+
+ FlashControl {
+ id: flashControl
+ x : 10
+ y : captureControls.state === "MobilePortrait" ?
+ parent.height - (buttonPaneShadow.height + height) : parent.height - height
+
+ cameraDevice: captureControls.captureSession.camera
}
states: [
State {
name: "MobilePortrait"
PropertyChanges {
- target: buttonPaneShadow
- width: parent.width
- height: captureControls.buttonsPanelPortraitHeight
- }
- PropertyChanges {
- target: buttonsColumn
- height: captureControls.buttonsPanelPortraitHeight / 2 - buttonsmargin
- }
- PropertyChanges {
- target: bottomColumn
- height: captureControls.buttonsPanelPortraitHeight / 2 - buttonsmargin
+ buttonPaneShadow.width: parent.width
+ buttonPaneShadow.height: captureControls.buttonsPanelPortraitHeight
+ buttonsColumn.height: captureControls.buttonsPanelPortraitHeight / 2 - buttonsmargin
+ bottomColumn.height: captureControls.buttonsPanelPortraitHeight / 2 - buttonsmargin
}
AnchorChanges {
target: buttonPaneShadow
- anchors.bottom: parent.bottom
- anchors.left: parent.left
- anchors.right: parent.right
+ // qmllint disable incompatible-type
+ anchors.bottom: captureControls.bottom
+ anchors.left: captureControls.left
+ anchors.right: captureControls.right
+ // qmllint enable incompatible-type
}
AnchorChanges {
target: buttonsColumn
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.top: parent.top
+ // qmllint disable incompatible-type
+ anchors.left: buttonPaneShadow.left
+ anchors.right: buttonPaneShadow.right
+ anchors.top: buttonPaneShadow.top
+ // qmllint enable incompatible-type
}
AnchorChanges {
target: bottomColumn
- anchors.bottom: parent.bottom
- anchors.left: parent.left
- anchors.right: parent.right
+ // qmllint disable incompatible-type
+ anchors.bottom: buttonPaneShadow.bottom
+ anchors.left: buttonPaneShadow.left
+ anchors.right: buttonPaneShadow.right
+ // qmllint enable incompatible-type
}
},
State {
name: "MobileLandscape"
PropertyChanges {
- target: buttonPaneShadow
- width: buttonsPanelWidth
- height: parent.height
- }
- PropertyChanges {
- target: buttonsColumn
- height: parent.height
- width: buttonPaneShadow.width / 2
- }
- PropertyChanges {
- target: bottomColumn
- height: parent.height
- width: buttonPaneShadow.width / 2
+ buttonPaneShadow.width: buttonsPanelWidth
+ buttonPaneShadow.height: parent.height
+ buttonsColumn.height: parent.height
+ buttonsColumn.width: buttonPaneShadow.width / 2
+ bottomColumn.height: parent.height
+ bottomColumn.width: buttonPaneShadow.width / 2
}
AnchorChanges {
target: buttonPaneShadow
- anchors.top: parent.top
- anchors.right: parent.right
+ // qmllint disable incompatible-type
+ anchors.top: captureControls.top
+ anchors.right: captureControls.right
+ // qmllint enable incompatible-type
}
AnchorChanges {
target: buttonsColumn
- anchors.top: parent.top
- anchors.bottom: parent.bottom
- anchors.left: parent.left
+ // qmllint disable incompatible-type
+ anchors.top: buttonPaneShadow.top
+ anchors.bottom: buttonPaneShadow.bottom
+ anchors.left: buttonPaneShadow.left
+ // qmllint enable incompatible-type
}
AnchorChanges {
target: bottomColumn
- anchors.top: parent.top
- anchors.bottom: parent.bottom
- anchors.right: parent.right
+ // qmllint disable incompatible-type
+ anchors.top: buttonPaneShadow.top
+ anchors.bottom: buttonPaneShadow.bottom
+ anchors.right: buttonPaneShadow.right
+ // qmllint enable incompatible-type
}
},
State {
name: "Other"
PropertyChanges {
- target: buttonPaneShadow
- width: bottomColumn.width + 16
- height: parent.height
+ buttonPaneShadow.width: bottomColumn.width + 16
+ buttonPaneShadow.height: parent.height
}
AnchorChanges {
target: buttonPaneShadow
- anchors.top: parent.top
- anchors.right: parent.right
+ // qmllint disable incompatible-type
+ anchors.top: captureControls.top
+ anchors.right: captureControls.right
+ // qmllint enable incompatible-type
}
AnchorChanges {
target: buttonsColumn
- anchors.top: parent.top
- anchors.right: parent.right
+ // qmllint disable incompatible-type
+ anchors.top: buttonPaneShadow.top
+ anchors.right: buttonPaneShadow.right
+ // qmllint enable incompatible-type
}
AnchorChanges {
target: bottomColumn
- anchors.bottom: parent.bottom
- anchors.right: parent.right
+ // qmllint disable incompatible-type
+ anchors.bottom: buttonPaneShadow.bottom
+ anchors.right: buttonPaneShadow.right
+ // qmllint enable incompatible-type
}
}
]
diff --git a/examples/multimedia/declarative-camera/PhotoPreview.qml b/examples/multimedia/declarative-camera/PhotoPreview.qml
index 8aeb116dd..98af8a12a 100644
--- a/examples/multimedia/declarative-camera/PhotoPreview.qml
+++ b/examples/multimedia/declarative-camera/PhotoPreview.qml
@@ -1,55 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
-import QtMultimedia
Item {
property alias source : preview.source
diff --git a/examples/multimedia/declarative-camera/Popup.qml b/examples/multimedia/declarative-camera/Popup.qml
index db304dccb..fc57f3002 100644
--- a/examples/multimedia/declarative-camera/Popup.qml
+++ b/examples/multimedia/declarative-camera/Popup.qml
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
@@ -64,12 +17,12 @@ Rectangle {
states: [
State {
name: "invisible"
- PropertyChanges { target: popup; opacity: 0 }
+ PropertyChanges { popup.opacity: 0 }
},
State {
name: "visible"
- PropertyChanges { target: popup; opacity: 1.0 }
+ PropertyChanges { popup.opacity: 1.0 }
}
]
diff --git a/examples/multimedia/declarative-camera/VideoCaptureControls.qml b/examples/multimedia/declarative-camera/VideoCaptureControls.qml
index b2dbe3bd3..39acae106 100644
--- a/examples/multimedia/declarative-camera/VideoCaptureControls.qml
+++ b/examples/multimedia/declarative-camera/VideoCaptureControls.qml
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtMultimedia
@@ -71,67 +24,68 @@ FocusScope {
GridLayout {
id: buttonsColumn
- anchors.margins: buttonsmargin
+ anchors.margins: captureControls.buttonsmargin
flow: captureControls.state === "MobilePortrait"
? GridLayout.LeftToRight : GridLayout.TopToBottom
Item {
- implicitWidth: buttonsWidth
- height: 70
+ implicitWidth: captureControls.buttonsWidth
+ implicitHeight: 70
CameraButton {
text: "Record"
anchors.fill: parent
- visible: captureSession.recorder.recorderState !== MediaRecorder.RecordingState
- onClicked: captureSession.recorder.record()
+ visible: captureControls.captureSession.recorder.recorderState !== MediaRecorder.RecordingState
+ onClicked: captureControls.captureSession.recorder.record()
}
}
Item {
- implicitWidth: buttonsWidth
- height: 70
+ implicitWidth: captureControls.buttonsWidth
+ implicitHeight: 70
CameraButton {
id: stopButton
text: "Stop"
anchors.fill: parent
- visible: captureSession.recorder.recorderState === MediaRecorder.RecordingState
- onClicked: captureSession.recorder.stop()
+ visible: captureControls.captureSession.recorder.recorderState === MediaRecorder.RecordingState
+ onClicked: captureControls.captureSession.recorder.stop()
}
}
Item {
- implicitWidth: buttonsWidth
- height: 70
+ implicitWidth: captureControls.buttonsWidth
+ implicitHeight: 70
CameraButton {
text: "View"
anchors.fill: parent
onClicked: captureControls.previewSelected()
//don't show View button during recording
- visible: captureSession.recorder.actualLocation && !stopButton.visible
+ visible: captureControls.captureSession.recorder.actualLocation.toString() !== ""
+ && !stopButton.visible
}
}
}
GridLayout {
id: bottomColumn
- anchors.margins: buttonsmargin
+ anchors.margins: captureControls.buttonsmargin
flow: captureControls.state === "MobilePortrait"
? GridLayout.LeftToRight : GridLayout.TopToBottom
CameraListButton {
- implicitWidth: buttonsWidth
- onValueChanged: captureSession.camera.cameraDevice = value
+ implicitWidth: captureControls.buttonsWidth
+ onValueChanged: captureControls.captureSession.camera.cameraDevice = value
state: captureControls.state
}
CameraButton {
text: "Switch to Photo"
- implicitWidth: buttonsWidth
+ implicitWidth: captureControls.buttonsWidth
onClicked: captureControls.photoModeSelected()
}
CameraButton {
id: quitButton
text: "Quit"
- implicitWidth: buttonsWidth
+ implicitWidth: captureControls.buttonsWidth
onClicked: Qt.quit()
}
}
@@ -139,106 +93,118 @@ FocusScope {
ZoomControl {
x : 0
- y : captureControls.state === "MobilePortrait" ? -buttonPaneShadow.height : 0
+ y : captureControls.state === "MobilePortrait" ? -buttonPaneShadow.height/2 : 0
width : 100
- height: parent.height
+ height: parent.height - (flashControl.visible * flashControl.height)
- currentZoom: captureSession.camera.zoomFactor
- maximumZoom: captureSession.camera.maximumZoomFactor
- onZoomTo: captureSession.camera.zoomFactor = value
+ currentZoom: captureControls.captureSession.camera.zoomFactor
+ maximumZoom: captureControls.captureSession.camera.maximumZoomFactor
+ onZoomTo: (target) => captureControls.captureSession.camera.zoomFactor = target
+ }
+
+ FlashControl {
+ id: flashControl
+ x : 10
+ y : captureControls.state === "MobilePortrait" ?
+ parent.height - (buttonPaneShadow.height + height) : parent.height - height
+
+ cameraDevice: captureControls.captureSession.camera
}
states: [
State {
name: "MobilePortrait"
PropertyChanges {
- target: buttonPaneShadow
- width: parent.width
- height: buttonsPanelPortraitHeight
- }
- PropertyChanges {
- target: buttonsColumn
- height: captureControls.buttonsPanelPortraitHeight / 2 - buttonsmargin
- }
- PropertyChanges {
- target: bottomColumn
- height: captureControls.buttonsPanelPortraitHeight / 2 - buttonsmargin
+ buttonPaneShadow.width: parent.width
+ buttonPaneShadow.height: buttonsPanelPortraitHeight
+ buttonsColumn.height: captureControls.buttonsPanelPortraitHeight / 2 - buttonsmargin
+ bottomColumn.height: captureControls.buttonsPanelPortraitHeight / 2 - buttonsmargin
}
AnchorChanges {
target: buttonPaneShadow
- anchors.bottom: parent.bottom
- anchors.left: parent.left
- anchors.right: parent.right
+ // qmllint disable incompatible-type
+ anchors.bottom: captureControls.bottom
+ anchors.left: captureControls.left
+ anchors.right: captureControls.right
+ // qmllint enable incompatible-type
}
AnchorChanges {
target: buttonsColumn
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.top: parent.top
+ // qmllint disable incompatible-type
+ anchors.left: buttonPaneShadow.left
+ anchors.right: buttonPaneShadow.right
+ anchors.top: buttonPaneShadow.top
+ // qmllint enable incompatible-type
}
AnchorChanges {
- target: bottomColumn;
- anchors.bottom: parent.bottom
- anchors.left: parent.left
- anchors.right: parent.right
+ target: bottomColumn
+ // qmllint disable incompatible-type
+ anchors.bottom: buttonPaneShadow.bottom
+ anchors.left: buttonPaneShadow.left
+ anchors.right: buttonPaneShadow.right
+ // qmllint enable incompatible-type
}
},
State {
name: "MobileLandscape"
PropertyChanges {
- target: buttonPaneShadow
- width: buttonsPanelWidth
- height: parent.height
- }
- PropertyChanges {
- target: buttonsColumn
- height: parent.height
- width: buttonPaneShadow.width / 2
- }
- PropertyChanges {
- target: bottomColumn
- height: parent.height
- width: buttonPaneShadow.width / 2
+ buttonPaneShadow.width: buttonsPanelWidth
+ buttonPaneShadow.height: parent.height
+ buttonsColumn.height: parent.height
+ buttonsColumn.width: buttonPaneShadow.width / 2
+ bottomColumn.height: parent.height
+ bottomColumn.width: buttonPaneShadow.width / 2
}
AnchorChanges {
target: buttonPaneShadow
- anchors.top: parent.top
- anchors.right: parent.right
+ // qmllint disable incompatible-type
+ anchors.top: captureControls.top
+ anchors.right: captureControls.right
+ // qmllint enable incompatible-type
}
AnchorChanges {
- target: buttonsColumn;
- anchors.top: parent.top
- anchors.bottom: parent.bottom
- anchors.left: parent.left;
+ target: buttonsColumn
+ // qmllint disable incompatible-type
+ anchors.top: buttonPaneShadow.top
+ anchors.bottom: buttonPaneShadow.bottom
+ anchors.left: buttonPaneShadow.left
+ // qmllint enable incompatible-type
}
AnchorChanges {
- target: bottomColumn;
- anchors.top: parent.top;
- anchors.bottom: parent.bottom;
- anchors.right: parent.right;
+ target: bottomColumn
+ // qmllint disable incompatible-type
+ anchors.top: buttonPaneShadow.top
+ anchors.bottom: buttonPaneShadow.bottom
+ anchors.right: buttonPaneShadow.right
+ // qmllint enable incompatible-type
}
},
State {
name: "Other"
PropertyChanges {
- target: buttonPaneShadow;
- width: bottomColumn.width + 16;
- height: parent.height;
+ buttonPaneShadow.width: bottomColumn.width + 16
+ buttonPaneShadow.height: parent.height
}
AnchorChanges {
- target: buttonPaneShadow;
- anchors.top: parent.top;
- anchors.right: parent.right;
+ target: buttonPaneShadow
+ // qmllint disable incompatible-type
+ anchors.top: captureControls.top
+ anchors.right: captureControls.right
+ // qmllint enable incompatible-type
}
AnchorChanges {
- target: buttonsColumn;
- anchors.top: parent.top
- anchors.right: parent.right
+ target: buttonsColumn
+ // qmllint disable incompatible-type
+ anchors.top: buttonPaneShadow.top
+ anchors.right: buttonPaneShadow.right
+ // qmllint enable incompatible-type
}
AnchorChanges {
- target: bottomColumn;
- anchors.bottom: parent.bottom;
- anchors.right: parent.right;
+ target: bottomColumn
+ // qmllint disable incompatible-type
+ anchors.bottom: buttonPaneShadow.bottom
+ anchors.right: buttonPaneShadow.right
+ // qmllint enable incompatible-type
}
}
]
diff --git a/examples/multimedia/declarative-camera/VideoPreview.qml b/examples/multimedia/declarative-camera/VideoPreview.qml
index e2d6a47e0..f7b306794 100644
--- a/examples/multimedia/declarative-camera/VideoPreview.qml
+++ b/examples/multimedia/declarative-camera/VideoPreview.qml
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtMultimedia
@@ -65,7 +18,7 @@ Item {
videoPreview.closed();
}
onSourceChanged: {
- if (visible && source !== "")
+ if (videoPreview.visible && source !== "")
play();
}
diff --git a/examples/multimedia/declarative-camera/ZoomControl.qml b/examples/multimedia/declarative-camera/ZoomControl.qml
index 9107ab4ae..c60495fd0 100644
--- a/examples/multimedia/declarative-camera/ZoomControl.qml
+++ b/examples/multimedia/declarative-camera/ZoomControl.qml
@@ -1,61 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
-import QtMultimedia
Item {
id : zoomControl
property real currentZoom : 1
property real maximumZoom : 1
- signal zoomTo(real value)
+ signal zoomTo(real target)
visible: zoomControl.maximumZoom > 1
diff --git a/examples/multimedia/declarative-camera/declarative-camera.qml b/examples/multimedia/declarative-camera/declarative-camera.qml
index 6260c4281..24477150e 100644
--- a/examples/multimedia/declarative-camera/declarative-camera.qml
+++ b/examples/multimedia/declarative-camera/declarative-camera.qml
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtMultimedia
@@ -56,30 +9,13 @@ Rectangle {
width: 800
height: 480
+
color: "black"
state: "PhotoCapture"
property string platformScreen: ""
- property int buttonsPanelLandscapeWidth: 328
- property int buttonsPanelPortraitHeight: 180
-
- onWidthChanged: {
- setState()
- }
- function setState() {
- if (Qt.platform.os === "android" || Qt.platform.os === "ios") {
- if (Screen.desktopAvailableWidth < Screen.desktopAvailableHeight) {
- stillControls.state = "MobilePortrait";
- } else {
- stillControls.state = "MobileLandscape";
- }
- } else {
- stillControls.state = "Other";
- }
- console.log("State: " + stillControls.state);
- stillControls.buttonsWidth = (stillControls.state === "MobilePortrait")
- ? Screen.desktopAvailableWidth/3.4 : 144
- }
+ property int buttonsPanelLandscapeWidth: cameraUI.width/2
+ property int buttonsPanelPortraitHeight: cameraUI.height/3
states: [
State {
@@ -151,18 +87,42 @@ Rectangle {
VideoOutput {
id: viewfinder
visible: ((cameraUI.state === "PhotoCapture") || (cameraUI.state === "VideoCapture"))
-
- x: 0
- y: 0
- width: ((stillControls.state === "MobilePortrait") ? parent.width : (parent.width-buttonsPanelLandscapeWidth))
- height: ((stillControls.state === "MobilePortrait") ? parent.height - buttonsPanelPortraitHeight : parent.height)
+ anchors.fill: parent
// autoOrientation: true
}
+ Item {
+ id: controlLayout
+
+ readonly property bool isMobile: Qt.platform.os === "android" || Qt.platform.os === "ios"
+ readonly property bool isLandscape: Screen.desktopAvailableWidth >= Screen.desktopAvailableHeight
+ property int buttonsWidth: state === "MobilePortrait" ? Screen.desktopAvailableWidth / 3.4 : 114
+
+ states: [
+ State {
+ name: "MobileLandscape"
+ when: controlLayout.isMobile && controlLayout.isLandscape
+ },
+ State {
+ name: "MobilePortrait"
+ when: controlLayout.isMobile && !controlLayout.isLandscape
+ },
+ State {
+ name: "Other"
+ when: !controlLayout.isMobile
+ }
+ ]
+
+ onStateChanged: {
+ console.log("State: " + controlLayout.state)
+ }
+ }
+
PhotoCaptureControls {
id: stillControls
- state: setState()
+ state: controlLayout.state
anchors.fill: parent
+ buttonsWidth: controlLayout.buttonsWidth
buttonsPanelPortraitHeight: cameraUI.buttonsPanelPortraitHeight
buttonsPanelWidth: cameraUI.buttonsPanelLandscapeWidth
captureSession: captureSession
@@ -174,9 +134,9 @@ Rectangle {
VideoCaptureControls {
id: videoControls
- state: stillControls.state
+ state: controlLayout.state
anchors.fill: parent
- buttonsWidth: stillControls.buttonsWidth
+ buttonsWidth: controlLayout.buttonsWidth
buttonsPanelPortraitHeight: cameraUI.buttonsPanelPortraitHeight
buttonsPanelWidth: cameraUI.buttonsPanelLandscapeWidth
captureSession: captureSession
diff --git a/examples/multimedia/declarative-camera/declarative-camera.qrc b/examples/multimedia/declarative-camera/declarative-camera.qrc
index e4f6ee981..ddfcefa7b 100644
--- a/examples/multimedia/declarative-camera/declarative-camera.qrc
+++ b/examples/multimedia/declarative-camera/declarative-camera.qrc
@@ -12,6 +12,7 @@
<file>CameraButton.qml</file>
<file>CameraListPopup.qml</file>
<file>CameraListButton.qml</file>
+ <file>FlashControl.qml</file>
<file>images/camera_auto_mode.png</file>
<file>images/camera_camera_setting.png</file>
<file>images/camera_flash_auto.png</file>
diff --git a/examples/multimedia/declarative-camera/doc/images/CaptureControls.png b/examples/multimedia/declarative-camera/doc/images/CaptureControls.png
new file mode 100644
index 000000000..8c24d8030
--- /dev/null
+++ b/examples/multimedia/declarative-camera/doc/images/CaptureControls.png
Binary files differ
diff --git a/examples/multimedia/declarative-camera/doc/images/FlashControls.png b/examples/multimedia/declarative-camera/doc/images/FlashControls.png
new file mode 100644
index 000000000..93eec867b
--- /dev/null
+++ b/examples/multimedia/declarative-camera/doc/images/FlashControls.png
Binary files differ
diff --git a/examples/multimedia/declarative-camera/doc/images/VideoCaptureControls.png b/examples/multimedia/declarative-camera/doc/images/VideoCaptureControls.png
new file mode 100644
index 000000000..c35be7beb
--- /dev/null
+++ b/examples/multimedia/declarative-camera/doc/images/VideoCaptureControls.png
Binary files differ
diff --git a/examples/multimedia/declarative-camera/doc/images/ZoomControl.png b/examples/multimedia/declarative-camera/doc/images/ZoomControl.png
new file mode 100644
index 000000000..d628e60f1
--- /dev/null
+++ b/examples/multimedia/declarative-camera/doc/images/ZoomControl.png
Binary files differ
diff --git a/examples/multimedia/declarative-camera/doc/images/qml-camera.png b/examples/multimedia/declarative-camera/doc/images/qml-camera.png
index 0cd61f0a0..4b710670d 100644
--- a/examples/multimedia/declarative-camera/doc/images/qml-camera.png
+++ b/examples/multimedia/declarative-camera/doc/images/qml-camera.png
Binary files differ
diff --git a/examples/multimedia/declarative-camera/doc/images/qml-declarative-portrait.png b/examples/multimedia/declarative-camera/doc/images/qml-declarative-portrait.png
new file mode 100644
index 000000000..7adfdb021
--- /dev/null
+++ b/examples/multimedia/declarative-camera/doc/images/qml-declarative-portrait.png
Binary files differ
diff --git a/examples/multimedia/declarative-camera/doc/src/declarative-camera.qdoc b/examples/multimedia/declarative-camera/doc/src/declarative-camera.qdoc
index 6aa8e8fa6..c6701a68b 100644
--- a/examples/multimedia/declarative-camera/doc/src/declarative-camera.qdoc
+++ b/examples/multimedia/declarative-camera/doc/src/declarative-camera.qdoc
@@ -1,55 +1,158 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2015 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\example multimedia/declarative-camera
-\title QML Camera Example
+\example declarative-camera
+\title QML Camera Application
\ingroup multimedia_examples
\ingroup camera_examples_qml
-\brief The Camera Example shows how to use the API to capture a still image
-or video.
+\examplecategory {Multimedia}
+\examplecategory {Mobile}
+\brief This Qt Quick based application shows how to use the API to capture a
+still image or video.
\image qml-camera.png
This example demonstrates how to access camera functions via QML.
-It shows how to change settings and to capture images.
+It shows how to change settings and capture images or video.
\include examples-run.qdocinc
-\section1 Application Structure
+\section1 Application structure
-Most of the QML code supports the user interface for this application with the
-camera types being mostly found in \e {declarative-camera.qml} and
-\e {CaptureControls.qml}.
+Most of the QML code in this example supports the user interface. Custom types
+that support the requirements have been implemented using existing Qt Quick
+controls.
-CaptureControls, which is implemented in \e {CaptureControls.qml},
-generates a column on the right hand side of the screen which includes control
-buttons for focus (not initially visible), capture, flash modes,
-white balance, exposure compensation, and if a preview is
-available, a preview button. The last button exits from the application.
+\section1 Using screen orientation to select layout
+The orientation and control layout state logic is encapsulated in a separate
+Item, \c controlLayout like so:
+
+\quotefromfile declarative-camera/declarative-camera.qml
+\skipto Item {
+\printuntil /^ }/
+
+The \c stillControls and \c videoControls objects both bind to the \c state
+and \c buttonsWidth properties of this Item, as shown in \c stillControls:
+
+\skipto PhotoCaptureControls
+\printuntil /^ }/
+
+To support debugging, a message about layout state change is logged.
+
+Here is the portrait layout:
+
+\image qml-declarative-portrait.png
+
+You can see the \c state property is initially set as \c PhotoCapture.
+
+Then the \c states themselves are defined like so:
+
+\quotefromfile declarative-camera/declarative-camera.qml
+\skipto states: [
+\printuntil /^ ]/
+
+\section1 Controls for capturing
+
+Controls for capturing are implemented in \c PhotoCaptureControls.qml and
+VideoCaptureControls.qml. They each are based on a \l FocusScope that defines
+common buttons dimensions and margins that are used by the control buttons and
+then declares the buttons.
+
+This generates a column on the right hand side of the screen which includes,
+listed top to bottom, the following controls:
+\div {class="multi-column"}
+ \div {class="doc-column"}
+ \list
+ \li A \c Capture or \c Record button, which initiates capturing.
+ \li A \c{capture properties} button that displays the icon of the current
+ white balance mode selected and when pressed uses a pop-up to displays
+ the following option's icons:
+ \list
+ \li Flash mode (if available)
+ \li White balance modes
+ \li Exposure compensation
+ \endlist
+ \li A \c View button, once something has been captured.
+ \li A button which displays the currently selected capture device and
+ when pressed provides a list of available devices to switch to, using a
+ pop-up.
+ \li A \c{Switch To} button that displays the alternate capture mode
+ (video or photo) depending on the current active selection and switches
+ the mode when pressed.
+ \li A \c Quit button, that exits the application.
+ \endlist
+ \enddiv
+ \div {class="doc-column"}
+ \inlineimage CaptureControls.png
+ \enddiv
+ \div {class="doc-column"}
+ \inlineimage VideoCaptureControls.png
+ \enddiv
+\enddiv
+
+\section1 Image capturing
+
+The button that triggers this is defined in CameraButton.qml:
+but its interaction with the camera is in the controls types, lets look at
+PhotoCaptureControls:
+
+\quotefromfile declarative-camera/PhotoCaptureControls.qml
+\skipto CameraButton {
+\printto CameraPropertyButton {
+
+\section1 Zoom control
+
+\div {class="multi-column"}
+ \div {class="doc-column"}
+ Implemented in \c ZoomControl.qml the ZoomControl type is based on an Item
+ and creates a bar that represents the zoom level, which can also be dragged.
+ It uses an exponential calculation method to determine the zoom factor given
+ the position of the \c grove.
+
+ The bar is only visible if the initialZoom is greater than 1. This means
+ the currently active camera has a zoom function.
+ \enddiv
+ \div {class="doc-column"}
+ \inlineimage ZoomControl.png
+ \enddiv
+\enddiv
+
+\quotefromfile declarative-camera/ZoomControl.qml
+\skipto Item {
+\printuntil font.pixelSize: 18
+
+In PhotoCaptureControls.qml and VideoCaptureControls.qml the signal \c zoomTo
+will set the selected camera's \l{Camera::}{zoomFactor} property to the
+calculated \c target value, as well as updating the ZoomControl bar.
+
+\quotefromfile declarative-camera/VideoCaptureControls.qml
+\skipto ZoomControl {
+\printto FlashControl {
+
+\section1 Flash and torch control
+
+\image FlashControls.png
+
+Defined in \c FlashControl.qml this enables flash mode selection and torch
+functionality to be toggled via a Switch. As with the zoom control, the switches
+are only visible on top of the preview window if the active device supports
+these functions.
+
+Here we check if the functions are supported:
+
+\quotefromfile declarative-camera/FlashControl.qml
+\skipto property Camera cameraDevice
+\printline Camera
+\printline FlashOn
+\printline TorchOn
+
+Here we implement the \c flashModeControl switch, which also directly controls
+the Camera device.
+
+\skipto Switch {
+\printuntil /^ }/
+
+Torch control is implemented in a similar way.
*/
diff --git a/examples/multimedia/declarative-camera/permission-denied.qml b/examples/multimedia/declarative-camera/permission-denied.qml
new file mode 100644
index 000000000..19eb58ead
--- /dev/null
+++ b/examples/multimedia/declarative-camera/permission-denied.qml
@@ -0,0 +1,20 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+
+
+Rectangle {
+ color: "black"
+ width: 800
+ height: 600
+
+ Text {
+ anchors.fill: parent
+ text: qsTr("Grant the camera permission and restart the app")
+ color: "white"
+ font.pointSize: 20
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ }
+}
diff --git a/examples/multimedia/declarative-camera/qmlcamera.cpp b/examples/multimedia/declarative-camera/qmlcamera.cpp
index edffe6bb0..9844fd53b 100644
--- a/examples/multimedia/declarative-camera/qmlcamera.cpp
+++ b/examples/multimedia/declarative-camera/qmlcamera.cpp
@@ -1,68 +1,39 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QGuiApplication>
-#include <QQuickView>
#include <QQmlEngine>
+#include <QQuickView>
+
+#if QT_CONFIG(permissions)
+ #include <QPermission>
+#endif
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
- QGuiApplication app(argc,argv);
+ QGuiApplication app(argc, argv);
QQuickView view;
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(), &QQmlEngine::quit,
- qApp, &QGuiApplication::quit);
- view.setSource(QUrl("qrc:///declarative-camera.qml"));
- view.resize(800, 480);
- view.show();
+
+ auto setupView = [&view](const QUrl &viewSource) {
+ // Qt.quit() called in embedded .qml by default only emits
+ // quit() signal, so do this (optionally use Qt.exit()).
+ QObject::connect(view.engine(), &QQmlEngine::quit, qApp, &QGuiApplication::quit);
+ view.setSource(viewSource);
+ view.show();
+ };
+
+#if QT_CONFIG(permissions)
+ QCameraPermission cameraPermission;
+ qApp->requestPermission(cameraPermission, [&setupView](const QPermission &permission) {
+ if (permission.status() == Qt::PermissionStatus::Denied)
+ setupView(QUrl("qrc:///permission-denied.qml"));
+ else
+ setupView(QUrl("qrc:///declarative-camera.qml"));
+ });
+#else
+ setupView();
+#endif
+
return app.exec();
}