#include "picture.h" #include "ui_picture.h" #include #include #include #include #include #include Picture::Picture(QWidget *parent) : QMainWindow(parent), ui(new Ui::Picture){ ui->setupUi(this); connect(ui->actionOpen_Files,SIGNAL(triggered()),this,SLOT(changeDirectory())); //changeDirectory(); fillList(); } 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; } void Picture::changeDirectory(){ QString path=QFileDialog::getExistingDirectory(this,tr("Directory"),directory.path()); if(path.isNull()==false){ directory.setPath(path); fillList(); ui->log->append("Changed directory to: "+path+"/"); }else{ ui->log->append("Could not change directory"); } } void Picture::fillList() { ui->fileList->clear(); ui->fileList->addItems(directory.entryList()); } void Picture::on_cd_clicked(){ changeDirectory(); } void Picture::on_erase_clicked(){ bool ignored=false; foreach(const QString &str,directory.entryList()){ QString tmp=QString("exiv2 rm "); QImageReader reader(directory.absolutePath()+"/"+str); if(!reader.format().isEmpty()){ tmp+=directory.absolutePath()+"/"+str+">>/tmp/log"; std::string tmp2=tmp.toStdString(); char* a=new char[tmp2.size()+1]; a[tmp2.size()]=0; memcpy(a,tmp2.c_str(),tmp2.size()); exec(a); }else{ if(!ignored){ ignored=true; ui->log->append("Ignored Files:"); } ui->log->append(str); } } ui->log->append("Done erasing metadata"); } void Picture::on_refresh_clicked(){ fillList(); } void Picture::on_clearLog_clicked(){ ui->log->setText(""); } void Picture::on_erase_pressed() { ui->log->append("Erasing metadata from images..."); }