* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-import QtQuick 1.1
+import QtQuick 2.0
import QtCamera 1.0
import CameraPlus 1.0
property Camera camera: null
property Item currentItem
property bool error: false
+ property int currentPolicyMode: CameraResources.None
onCurrentItemChanged: {
if (state == "on" || state == "policyLost") {
function startCamera() {
if (error) {
return
+ } else if ((currentPolicyMode == currentItem.policyMode) && camera.running) {
+ return
} else if (!policy.acquire(currentItem.policyMode)) {
console.log("Failed to acquire policy resources")
return
+ } else if (currentItem.policyMode == CameraResources.Player) {
+ currentPolicyMode = CameraResources.Player
+ camera.stop(true)
} else if (!camera.start()) {
showError(qsTr("Failed to start camera. Please restart the application."))
+ } else {
+ currentPolicyMode = currentItem.policyMode
}
}
function stopCamera() {
if (camera.stop(false)) {
policy.acquire(CameraResources.None)
+ currentPolicyMode = CameraResources.None
error = false
}
}
// when they become available
currentItem.policyLost()
camera.stop(true)
+ currentPolicyMode = CameraResources.None
error = false
}