import com.nokia.meego 1.1
import QtCamera 1.0
import CameraPlus 1.0
-import QtMobility.systeminfo 1.2
Page {
id: page
function checkDiskSpace() {
return fileSystem.hasFreeSpace(fileNaming.path);
}
-
- 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 {
- // TODO: replace this
- id: batteryMonitor
- monitorChargingStateChanges: cam.running
- monitorBatteryStatusChanges: cam.running
-
- onChargingStateChanged: {
- if (!checkBattery()) {
- parent.batteryLow();
- }
- }
-
- onBatteryStatusChanged: {
- if (!checkBattery()) {
- parent.batteryLow();
- }
- }
- }
}
import com.nokia.meego 1.1
import com.nokia.extras 1.1
import QtCamera 1.0
-import CameraPlus 1.0
import QtMobility.systeminfo 1.2
import QtMobility.location 1.2
+// TODO: this has to be below QtMobility.systeminfo
+// We define an element called BatteryInfo which conflicts with the one defined by QtMobility
+// Thus we have to be the last so our element can be used instead of the one from QtMobility
+import CameraPlus 1.0
+
// TODO: flash not ready (battery low or flash not ready message)
// TODO: portrait/landscape
// TODO: grid lines, face tracking
path: fileNaming.path
}
+ BatteryInfo {
+ id: batteryMonitor
+ active: cam.running
+
+ function check() {
+ if (!checkBattery()) {
+ pageStack.currentPage.batteryLow();
+ }
+ }
+
+ onChargingChanged: {
+ batteryMonitor.check();
+ }
+
+ onCriticalChanged: {
+ batteryMonitor.check();
+ }
+ }
+
function replacePage(file) {
pageStack.replace(Qt.resolvedUrl(file), {cam: cam, dimmer: root.dimmer}, true);
}
pageStack.push(Qt.resolvedUrl(file), {cam: cam, dimmer: root.dimmer}, true);
}
+ function checkBattery() {
+ // We are fine if we are connected to the charger:
+ if (batteryMonitor.charging) {
+ return true;
+ }
+
+ // If we have enough battery then we are fine:
+ if (!batteryMonitor.critical) {
+ return true;
+ }
+
+ return false;
+ }
+
platformStyle: PageStackWindowStyle {
cornersVisible: false
background: ""
--- /dev/null
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "batteryinfo.h"
+#include <qmbattery.h>
+#include <QDeclarativeInfo>
+
+BatteryInfo::BatteryInfo(QObject *parent) :
+ QObject(parent), m_battery(0) {
+
+}
+
+BatteryInfo::~BatteryInfo() {
+ setActive(false);
+}
+
+bool BatteryInfo::isCharging() const {
+ if (!m_battery) {
+ qmlInfo(this) << "BatteryInfo has to be activated first";
+ return false;
+ }
+
+ if (m_battery->getChargingState() == MeeGo::QmBattery::StateCharging) {
+ return true;
+ }
+
+ return false;
+}
+
+bool BatteryInfo::isCritical() const {
+ if (!m_battery) {
+ qmlInfo(this) << "BatteryInfo has to be activated first";
+ return true;
+ }
+
+ MeeGo::QmBattery::BatteryState state = m_battery->getBatteryState();
+
+ if (state == MeeGo::QmBattery::StateOK || state == MeeGo::QmBattery::StateFull) {
+ return false;
+ }
+
+ return true;
+}
+
+bool BatteryInfo::isActive() const {
+ return m_battery != 0;
+}
+
+void BatteryInfo::setActive(bool active) {
+ if (isActive() == active) {
+ return;
+ }
+
+ m_battery = new MeeGo::QmBattery(this);
+ QObject::connect(m_battery, SIGNAL(batteryStateChanged(MeeGo::QmBattery::BatteryState)),
+ this, SIGNAL(chargingChanged()));
+ QObject::connect(m_battery, SIGNAL(chargingStateChanged(MeeGo::QmBattery::ChargingState)),
+ this, SIGNAL(chargingChanged()));
+
+ emit activeChanged();
+}
--- /dev/null
+// -*- c++ -*-
+
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef BATTERY_INFO_H
+#define BATTERY_INFO_H
+
+#include <QObject>
+
+namespace MeeGo {
+ class QmBattery;
+};
+
+class BatteryInfo : public QObject {
+ Q_OBJECT
+
+ Q_PROPERTY(bool charging READ isCharging NOTIFY chargingChanged);
+ Q_PROPERTY(bool critical READ isCritical NOTIFY criticalChanged);
+ Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged);
+
+public:
+ BatteryInfo(QObject *parent = 0);
+ ~BatteryInfo();
+
+ bool isCharging() const;
+ bool isCritical() const;
+
+ bool isActive() const;
+ void setActive(bool active);
+
+signals:
+ void chargingChanged();
+ void criticalChanged();
+ void activeChanged();
+
+private:
+ MeeGo::QmBattery *m_battery;
+};
+
+#endif /* BATTERY_INFO_H */
#include "deletehelper.h"
#include "galleryhelper.h"
#include "postcapturemodel.h"
+#include "batteryinfo.h"
static void initQuill() {
// TODO: All these are hardcoded.
qmlRegisterType<DeleteHelper>("CameraPlus", 1, 0, "DeleteHelper");
qmlRegisterType<GalleryHelper>("CameraPlus", 1, 0, "GalleryHelper");
qmlRegisterType<PostCaptureModel>("CameraPlus", 1, 0, "PostCaptureModel");
+ qmlRegisterType<BatteryInfo>("CameraPlus", 1, 0, "BatteryInfo");
view.setSource(QUrl("qrc:/qml/main.qml"));
SOURCES += main.cpp settings.cpp filenaming.cpp quillitem.cpp displaystate.cpp fsmonitor.cpp \
cameraresources.cpp compass.cpp orientation.cpp geocode.cpp mountprotector.cpp \
trackerstore.cpp focusrectangle.cpp sharehelper.cpp deletehelper.cpp galleryhelper.cpp \
- postcapturemodel.cpp
+ postcapturemodel.cpp batteryinfo.cpp
HEADERS += settings.h filenaming.h quillitem.h displaystate.h fsmonitor.h \
cameraresources.h compass.h orientation.h geocode.h mountprotector.h \
trackerstore.h focusrectangle.h sharehelper.h deletehelper.h galleryhelper.h \
- postcapturemodel.h
+ postcapturemodel.h batteryinfo.h
RESOURCES += ../qml/qml.qrc