digiKam
canvas.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 : 2013-08-04
7  * Description : image editor canvas management class
8  *
9  * Copyright (C) 2013-2014 by Yiou Wang <geow812 at gmail dot com>
10  * Copyright (C) 2004-2005 by Renchi Raju <renchi dot raju at gmail dot com>
11  * Copyright (C) 2004-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
12  *
13  * This program is free software; you can redistribute it
14  * and/or modify it under the terms of the GNU General
15  * Public License as published by the Free Software Foundation;
16  * either version 2, or (at your option)
17  * any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * ============================================================ */
25 
26 #ifndef DIGIKAM_IMAGE_EDITOR_CANVAS_H
27 #define DIGIKAM_IMAGE_EDITOR_CANVAS_H
28 
29 // Qt includes
30 
31 #include <QRect>
32 #include <QWheelEvent>
33 #include <QMouseEvent>
34 #include <QKeyEvent>
35 
36 // Local includes
37 
38 #include "digikam_export.h"
39 #include "dimg.h"
40 #include "graphicsdimgview.h"
41 #include "editorcore.h"
42 
43 class QWheelEvent;
44 class QKeyEvent;
45 
46 namespace Digikam
47 {
48 
49 class EditorCore;
50 class ExposureSettingsContainer;
51 class ICCSettingsContainer;
52 class IccTransform;
53 class IOFileSettings;
54 
55 class DIGIKAM_EXPORT Canvas : public GraphicsDImgView
56 {
57  Q_OBJECT
58 
59 public:
60 
61  explicit Canvas(QWidget* const parent = nullptr);
62  ~Canvas() override;
63 
64  void load(const QString& filename, IOFileSettings* const IOFileSettings);
65  void preload(const QString& filename);
66 
67  void resetImage();
68  void abortSaving();
69  void setModified();
70  void makeDefaultEditingCanvas();
71 
72  QString ensureHasCurrentUuid() const;
73 
77  EditorCore* interface() const;
78 
82  DImg currentImage() const;
83 
87  QString currentImageFileFormat() const;
88 
92  QString currentImageFilePath() const;
93 
97  int imageWidth() const;
98 
102  int imageHeight() const;
103 
107  QRect getSelectedArea() const;
108 
113  bool isReadOnly() const;
114 
118  void setICCSettings(const ICCSettingsContainer& cmSettings);
119 
123  void applyTransform(const IccTransform& transform);
124 
128  void setExposureSettings(ExposureSettingsContainer* const expoSettings);
129 
133  void setSoftProofingEnabled(bool enable);
134 
138  void setExifOrient(bool exifOrient);
139 
143  bool exifRotated() const;
144 
148  void fitToSelect();
149 
150 Q_SIGNALS:
151 
153  void signalSelected(bool);
158  void signalLoadingStarted(const QString& filename);
159  void signalLoadingFinished(const QString& filename, bool success);
160  void signalLoadingProgress(const QString& filePath, float progress);
161  void signalSavingStarted(const QString& filename);
162  void signalSavingFinished(const QString& filename, bool success);
163  void signalSavingProgress(const QString& filePath, float progress);
164  void signalSelectionChanged(const QRect&);
165  void signalSelectionSetText(const QRect&);
167  void signalUndoSteps(int);
168  void signalRedoSteps(int);
169  void signalZoomChanged(double);
170  void signalAddedDropedItems(QDropEvent*);
171 
172 public Q_SLOTS:
173 
175  void slotRotate90();
176  void slotRotate180();
177  void slotRotate270();
178  void slotFlipHoriz();
179  void slotFlipVert();
180  void slotCrop();
181 
182  void slotRestore();
183  void slotUndo(int steps = 1);
184  void slotRedo(int steps = 1);
185 
186  void slotCopy();
187 
188  void slotSelectAll();
189  void slotSelectNone();
190  void slotSelected();
191  void slotSelectionMoved();
192 
193 protected:
194 
195  void keyPressEvent(QKeyEvent*) override;
196  void mousePressEvent(QMouseEvent*) override;
197  void addRubber();
198 
199  void dragMoveEvent(QDragMoveEvent*) override;
200  void dragEnterEvent(QDragEnterEvent*) override;
201  void dropEvent(QDropEvent*) override;
202 
203 private:
204 
205  QRect calcSelectedArea() const;
206  void reset();
207 
208 private Q_SLOTS:
209 
210  void slotModified();
211  void slotImageLoaded(const QString& filePath, bool success);
212  void slotImageSaved(const QString& filePath, bool success);
213  void slotAddItemStarted(const QPointF& pos);
214  void slotAddItemMoving(const QRectF& rect);
215  void slotAddItemFinished(const QRectF& rect);
216  void cancelAddItem();
217 
218 private:
219 
220  class Private;
221  Private* const d;
222 };
223 
224 } // namespace Digikam
225 
226 #endif // DIGIKAM_IMAGE_EDITOR_CANVAS_H
Definition: canvas.h:56
void signalSelected(bool)
void signalSavingProgress(const QString &filePath, float progress)
void signalLoadingProgress(const QString &filePath, float progress)
void signalChanged()
void signalRedoSteps(int)
void signalLoadingFinished(const QString &filename, bool success)
void signalAddedDropedItems(QDropEvent *)
void signalZoomChanged(double)
void signalLoadingStarted(const QString &filename)
void signalSavingStarted(const QString &filename)
void signalSelectionChanged(const QRect &)
void signalShowPrevImage()
void signalRightButtonClicked()
void signalSavingFinished(const QString &filename, bool success)
void signalUndoSteps(int)
void signalPrepareToLoad()
void signalSelectionSetText(const QRect &)
void signalToggleOffFitToWindow()
void signalShowNextImage()
Definition: dimg.h:62
Definition: editorcore.h:58
Definition: exposurecontainer.h:39
Definition: graphicsdimgview.h:44
Definition: iccsettingscontainer.h:44
Definition: iofilesettings.h:36
Definition: icctransform.h:49
Definition: datefolderview.cpp:43