4 * This file is part of CameraPlus.
6 * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 import com.nokia.meego 1.1
31 property alias standbyWidget: standby
33 property bool needsPipeline: true
34 property int policyMode: CameraResources.None
36 Component.onCompleted: {
37 if (Qt.application.active && needsPipeline) {
38 resourcePolicy.acquire(page.policyMode);
43 if (Qt.application.active && status == PageStatus.Activating) {
44 resourcePolicy.acquire(page.policyMode);
49 if (status == PageStatus.Active && !page.needsPipeline) {
55 onPolicyModeChanged: {
56 if (Qt.application.active) {
57 resourcePolicy.acquire(page.policyMode);
61 function handlePipeline() {
62 if (!Qt.application.active) {
63 // TODO: force if we lost resources ?
66 else if (resourcePolicy.acquired && page.needsPipeline && !cam.running) {
70 else if (!resourcePolicy.acquired) {
77 target: resourcePolicy
78 onAcquiredChanged: handlePipeline();
82 target: Qt.application
84 if (!Qt.application.active) {
85 // This is a noop if camera is not
86 // idle so calling it will not hurt
88 resourcePolicy.acquire(CameraResources.None);
91 else if (page.needsPipeline) {
92 resourcePolicy.acquire(page.policyMode);
100 if (cam.idle && !Qt.application.active) {
102 resourcePolicy.acquire(CameraResources.None);
105 else if (cam.idle && !page.needsPipeline) {
114 // TODO: fade out transition
115 // TODO: there is a toolbar visible on the first startup
119 visible: !Qt.application.active || !cam.running || !resourcePolicy.acquired
121 source: "image://theme/icon-l-camera-standby"
122 anchors.centerIn: parent
126 property Camera cam: null
127 property bool controlsVisible: cam.running && !standby.visible
131 property alias previewAnimationRunning: preview.animationRunning
133 function setPreview(image) {
134 preview.setPreview(image);
138 anchors.bottom: parent.bottom
139 anchors.right: parent.right
140 anchors.rightMargin: 20
141 anchors.bottomMargin: 20
142 visible: controlsVisible
152 anchors.top: parent.top
154 anchors.horizontalCenter: parent.horizontalCenter
155 visible: controlsVisible