Commit 8f332525 authored by Gilles Caulier's avatar Gilles Caulier 🗼
Browse files

DNGWriter : include ExifTool Error View in Settings Widget.

Fix API to check ExifTool program availability.
Factoring codes.
CCBUGS: 134486, 170693, 219856, 237504, 264210, 309341, 325458, 326408, 377622, 384092, 406540, 416516, 421464, 436286, 381967
parent aad3b9b1
Pipeline #62165 passed with stage
in 35 minutes and 5 seconds
......@@ -43,6 +43,8 @@
#include "dcombobox.h"
#include "dngwriter.h"
#include "exiftoolerrorview.h"
#include "exiftoolparser.h"
namespace Digikam
{
......@@ -55,16 +57,19 @@ public:
: previewModeLabel (nullptr),
compressLossLess (nullptr),
backupOriginalRawFile(nullptr),
previewModeCB (nullptr)
previewModeCB (nullptr),
errorView (nullptr)
{
}
QLabel* previewModeLabel;
QLabel* previewModeLabel;
QCheckBox* compressLossLess;
QCheckBox* backupOriginalRawFile;
QCheckBox* compressLossLess;
QCheckBox* backupOriginalRawFile;
DComboBox* previewModeCB;
DComboBox* previewModeCB;
ExifToolErrorView* errorView;
};
DNGSettings::DNGSettings(QWidget* const parent)
......@@ -91,14 +96,21 @@ DNGSettings::DNGSettings(QWidget* const parent)
d->previewModeCB->insertItem(DNGWriter::FULL_SIZE, i18nc("embedded preview type in dng file", "Full size"));
d->previewModeCB->setDefaultIndex(DNGWriter::MEDIUM);
d->errorView = new ExifToolErrorView(this);
d->errorView->setErrorText(i18n("Warning: ExifTool is not available to post-process metadata. "
"Without ExifTool, DNG will not includes all RAW source properties."));
settingsBoxLayout->addWidget(d->backupOriginalRawFile, 0, 0, 1, 1);
settingsBoxLayout->addWidget(d->compressLossLess, 1, 0, 1, 1);
settingsBoxLayout->addWidget(d->previewModeLabel, 3 ,0, 1, 1);
settingsBoxLayout->addWidget(d->previewModeCB, 4 ,0 ,1, 1);
settingsBoxLayout->addWidget(d->errorView, 5 ,0 ,1, 1);
settingsBoxLayout->setRowStretch(9, 10);
settingsBoxLayout->setContentsMargins(spacing, spacing, spacing, spacing);
settingsBoxLayout->setSpacing(spacing);
// ------------------------------------------------------------------------
connect(d->backupOriginalRawFile, SIGNAL(toggled(bool)),
this, SIGNAL(signalSettingsChanged()));
......@@ -107,6 +119,13 @@ DNGSettings::DNGSettings(QWidget* const parent)
connect(d->previewModeCB, SIGNAL(activated(int)),
this, SIGNAL(signalSettingsChanged()));
connect(d->errorView, SIGNAL(signalSetupExifTool()),
this, SIGNAL(signalSetupExifTool()));
// ------------------------------------------------------------------------
slotSetupChanged();
}
DNGSettings::~DNGSettings()
......@@ -151,4 +170,9 @@ bool DNGSettings::backupOriginalRawFile() const
return d->backupOriginalRawFile->isChecked();
}
void DNGSettings::slotSetupChanged()
{
d->errorView->setVisible(!ExifToolParser().exifToolAvailable());
}
} // namespace Digikam
......@@ -54,9 +54,15 @@ public:
void setDefaultSettings();
public Q_SLOTS:
/// To handle changes from host application Setup dialog.
void slotSetupChanged();
Q_SIGNALS:
void signalSettingsChanged();
void signalSetupExifTool();
private:
......
......@@ -100,18 +100,11 @@ void ExifToolParser::slotMetaEngineSettingsChanged()
qCDebug(DIGIKAM_METAENGINE_LOG) << "ExifTool path:" << d->proc->program();
}
bool ExifToolParser::exifToolAvailable()
bool ExifToolParser::exifToolAvailable() const
{
bool ret = false;
bool ret = d->proc->checkExifToolProgram();
QFileInfo fi(MetaEngineSettings::instance()->settings().exifToolPath);
if (fi.exists() && fi.isExecutable())
{
ret = true;
}
qCDebug(DIGIKAM_METAENGINE_LOG) << "Check ExifTool availability:" << fi.filePath() << "==>" << ret;
qCDebug(DIGIKAM_METAENGINE_LOG) << "Check ExifTool availability:" << ret;
return ret;
}
......
......@@ -102,7 +102,10 @@ public:
ExifToolData currentData() const;
QString currentErrorString() const;
static bool exifToolAvailable();
/**
* Check the ExifTool program availability.
*/
bool exifToolAvailable() const;
//@}
......
......@@ -112,28 +112,8 @@ void ExifToolProcess::start()
return;
}
// Check if Exiftool program exists and have execution permissions
qCDebug(DIGIKAM_METAENGINE_LOG) << "Path to ExifTool:" << d->etExePath;
if (
(d->etExePath != exifToolBin()) &&
(!QFile::exists(d->etExePath) ||
!(QFile::permissions(d->etExePath) & QFile::ExeUser))
)
{
d->setProcessErrorAndEmit(QProcess::FailedToStart,
QString::fromLatin1("ExifTool does not exists or exec permission is missing"));
return;
}
// If perl path is defined, check if Perl program exists and have execution permissions
if (!d->perlExePath.isEmpty() && (!QFile::exists(d->perlExePath) ||
!(QFile::permissions(d->perlExePath) & QFile::ExeUser)))
if (!checkExifToolProgram())
{
d->setProcessErrorAndEmit(QProcess::FailedToStart,
QString::fromLatin1("Perl does not exists or exec permission is missing"));
return;
}
......@@ -388,4 +368,34 @@ QString ExifToolProcess::exifToolBin() const
}
bool ExifToolProcess::checkExifToolProgram()
{
// Check if Exiftool program exists and have execution permissions
qCDebug(DIGIKAM_METAENGINE_LOG) << "Path to ExifTool:" << d->etExePath;
if (
(d->etExePath != exifToolBin()) &&
(!QFile::exists(d->etExePath) ||
!(QFile::permissions(d->etExePath) & QFile::ExeUser))
)
{
d->setProcessErrorAndEmit(QProcess::FailedToStart,
QString::fromLatin1("ExifTool does not exists or exec permission is missing"));
return false;
}
// If perl path is defined, check if Perl program exists and have execution permissions
if (!d->perlExePath.isEmpty() && (!QFile::exists(d->perlExePath) ||
!(QFile::permissions(d->perlExePath) & QFile::ExeUser)))
{
d->setProcessErrorAndEmit(QProcess::FailedToStart,
QString::fromLatin1("Perl does not exists or exec permission is missing"));
return false;
}
return true;
}
} // namespace Digikam
......@@ -98,6 +98,8 @@ public:
QString program() const;
bool checkExifToolProgram();
/**
* Starts exiftool in a new process.
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment