ubuntu: use application directory for images

This commit is contained in:
Maxim Ermilov 2014-05-02 21:08:27 +04:00 committed by Steven Gill
parent 6e93ebbf90
commit 8ff4d3f16e
3 changed files with 17 additions and 11 deletions

View File

@ -40,7 +40,6 @@ Rectangle {
console.log(errorString);
}
videoRecorder.audioBitRate: 128000
videoRecorder.mediaContainer: "mp4"
imageCapture {
onImageSaved: {
root.exec("Camera", "onImageSaved", [path]);
@ -100,7 +99,7 @@ Rectangle {
MouseArea {
anchors.fill: parent
onClicked: {
camera.imageCapture.capture();
camera.imageCapture.captureToLocation(ui.parent.plugin('Camera').generateLocation("jpg"));
}
}
}

View File

@ -38,7 +38,7 @@ function createObject() { \
component.statusChanged.connect(finishCreation); \
} \
function finishCreation() { \
CordovaWrapper.object = component.createObject(root, \
CordovaWrapper.global.cameraPluginWidget = component.createObject(root, \
{root: root, cordova: cordova}); \
} \
createObject()";
@ -68,18 +68,15 @@ bool Camera::preprocessImage(QString &path) {
const char *type;
if (convertToPNG) {
newImage.setFileTemplate("imgXXXXXX.png");
path = generateLocation("png");
type = "png";
} else {
newImage.setFileTemplate("imgXXXXXX.jpg");
path = generateLocation("jpg");
type = "jpg";
}
newImage.open();
newImage.setAutoRemove(false);
image.save(newImage.fileName(), type, quality);
image.save(path, type, quality);
path = newImage.fileName();
oldImage.remove();
return true;
@ -98,7 +95,7 @@ void Camera::onImageSaved(QString path) {
cbParams = QString("\"%1\"").arg(content.data());
image.remove();
} else {
cbParams = CordovaInternal::format(QUrl::fromLocalFile(absolutePath).toString());
cbParams = CordovaInternal::format(QString("file://localhost") + absolutePath);
}
}
@ -136,7 +133,7 @@ void Camera::takePicture(int scId, int ecId, int quality, int destinationType, i
}
void Camera::cancel() {
m_cordova->execQML("CordovaWrapper.object.destroy()");
m_cordova->execQML("CordovaWrapper.global.cameraPluginWidget.destroy()");
this->cb(_lastEcId, "canceled");
_lastEcId = _lastScId = 0;

View File

@ -54,6 +54,16 @@ public slots:
void onImageSaved(QString path);
QString generateLocation(const QString &extension) {
int i = 1;
for (;;++i) {
QString path = QString("%1/.local/share/%2/persistent/%3.%4").arg(QDir::homePath())
.arg(QCoreApplication::applicationName()).arg(i).arg(extension);
if (!QFileInfo(path).exists())
return path;
}
}
private:
bool preprocessImage(QString &path);