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) {
116 // TODO: fade out transition
117 // TODO: there is a toolbar visible on the first startup
121 visible: !Qt.application.active || !cam.running || !resourcePolicy.acquired
123 source: "image://theme/icon-l-camera-standby"
124 anchors.centerIn: parent
128 property Camera cam: null
129 property bool controlsVisible: cam.running && !standby.visible
133 property alias previewAnimationRunning: preview.animationRunning
135 function setPreview(image) {
136 preview.setPreview(image);
140 anchors.bottom: parent.bottom
141 anchors.right: parent.right
142 anchors.rightMargin: 20
143 anchors.bottomMargin: 20
144 visible: controlsVisible
154 anchors.top: parent.top
156 anchors.horizontalCenter: parent.horizontalCenter
157 visible: controlsVisible
160 function checkDiskSpace() {
161 return fileSystem.hasFreeSpace(fileNaming.path);
164 function checkBattery() {
165 // We are fine if we are connected to the charger:
166 if (batteryMonitor.chargingState == BatteryInfo.Charging) {
170 // If we have enough battery then we are fine:
171 if (batteryMonitor.batteryStatus > BatteryInfo.BatteryCritical) {
180 monitorChargingStateChanges: cam.running
181 monitorBatteryStatusChanges: cam.running
183 onChargingStateChanged: {
184 if (!checkBattery()) {
189 onBatteryStatusChanged: {
190 if (!checkBattery()) {