initial commit

This commit is contained in:
2022-04-01 15:57:11 +02:00
parent e3a68c1e00
commit cd90f4e811
8 changed files with 1123 additions and 0 deletions
+417
View File
@@ -0,0 +1,417 @@
/*!
\file cexportdialog.cpp
*/
#include "cexportdialog.h"
#include "ui_cexportdialog.h"
#include <QSettings>
#include <QCloseEvent>
#include <QImageWriter>
#include <QFileDialog>
cExportDialog::cExportDialog(const QList<IMAGEFORMAT>& imageFormats, QWidget *parent) :
QDialog(parent),
ui(new Ui::cExportDialog)
{
initUI(imageFormats);
createActions();
}
cExportDialog::~cExportDialog()
{
delete ui;
}
void cExportDialog::accept()
{
saveSettings();
QDialog::accept();
}
void cExportDialog::reject()
{
saveSettings();
QDialog::reject();
}
void cExportDialog::saveSettings()
{
QSettings settings;
settings.setValue("export/width", QVariant::fromValue(size().width()));
settings.setValue("export/height", QVariant::fromValue(size().height()));
settings.setValue("export/x", QVariant::fromValue(x()));
settings.setValue("export/y", QVariant::fromValue(y()));
if(ui->m_lpNewDirectoryTag->isChecked())
settings.setValue("export/directoryMethod", QVariant::fromValue(QString("newDirectoryTag")));
else if(ui->m_lpNewDirectory->isChecked())
settings.setValue("export/directoryMethod", QVariant::fromValue(QString("newDirectory")));
else
settings.setValue("export/directoryMethod", QVariant::fromValue(QString("keepDirectory")));
settings.setValue("export/destinationPath", QVariant::fromValue(ui->m_lpDestinationPath->text()));
settings.setValue("export/keepStructure", QVariant::fromValue(ui->m_lpKeepStructure->isChecked()));
settings.setValue("export/destinationPathTag", QVariant::fromValue(ui->m_lpDestinationPathTag->text()));
if(ui->m_lpNewFilename->isChecked())
settings.setValue("export/fileMethod", QVariant::fromValue(QString("newFilename")));
else
settings.setValue("export/fileMethod", QVariant::fromValue(QString("keepFilename")));
if(ui->m_lpFilenameTag->isChecked())
settings.setValue("export/filenamePlus", QVariant::fromValue(QString("TAG")));
else
settings.setValue("export/filenamePlus", QVariant::fromValue(QString("converted")));
settings.setValue("export/fileTag", QVariant::fromValue(ui->m_lpFileTag->text()));
if(ui->m_lpFileNoExport->isChecked())
settings.setValue("export/overwrite", QVariant::fromValue(QString("no")));
else if(ui->m_lpFileOverwrite->isChecked())
settings.setValue("export/overwrite", QVariant::fromValue(QString("overwrite")));
else if(ui->m_lpFileRename->isChecked())
settings.setValue("export/overwrite", QVariant::fromValue(QString("rename")));
else
settings.setValue("export/overwrite", QVariant::fromValue(QString("ask")));
settings.setValue("export/copyEXIF", QVariant::fromValue(ui->m_lpCopyEXIF->isChecked()));
settings.setValue("export/fileFormat", QVariant::fromValue(ui->m_lpFileFormat->currentText()));
settings.setValue("export/quality", QVariant::fromValue(ui->m_lpQuality->value()));
settings.setValue("export/stripLastDirectory", QVariant::fromValue(ui->m_lpStripLastDirectory->isChecked()));
settings.setValue("export/stripLastDirectoryIf", QVariant::fromValue(ui->m_lpStripLastDirectoryIf->isChecked()));
settings.setValue("export/stripLastDirectoryIfList", QVariant::fromValue(ui->m_lpStripLastDirectoryIfList->toPlainText()));
}
void cExportDialog::initUI(const QList<IMAGEFORMAT>& imageFormats)
{
QSettings settings;
ui->setupUi(this);
qint32 iX = settings.value("export/x", QVariant::fromValue(-1)).toInt();
qint32 iY = settings.value("export/y", QVariant::fromValue(-1)).toInt();
qint32 iWidth = settings.value("export/width", QVariant::fromValue(-1)).toInt();
qint32 iHeight = settings.value("export/height", QVariant::fromValue(-1)).toInt();
if(iWidth != -1 && iHeight != -1)
resize(iWidth, iHeight);
if(iX != -1 && iY != -1)
move(iX, iY);
QString directoryMethod = settings.value("export/directoryMethod", QVariant::fromValue(QString("keepDirectory"))).toString();
if(directoryMethod == "newDirectoryTag")
{
ui->m_lpKeepDirectory->setChecked(false);
ui->m_lpNewDirectory->setChecked(false);
ui->m_lpNewDirectoryTag->setChecked(true);
ui->m_lpDestinationPath->setEnabled(false);
ui->m_lpDestinationPathBrowse->setEnabled(false);
}
else if(directoryMethod == "newDirectory")
{
ui->m_lpKeepDirectory->setChecked(false);
ui->m_lpNewDirectory->setChecked(true);
ui->m_lpNewDirectoryTag->setChecked(false);
ui->m_lpDestinationPathTag->setEnabled(false);
}
else
{
ui->m_lpKeepDirectory->setChecked(true);
ui->m_lpNewDirectory->setChecked(false);
ui->m_lpNewDirectoryTag->setChecked(false);
ui->m_lpDestinationPath->setEnabled(false);
ui->m_lpDestinationPathBrowse->setEnabled(false);
ui->m_lpDestinationPathTag->setEnabled(false);
ui->m_lpKeepStructure->setEnabled(false);
}
ui->m_lpStripLastDirectory->setChecked(settings.value("export/stripLastDirectory", QVariant::fromValue(false)).toBool());
ui->m_lpStripLastDirectoryIf->setChecked(settings.value("export/stripLastDirectoryIf", QVariant::fromValue(false)).toBool());
ui->m_lpStripLastDirectoryIfList->setText(settings.value("export/stripLastDirectoryIfList", QVariant::fromValue(QString(""))).toString());
onStripLastDirectoryChanged(ui->m_lpStripLastDirectory->checkState());
ui->m_lpDestinationPath->setText(settings.value("export/destinationPath", QVariant::fromValue(QString(""))).toString());
ui->m_lpKeepStructure->setChecked(settings.value("export/keepStructure", QVariant::fromValue(false)).toBool());
ui->m_lpDestinationPathTag->setText(settings.value("export/destinationPathTag", QVariant::fromValue(QString(""))).toString());
QString fileMethod = settings.value("export/fileMethod", QVariant::fromValue(QString("keepFilename"))).toString();
if(fileMethod == "newFilename")
{
ui->m_lpKeepFilename->setChecked(false);
ui->m_lpNewFilename->setChecked(true);
ui->m_lpFilenamePlusConverted->setEnabled(true);
ui->m_lpFilenameTag->setEnabled(true);
ui->m_lpFileTag->setEnabled(true);
}
else
{
ui->m_lpKeepFilename->setChecked(true);
ui->m_lpNewFilename->setChecked(false);
ui->m_lpFilenamePlusConverted->setEnabled(false);
ui->m_lpFilenameTag->setEnabled(false);
ui->m_lpFileTag->setEnabled(false);
}
QString filenamePlus = settings.value("export/filenamePlus", QVariant::fromValue(QString("converted"))).toString();
if(filenamePlus == "TAG")
{
ui->m_lpFilenamePlusConverted->setChecked(false);
ui->m_lpFilenameTag->setChecked(true);
}
else
{
ui->m_lpFilenamePlusConverted->setChecked(true);
ui->m_lpFilenameTag->setChecked(false);
ui->m_lpFileTag->setEnabled(false);
}
ui->m_lpFileTag->setText(settings.value("export/fileTag", QVariant::fromValue(QString(""))).toString());
QString fileOverwrite = settings.value("export/overwrite", QVariant::fromValue(QString("ask"))).toString();
if(fileOverwrite == "no")
{
ui->m_lpFileNoExport->setChecked(true);
ui->m_lpFileAsk->setChecked(false);
ui->m_lpFileRename->setChecked(false);
ui->m_lpFileOverwrite->setChecked(false);
}
else if(fileOverwrite == "overwrite")
{
ui->m_lpFileNoExport->setChecked(false);
ui->m_lpFileAsk->setChecked(false);
ui->m_lpFileRename->setChecked(false);
ui->m_lpFileOverwrite->setChecked(true);
}
else if(fileOverwrite == "rename")
{
ui->m_lpFileNoExport->setChecked(false);
ui->m_lpFileAsk->setChecked(false);
ui->m_lpFileRename->setChecked(true);
ui->m_lpFileOverwrite->setChecked(false);
}
else
{
ui->m_lpFileNoExport->setChecked(false);
ui->m_lpFileAsk->setChecked(true);
ui->m_lpFileRename->setChecked(false);
ui->m_lpFileOverwrite->setChecked(false);
}
for(int x = 0;x < imageFormats.count();x++)
{
IMAGEFORMAT i = imageFormats[x];
if(i.write)
ui->m_lpFileFormat->addItem(i.description + " (" + i.extension + ")");
}
ui->m_lpFileFormat->setCurrentText(settings.value("export/fileFormat").toString());
(ui->m_lpCopyEXIF->setChecked(settings.value("export/copyEXIF", QVariant::fromValue(true)).toBool()));
ui->m_lpQuality->setValue(settings.value("export/quality", QVariant::fromValue(50)).toInt());
ui->m_lpQualityValue->setText(QString::number(ui->m_lpQuality->value()));
ui->m_lpPathTagHelp->setText("<table>"
"<tr><td>%o</td><td>original directory</td></tr>"
"<tr><td>%y</td><td>year of picture taken</td></tr>"
"<tr><td>%m</td><td>month of picture taken</td></tr>"
"<tr><td>%d</td><td>day of picture taken</td></tr>"
"<tr><td>%H</td><td>hour of picture taken</td></tr>"
"<tr><td>%M</td><td>minute of picture taken</td></tr>"
"<tr><td>%S</td><td>second of picture taken</td></tr>"
"<tr><td>%c</td><td>camera manufacturer</td></tr>"
"<tr><td>%l</td><td>camera model</td></tr>"
"<tr><td>%t</td><td>type of created picture</td></tr>"
"</table>");
ui->m_lpFileTagHelp->setText("<table>"
"<tr><td>%o</td><td>original filename (without extension)</td></tr>"
"<tr><td>%y</td><td>year of picture taken</td></tr>"
"<tr><td>%m</td><td>month of picture taken</td></tr>"
"<tr><td>%d</td><td>day of picture taken</td></tr>"
"<tr><td>%H</td><td>hour of picture taken</td></tr>"
"<tr><td>%M</td><td>minute of picture taken</td></tr>"
"<tr><td>%S</td><td>second of picture taken</td></tr>"
"<tr><td>%c</td><td>camera manufacturer</td></tr>"
"<tr><td>%l</td><td>camera model</td></tr>"
"<tr><td>%t</td><td>type of created picture</td></tr>"
"</table>");
onFileFormatChanged(ui->m_lpFileFormat->currentText());
}
void cExportDialog::createActions()
{
QSettings settings;
connect(ui->m_lpQuality, &QSlider::valueChanged, this, &cExportDialog::onQualityChanged);
connect(ui->m_lpDirectoryMethod, QOverload<QAbstractButton*>::of(&QButtonGroup::buttonClicked), this, &cExportDialog::onDirectoryMethodChanged);
connect(ui->m_lpFilenameMethod, QOverload<QAbstractButton*>::of(&QButtonGroup::buttonClicked), this, &cExportDialog::onFileMethodChanged);
connect(ui->m_lpFilenameAdd, QOverload<QAbstractButton*>::of(&QButtonGroup::buttonClicked), this, &cExportDialog::onFileNamePlusChanged);
connect(ui->m_lpFileOverwriteMethod, QOverload<QAbstractButton*>::of(&QButtonGroup::buttonClicked), this, &cExportDialog::onFileOverwriteMethodChanged);
connect(ui->m_lpStripLastDirectory, &QCheckBox::stateChanged, this, &cExportDialog::onStripLastDirectoryChanged);
connect(ui->m_lpStripLastDirectoryIf, &QCheckBox::stateChanged, this, &cExportDialog::onStripLastDirectoryIfChanged);
connect(ui->m_lpFileFormat, &QComboBox::currentTextChanged, this, &cExportDialog::onFileFormatChanged);
connect(ui->m_lpDestinationPathBrowse, &QPushButton::clicked, this, &cExportDialog::onPathSelect);
}
void cExportDialog::onQualityChanged(int value)
{
ui->m_lpQualityValue->setNum(value);
}
void cExportDialog::onDirectoryMethodChanged(QAbstractButton* /*button*/)
{
if(ui->m_lpNewDirectoryTag->isChecked())
{
ui->m_lpDestinationPath->setEnabled(false);
ui->m_lpDestinationPathBrowse->setEnabled(false);
ui->m_lpKeepStructure->setEnabled(false);
ui->m_lpDestinationPathTag->setEnabled(true);
}
else if(ui->m_lpNewDirectory->isChecked())
{
ui->m_lpDestinationPath->setEnabled(true);
ui->m_lpDestinationPathBrowse->setEnabled(true);
ui->m_lpKeepStructure->setEnabled(true);
ui->m_lpDestinationPathTag->setEnabled(false);
}
else
{
ui->m_lpDestinationPath->setEnabled(false);
ui->m_lpDestinationPathBrowse->setEnabled(false);
ui->m_lpKeepStructure->setEnabled(false);
ui->m_lpDestinationPathTag->setEnabled(false);
}
}
void cExportDialog::onFileMethodChanged(QAbstractButton* /*button*/)
{
if(ui->m_lpNewFilename->isChecked())
{
ui->m_lpFilenamePlusConverted->setEnabled(true);
ui->m_lpFilenameTag->setEnabled(true);
ui->m_lpFilenamePlusConverted->setEnabled(true);
ui->m_lpFilenameTag->setEnabled(true);
onFileNamePlusChanged(0);
}
else
{
ui->m_lpFilenamePlusConverted->setEnabled(false);
ui->m_lpFilenameTag->setEnabled(false);
ui->m_lpFileTag->setEnabled(false);
}
}
void cExportDialog::onFileNamePlusChanged(QAbstractButton* /*button*/)
{
if(ui->m_lpNewFilename->isChecked() && ui->m_lpFilenameTag->isChecked())
ui->m_lpFileTag->setEnabled(true);
else
ui->m_lpFileTag->setEnabled(false);
}
void cExportDialog::onFileOverwriteMethodChanged(QAbstractButton* /*button*/)
{
//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);
}
}
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);
}
void cExportDialog::onStripLastDirectoryChanged(int state)
{
if(state == Qt::Unchecked)
{
ui->m_lpStripLastDirectoryIf->setEnabled(false);
ui->m_lpStripLastDirectoryIfList->setEnabled(false);
}
else
{
ui->m_lpStripLastDirectoryIf->setEnabled(true);
onStripLastDirectoryIfChanged(ui->m_lpStripLastDirectoryIf->checkState());
}
}
void cExportDialog::onStripLastDirectoryIfChanged(int state)
{
if(state == Qt::Unchecked)
{
ui->m_lpStripLastDirectoryIfList->setEnabled(false);
}
else
{
ui->m_lpStripLastDirectoryIfList->setEnabled(true);
}
}
/*
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);
*/
+163
View File
@@ -0,0 +1,163 @@
/*!
\file cexportdialog.h
*/
#ifndef CEXPORTDIALOG_H
#define CEXPORTDIALOG_H
#include <QDialog>
#include <QAbstractButton>
#include "common.h"
/*
* altes Verzeichnis
* neues Verzeichnis, alte Struktur
* neues Verzeichnis
*
* alter Name (umbenennen, wenn gleich)
* alter Name + _converted
* alter Name + tag
* tag
*
* überschreiben / fragen / umbenennen
*/
namespace Ui {
class cExportDialog;
}
/*!
\brief
\class cExportDialog cexportdialog.h "cexportdialog.h"
*/
class cExportDialog : public QDialog
{
Q_OBJECT
public:
/*!
\brief
\fn cExportDialog
\param imageFormats
\param parent
*/
explicit cExportDialog(const QList<IMAGEFORMAT>& imageFormats, QWidget *parent = nullptr);
/*!
\brief
\fn ~cExportDialog
*/
~cExportDialog();
private:
Ui::cExportDialog *ui; /*!< TODO: describe */
/*!
\brief
\fn accept
*/
void accept();
/*!
\brief
\fn reject
*/
void reject();
/*!
\brief
\fn saveSettings
*/
void saveSettings();
/*!
\brief
\fn initUI
\param imageFormats
*/
void initUI(const QList<IMAGEFORMAT>& imageFormats);
/*!
\brief
\fn createActions
*/
void createActions();
private slots:
/*!
\brief
\fn onQualityChanged
\param value
*/
void onQualityChanged(int value);
/*!
\brief
\fn onDirectoryMethodChanged
\param button
*/
void onDirectoryMethodChanged(QAbstractButton* button);
/*!
\brief
\fn onStripLastDirectoryChanged
\param button
*/
void onStripLastDirectoryChanged(int state);
/*!
\brief
\fn onStripLastDirectoryIfChanged
\param button
*/
void onStripLastDirectoryIfChanged(int state);
/*!
\brief
\fn onFileMethodChanged
\param button
*/
void onFileMethodChanged(QAbstractButton* button);
/*!
\brief
\fn onFileNamePlusChanged
\param button
*/
void onFileNamePlusChanged(QAbstractButton* button);
/*!
\brief
\fn onFileOverwriteMethodChanged
\param button
*/
void onFileOverwriteMethodChanged(QAbstractButton* button);
/*!
\brief
\fn onFileFormatChanged
\param text
*/
void onFileFormatChanged(const QString &text);
/*!
\brief
\fn onPathSelect
*/
void onPathSelect();
protected:
};
#endif // CEXPORTDIALOG_H
+354
View File
@@ -0,0 +1,354 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>cExportDialog</class>
<widget class="QDialog" name="cExportDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>554</width>
<height>610</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Destination Path</string>
</property>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="0">
<widget class="QRadioButton" name="m_lpNewDirectoryTag">
<property name="text">
<string>TAG</string>
</property>
<attribute name="buttonGroup">
<string notr="true">m_lpDirectoryMethod</string>
</attribute>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QLineEdit" name="m_lpDestinationPathTag"/>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="m_lpNewDirectory">
<property name="text">
<string>new folder</string>
</property>
<attribute name="buttonGroup">
<string notr="true">m_lpDirectoryMethod</string>
</attribute>
</widget>
</item>
<item row="1" column="4">
<widget class="QCheckBox" name="m_lpKeepStructure">
<property name="text">
<string>keep structure</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QLineEdit" name="m_lpDestinationPath"/>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="m_lpKeepDirectory">
<property name="text">
<string>keep folder</string>
</property>
<attribute name="buttonGroup">
<string notr="true">m_lpDirectoryMethod</string>
</attribute>
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="m_lpStripLastDirectoryIf">
<property name="text">
<string>if</string>
</property>
</widget>
</item>
<item row="4" column="2" colspan="3">
<widget class="QTextEdit" name="m_lpStripLastDirectoryIfList"/>
</item>
<item row="1" column="3">
<widget class="QPushButton" name="m_lpDestinationPathBrowse">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="m_lpStripLastDirectory">
<property name="text">
<string>strip last folder</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="m_lpPathTagHelp">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Filename</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_3">
<item row="2" column="1">
<widget class="QRadioButton" name="m_lpFilenameTag">
<property name="text">
<string>TAG:</string>
</property>
<attribute name="buttonGroup">
<string notr="true">m_lpFilenameAdd</string>
</attribute>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="m_lpNewFilename">
<property name="text">
<string>rename</string>
</property>
<attribute name="buttonGroup">
<string notr="true">m_lpFilenameMethod</string>
</attribute>
</widget>
</item>
<item row="7" column="0" colspan="3">
<widget class="QRadioButton" name="m_lpFileOverwrite">
<property name="text">
<string>overwrite existing file</string>
</property>
<attribute name="buttonGroup">
<string notr="true">m_lpFileOverwriteMethod</string>
</attribute>
</widget>
</item>
<item row="6" column="0" colspan="3">
<widget class="QRadioButton" name="m_lpFileRename">
<property name="text">
<string>auto rename existing file</string>
</property>
<attribute name="buttonGroup">
<string notr="true">m_lpFileOverwriteMethod</string>
</attribute>
</widget>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="m_lpKeepFilename">
<property name="text">
<string>keep filename</string>
</property>
<attribute name="buttonGroup">
<string notr="true">m_lpFilenameMethod</string>
</attribute>
</widget>
</item>
<item row="1" column="1">
<widget class="QRadioButton" name="m_lpFilenamePlusConverted">
<property name="text">
<string>old filename + _converted</string>
</property>
<attribute name="buttonGroup">
<string notr="true">m_lpFilenameAdd</string>
</attribute>
</widget>
</item>
<item row="5" column="0" colspan="3">
<widget class="QRadioButton" name="m_lpFileAsk">
<property name="text">
<string>ask before overwrite existing file</string>
</property>
<attribute name="buttonGroup">
<string notr="true">m_lpFileOverwriteMethod</string>
</attribute>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="m_lpFileTag"/>
</item>
<item row="3" column="2">
<widget class="QLabel" name="m_lpFileTagHelp">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="8" column="0" colspan="3">
<widget class="QCheckBox" name="m_lpCopyEXIF">
<property name="text">
<string>copy EXIF data</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="3">
<widget class="QRadioButton" name="m_lpFileNoExport">
<property name="text">
<string>do not export existing file</string>
</property>
<attribute name="buttonGroup">
<string notr="true">m_lpFileOverwriteMethod</string>
</attribute>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>File Format</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout" columnstretch="0,0">
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QSlider" name="m_lpQuality">
<property name="maximum">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="m_lpQualityValue">
<property name="text">
<string>0</string>
</property>
<property name="buddy">
<cstring>m_lpQuality</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>file format:</string>
</property>
<property name="buddy">
<cstring>m_lpFileFormat</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="m_lpFileFormat"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>quality:</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<tabstops>
<tabstop>m_lpKeepDirectory</tabstop>
<tabstop>m_lpNewDirectory</tabstop>
<tabstop>m_lpDestinationPath</tabstop>
<tabstop>m_lpDestinationPathBrowse</tabstop>
<tabstop>m_lpKeepStructure</tabstop>
<tabstop>m_lpNewDirectoryTag</tabstop>
<tabstop>m_lpDestinationPathTag</tabstop>
<tabstop>m_lpStripLastDirectory</tabstop>
<tabstop>m_lpStripLastDirectoryIf</tabstop>
<tabstop>m_lpStripLastDirectoryIfList</tabstop>
<tabstop>m_lpKeepFilename</tabstop>
<tabstop>m_lpNewFilename</tabstop>
<tabstop>m_lpFilenamePlusConverted</tabstop>
<tabstop>m_lpFilenameTag</tabstop>
<tabstop>m_lpFileTag</tabstop>
<tabstop>m_lpFileAsk</tabstop>
<tabstop>m_lpFileRename</tabstop>
<tabstop>m_lpFileOverwrite</tabstop>
<tabstop>m_lpCopyEXIF</tabstop>
<tabstop>m_lpFileFormat</tabstop>
<tabstop>m_lpQuality</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>cExportDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>237</x>
<y>522</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>134</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>cExportDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>305</x>
<y>522</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>134</y>
</hint>
</hints>
</connection>
</connections>
<buttongroups>
<buttongroup name="m_lpFilenameAdd"/>
<buttongroup name="m_lpFilenameMethod"/>
<buttongroup name="m_lpFileOverwriteMethod"/>
<buttongroup name="m_lpDirectoryMethod"/>
</buttongroups>
</ui>
+55
View File
@@ -7,6 +7,11 @@
#include <QDebug>
#include "cimage.h"
#include "cexportdialog.h"
#include <QImageReader>
#include <QImageWriter>
#include <QSqlQuery>
cMainWindow::cMainWindow(QWidget *parent) :
@@ -19,14 +24,17 @@ cMainWindow::cMainWindow(QWidget *parent) :
m_exportAction(nullptr),
m_stopAction(nullptr),
m_albumRootsList(nullptr),
m_albumsList(nullptr),
m_folderViewModel(nullptr),
m_folderSortFilterProxyModel(nullptr),
m_thumbnailViewModel(nullptr),
m_thumbnailSortFilterProxyModel(nullptr),
m_rootItem(nullptr),
m_loading(false)
{
initUI();
createActions();
setImageFormats();
loadData();
initSignals();
}
@@ -140,6 +148,50 @@ void cMainWindow::createContextActions()
{
}
void cMainWindow::setImageFormats()
{
QList<QByteArray> readList = QImageReader::supportedImageFormats();
QList<QByteArray> writeList = QImageWriter::supportedImageFormats();
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "exportDigikam");
db.setHostName("localhost");
db.setDatabaseName("exportDigikam.db");
if(!db.open())
return;
QSqlQuery query(db);
query.prepare("SELECT shortname, description, extension FROM imageFormat;");
if(!query.exec())
{
db.close();
return;
}
while(query.next())
addImageFormat(query.value("shortname").toString(), query.value("description").toString(), query.value("extension").toString(), readList, writeList);
db.close();
}
void cMainWindow::addImageFormat(const QString& shortName, const QString& description, const QString& extension, QList<QByteArray>& readList, QList<QByteArray>& writeList)
{
bool r = readList.contains(QByteArray(shortName.toUtf8()));
bool w = writeList.contains(QByteArray(shortName.toUtf8()));
if(QString(shortName).isEmpty())
r = true;
IMAGEFORMAT i;
i.shortName = shortName;
i.description = description;
i.extension = extension;
i.read = r;
i.write = w;
m_imageFormats.append(i);
}
void cMainWindow::loadData()
{
m_thumbnailViewModel->clear();
@@ -384,6 +436,9 @@ void cMainWindow::onRefreshList()
void cMainWindow::onExport()
{
cExportDialog exportDialog(m_imageFormats, this);
if(exportDialog.exec() == QDialog::Rejected)
return;
}
void cMainWindow::onStop()
+6
View File
@@ -2,6 +2,8 @@
#define CMAINWINDOW_H
#include "common.h"
#include "calbumroots.h"
#include "calbums.h"
#include "cfoldersortfilterproxymodel.h"
@@ -56,12 +58,16 @@ private:
cThumbnailSortFilterProxyModel* m_thumbnailSortFilterProxyModel;
QStandardItem* m_rootItem;
QList<IMAGEFORMAT> m_imageFormats;
bool m_loading;
void initUI();
void createActions();
void createMenuActions();
void createContextActions();
void setImageFormats();
void addImageFormat(const QString& shortName, const QString& description, const QString& extension, QList<QByteArray>& readList, QList<QByteArray>& writeList);
void loadData();
void displayData();
void initSignals();
+60
View File
@@ -0,0 +1,60 @@
/*!
\file common.cpp
*/
#include "common.h"
QString generateReadList(const QList<IMAGEFORMAT>& imageFormats)
{
QString all("all supported files (");
QString readList;
for(int z = 0;z < imageFormats.count();z++)
{
IMAGEFORMAT i = imageFormats[z];
if(i.read)
{
all.append(i.extension);
all.append(" ");
readList.append(";;");
readList.append(i.description);
readList.append(" (");
readList.append(i.extension);
readList.append(")");
}
}
readList.prepend(all);
return(readList);
}
QString generateWriteList(const QList<IMAGEFORMAT>& imageFormats)
{
QString all("all supported files (");
QString writeList;
for(int z = 0;z < imageFormats.count();z++)
{
IMAGEFORMAT i = imageFormats[z];
if(i.write)
{
all.append(i.extension);
all.append(" ");
writeList.append(";;");
writeList.append(i.description);
writeList.append(" (");
writeList.append(i.extension);
writeList.append(")");
}
}
writeList.prepend(all);
return(writeList);
}
+63
View File
@@ -0,0 +1,63 @@
/*!
\file common.h
*/
#ifndef COMMON_H
#define COMMON_H
#include <QDebug>
#define THUMBNAIL_WIDTH 160
#define THUMBNAIL_HEIGHT 120
#ifdef __GNUC__
#define myDebug qDebug() << __FILE__ << "(" << __LINE__ << ") - " << __PRETTY_FUNCTION__ << ":"
#elif __MINGW32__
#define myDebug qDebug() << __FILE__ << "(" << __LINE__ << ") - " << __PRETTY_FUNCTION__ << ":"
#else
#define myDebug qDebug() << __FILE__ << "(" << __LINE__ << ") - " << __FUNCTION__ << ":"
#endif
/*!
\brief
\class tagIMAGEFORMAT common.h "common.h"
*/
typedef struct tagIMAGEFORMAT
{
QString shortName; /*!< TODO: describe */
QString description; /*!< TODO: describe */
QString extension; /*!< TODO: describe */
bool read; /*!< TODO: describe */
bool write; /*!< TODO: describe */
/*!
\brief
\typedef IMAGEFORMAT*/
} IMAGEFORMAT;
/*!
\brief
\fn generateReadList
\param imageFormats
\return QString
*/
QString generateReadList(const QList<IMAGEFORMAT>& imageFormats);
/*!
\brief
\fn generateWriteList
\param imageFormats
\return QString
*/
QString generateWriteList(const QList<IMAGEFORMAT>& imageFormats);
#endif // COMMON_H
+5
View File
@@ -41,9 +41,11 @@ DEFINES += APP_VERSION=\\\"$$VERSION\\\"
SOURCES += \
calbumroots.cpp \
calbums.cpp \
cexportdialog.cpp \
cfoldersortfilterproxymodel.cpp \
cimage.cpp \
cimages.cpp \
common.cpp \
cthumbnailsortfilterproxymodel.cpp \
main.cpp \
cmainwindow.cpp \
@@ -58,10 +60,12 @@ SOURCES += \
HEADERS += \
calbumroots.h \
calbums.h \
cexportdialog.h \
cfoldersortfilterproxymodel.h \
cimage.h \
cimages.h \
cmainwindow.h \
common.h \
cthumbnailsortfilterproxymodel.h \
pgfutils/libpgf/BitStream.h \
pgfutils/libpgf/Decoder.h \
@@ -75,6 +79,7 @@ HEADERS += \
pgfutils/pgfutils.h
FORMS += \
cexportdialog.ui \
cmainwindow.ui
# Default rules for deployment.