import QtQuick 2.5 import QtQuick.Window 2.2 import QtQuick.Controls 1.2 import QtMultimedia 5.4 Window { id: window color: "green" visible: true width: 640 height: 960 Camera { id: camera onCameraStateChanged: { if (cameraState != Camera.ActiveState) return console.log("-----------------------") console.log("FocusManual", Camera.FocusManual, camera.focus.isFocusModeSupported(Camera.FocusManual)) console.log("FocusHyperfocal", Camera.FocusHyperfocal, camera.focus.isFocusModeSupported(Camera.FocusHyperfocal)) console.log("FocusInfinity", Camera.FocusInfinity, camera.focus.isFocusModeSupported(Camera.FocusInfinity)) console.log("FocusAuto", Camera.FocusAuto, camera.focus.isFocusModeSupported(Camera.FocusAuto)) console.log("FocusContinuous", Camera.FocusContinuous, camera.focus.isFocusModeSupported(Camera.FocusContinuous)) console.log("FocusMacro", Camera.FocusMacro, camera.focus.isFocusModeSupported(Camera.FocusMacro)) console.log("-----------------------") console.log("FocusMode:", camera.focus.focusMode) loader.sourceComponent = buttons } onLockStatusChanged: { if (camera.lockStatus != Camera.Searching) return focusRect.show() } } VideoOutput { id: viewfinder anchors { fill: parent } autoOrientation: true source: camera } Rectangle { id: focusRect function show() { opacity = 1.0 searching.restart() } anchors { centerIn: parent } border { color: "white"; width: 5 } color: "transparent" height: Math.round(parent.height / 5) opacity: 0.0 visible: opacity > 0 width: height Behavior on opacity { NumberAnimation { easing.type: Easing.InOutQuad } } SequentialAnimation { id: searching NumberAnimation { duration: 1500 target: focusRect property: "scale" from: 1.5; to: 1 easing.type: Easing.OutBounce } ScriptAction { script: focusRect.opacity = 0.0 } } } MouseArea { anchors { fill: parent } onClicked: camera.searchAndLock() } Loader { id: loader anchors { top: parent.top; left: parent.left; right: parent.right; margins: 10 } } Component { id: buttons Grid { id: grid property var modes: [Camera.FocusManual, Camera.FocusHyperfocal, Camera.FocusInfinity, Camera.FocusAuto, Camera.FocusContinuous, Camera.FocusMacro] property var text: ["Manual", "Hyperfocal", "Infinity", "Auto", "Continuous", "Macro"] spacing: 10 Repeater { model: grid.modes Button { text: grid.text[index] visible: camera.focus.isFocusModeSupported(grid.modes[index]) onClicked: camera.focus.focusMode = grid.modes[index] Rectangle { anchors { fill: parent; margins: -5 } border { color: "blue" width: 5 } color: "transparent" visible: camera.focus.focusMode === grid.modes[index] } } } } } }