Changed two buttons to two radiobuttons of "Label Images" and "Erase All Metadata"

This commit is contained in:
Austen Adler 2014-06-23 23:51:36 -04:00
parent 88ab8a2500
commit b346ed838b
5 changed files with 91 additions and 67 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
Picture.pro.user
./Picture.pro.user

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.0.1, 2014-06-22T20:11:46. -->
<!-- Written by QtCreator 3.0.1, 2014-06-23T22:55:24. -->
<qtcreator>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>

View File

@ -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()<<fileName;
//}
//qDebug() << "Dropped file:" << fileName;
}
}
void Picture::changeDirectory(){
@ -44,7 +39,8 @@ void Picture::fillList() {
foreach(const QString &str,directory.entryList()){
QImageReader reader(directory.absolutePath()+"/"+str);
if(!reader.format().isEmpty()){
ui->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,12 +70,12 @@ void Picture::on_processButton_clicked(){
for (int i=0;i<ui->fileList->count();++i){
myStringList.append(ui->fileList->item(i)->text());
}
qDebug()<<myStringList;
foreach(const QString &str,myStringList){
QImageReader reader(str);
if(!reader.format().isEmpty()){
QString fullPath=str;
try{
if(ui->labelImagesRadio->isChecked()){
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fullPath.toStdString());
assert (image.get() != 0);
image->readMetadata();
@ -128,6 +85,13 @@ void Picture::on_processButton_clicked(){
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();
}
}catch(Exiv2::AnyError& e){
QMessageBox msgBox;
msgBox.setInformativeText("The program could not process the file: "+fullPath);

View File

@ -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:

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>656</width>
<height>463</height>
<width>783</width>
<height>607</height>
</rect>
</property>
<property name="windowTitle">
@ -58,13 +58,6 @@
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QPushButton" name="erase">
<property name="text">
<string>Erase All Metadata</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
@ -78,6 +71,27 @@
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QRadioButton" name="labelImagesRadio">
<property name="text">
<string>Label Images</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="eraseAllRadio">
<property name="text">
<string>Erase All Metadata</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="labelLabel">
<property name="text">
@ -145,7 +159,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>656</width>
<width>783</width>
<height>21</height>
</rect>
</property>
@ -191,5 +205,53 @@
</hint>
</hints>
</connection>
<connection>
<sender>eraseAllRadio</sender>
<signal>toggled(bool)</signal>
<receiver>labelText</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>527</x>
<y>120</y>
</hint>
<hint type="destinationlabel">
<x>457</x>
<y>332</y>
</hint>
</hints>
</connection>
<connection>
<sender>eraseAllRadio</sender>
<signal>toggled(bool)</signal>
<receiver>eraseOtherMetadata</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>583</x>
<y>120</y>
</hint>
<hint type="destinationlabel">
<x>381</x>
<y>369</y>
</hint>
</hints>
</connection>
<connection>
<sender>eraseAllRadio</sender>
<signal>toggled(bool)</signal>
<receiver>eraseGpsData</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>601</x>
<y>118</y>
</hint>
<hint type="destinationlabel">
<x>539</x>
<y>386</y>
</hint>
</hints>
</connection>
</connections>
</ui>