digiKam
Loading...
Searching...
No Matches
exiftoolprocess.h
Go to the documentation of this file.
1/* ============================================================
2 *
3 * This file is a part of digiKam project
4 * https://www.digikam.org
5 *
6 * Date : 2021-02-18
7 * Description : Qt5 and Qt6 interface for exiftool.
8 * Based on ZExifTool Qt interface published at 18 Feb 2021
9 * https://github.com/philvl/ZExifTool
10 *
11 * SPDX-FileCopyrightText: 2021-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
12 * SPDX-FileCopyrightText: 2021 by Philippe Vianney Liaud <philvl dot dev at gmail dot com>
13 *
14 * SPDX-License-Identifier: GPL-2.0-or-later
15 *
16 * ============================================================ */
17
18#pragma once
19
20// Qt includes
21
22#include <QString>
23#include <QProcess>
24#include <QPointer>
25
26// Local includes
27
28#include "digikam_export.h"
29
30namespace Digikam
31{
32class ExifToolParser;
33
34class DIGIKAM_EXPORT ExifToolProcess : public QProcess
35{
36 Q_OBJECT
37
38public:
39
60
65 {
66 COPY_EXIF = 0x01,
67 COPY_MAKERNOTES = 0x02,
68 RESTORE_PREVIEW = 0x04,
69 COPY_IPTC = 0x08,
70 COPY_XMP = 0x10,
71 COPY_ICC = 0x20,
72 COPY_ALL = 0x40,
73 COPY_NONE = 0x80
74 };
75
80 {
81 WRITE_EXISTING_TAGS = 0x01,
82 CREATE_NEW_TAGS = 0x02,
83 CREATE_NEW_GROUPS = 0x04,
84 ALL_MODES = WRITE_EXISTING_TAGS |
85 CREATE_NEW_TAGS |
86 CREATE_NEW_GROUPS
87 };
88
93 {
94 TRANS_ALL_XMP = 0x01,
95 TRANS_ALL_IPTC = 0x02,
96 TRANS_ALL_EXIF = 0x04
97 };
98
103 {
104 COMMAND_RESULT = 0,
106 ERROR_RESULT
107 };
108
109public:
110
111 class Result
112 {
113 public:
114
115 Result() = default;
116
117 bool waitError = false;
118 int cmdStatus = ExifToolProcess::COMMAND_RESULT;
119 int cmdAction = ExifToolProcess::NO_ACTION;
120 int cmdNumber = 0;
121 int elapsed = 0;
122 QByteArray output;
123 };
124
125public:
126
131
137
141 static ExifToolProcess* instance();
142 static bool isCreated();
143
148 void initExifTool();
149
154 void shutDownExifTool();
155
156public:
157
162 void setExifToolProgram(const QString& etExePath);
163
164 QString getExifToolProgram() const;
165
166public:
167
171 bool exifToolAvailable() const;
172
176 bool exifToolIsBusy() const;
177
181 QProcess::ProcessError exifToolError() const;
182
186 QString exifToolErrorString() const;
187
191 ExifToolProcess::Result getExifToolResult(int cmdId) const;
192
197 ExifToolProcess::Result waitForExifToolResult(int cmdId) const;
198
204 int command(const QByteArrayList& args, Action ac);
205
206Q_SIGNALS:
207
208 void signalExifToolResult(int cmdId);
209
210private:
211
215 bool startExifTool();
216
220 void restartExifTool();
221
227 void killExifTool();
228
229 QString exifToolBin() const;
230
231 bool checkExifToolProgram() const;
232
233 void changeExifToolProgram(const QString& etExePath);
234
235Q_SIGNALS:
236
238 void signalChangeProgram(const QString& etExePath);
239
240private Q_SLOTS:
241
242 void slotStarted();
243 void slotApplySettingsAndStart();
244 void slotReadyReadStandardError();
245 void slotReadyReadStandardOutput();
246 void slotChangeProgram(const QString& etExePath);
247 void slotErrorOccurred(QProcess::ProcessError error);
248 void slotFinished(int exitCode, QProcess::ExitStatus exitStatus);
249
250private:
251
252 // Disable
253 explicit ExifToolProcess(QObject*) = delete;
254
255private:
256
257 class Private;
258 Private* const d = nullptr;
259};
260
261} // namespace Digikam
Definition exiftoolprocess_p.h:51
Definition exiftoolprocess.h:112
QByteArray output
Definition exiftoolprocess.h:122
Definition exiftoolprocess.h:35
ResultStatus
Definition exiftoolprocess.h:103
@ FINISH_RESULT
Definition exiftoolprocess.h:105
TranslateTagsOps
Definition exiftoolprocess.h:93
void signalChangeProgram(const QString &etExePath)
CopyTagsSource
Definition exiftoolprocess.h:65
WritingTagsMode
Definition exiftoolprocess.h:80
void signalExifToolResult(int cmdId)
Action
Definition exiftoolprocess.h:44
@ LOAD_CHUNKS
Load Exif, Iptc, and Xmp chunks from a file as byte-array for MetaEngine.
Definition exiftoolprocess.h:46
@ VERSION_STRING
Return the ExifTool version as string.
Definition exiftoolprocess.h:55
@ COPY_TAGS
Copy tags from one file to another one. See CopyTagsSource enum for details.
Definition exiftoolprocess.h:56
@ APPLY_METADATA_FILE
Apply a metadata file to a file with ExifTool.
Definition exiftoolprocess.h:49
@ APPLY_CHANGES_EXV
Apply tag changes in a file with ExifTool using an EXV container.
Definition exiftoolprocess.h:48
@ APPLY_CHANGES
Apply tag changes in a file with ExifTool.
Definition exiftoolprocess.h:47
@ TRANS_TAGS
Translate tags in file. See TranslateTagsOps enum for details.
Definition exiftoolprocess.h:57
@ READ_FORMATS
Return the list of readable ExifTool file formats.
Definition exiftoolprocess.h:51
@ TRANSLATIONS_LIST
List of ExifTool languages available for translations.
Definition exiftoolprocess.h:53
@ TAGS_DATABASE
List of ExifTool tags from database.
Definition exiftoolprocess.h:54
@ WRITE_FORMATS
Return the list of writable ExifTool file formats.
Definition exiftoolprocess.h:52
@ CHANGE_TIMESTAMPS
Change all timestamps in a file with ExifTool.
Definition exiftoolprocess.h:50
Definition datefolderview.cpp:34