Skip to content

Commit dcee9d3

Browse files
committed
Camera App ubports#79 : Initial try
1 parent 9251941 commit dcee9d3

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ find_package(Qt5Qml)
1515
find_package(Qt5Quick)
1616
find_package(Qt5Multimedia)
1717
find_package(Qt5Gui)
18+
find_package(PkgConfig REQUIRED)
19+
20+
pkg_check_modules(EXIV2 REQUIRED exiv2)
1821

1922
find_program(INTLTOOL_MERGE intltool-merge)
2023
find_program(INTLTOOL_EXTRACT intltool-extract)
@@ -121,7 +124,7 @@ install(TARGETS ${CAMERA_APP}
121124
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
122125
)
123126

124-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
127+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -std=c++11 -Wall -Werror")
125128

126129
file(GLOB QML_JS_FILES *.qml *.js *.png)
127130

CameraApp/adddatestamp.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include <exiv2/exiv2.hpp>
2+
13
#include <QtCore/QFile>
24
#include <QImage>
35
#include <QPainter>
@@ -16,6 +18,10 @@ AddDateStamp::AddDateStamp(QString inPath, QString dateFormat, QColor stampColo
1618

1719
void AddDateStamp::run() {
1820
try {
21+
const char* exifPath = path.toUtf8().toStdString().c_str();
22+
Exiv2::Image::AutoPtr oldExifImage = Exiv2::ImageFactory::open(exifPath);
23+
oldExifImage->readMetadata();
24+
Exiv2::ExifData &exifData = oldExifImage->exifData();
1925

2026
QImage image = QImage(path);
2127
QDateTime now = QDateTime::currentDateTime();
@@ -42,6 +48,10 @@ void AddDateStamp::run() {
4248
success &= QFile::rename(tmpPath, path);
4349
if(success) {
4450
QFile::remove(backupFilePath);
51+
Exiv2::Image::AutoPtr newExifImage = Exiv2::ImageFactory::open(exifPath);
52+
newExifImage->setExifData(exifData);
53+
newExifImage->writeMetadata();
54+
4555
} else { //try and move the backup file back to it original name
4656
QFile::rename(backupFilePath, path);
4757
}

CameraApp/adddatestamp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
class AddDateStamp : public QThread
77
{
8-
static const float MAXIMUM_TEXT_HEIGHT_PECENT_OF_IMAGE = 0.04f;
9-
static const float MINIMUM_TEXT_HEIGHT_PECENT_OF_IMAGE = 0.02f;
8+
static constexpr float MAXIMUM_TEXT_HEIGHT_PECENT_OF_IMAGE = 0.04f;
9+
static constexpr float MINIMUM_TEXT_HEIGHT_PECENT_OF_IMAGE = 0.02f;
1010

1111
public:
1212
AddDateStamp(QString inPath, QString dateFormat, QColor stampColor, float opacity, int alignment);

0 commit comments

Comments
 (0)