import com.nokia.meego 1.1
import QtCamera 1.0
import CameraPlus 1.0
+import QtMobility.systeminfo 1.2
Page {
id: page
property bool needsPipeline: true
property int policyMode: CameraResources.None
+ signal batteryLow
+
Component.onCompleted: {
if (Qt.application.active && needsPipeline) {
resourcePolicy.acquire(page.policyMode);
anchors.horizontalCenter: parent.horizontalCenter
visible: controlsVisible
}
+
+ function checkBattery() {
+ // We are fine if we are connected to the charger:
+ if (batteryMonitor.chargingState == BatteryInfo.Charging) {
+ return true;
+ }
+
+ // If we have enough battery then we are fine:
+ if (batteryMonitor.batteryStatus > BatteryInfo.BatteryCritical) {
+ return true;
+ }
+
+ return false;
+ }
+
+ BatteryInfo {
+ id: batteryMonitor
+ monitorChargingStateChanges: cam.running
+ monitorBatteryStatusChanges: cam.running
+
+ onChargingStateChanged: {
+ if (!checkBattery()) {
+ parent.batteryLow();
+ }
+ }
+
+ onBatteryStatusChanged: {
+ if (!checkBattery()) {
+ parent.batteryLow();
+ }
+ }
+ }
}
height: 75
opacity: 0.5
onClicked: {
+ if (!checkBattery()) {
+ showError(qsTr("Not enough battery to capture images."));
+ return;
+ }
+
if (!fileSystem.available) {
showError(qsTr("Camera cannot capture images in mass storage mode."));
return;
import CameraPlus 1.0
import "data.js" as Data
-// TODO: stop recording when battery low
// TODO: stop recording when disk is low
CameraPage {
inhibitDim: videoMode.recording
}
+ onBatteryLow: {
+ if (!videoMode.recording) {
+ return;
+ }
+
+ if (!checkBattery()) {
+ videoMode.stopRecording();
+ showError(qsTr("Not enough battery to record video."));
+ }
+ }
+
Button {
id: recording
anchors.right: parent.right
// policy can acquire the needed resources
if (policyMode == CameraResources.Video) {
+ if (!checkBattery()) {
+ showError(qsTr("Not enough battery to record video."));
+ return;
+ }
+
policyMode = CameraResources.Recording;
}
else if (videoMode.recording) {
import QtMobility.location 1.2
// TODO: postcapture
-// TODO: battery low state
// TODO: disk space
// TODO: flash not ready
// TODO: focus, caf, ...