mirror of
https://github.com/apache/cordova-plugin-camera.git
synced 2025-01-31 12:42:50 +08:00
ubuntu: use application directory for images
This commit is contained in:
parent
6e93ebbf90
commit
8ff4d3f16e
@ -40,7 +40,6 @@ Rectangle {
|
|||||||
console.log(errorString);
|
console.log(errorString);
|
||||||
}
|
}
|
||||||
videoRecorder.audioBitRate: 128000
|
videoRecorder.audioBitRate: 128000
|
||||||
videoRecorder.mediaContainer: "mp4"
|
|
||||||
imageCapture {
|
imageCapture {
|
||||||
onImageSaved: {
|
onImageSaved: {
|
||||||
root.exec("Camera", "onImageSaved", [path]);
|
root.exec("Camera", "onImageSaved", [path]);
|
||||||
@ -100,7 +99,7 @@ Rectangle {
|
|||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: {
|
onClicked: {
|
||||||
camera.imageCapture.capture();
|
camera.imageCapture.captureToLocation(ui.parent.plugin('Camera').generateLocation("jpg"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ function createObject() { \
|
|||||||
component.statusChanged.connect(finishCreation); \
|
component.statusChanged.connect(finishCreation); \
|
||||||
} \
|
} \
|
||||||
function finishCreation() { \
|
function finishCreation() { \
|
||||||
CordovaWrapper.object = component.createObject(root, \
|
CordovaWrapper.global.cameraPluginWidget = component.createObject(root, \
|
||||||
{root: root, cordova: cordova}); \
|
{root: root, cordova: cordova}); \
|
||||||
} \
|
} \
|
||||||
createObject()";
|
createObject()";
|
||||||
@ -68,18 +68,15 @@ bool Camera::preprocessImage(QString &path) {
|
|||||||
|
|
||||||
const char *type;
|
const char *type;
|
||||||
if (convertToPNG) {
|
if (convertToPNG) {
|
||||||
newImage.setFileTemplate("imgXXXXXX.png");
|
path = generateLocation("png");
|
||||||
type = "png";
|
type = "png";
|
||||||
} else {
|
} else {
|
||||||
newImage.setFileTemplate("imgXXXXXX.jpg");
|
path = generateLocation("jpg");
|
||||||
type = "jpg";
|
type = "jpg";
|
||||||
}
|
}
|
||||||
|
|
||||||
newImage.open();
|
image.save(path, type, quality);
|
||||||
newImage.setAutoRemove(false);
|
|
||||||
image.save(newImage.fileName(), type, quality);
|
|
||||||
|
|
||||||
path = newImage.fileName();
|
|
||||||
oldImage.remove();
|
oldImage.remove();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -98,7 +95,7 @@ void Camera::onImageSaved(QString path) {
|
|||||||
cbParams = QString("\"%1\"").arg(content.data());
|
cbParams = QString("\"%1\"").arg(content.data());
|
||||||
image.remove();
|
image.remove();
|
||||||
} else {
|
} 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() {
|
void Camera::cancel() {
|
||||||
m_cordova->execQML("CordovaWrapper.object.destroy()");
|
m_cordova->execQML("CordovaWrapper.global.cameraPluginWidget.destroy()");
|
||||||
this->cb(_lastEcId, "canceled");
|
this->cb(_lastEcId, "canceled");
|
||||||
|
|
||||||
_lastEcId = _lastScId = 0;
|
_lastEcId = _lastScId = 0;
|
||||||
|
@ -54,6 +54,16 @@ public slots:
|
|||||||
|
|
||||||
void onImageSaved(QString path);
|
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:
|
private:
|
||||||
bool preprocessImage(QString &path);
|
bool preprocessImage(QString &path);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user