digiKam
editorcore.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 : 2003-01-15
7  * Description : DImg interface for image editor
8  *
9  * Copyright (C) 2004-2005 by Renchi Raju <renchi dot raju at gmail dot com>
10  * Copyright (C) 2004-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_IMAGE_EDITOR_CORE_H
26 #define DIGIKAM_IMAGE_EDITOR_CORE_H
27 
28 // Qt includes
29 
30 #include <QObject>
31 #include <QString>
32 #include <QByteArray>
33 
34 // Local includes
35 
36 #include "digikam_export.h"
37 #include "dimg.h"
38 #include "dimagehistory.h"
39 #include "versionmanager.h"
40 
41 class QWidget;
42 class QPixmap;
43 
44 namespace Digikam
45 {
46 
47 class UndoState;
48 class ICCSettingsContainer;
49 class ExposureSettingsContainer;
50 class IOFileSettings;
51 class LoadingDescription;
52 class DImgBuiltinFilter;
53 class UndoAction;
54 class UndoMetadataContainer;
55 class VersionFileOperation;
56 
57 class DIGIKAM_EXPORT EditorCore : public QObject
58 {
59  Q_OBJECT
60 
61 public:
62 
63  static EditorCore* defaultInstance();
64  static void setDefaultInstance(EditorCore* const instance);
65 
66 public:
67 
68  explicit EditorCore();
69  ~EditorCore() override;
70 
71  void load(const QString& filename, IOFileSettings* const iofileSettings);
72  void applyTransform(const IccTransform& transform);
73  void setSoftProofingEnabled(bool enabled);
74  bool softProofingEnabled() const;
75 
76  void setICCSettings(const ICCSettingsContainer& cmSettings);
77  ICCSettingsContainer getICCSettings() const;
78 
79  void setExposureSettings(ExposureSettingsContainer* const expoSettings);
80  ExposureSettingsContainer* getExposureSettings() const;
81 
82  void setExifOrient(bool exifOrient);
83  void setDisplayingWidget(QWidget* const widget);
84 
85  void undo();
86  void redo();
87  void restore();
88  void rollbackToOrigin();
89 
90  void saveAs(const QString& file, IOFileSettings* const iofileSettings,
91  bool setExifOrientationTag, const QString& givenMimeType,
92  const QString& intendedFilePath);
93 
94  void saveAs(const QString& file, IOFileSettings* const iofileSettings,
95  bool setExifOrientationTag, const QString& givenMimeType,
96  const VersionFileOperation& operation);
97 
98  void setHistoryIsBranch(bool isBranching);
99  void setLastSaved(const QString& filePath);
100  void switchToLastSaved(const DImageHistory& resolvedCurrentHistory = DImageHistory());
101  void abortSaving();
102  void setModified();
103  void readMetadataFromFile(const QString& file);
104  void clearUndoManager();
105  void setUndoManagerOrigin();
106  void resetImage();
107 
108  QString ensureHasCurrentUuid() const;
109  void provideCurrentUuid(const QString& uuid);
110 
111  void zoom(double val);
112 
116  DImg getImgSelection() const;
117  DImg* getImg() const;
118  bool isValid() const;
119  bool isReadOnly() const;
120  bool hasAlpha() const;
121  bool sixteenBit() const;
122  bool exifRotated() const;
123  int width() const;
124  int height() const;
125  int origWidth() const;
126  int origHeight() const;
127  int bytesDepth() const;
128 
132  void rotate90();
133  void rotate180();
134  void rotate270();
135  void flipHoriz();
136  void flipVert();
137  void convertDepth(int depth);
138  void crop(const QRect& rect);
139 
140  void setSelectedArea(const QRect& rect);
141  QRect getSelectedArea() const;
142 
143  void putIccProfile(const IccProfile& profile);
144  void putImgSelection(const QString& caller, const FilterAction& action, const DImg& img);
145  void putImg(const QString& caller, const FilterAction& action, const DImg& img);
146 
150  void setUndoImg(const UndoMetadataContainer& c, const DImg& img);
151 
152  void imageUndoChanged(const UndoMetadataContainer& c);
153  void setFileOriginData(const QVariant& data);
154 
159  QPixmap convertToPixmap(const DImg& img) const;
160 
161  QString getImageFileName() const;
162  QString getImageFilePath() const;
163  QString getImageFormat() const;
164  QStringList getUndoHistory() const;
165  QStringList getRedoHistory() const;
166  UndoState undoState() const;
167  int availableUndoSteps() const;
168  int availableRedoSteps() const;
169  IccProfile getEmbeddedICC() const;
170  MetaEngineData getMetadata() const;
171  DImageHistory getItemHistory() const;
172  DImageHistory getInitialImageHistory() const;
173  DImageHistory getImageHistoryOfFullRedo() const;
174  DImageHistory getResolvedInitialHistory() const;
175  void setResolvedInitialHistory(const DImageHistory& history);
176 
177 protected Q_SLOTS:
178 
179  void slotImageLoaded(const LoadingDescription& loadingDescription, const DImg& img);
180  void slotImageSaved(const QString& filePath, bool success);
181  void slotLoadingProgress(const LoadingDescription& loadingDescription, float progress);
182  void slotSavingProgress(const QString& filePath, float progress);
183 
184 Q_SIGNALS:
185 
188  void signalFileOriginChanged(const QString& filePath);
189 
190  void signalLoadingStarted(const QString& filename);
191  void signalLoadingProgress(const QString& filePath, float progress);
192  void signalImageLoaded(const QString& filePath, bool success);
193  void signalSavingStarted(const QString& filename);
194  void signalSavingProgress(const QString& filePath, float progress);
195  void signalImageSaved(const QString& filePath, bool success);
196 
197 private Q_SLOTS:
198 
199  void slotLoadRawFromTool(const Digikam::LoadingDescription&, const Digikam::DImg&);
200  void slotLoadRaw(const Digikam::LoadingDescription&);
201 
202 private:
203 
204  // Disable
205  EditorCore(QObject*);
206 
207 private:
208 
209  static EditorCore* m_defaultInstance;
210 
211  class Private;
212  Private* const d;
213 };
214 
215 } // namespace Digikam
216 
217 #endif // DIGIKAM_IMAGE_EDITOR_CORE_H
Definition: dimagehistory.h:49
Definition: dimg.h:62
Definition: editorcore_p.h:60
Definition: editorcore.h:58
void signalImageSaved(const QString &filePath, bool success)
void signalImageLoaded(const QString &filePath, bool success)
void signalSavingStarted(const QString &filename)
void signalFileOriginChanged(const QString &filePath)
void signalUndoStateChanged()
void signalLoadingProgress(const QString &filePath, float progress)
void signalSavingProgress(const QString &filePath, float progress)
void signalLoadingStarted(const QString &filename)
Definition: exposurecontainer.h:39
Definition: filteraction.h:43
Definition: iccsettingscontainer.h:44
Definition: iofilesettings.h:36
Definition: iccprofile.h:43
Definition: icctransform.h:49
Definition: loadingdescription.h:45
Definition: metaengine_data.h:41
Definition: undoaction.h:42
Definition: undostate.h:31
Definition: versionfileoperation.h:72
Definition: datefolderview.cpp:43