54 |
54 |
|
55 |
55 |
ui->stackedWidget->setCurrentWidget(ui->page);
|
56 |
56 |
|
|
57 |
m_currentProjectPictureNumber = 0;
|
|
58 |
|
57 |
59 |
m_baseDir = QDir(QDir::homePath() + "/RyXeo-WebPhotoAlbum");
|
58 |
60 |
m_baseDir.setFilter(QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot);
|
59 |
61 |
QFileInfoList list = m_baseDir .entryInfoList();
|
... | ... | |
82 |
84 |
actions << a_nouveau << a_renommer << a_supprimer;
|
83 |
85 |
m_menu->addActions(actions);
|
84 |
86 |
|
85 |
|
//============== le menu contextuel du treewidget (gauche)
|
86 |
|
ui->lwPictures->setDragEnabled(true);
|
87 |
|
ui->lwPictures->setDropIndicatorShown(true);
|
|
87 |
//============== Accepte le drag & drop
|
|
88 |
ui->lwPictures->setDragEnabled(true);
|
|
89 |
ui->lwPictures->setDropIndicatorShown(true);
|
88 |
90 |
}
|
89 |
91 |
|
90 |
92 |
original::~original()
|
... | ... | |
224 |
226 |
|
225 |
227 |
void original::on_action_Nouvel_album_triggered()
|
226 |
228 |
{
|
|
229 |
m_currentProjectPictureNumber = 0;
|
227 |
230 |
bool ok;
|
228 |
231 |
QString text = QInputDialog::getText(this, trUtf8("Nom du nouvel album à créer"),
|
229 |
232 |
trUtf8("Nom du nouvel album à créer"), QLineEdit::Normal,
|
... | ... | |
231 |
234 |
//Si ce nom n'existe pas déjà ...
|
232 |
235 |
QTreeWidgetItem *i = new QTreeWidgetItem(ui->treeWidget);
|
233 |
236 |
i->setText(0, text);
|
234 |
|
QDir d(m_baseDir.absolutePath() + "/" + text);
|
235 |
|
d.mkpath(d.absolutePath());
|
|
237 |
m_currentProjectDir = m_baseDir.absolutePath() + "/" + text;
|
|
238 |
|
|
239 |
//Creation de la destination
|
|
240 |
QDir rep;
|
|
241 |
rep.mkpath(m_currentProjectDir);
|
|
242 |
rep.mkpath(m_currentProjectDir + "/hq");
|
|
243 |
rep.mkpath(m_currentProjectDir + "/lq");
|
|
244 |
rep.mkpath(m_currentProjectDir + "/mq");
|
|
245 |
rep.mkpath(m_currentProjectDir + "/thumbs");
|
|
246 |
rep.mkpath(m_currentProjectDir + "/zip");
|
|
247 |
rep.mkpath(m_currentProjectDir + "/comments");
|
|
248 |
|
236 |
249 |
}
|
237 |
250 |
|
238 |
251 |
void original::on_treeWidget_itemClicked(QTreeWidgetItem *item, int column)
|
239 |
252 |
{
|
240 |
253 |
ui->lwPictures->clear();
|
|
254 |
m_currentProjectDir = item->data(1,0).toString();
|
|
255 |
|
241 |
256 |
QDir dir(item->data(1,0).toString()+"/thumbs/");
|
242 |
257 |
dir.setFilter(QDir::Files);
|
243 |
258 |
dir.setSorting(QDir::Name | QDir::IgnoreCase | QDir::LocaleAware);
|
... | ... | |
249 |
264 |
newitem->setIcon(icone); // ajout de la petite icone sur l'item
|
250 |
265 |
newitem->setText(list.at(i).fileName());
|
251 |
266 |
ui->lwPictures->insertItem(i,newitem);
|
|
267 |
m_currentProjectPictureNumber = i;
|
252 |
268 |
}
|
|
269 |
m_currentProjectPictureNumber++;
|
|
270 |
qDebug() << "On continue la numerotation a " << m_currentProjectPictureNumber;
|
253 |
271 |
}
|
254 |
272 |
|
255 |
273 |
void original::on_commandLinkButton_clicked()
|
... | ... | |
344 |
362 |
for(int i = 0; i < event->mimeData()->urls().count(); i++) {
|
345 |
363 |
//recopier l'image dans le projet
|
346 |
364 |
qDebug() << "Windows d&drop : " << event->mimeData()->urls().at(i).toString();
|
347 |
|
/*
|
|
365 |
|
348 |
366 |
//Attention sous windows le drag & drop est un file:/// sous linux file:// et osx ?
|
349 |
367 |
#ifdef Q_OS_WIN32
|
350 |
368 |
addPictureToProject(event->mimeData()->urls().at(i).toString().remove("file:///"));
|
351 |
369 |
#endif
|
352 |
370 |
#ifdef Q_OS_LINUX
|
353 |
|
QString f(event->mimeData()->urls().at(i).toString().remove("file://"));
|
354 |
|
qDebug() << "On importe par d&d le fichier " << f;
|
355 |
|
addPictureToProject(f);
|
|
371 |
addPictureToProject(event->mimeData()->urls().at(i).toString().remove("file://"));
|
356 |
372 |
#endif
|
357 |
|
*/
|
358 |
373 |
qDebug() << "Accepte le drop d'une image";
|
359 |
374 |
event->acceptProposedAction();
|
360 |
375 |
}
|
361 |
376 |
}
|
362 |
377 |
}
|
|
378 |
|
|
379 |
void original::addPictureToProject(QString fic)
|
|
380 |
{
|
|
381 |
ui->statusBar->clearMessage();
|
|
382 |
ui->statusBar->showMessage(trUtf8("Fichier en cours: %1").arg(fic),3000);
|
|
383 |
qApp->processEvents();
|
|
384 |
|
|
385 |
qDebug() << "Processing : " << fic;
|
|
386 |
QPixmap pixmap(fic);
|
|
387 |
pixmap.save(QString("%1/hq/img-%2.jpg").arg(m_currentProjectDir).arg(m_currentProjectPictureNumber));
|
|
388 |
qDebug() << "Save to : " << QString("%1/hq/img-%2.jpg").arg(m_currentProjectDir).arg(m_currentProjectPictureNumber);
|
|
389 |
|
|
390 |
ui->statusBar->showMessage(trUtf8("Fichier en cours: %1 [hq]").arg(fic),3000);
|
|
391 |
QPixmap pixmapThumbs(pixmap.scaled(QSize(120,120), Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
|
392 |
pixmapThumbs.save(QString("%1/thumbs/img-%2.jpg").arg(m_currentProjectDir).arg(m_currentProjectPictureNumber));
|
|
393 |
|
|
394 |
ui->statusBar->showMessage(trUtf8("Fichier en cours: %1 [hq] [mq]").arg(fic),3000);
|
|
395 |
QPixmap pixmapMQ(pixmap.scaled(QSize(800,600), Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
|
396 |
pixmapMQ.save(QString("%1/mq/img-%2.jpg").arg(m_currentProjectDir).arg(m_currentProjectPictureNumber));
|
|
397 |
|
|
398 |
ui->statusBar->showMessage(trUtf8("Fichier en cours: %1 [hq] [mq] [lq]").arg(fic),3000);
|
|
399 |
QPixmap pixmapLQ(pixmap.scaled(QSize(640,480), Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
|
400 |
pixmapLQ.save(QString("%1/lq/img-%2.jpg").arg(m_currentProjectDir).arg(m_currentProjectPictureNumber));
|
|
401 |
|
|
402 |
|
|
403 |
QFile file(QString("%1/comments/%2.txt").arg(m_currentProjectDir).arg(m_currentProjectPictureNumber));
|
|
404 |
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
|
405 |
return;
|
|
406 |
|
|
407 |
QTextStream out(&file);
|
|
408 |
out << "<span>Photo " + QString::number(m_currentProjectPictureNumber) + "</span>\n";
|
|
409 |
file.close();
|
|
410 |
ui->statusBar->showMessage(trUtf8("Fichier en cours: %1 [hq] [mq] [lq] [meta]").arg(fic),3000);
|
|
411 |
|
|
412 |
//================== on copie les metadata
|
|
413 |
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fic.toStdString());
|
|
414 |
Exiv2::Image::AutoPtr imageLQ = Exiv2::ImageFactory::open(QString("%1/lq/img-%2.jpg").arg(m_currentProjectDir).arg(m_currentProjectPictureNumber).toStdString());
|
|
415 |
Exiv2::Image::AutoPtr imageMQ = Exiv2::ImageFactory::open(QString("%1/mq/img-%2.jpg").arg(m_currentProjectDir).arg(m_currentProjectPictureNumber).toStdString());
|
|
416 |
Exiv2::Image::AutoPtr imageHQ = Exiv2::ImageFactory::open(QString("%1/hq/img-%2.jpg").arg(m_currentProjectDir).arg(m_currentProjectPictureNumber).toStdString());
|
|
417 |
Exiv2::Image::AutoPtr imageThumb = Exiv2::ImageFactory::open(QString("%1/thumbs/img-%2.jpg").arg(m_currentProjectDir).arg(m_currentProjectPictureNumber).toStdString());
|
|
418 |
if (image.get() != 0)
|
|
419 |
{
|
|
420 |
image->readMetadata();
|
|
421 |
Exiv2::ExifData &exifData = image->exifData();
|
|
422 |
if (!exifData.empty())
|
|
423 |
{
|
|
424 |
bool setArtist = false;
|
|
425 |
bool setCopyright = false;
|
|
426 |
bool setSoftware = false;
|
|
427 |
Exiv2::ExifData::const_iterator end = exifData.end();
|
|
428 |
qDebug() << "============================ DEBUT ===============================";
|
|
429 |
for (Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i)
|
|
430 |
{
|
|
431 |
qDebug() << i->key().c_str() << " = " << i->value().toString().c_str();
|
|
432 |
if (i->key() == "Exif.Image.Artist") {
|
|
433 |
exifData["Exif.Image.Artist"] = "Eric S.";
|
|
434 |
setArtist = true;
|
|
435 |
}
|
|
436 |
if (i->key() == "Exif.Image.Copyright") {
|
|
437 |
exifData["Exif.Image.Copyright"] = "Eric S.";
|
|
438 |
setCopyright = true;
|
|
439 |
}
|
|
440 |
if (i->key() == "Exif.Image.Software") {
|
|
441 |
exifData["Exif.Image.Software"] = "RyXeo WebPhotoAlbum - http://www.ryxeo.com/";
|
|
442 |
setSoftware = true;
|
|
443 |
}
|
|
444 |
}
|
|
445 |
//Si on n'a pas les meta il faut les ajouter
|
|
446 |
|
|
447 |
//Mise à jour de l'auteur
|
|
448 |
if(!setArtist) {
|
|
449 |
Exiv2::ExifKey k("Exif.Image.Artist");
|
|
450 |
Exiv2::Value::AutoPtr v = Exiv2::Value::create(Exiv2::asciiString);
|
|
451 |
v->read("Eric S.");
|
|
452 |
exifData.add(k,v.get());
|
|
453 |
}
|
|
454 |
|
|
455 |
if(!setCopyright) {
|
|
456 |
Exiv2::ExifKey k2("Exif.Image.Copyright");
|
|
457 |
Exiv2::Value::AutoPtr v2 = Exiv2::Value::create(Exiv2::asciiString);
|
|
458 |
v2->read("Eric S.");
|
|
459 |
exifData.add(k2,v2.get());
|
|
460 |
}
|
|
461 |
|
|
462 |
if(!setSoftware) {
|
|
463 |
Exiv2::ExifKey k3("Exif.Image.Software");
|
|
464 |
Exiv2::Value::AutoPtr v3 = Exiv2::Value::create(Exiv2::asciiString);
|
|
465 |
v3->read("RyXéo WebPhotoAlbum - http://www.ryxeo.com/");
|
|
466 |
exifData.add(k3,v3.get());
|
|
467 |
}
|
|
468 |
|
|
469 |
qDebug() << "============================ APRES ===============================";
|
|
470 |
Exiv2::ExifData::const_iterator end2 = exifData.end();
|
|
471 |
for (Exiv2::ExifData::const_iterator i2 = exifData.begin(); i2 != end2; ++i2)
|
|
472 |
{
|
|
473 |
qDebug() << i2->key().c_str() << " = " << i2->value().toString().c_str();
|
|
474 |
}
|
|
475 |
qDebug() << "============================ FIN ===============================";
|
|
476 |
|
|
477 |
imageLQ->setExifData(exifData);
|
|
478 |
imageLQ->writeMetadata();
|
|
479 |
|
|
480 |
imageMQ->setExifData(exifData);
|
|
481 |
imageMQ->writeMetadata();
|
|
482 |
|
|
483 |
imageHQ->setExifData(exifData);
|
|
484 |
imageHQ->writeMetadata();
|
|
485 |
|
|
486 |
imageThumb->setExifData(exifData);
|
|
487 |
imageThumb->writeMetadata();
|
|
488 |
}
|
|
489 |
}
|
|
490 |
m_currentProjectPictureNumber++;
|
|
491 |
ui->statusBar->showMessage(trUtf8("Fichier en cours: %1 [hq] [mq] [lq] [meta] ... terminé").arg(fic),3000);
|
|
492 |
}
|