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
27 import QtMobility.systeminfo 1.2
32 property alias standbyWidget: standby
34 property bool needsPipeline: true
35 property int policyMode: CameraResources.None
39 Component.onCompleted: {
40 if (Qt.application.active && needsPipeline) {
41 resourcePolicy.acquire(page.policyMode);
46 if (Qt.application.active && status == PageStatus.Activating) {
47 resourcePolicy.acquire(page.policyMode);
52 if (status == PageStatus.Active && !page.needsPipeline) {
58 onPolicyModeChanged: {
59 if (Qt.application.active) {
60 resourcePolicy.acquire(page.policyMode);
64 function handlePipeline() {
65 if (!Qt.application.active) {
66 // TODO: force if we lost resources ?
69 else if (resourcePolicy.acquired && page.needsPipeline && !cam.running) {
73 else if (!resourcePolicy.acquired) {
80 target: resourcePolicy
81 onAcquiredChanged: handlePipeline();
85 target: Qt.application
87 if (!Qt.application.active) {
88 // This is a noop if camera is not
89 // idle so calling it will not hurt
91 resourcePolicy.acquire(CameraResources.None);
94 else if (page.needsPipeline) {
95 resourcePolicy.acquire(page.policyMode);
103 if (cam.idle && !Qt.application.active) {
105 resourcePolicy.acquire(CameraResources.None);
108 else if (cam.idle && !page.needsPipeline) {
117 // TODO: fade out transition
118 // TODO: there is a toolbar visible on the first startup
122 visible: !Qt.application.active || !cam.running || !resourcePolicy.acquired
124 source: "image://theme/icon-l-camera-standby"
125 anchors.centerIn: parent
129 property Camera cam: null
130 property bool controlsVisible: cam.running && !standby.visible
134 property alias previewAnimationRunning: preview.animationRunning
136 function setPreview(image) {
137 preview.setPreview(image);
141 anchors.bottom: parent.bottom
142 anchors.right: parent.right
143 anchors.rightMargin: 20
144 anchors.bottomMargin: 20
145 visible: controlsVisible
155 anchors.top: parent.top
157 anchors.horizontalCenter: parent.horizontalCenter
158 visible: controlsVisible
161 function checkDiskSpace() {
162 return fileSystem.hasFreeSpace(fileNaming.path);
165 function checkBattery() {
166 // We are fine if we are connected to the charger:
167 if (batteryMonitor.chargingState == BatteryInfo.Charging) {
171 // If we have enough battery then we are fine:
172 if (batteryMonitor.batteryStatus > BatteryInfo.BatteryCritical) {
181 monitorChargingStateChanges: cam.running
182 monitorBatteryStatusChanges: cam.running
184 onChargingStateChanged: {
185 if (!checkBattery()) {
190 onBatteryStatusChanged: {
191 if (!checkBattery()) {