digiKam
batchtool.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 : 2008-11-24
7  * Description : Batch Tool Container.
8  *
9  * Copyright (C) 2008-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  *
11  * This program is free software; you can redistribute it
12  * and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation;
14  * either version 2, or (at your option)
15  * any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * ============================================================ */
23 
24 #ifndef DIGIKAM_BQM_BATCH_TOOL_H
25 #define DIGIKAM_BQM_BATCH_TOOL_H
26 
27 // Qt includes
28 
29 #include <QObject>
30 #include <QIcon>
31 
32 // Local includes
33 
34 #include "digikam_export.h"
35 #include "drawdecodersettings.h"
36 #include "dimg.h"
37 #include "iteminfo.h"
38 #include "queuesettings.h"
39 #include "iofilesettings.h"
40 
41 class QWidget;
42 
43 namespace Digikam
44 {
45 
46 class DImgBuiltinFilter;
47 class DImgThreadedFilter;
48 class DPluginBqm;
49 
53 typedef QMap<QString, QVariant> BatchToolSettings;
54 
55 class DIGIKAM_GUI_EXPORT BatchTool : public QObject
56 {
57  Q_OBJECT
58 
59 public:
60 
62  {
63  BaseTool = 0,
65 
72  MetadataTool
73  };
74 
76 
77 public:
78 
79  explicit BatchTool(const QString& name, BatchToolGroup group, QObject* const parent = nullptr);
80  ~BatchTool() override;
81 
82  void setPlugin(DPluginBqm* const plugin);
83  DPluginBqm* plugin() const;
84 
88  QString errorDescription() const;
89 
93  BatchToolGroup toolGroup() const;
94 
98  QString toolGroupToString() const;
99 
103  void setToolTitle(const QString& toolTitle);
104  QString toolTitle() const;
105 
109  void setToolDescription(const QString& toolDescription);
110  QString toolDescription() const;
111 
115  void setToolIconName(const QString& iconName);
116  void setToolIcon(const QIcon& icon);
117  QIcon toolIcon() const;
118 
122  void setSettings(const BatchToolSettings& settings);
123  BatchToolSettings settings() const;
124 
128  void setInputUrl(const QUrl& inputUrl);
129  QUrl inputUrl() const;
130 
134  void setOutputUrl(const QUrl& outputUrl);
135  QUrl outputUrl() const;
136 
140  void setWorkingUrl(const QUrl& workingUrl);
141  QUrl workingUrl() const;
142 
146  void setImageData(const DImg& img);
147  DImg imageData() const;
148 
152  void setItemInfo(const ItemInfo& info);
153  ItemInfo imageInfo() const;
154 
158  void setLastChainedTool(bool last);
159  bool isLastChainedTool() const;
160 
166  void setOutputUrlFromInputUrl();
167 
172  bool loadToDImg() const;
173 
180  bool savefromDImg() const;
181 
185  void setResetExifOrientationAllowed(bool reset);
186 
190  bool getResetExifOrientationAllowed() const;
191 
195  void setNeedResetExifOrientation(bool reset);
196 
200  bool getNeedResetExifOrientation() const;
201 
205  void setRawLoadingRules(QueueSettings::RawLoadingRule rule);
206 
210  void setSaveAsNewVersion(bool fork = true);
211 
216  void setBranchHistory(bool branch = true);
217  bool getBranchHistory() const;
218 
222  void setDRawDecoderSettings(const DRawDecoderSettings& settings);
223 
227  DRawDecoderSettings rawDecodingSettings() const;
228 
232  void setIOFileSettings(const IOFileSettings& settings);
233 
237  IOFileSettings ioFileSettings() const;
238 
242  bool apply();
243 
247  virtual int toolVersion() const
248  {
249  return 1;
250  };
251 
257  virtual void cancel();
258 
264  virtual QString outputSuffix() const;
265 
270 
275  virtual BatchTool* clone(QObject* const parent = nullptr) const = 0;
276 
277 Q_SIGNALS:
278 
280  void signalVisible(bool);
281 
282 public Q_SLOTS:
283 
284  void slotResetSettingsToDefault();
285  void slotSettingsChanged(const BatchToolSettings& settings);
286 
287 protected:
288 
292  bool isRawFile(const QUrl& url) const;
293 
297  void setErrorDescription(const QString& errmsg);
298 
302  DImg& image() const;
303 
307  bool isCancelled() const;
308 
313  void applyFilter(DImgThreadedFilter* const filter);
314  void applyFilterChangedProperties(DImgThreadedFilter* const filter);
315  void applyFilter(DImgBuiltinFilter* const filter);
316 
321  virtual bool toolOperations() = 0;
322 
323 protected Q_SLOTS:
324 
325  virtual void slotSettingsChanged() = 0;
326 
328 
329 public:
330 
334  QWidget* settingsWidget() const;
335 
339  void deleteSettingsWidget();
340 
346  virtual void registerSettingsWidget();
347 
348 Q_SIGNALS:
349 
354 
355 protected:
356 
361 
362 protected Q_SLOTS:
363 
368  virtual void slotAssignSettings2Widget() = 0;
369 
371 
372 public:
373 
374  // Declared as public due to BatchToolObserver class.
375  class Private;
376 
377 private:
378 
379  Private* const d;
380 };
381 
382 } // namespace Digikam
383 
384 #endif // DIGIKAM_BQM_BATCH_TOOL_H
Definition: batchtool.h:56
virtual bool toolOperations()=0
virtual void slotSettingsChanged()=0
virtual BatchToolSettings defaultSettings()=0
QWidget * m_settingsWidget
Definition: batchtool.h:360
void signalSettingsChanged(const BatchToolSettings &)
virtual void slotAssignSettings2Widget()=0
virtual BatchTool * clone(QObject *const parent=nullptr) const =0
virtual int toolVersion() const
Definition: batchtool.h:247
void signalVisible(bool)
void signalAssignSettings2Widget()
BatchToolGroup
Definition: batchtool.h:62
@ CustomTool
List of tools grouped and customized by users.
Definition: batchtool.h:64
@ FiltersTool
Tools to apply filters and special effects (film grain, BlurFx, etc...)
Definition: batchtool.h:70
@ TransformTool
Tools to transform images geometry (resize, rotate, flip, etc...)
Definition: batchtool.h:68
@ ColorTool
Tools to manage image colors (Curves, BCG, etc...)
Definition: batchtool.h:66
@ ConvertTool
Tools to convert images format (PNG, JPEG, TIFF, etc...)
Definition: batchtool.h:71
@ DecorateTool
Tools to decorate images (Border, watermark, etc...)
Definition: batchtool.h:69
@ EnhanceTool
Tools to enhance images (NR, sharp, etc...)
Definition: batchtool.h:67
Definition: dimgbuiltinfilter.h:44
Definition: dimgthreadedfilter.h:41
Definition: dimg.h:62
Definition: dpluginbqm.h:42
Definition: drawdecodersettings.h:43
Definition: iofilesettings.h:36
Definition: iteminfo.h:78
RawLoadingRule
Definition: queuesettings.h:55
Definition: datefolderview.cpp:43
QMap< QString, QVariant > BatchToolSettings
Definition: batchtool.h:48