From b346ed838bedf1709e8c8819c2505ecc6809fc90 Mon Sep 17 00:00:00 2001 From: Austen Date: Mon, 23 Jun 2014 23:51:36 -0400 Subject: [PATCH] Changed two buttons to two radiobuttons of "Label Images" and "Erase All Metadata" --- .gitignore | 2 +- Picture.pro.user | 2 +- picture.cpp | 70 ++++++++++------------------------------- picture.h | 2 -- picture.ui | 82 ++++++++++++++++++++++++++++++++++++++++++------ 5 files changed, 91 insertions(+), 67 deletions(-) diff --git a/.gitignore b/.gitignore index 6342be1..cc40fd6 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -Picture.pro.user \ No newline at end of file +./Picture.pro.user diff --git a/Picture.pro.user b/Picture.pro.user index b8873f4..0dd141d 100644 --- a/Picture.pro.user +++ b/Picture.pro.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/picture.cpp b/picture.cpp index 2816bef..2aeeef3 100644 --- a/picture.cpp +++ b/picture.cpp @@ -20,12 +20,7 @@ void Picture::dragEnterEvent(QDragEnterEvent *event){ void Picture::dropEvent(QDropEvent *event){ foreach (const QUrl &url, event->mimeData()->urls()) { const QString &fileName = url.toLocalFile(); - //if(fileName.contains(QRegExp("\.(?i)(jpe?g|png|gif)$"))){ ui->fileList->addItem(fileName); - //}else{ - // qDebug()<fileList->addItem(str); + QString itemString=directory.path()+"/"+str; + ui->fileList->addItem(itemString); } } if(ui->fileList->count()==0){ @@ -54,40 +50,6 @@ void Picture::fillList() { void Picture::on_cd_clicked(){ changeDirectory(); } -void Picture::on_erase_clicked(){ - bool ignored=false; - QStringList myStringList; - for (int i = 0; i < ui->fileList->count(); ++i) - myStringList.append(ui->fileList->item(i)->text()); - qDebug() << myStringList; - //foreach(const QString &str,directory.entryList()){ - foreach(const QString &str,myStringList){ - QImageReader reader(str); - if(!reader.format().isEmpty()){ - QString fullPath=str; - try{ - Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fullPath.toStdString()); - assert (image.get() != 0); - image->readMetadata(); - image->clearMetadata(); - image->writeMetadata(); - }catch(Exiv2::AnyError& e){ - QMessageBox msgBox; - msgBox.setInformativeText("The program could not process the file: "+fullPath); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - int ret=msgBox.exec(); - } - }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(); ui->fileList->clear(); @@ -97,11 +59,6 @@ void Picture::on_clearLog_clicked(){ ui->log->setText(""); ui->tabField->setCurrentIndex(0); } -void Picture::on_erase_pressed(){ - ui->log->append("Erasing metadata from images..."); - ui->tabField->setCurrentIndex(1); - on_erase_clicked(); -} void Picture::on_processButton_pressed(){ ui->log->append("Processing images..."); ui->tabField->setCurrentIndex(1); @@ -113,21 +70,28 @@ void Picture::on_processButton_clicked(){ for (int i=0;ifileList->count();++i){ myStringList.append(ui->fileList->item(i)->text()); } - qDebug()<readMetadata(); - if(ui->eraseOtherMetadata->isChecked()){ + if(ui->labelImagesRadio->isChecked()){ + Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fullPath.toStdString()); + assert (image.get() != 0); + image->readMetadata(); + if(ui->eraseOtherMetadata->isChecked()){ + image->clearMetadata(); + } + Exiv2::ExifData &exifData=image->exifData(); + exifData["Exif.Photo.UserComment"] = "charset=Ascii "+ui->labelText->text().toStdString(); + image->writeMetadata(); + }else{ + Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fullPath.toStdString()); + assert (image.get() != 0); + image->readMetadata(); image->clearMetadata(); + image->writeMetadata(); } - Exiv2::ExifData &exifData=image->exifData(); - exifData["Exif.Photo.UserComment"] = "charset=Ascii "+ui->labelText->text().toStdString(); - image->writeMetadata(); }catch(Exiv2::AnyError& e){ QMessageBox msgBox; msgBox.setInformativeText("The program could not process the file: "+fullPath); diff --git a/picture.h b/picture.h index 0f7f402..d5ba9b4 100644 --- a/picture.h +++ b/picture.h @@ -33,10 +33,8 @@ class Picture : public QMainWindow { void changeDirectory(); void fillList(); void on_cd_clicked(); - void on_erase_clicked(); void on_refresh_clicked(); void on_clearLog_clicked(); - void on_erase_pressed(); void on_processButton_clicked(); void on_processButton_pressed(); private: diff --git a/picture.ui b/picture.ui index ea002ac..a319615 100644 --- a/picture.ui +++ b/picture.ui @@ -6,8 +6,8 @@ 0 0 - 656 - 463 + 783 + 607 @@ -58,13 +58,6 @@ - - - - Erase All Metadata - - - @@ -78,6 +71,27 @@ + + + + + + Label Images + + + true + + + + + + + Erase All Metadata + + + + + @@ -145,7 +159,7 @@ 0 0 - 656 + 783 21 @@ -191,5 +205,53 @@ + + eraseAllRadio + toggled(bool) + labelText + setDisabled(bool) + + + 527 + 120 + + + 457 + 332 + + + + + eraseAllRadio + toggled(bool) + eraseOtherMetadata + setDisabled(bool) + + + 583 + 120 + + + 381 + 369 + + + + + eraseAllRadio + toggled(bool) + eraseGpsData + setDisabled(bool) + + + 601 + 118 + + + 539 + 386 + + +