digiKam
editortool.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-08-20
7  * Description : editor tool template class.
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_IMAGE_EDITOR_TOOL_H
25 #define DIGIKAM_IMAGE_EDITOR_TOOL_H
26 
27 // Qt includes
28 
29 #include <QObject>
30 #include <QString>
31 #include <QPixmap>
32 #include <QPoint>
33 
34 // Local includes
35 
36 #include "digikam_export.h"
37 #include "dcolor.h"
38 #include "previewtoolbar.h"
39 #include "filteraction.h"
40 #include "dplugineditor.h"
41 
42 namespace Digikam
43 {
44 
45 class DImgThreadedFilter;
46 class DImgThreadedAnalyser;
47 class EditorToolSettings;
48 
49 class DIGIKAM_EXPORT EditorTool : public QObject
50 {
51  Q_OBJECT
52 
53 public:
54 
55  explicit EditorTool(QObject* const parent);
56  ~EditorTool() override;
57 
58  void setPlugin(DPlugin* const plugin);
59  DPlugin* plugin() const;
60 
64  void init();
65 
69  void setInitPreview(bool b);
70 
71  QString toolHelp() const;
72  QString toolName() const;
73  int toolVersion() const;
74  QIcon toolIcon() const;
75  QWidget* toolView() const;
76  EditorToolSettings* toolSettings() const;
77  FilterAction::Category toolCategory() const;
78 
79  virtual void setBackgroundColor(const QColor& bg);
80  virtual void ICCSettingsChanged();
81  virtual void exposureSettingsChanged();
82 
83 public Q_SLOTS:
84 
85  void slotUpdateSpotInfo(const Digikam::DColor& col, const QPoint& point);
86  void slotPreviewModeChanged();
87 
88  virtual void slotCloseTool();
89  virtual void slotApplyTool();
90 
91 Q_SIGNALS:
92 
93  void okClicked();
94  void cancelClicked();
95 
96 protected:
97 
98  void setToolInfoMessage(const QString& txt);
99  void setToolHelp(const QString& anchor);
100  void setToolName(const QString& name);
101  void setToolVersion(const int version);
102  void setToolIcon(const QIcon& icon);
103  void setPreviewModeMask(int mask);
104  void setToolCategory(const FilterAction::Category category);
105 
106  virtual void setToolView(QWidget* const view);
107  virtual void setToolSettings(EditorToolSettings* const settings);
108  virtual void setBusy(bool);
109  virtual void readSettings();
110  virtual void writeSettings();
111  virtual void finalRendering() {};
112 
113 protected Q_SLOTS:
114 
115  void slotTimer();
116 
117  virtual void slotOk();
118  virtual void slotCancel();
119  virtual void slotInit();
120  virtual void slotResetSettings();
121  virtual void slotLoadSettings() {};
122  virtual void slotSaveAsSettings() {};
123  virtual void slotPreview() {};
124  virtual void slotChannelChanged() {};
125  virtual void slotScaleChanged() {};
126 
127 private:
128 
129  class Private;
130  Private* const d;
131 };
132 
133 // -----------------------------------------------------------------
134 
135 class DIGIKAM_EXPORT EditorToolThreaded : public EditorTool
136 {
137  Q_OBJECT
138 
139 public:
140 
142  {
143  NoneRendering = 0,
145  FinalRendering
146  };
147 
148 public:
149 
150  explicit EditorToolThreaded(QObject* const parent);
151  ~EditorToolThreaded() override;
152 
157  void setProgressMessage(const QString& mess);
158 
162  RenderingMode renderingMode() const;
163 
164 public Q_SLOTS:
165 
166  virtual void slotAbort();
167 
168 protected:
169 
173  DImgThreadedFilter* filter() const;
174  void setFilter(DImgThreadedFilter* const filter);
175 
179  DImgThreadedAnalyser* analyser() const;
180  void setAnalyser(DImgThreadedAnalyser* const analyser);
181 
186  void deleteFilterInstance(bool b = true);
187 
188  virtual void preparePreview() {};
189  virtual void prepareFinal() {};
190  virtual void setPreviewImage() {};
191  virtual void setFinalImage() {};
192  virtual void renderingFinished() {};
193  virtual void analyserCompleted() {};
194 
195 protected Q_SLOTS:
196 
200  void slotFilterStarted();
201  void slotFilterFinished(bool success);
202 
206  void slotAnalyserStarted();
207  void slotAnalyserFinished(bool success);
208 
212  void slotProgress(int progress);
213 
214  void slotInit() override;
215  void slotOk() override;
216  void slotCancel() override;
217  void slotPreview() override;
218 
219 private Q_SLOTS:
220 
221  void slotResized();
222 
223 private:
224 
225  class Private;
226  Private* const d;
227 };
228 
229 } // namespace Digikam
230 
231 #endif // DIGIKAM_IMAGE_EDITOR_TOOL_H
Definition: dcolor.h:43
Definition: dimgthreadedanalyser.h:38
Definition: dimgthreadedfilter.h:41
Definition: dplugin.h:61
Definition: editortoolsettings.h:50
Definition: editortool.h:136
virtual void renderingFinished()
Definition: editortool.h:192
virtual void prepareFinal()
Definition: editortool.h:189
virtual void setFinalImage()
Definition: editortool.h:191
virtual void analyserCompleted()
Definition: editortool.h:193
virtual void preparePreview()
Definition: editortool.h:188
virtual void setPreviewImage()
Definition: editortool.h:190
RenderingMode
Definition: editortool.h:142
@ PreviewRendering
Definition: editortool.h:144
Definition: editortool.h:50
virtual void slotPreview()
Definition: editortool.h:123
virtual void slotChannelChanged()
Definition: editortool.h:124
virtual void finalRendering()
Definition: editortool.h:111
virtual void slotScaleChanged()
Definition: editortool.h:125
virtual void slotLoadSettings()
Definition: editortool.h:121
virtual void slotSaveAsSettings()
Definition: editortool.h:122
Category
Definition: filteraction.h:47
Definition: datefolderview.cpp:43