Skip to content

Commit

Permalink
Camera App ubports#79 : Initial try
Browse files Browse the repository at this point in the history
  • Loading branch information
EranUzan committed May 29, 2018
1 parent 9251941 commit dcee9d3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ find_package(Qt5Qml)
find_package(Qt5Quick)
find_package(Qt5Multimedia)
find_package(Qt5Gui)
find_package(PkgConfig REQUIRED)

pkg_check_modules(EXIV2 REQUIRED exiv2)

find_program(INTLTOOL_MERGE intltool-merge)
find_program(INTLTOOL_EXTRACT intltool-extract)
Expand Down Expand Up @@ -121,7 +124,7 @@ install(TARGETS ${CAMERA_APP}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

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

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

Expand Down
10 changes: 10 additions & 0 deletions CameraApp/adddatestamp.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <exiv2/exiv2.hpp>

#include <QtCore/QFile>
#include <QImage>
#include <QPainter>
Expand All @@ -16,6 +18,10 @@ AddDateStamp::AddDateStamp(QString inPath, QString dateFormat, QColor stampColo

void AddDateStamp::run() {
try {
const char* exifPath = path.toUtf8().toStdString().c_str();
Exiv2::Image::AutoPtr oldExifImage = Exiv2::ImageFactory::open(exifPath);
oldExifImage->readMetadata();
Exiv2::ExifData &exifData = oldExifImage->exifData();

QImage image = QImage(path);
QDateTime now = QDateTime::currentDateTime();
Expand All @@ -42,6 +48,10 @@ void AddDateStamp::run() {
success &= QFile::rename(tmpPath, path);
if(success) {
QFile::remove(backupFilePath);
Exiv2::Image::AutoPtr newExifImage = Exiv2::ImageFactory::open(exifPath);
newExifImage->setExifData(exifData);
newExifImage->writeMetadata();

} else { //try and move the backup file back to it original name
QFile::rename(backupFilePath, path);
}
Expand Down
4 changes: 2 additions & 2 deletions CameraApp/adddatestamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

class AddDateStamp : public QThread
{
static const float MAXIMUM_TEXT_HEIGHT_PECENT_OF_IMAGE = 0.04f;
static const float MINIMUM_TEXT_HEIGHT_PECENT_OF_IMAGE = 0.02f;
static constexpr float MAXIMUM_TEXT_HEIGHT_PECENT_OF_IMAGE = 0.04f;
static constexpr float MINIMUM_TEXT_HEIGHT_PECENT_OF_IMAGE = 0.02f;

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

0 comments on commit dcee9d3

Please sign in to comment.