visible: controlsVisible
}
+ 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;
}
+ if (!checkDiskSpace()) {
+ showError(qsTr("Not enough space 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 disk is low
-
CameraPage {
id: page
return;
}
+ if (!checkDiskSpace()) {
+ showError(qsTr("Not enough space to record video."));
+ return;
+ }
+
policyMode = CameraResources.Recording;
}
else if (videoMode.recording) {
videoMode.stopRecording();
showError(qsTr("Maximum recording time reached."));
}
+ else if (!checkDiskSpace()) {
+ videoMode.stopRecording();
+ showError(qsTr("Not enough space to continue recording."));
+ }
}
onRunningChanged: {
import QtMobility.location 1.2
// TODO: postcapture
-// TODO: disk space
// TODO: flash not ready
// TODO: focus, caf, ...
// TODO: portrait/landscape
return name;
}
+
+QString FileNaming::path() const {
+ return PATH;
+}
Q_PROPERTY(QString imageSuffix READ imageSuffix WRITE setImageSuffix NOTIFY imageSuffixChanged);
Q_PROPERTY(QString videoSuffix READ videoSuffix WRITE setVideoSuffix NOTIFY videoSuffixChanged);
+ Q_PROPERTY(QString path READ path CONSTANT);
public:
FileNaming(QObject *parent = 0);
Q_INVOKABLE QString imageFileName();
Q_INVOKABLE QString videoFileName();
+ QString path() const;
+
signals:
void imageSuffixChanged();
void videoSuffixChanged();
#include "fsmonitor.h"
#include <qmusbmode.h>
+#include <sys/statvfs.h>
+#include <cstdio>
+
+#define MIN_SPACE 100 * 1024 * 1024 // 100 MB
FSMonitor::FSMonitor(QObject *parent) :
QObject(parent), m_mode(new MeeGo::QmUSBMode(this)) {
setAvailable(m_mode->mountStatus(MeeGo::QmUSBMode::DocumentDirectoryMount)
.testFlag(MeeGo::QmUSBMode::ReadWriteMount));
}
+
+bool FSMonitor::hasFreeSpace(const QString& path) {
+ struct statvfs buf;
+
+ if (statvfs(path.toLocal8Bit().data(), &buf) == -1) {
+ std::perror("statvfs");
+ return false;
+ }
+
+ return (buf.f_bsize * buf.f_bavail >= MIN_SPACE);
+}
void setAvailable(bool available);
+ Q_INVOKABLE bool hasFreeSpace(const QString& path);
+
signals:
void availabilityChanged();