Working though issue 1

This commit is contained in:
Austen Adler 2014-06-19 11:39:37 -04:00
parent e1dbb7db6d
commit 899c0a6543
2 changed files with 9 additions and 27 deletions

View File

@ -3,34 +3,10 @@ Picture::Picture(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::Picture){
ui->setupUi(this);
connect(&commandProcess,SIGNAL(readyReadStandardOutput()),this,SLOT(log()));
connect(&commandProcess,SIGNAL(readyReadStandardError()),this,SLOT(log()));
connect(ui->actionOpen_Files,SIGNAL(triggered()),this,SLOT(changeDirectory()));
//changeDirectory();
fillList();
}
void Picture::log(){
QByteArray cmdoutput = commandProcess.readAllStandardOutput();
QString txtoutput = cmdoutput;
ui->log->append(txtoutput);
cmdoutput = commandProcess.readAllStandardError();
txtoutput = cmdoutput;
ui->log->append(txtoutput);
}
std::string exec(char* cmd) {
FILE* pipe = popen(cmd, "r");
if (!pipe) return "ERROR";
char buffer[128];
std::string result = "";
while(!feof(pipe)) {
if(fgets(buffer, 128, pipe) != NULL){
result += buffer;
}
}
pclose(pipe);
return result;
}
Picture::~Picture(){
delete ui;
}
@ -72,7 +48,13 @@ void Picture::on_erase_clicked(){
a[tmp2.size()]=0;
memcpy(a,tmp2.c_str(),tmp2.size());
//exec(a);
commandProcess.start(a);
ui->log->append(str);
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(str.toStdString());
assert (image.get() != 0);
image->readMetadata();
Exiv2::ExifData &exifData = image->exifData();
exifData["Exif.Photo.UserComment"] = "charset=Ascii An ASCII Exif comment added with Exiv2";
image->writeMetadata();
}else{
if(!ignored){
ignored=true;

View File

@ -14,6 +14,8 @@
#include <QImageReader>
#include <QDialog>
#include <QProcess>
#include <exiv2/exiv2.hpp>
#include <cassert>
namespace Ui {
class Picture;
@ -35,10 +37,8 @@ private slots:
void on_refresh_clicked();
void on_clearLog_clicked();
void on_erase_pressed();
void log();
private:
Ui::Picture *ui;
QDir directory;
QProcess commandProcess;
};
#endif // PICTURE_H