From b6a9f56069fe994af341a46c9f82969868f0b997 Mon Sep 17 00:00:00 2001 From: Herwig Birke Date: Tue, 12 Nov 2019 15:52:25 +0100 Subject: [PATCH] image count, export options --- cexportdialog.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ cexportdialog.h | 7 +++++++ cexportdialog.ui | 7 +++++-- cmainwindow.cpp | 33 ++++++++++++++++++++++++++++----- cmainwindow.h | 11 +++++++++-- 5 files changed, 96 insertions(+), 9 deletions(-) diff --git a/cexportdialog.cpp b/cexportdialog.cpp index ec8d167..a7c7b65 100644 --- a/cexportdialog.cpp +++ b/cexportdialog.cpp @@ -8,6 +8,7 @@ #include #include +#include cExportDialog::cExportDialog(const QList& imageFormats, QWidget *parent) : @@ -221,6 +222,8 @@ void cExportDialog::initUI(const QList& imageFormats) "%Ssecond of picture taken" "%ttype of created picture" ""); + + onFileFormatChanged(ui->m_lpFileFormat->currentText()); } void cExportDialog::createActions() @@ -233,6 +236,8 @@ void cExportDialog::createActions() connect(ui->m_lpFilenameMethod, QOverload::of(&QButtonGroup::buttonClicked), this, &cExportDialog::onFileMethodChanged); connect(ui->m_lpFilenameAdd, QOverload::of(&QButtonGroup::buttonClicked), this, &cExportDialog::onFileNamePlusChanged); connect(ui->m_lpFileOverwriteMethod, QOverload::of(&QButtonGroup::buttonClicked), this, &cExportDialog::onFileOverwriteMethodChanged); + + connect(ui->m_lpFileFormat, &QComboBox::currentTextChanged, this, &cExportDialog::onFileFormatChanged); } void cExportDialog::onQualityChanged(int value) @@ -295,3 +300,45 @@ void cExportDialog::onFileOverwriteMethodChanged(int /*id*/) { //NOTHING } + +void cExportDialog::onFileFormatChanged(const QString &text) +{ + QString ext = text.mid(text.lastIndexOf("*.")+1).replace(")", ""); + QImageWriter writer("test" + ext); + + if(writer.supportsOption(QImageIOHandler::Quality)) + { + ui->m_lpQuality->setEnabled(true); + ui->m_lpQualityValue->setEnabled(true); + } + else + { + ui->m_lpQuality->setEnabled(false); + ui->m_lpQualityValue->setEnabled(false); + } +} + +/* + QImageWriter writer(destFile); + + qDebug() << "QImageIOHandler::Size: " << writer.supportsOption(QImageIOHandler::Size); + qDebug() << "QImageIOHandler::ClipRect: " << writer.supportsOption(QImageIOHandler::ClipRect); + qDebug() << "QImageIOHandler::ScaledSize: " << writer.supportsOption(QImageIOHandler::ScaledSize); + qDebug() << "QImageIOHandler::ScaledClipRect: " << writer.supportsOption(QImageIOHandler::ScaledClipRect); + qDebug() << "QImageIOHandler::Description: " << writer.supportsOption(QImageIOHandler::Description); + qDebug() << "QImageIOHandler::CompressionRatio: " << writer.supportsOption(QImageIOHandler::CompressionRatio); + qDebug() << "QImageIOHandler::Gamma: " << writer.supportsOption(QImageIOHandler::Gamma); + qDebug() << "QImageIOHandler::Quality: " << writer.supportsOption(QImageIOHandler::Quality); + qDebug() << "QImageIOHandler::Name: " << writer.supportsOption(QImageIOHandler::Name); + qDebug() << "QImageIOHandler::SubType: " << writer.supportsOption(QImageIOHandler::SubType); + qDebug() << "QImageIOHandler::IncrementalReading: " << writer.supportsOption(QImageIOHandler::IncrementalReading); + qDebug() << "QImageIOHandler::Endianness: " << writer.supportsOption(QImageIOHandler::Endianness); + qDebug() << "QImageIOHandler::Animation: " << writer.supportsOption(QImageIOHandler::Animation); + qDebug() << "QImageIOHandler::BackgroundColor: " << writer.supportsOption(QImageIOHandler::BackgroundColor); + qDebug() << "QImageIOHandler::ImageFormat: " << writer.supportsOption(QImageIOHandler::ImageFormat); + qDebug() << "QImageIOHandler::SupportedSubTypes: " << writer.supportsOption(QImageIOHandler::SupportedSubTypes); + qDebug() << "QImageIOHandler::OptimizedWrite: " << writer.supportsOption(QImageIOHandler::OptimizedWrite); + qDebug() << "QImageIOHandler::ProgressiveScanWrite: " << writer.supportsOption(QImageIOHandler::ProgressiveScanWrite); + qDebug() << "QImageIOHandler::ImageTransformation: " << writer.supportsOption(QImageIOHandler::ImageTransformation); + qDebug() << "QImageIOHandler::TransformedByDefault: " << writer.supportsOption(QImageIOHandler::TransformedByDefault); +*/ diff --git a/cexportdialog.h b/cexportdialog.h index ec707e0..03dedd8 100644 --- a/cexportdialog.h +++ b/cexportdialog.h @@ -128,6 +128,13 @@ private slots: \param id */ void onFileOverwriteMethodChanged(int id); + /*! + \brief + + \fn onFileFormatChanged + \param text + */ + void onFileFormatChanged(const QString &text); protected: }; diff --git a/cexportdialog.ui b/cexportdialog.ui index 8d76c09..fbff0ac 100644 --- a/cexportdialog.ui +++ b/cexportdialog.ui @@ -191,6 +191,9 @@ + + 100 + Qt::Horizontal @@ -286,9 +289,9 @@ - + - + diff --git a/cmainwindow.cpp b/cmainwindow.cpp index 0bedcf4..75c9d38 100644 --- a/cmainwindow.cpp +++ b/cmainwindow.cpp @@ -38,6 +38,8 @@ cMainWindow::cMainWindow(cSplashScreen* lpSplashScreen, QWidget *parent) : createActions(); setImageFormats(); + + countImages(); } cMainWindow::~cMainWindow() @@ -270,6 +272,8 @@ void cMainWindow::onAddFolder() ui->m_lpStatusBar->showMessage(tr("done."), 3000); m_working = false; + + countImages(); } void cMainWindow::onRemoveSelected() @@ -289,6 +293,8 @@ void cMainWindow::onClearList() QStringList headerLabels = QStringList() << tr("path") << tr("file") << tr("size") << tr("date") << tr("width") << tr("height") << (""); m_lpFileListModel->setHorizontalHeaderLabels(headerLabels); + + countImages(); } void cMainWindow::onAddEntrys(const QStringList& fileList) @@ -319,6 +325,8 @@ void cMainWindow::onAddEntrys(const QStringList& fileList) ui->m_lpStatusBar->showMessage(tr("done."), 3000); m_working = false; + + countImages(); } void cMainWindow::addPath(const QString& path, bool recursive) @@ -377,6 +385,7 @@ void cMainWindow::addFile(const QString& file) m_lpFileListModel->appendRow(items); + countImages(); qApp->processEvents(); } @@ -432,7 +441,7 @@ void cMainWindow::doExport() overwrite = exportFile(exportSettings, lpExif, overwrite); - m_lpProgressBar->setValue(i); + m_lpProgressBar->setValue(i+1); qApp->processEvents(); } @@ -598,9 +607,9 @@ OVERWRITE cMainWindow::exportFile(const EXPORTSETTINGS& exportSettings, cEXIF* l QFileInfo info(destFile); - if(info.exists()) - qDebug() << "MACHMA NED!!!"; - else +// if(info.exists()) +// qDebug() << "MACHMA NED!!!"; +// else { ui->m_lpStatusBar->showMessage(QString(tr("converting to %1...")).arg(destFile)); qApp->processEvents(); @@ -609,7 +618,7 @@ OVERWRITE cMainWindow::exportFile(const EXPORTSETTINGS& exportSettings, cEXIF* l QFileInfo info(destFile); if(dir.mkpath(info.absolutePath())) - image.save(destFile); + image.save(destFile, nullptr, exportSettings.quality); } } @@ -667,4 +676,18 @@ void cMainWindow::onDeleteEntrys() auto idx = ui->m_lpFileList->selectionModel()->selectedIndexes().first(); m_lpFileListModel->removeRow(idx.row(), idx.parent()); } + + countImages(); +} + +void cMainWindow::countImages() +{ + int count = m_lpFileListModel->rowCount(); + + ui->m_lpStatusBar->showMessage(QString("%1 image(s)").arg(count)); + + if(count) + ui->m_lpConvert->setEnabled(true); + else + ui->m_lpConvert->setEnabled(false); } diff --git a/cmainwindow.h b/cmainwindow.h index 347f594..24c2c93 100644 --- a/cmainwindow.h +++ b/cmainwindow.h @@ -130,8 +130,8 @@ private: QStandardItemModel* m_lpFileListModel; /*!< TODO: describe */ QProgressBar* m_lpProgressBar; /*!< TODO: describe */ - QMimeDatabase m_mimeDB; - QList m_imageFormats; + QMimeDatabase m_mimeDB; /*!< TODO: describe */ + QList m_imageFormats; /*!< TODO: describe */ bool m_working; /*!< TODO: describe */ @@ -246,6 +246,13 @@ private: */ void addImageFormat(const char* shortName, const char* description, const char* extension, QList& readList, QList& writeList); + /*! + \brief + + \fn countImages + */ + void countImages(); + private slots: /*! \brief