From ede485d68cd7aeae1635d91d8cefd84489cc4a16 Mon Sep 17 00:00:00 2001 From: birkeh Date: Tue, 12 Nov 2019 22:35:36 +0100 Subject: [PATCH] center thumbnail, extend TAGs --- cexif.cpp | 66 ----------------------------------------------- cexportdialog.cpp | 19 ++++++++++++++ cexportdialog.h | 6 +++++ cmainwindow.cpp | 36 ++++++++++++++++++++++---- 4 files changed, 56 insertions(+), 71 deletions(-) diff --git a/cexif.cpp b/cexif.cpp index 32cabaf..4754882 100644 --- a/cexif.cpp +++ b/cexif.cpp @@ -76,28 +76,6 @@ bool cEXIF::fromFile(const QString& szFileName) QImage image; image.loadFromData(static_cast(previewImage.pData()), static_cast(previewImage.size())); -// QTransform rotation; -// int angle = 0; - -// switch(imageOrientation()) -// { -// case 8: -// angle = 270; -// break; -// case 3: -// angle = 180; -// break; -// case 6: -// angle = 90; -// break; -// } - -// if(angle != 0) -// { -// rotation.rotate(angle); -// image = image.transformed(rotation); -// } - m_previewList.append(image); } } @@ -126,28 +104,6 @@ bool cEXIF::fromFile(const QString& szFileName) QImage image; image.loadFromData(static_cast(previewImage.pData()), static_cast(previewImage.size())); -// QTransform rotation; -// int angle = 0; - -// switch(imageOrientation()) -// { -// case 8: -// angle = 270; -// break; -// case 3: -// angle = 180; -// break; -// case 6: -// angle = 90; -// break; -// } - -// if(angle != 0) -// { -// rotation.rotate(angle); -// image = image.transformed(rotation); -// } - m_previewList.append(image); } } @@ -177,28 +133,6 @@ bool cEXIF::fromFile(const QString& szFileName) QImage image; image.loadFromData(static_cast(previewImage.pData()), static_cast(previewImage.size())); -// QTransform rotation; -// int angle = 0; - -// switch(imageOrientation()) -// { -// case 8: -// angle = 270; -// break; -// case 3: -// angle = 180; -// break; -// case 6: -// angle = 90; -// break; -// } - -// if(angle != 0) -// { -// rotation.rotate(angle); -// image = image.transformed(rotation); -// } - m_previewList.append(image); } } diff --git a/cexportdialog.cpp b/cexportdialog.cpp index a7c7b65..d4248d5 100644 --- a/cexportdialog.cpp +++ b/cexportdialog.cpp @@ -9,6 +9,7 @@ #include #include #include +#include cExportDialog::cExportDialog(const QList& imageFormats, QWidget *parent) : @@ -210,6 +211,8 @@ void cExportDialog::initUI(const QList& imageFormats) "%Hhour of picture taken" "%Mminute of picture taken" "%Ssecond of picture taken" + "%ccamera manufacturer" + "%lcamera model" "%ttype of created picture" ""); ui->m_lpFileTagHelp->setText("" @@ -220,6 +223,8 @@ void cExportDialog::initUI(const QList& imageFormats) "" "" "" + "" + "" "" "
%Hhour of picture taken
%Mminute of picture taken
%Ssecond of picture taken
%ccamera manufacturer
%lcamera model
%ttype of created picture
"); @@ -238,6 +243,8 @@ void cExportDialog::createActions() connect(ui->m_lpFileOverwriteMethod, QOverload::of(&QButtonGroup::buttonClicked), this, &cExportDialog::onFileOverwriteMethodChanged); connect(ui->m_lpFileFormat, &QComboBox::currentTextChanged, this, &cExportDialog::onFileFormatChanged); + + connect(ui->m_lpDestinationPathBrowse, &QPushButton::clicked, this, &cExportDialog::onPathSelect); } void cExportDialog::onQualityChanged(int value) @@ -318,6 +325,18 @@ void cExportDialog::onFileFormatChanged(const QString &text) } } +void cExportDialog::onPathSelect() +{ + QSettings settings; + QString szPath = settings.value("export/path", QDir::homePath()).toString(); + szPath = QFileDialog::getExistingDirectory(this, tr("Export Directory"), szPath, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + + if(szPath.isEmpty()) + return; + + ui->m_lpDestinationPath->setText(szPath); +} + /* QImageWriter writer(destFile); diff --git a/cexportdialog.h b/cexportdialog.h index 03dedd8..3b50206 100644 --- a/cexportdialog.h +++ b/cexportdialog.h @@ -135,6 +135,12 @@ private slots: \param text */ void onFileFormatChanged(const QString &text); + /*! + \brief + + \fn onPathSelect + */ + void onPathSelect(); protected: }; diff --git a/cmainwindow.cpp b/cmainwindow.cpp index d69fc77..9841a85 100644 --- a/cmainwindow.cpp +++ b/cmainwindow.cpp @@ -3,6 +3,8 @@ */ +#include "common.h" + #include "cmainwindow.h" #include "ui_cmainwindow.h" @@ -104,7 +106,7 @@ void cMainWindow::initUI() m_lpProgressBar->setVisible(false); ui->m_lpStatusBar->addPermanentWidget(m_lpProgressBar); - QStringList headerLabels = QStringList() << tr("path") << tr("file") << tr("size") << tr("date") << tr("width") << tr("height") << (""); + QStringList headerLabels = QStringList() << tr("icon") << tr("path") << tr("file") << tr("size") << tr("date") << tr("width") << tr("height") << (""); m_lpFileListModel->setHorizontalHeaderLabels(headerLabels); } @@ -293,7 +295,7 @@ void cMainWindow::onClearList() m_lpFileListModel->clear(); - QStringList headerLabels = QStringList() << tr("path") << tr("file") << tr("size") << tr("date") << tr("width") << tr("height") << (""); + QStringList headerLabels = QStringList() << tr("icon") << tr("path") << tr("file") << tr("size") << tr("date") << tr("width") << tr("height") << (""); m_lpFileListModel->setHorizontalHeaderLabels(headerLabels); countImages(); @@ -369,6 +371,15 @@ void cMainWindow::addFile(const QString& file) QList items; + QImage thumbnail = lpExif->thumbnail(); + + QImage thumb(THUMBNAIL_WIDTH, thumbnail.height(), QImage::Format_ARGB32); + thumb.fill(qRgba(0, 0, 0, 0)); + QPainter painter(&thumb); + painter.drawImage((THUMBNAIL_WIDTH-thumbnail.width())/2, 0, thumbnail); + QIcon icon = QIcon(QPixmap::fromImage(thumb)); + + items.append(new QStandardItem("")); items.append(new QStandardItem(info.path())); items.append(new QStandardItem(info.fileName())); items.append(new QStandardItem(QString::number(info.size()/1024)+" kb")); @@ -376,12 +387,12 @@ void cMainWindow::addFile(const QString& file) items.append(new QStandardItem(QString::number(lpExif->imageWidth()))); items.append(new QStandardItem(QString::number(lpExif->imageHeight()))); - items[0]->setIcon(QIcon(QPixmap::fromImage(lpExif->thumbnail()))); -// items[0]->setCheckable(true); - items[2]->setTextAlignment(Qt::AlignRight | Qt::AlignCenter); + items[0]->setIcon(icon); + items[0]->setTextAlignment(Qt::AlignHCenter | Qt::AlignCenter); items[3]->setTextAlignment(Qt::AlignRight | Qt::AlignCenter); items[4]->setTextAlignment(Qt::AlignRight | Qt::AlignCenter); items[5]->setTextAlignment(Qt::AlignRight | Qt::AlignCenter); + items[6]->setTextAlignment(Qt::AlignRight | Qt::AlignCenter); items[0]->setData(QVariant::fromValue(lpExif), Qt::UserRole+1); @@ -728,6 +739,14 @@ QString cMainWindow::replaceTags(const QString& path, cEXIF* lpExif, const QStri { QString dest = path; QFileInfo fileInfo(lpExif->fileName()); + QString model = lpExif->cameraModel().replace("/", "_").replace("\\", "_").replace(":", "_"); + QString maker = lpExif->cameraMake().replace("/", "_").replace("\\", "_").replace(":", "_"); + + if(model.isEmpty()) + model = "UNKNOWN"; + + if(maker.isEmpty()) + maker = "UNKNOWN"; if(directory) dest = dest.replace("%o", fileInfo.absolutePath()); @@ -740,6 +759,8 @@ QString cMainWindow::replaceTags(const QString& path, cEXIF* lpExif, const QStri dest = dest.replace("%H", lpExif->dateTime().toString("hh")); dest = dest.replace("%M", lpExif->dateTime().toString("mm")); dest = dest.replace("%S", lpExif->dateTime().toString("ss")); + dest = dest.replace("%c", maker); + dest = dest.replace("%l", model); dest = dest.replace("%t", extension); dest = dest.replace("\\", "/"); @@ -747,6 +768,11 @@ QString cMainWindow::replaceTags(const QString& path, cEXIF* lpExif, const QStri return(dest); } +/* + if(!lpPicture->cameraModel().isEmpty()) + szPath.append("/" + lpPicture->cameraModel().replace("/", "_").replace("\\", "_").replace(":", "_")); +*/ + QString cMainWindow::findFreeFileName(const QString& fileName) { QFileInfo fileInfo(fileName);