digiKam
editorwindow.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 : 2006-01-20
7  * Description : core image editor GUI implementation
8  *
9  * Copyright (C) 2006-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  * Copyright (C) 2009-2011 by Andi Clemens <andi dot clemens at gmail dot com>
11  * Copyright (C) 2015 by Mohamed_Anwer <m_dot_anwer at gmx 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_WINDOW_H
27 #define DIGIKAM_IMAGE_EDITOR_WINDOW_H
28 
29 // C++ includes
30 
31 #include <queue>
32 
33 // Qt includes
34 
35 #include <QColor>
36 #include <QPointer>
37 #include <QRect>
38 #include <QString>
39 #include <QProgressDialog>
40 #include <QUrl>
41 
42 // Local includes
43 
44 #include "digikam_export.h"
45 #include "digikam_config.h"
46 #include "thumbbardock.h"
47 #include "previewtoolbar.h"
48 #include "savingcontext.h"
49 #include "dxmlguiwindow.h"
50 
51 class QSplitter;
52 class QMenu;
53 class QAction;
54 
55 class KSelectAction;
56 class KToolBarPopupAction;
57 
58 namespace Digikam
59 {
60 
61 class DAdjustableLabel;
62 class DCategorizedView;
63 class Canvas;
64 class DImageHistory;
65 class EditorTool;
66 class EditorStackView;
67 class ExposureSettingsContainer;
68 class IOFileSettings;
69 class ICCSettingsContainer;
70 class Sidebar;
71 class SidebarSplitter;
72 class StatusProgressBar;
73 class VersionManager;
74 class VersionFileOperation;
75 class IccProfile;
76 
77 class DIGIKAM_EXPORT EditorWindow : public DXmlGuiWindow
78 {
79  Q_OBJECT
80 
81 public:
82 
84  {
88  FlipVertical
89  };
90 
91  const static QString CONFIG_GROUP_NAME;
92 
93 public:
94 
95  explicit EditorWindow(const QString& name, QWidget* const parent = nullptr);
96  ~EditorWindow() override;
97 
98  void registerExtraPluginsActions(QString& dom) override;
99  void loadTool(EditorTool* const tool);
100  bool actionEnabledState() const;
101 
102 public Q_SLOTS:
103 
104  void slotSetup() override = 0;
105  virtual void slotSetupICC() = 0;
106 
107 Q_SIGNALS:
108 
109  void signalSelectionChanged(const QRect&);
113 
114 protected:
115 
120 
122 
123  QColor m_bgColor;
124 
126  QSplitter* m_vSplitter;
127 
129  QAction* m_saveAction;
130  QAction* m_saveAsAction;
131  KToolBarPopupAction* m_saveNewVersionAction;
135  QAction* m_exportAction;
136  QAction* m_revertAction;
139  QAction* m_forwardAction;
141 
142  QAction* m_lastAction;
143  QAction* m_firstAction;
144 
147 
148  QAction* m_showBarAction;
149 
150  KToolBarPopupAction* m_undoAction;
151  KToolBarPopupAction* m_redoAction;
152 
155  QAction* m_serviceAction;
156 
161  QPointer<QProgressDialog> m_savingProgressDialog;
162 
164 
167 
169  QVector<TransformType> m_transformQue;
170 
171 protected:
172 
174  {
178  SaveVersionWithoutAsking = OverwriteWithoutAsking,
179  AlwaysNewVersion = AlwaysSaveAs
180  };
181 
182 protected:
183 
184  void saveStandardSettings();
185  void readStandardSettings();
186  void applyStandardSettings();
187  void applyIOSettings();
188  void applyColorManagementSettings();
189 
190  void setupStandardConnections();
191  void setupStandardActions();
192  void setupStatusBar();
193  void setupContextMenu();
194  void setupSelectToolsAction();
195  void toggleStandardActions(bool val);
196  void toggleZoomActions(bool val);
197  void toggleNonDestructiveActions();
198  void toggleToolActions(EditorTool* tool = nullptr);
199 
200  bool promptForOverWrite();
201 
202  bool promptUserDelete(const QUrl& url);
203  bool promptUserSave(const QUrl& url, SaveAskMode mode = AskIfNeeded, bool allowCancel = true);
204  bool waitForSavingToComplete();
205  void startingSave(const QUrl& url);
206  bool startingSaveAs(const QUrl& url);
207  bool startingSaveCurrentVersion(const QUrl& url);
208  bool startingSaveNewVersion(const QUrl& url);
209  bool startingSaveNewVersionAs(const QUrl& url);
210  bool startingSaveNewVersionInFormat(const QUrl& url, const QString& format);
211  bool checkPermissions(const QUrl& url);
212  bool checkOverwrite(const QUrl& url);
213  bool moveLocalFile(const QString& src, const QString& dest);
214  void movingSaveFileFinished(bool successful);
215  void colorManage();
216  void execSavingProgressDialog();
217 
218  void resetOrigin();
219  void resetOriginSwitchFile();
220 
221  void addServicesMenuForUrl(const QUrl& url);
222  void openWith(const QUrl& url, QAction* action);
223 
224  SidebarSplitter* sidebarSplitter() const;
225  EditorStackView* editorStackView() const;
226  ExposureSettingsContainer* exposureSettings() const;
227 
228  VersionFileOperation saveVersionFileOperation(const QUrl& url, bool fork);
229  VersionFileOperation saveAsVersionFileOperation(const QUrl& url, const QUrl& saveLocation, const QString& format);
230  VersionFileOperation saveInFormatVersionFileOperation(const QUrl& url, const QString& format);
231 
232  virtual bool hasOriginalToRestore();
233  virtual DImageHistory resolvedImageHistory(const DImageHistory& history);
234 
235  virtual void moveFile();
236  virtual void finishSaving(bool success);
237 
238  virtual void readSettings();
239  virtual void saveSettings();
240  virtual void toggleActions(bool val);
241 
242  virtual ThumbBarDock* thumbBar() const = 0;
243  virtual Sidebar* rightSideBar() const = 0;
244 
245  virtual void setupConnections() = 0;
246  virtual void setupActions() = 0;
247  virtual void setupUserArea() = 0;
248 
249  virtual void addServicesMenu() = 0;
250 
251  virtual VersionManager* versionManager() const;
252 
261  virtual QUrl saveDestinationUrl() = 0;
262 
263  virtual void saveIsComplete() = 0;
264  virtual void saveAsIsComplete() = 0;
265  virtual void saveVersionIsComplete() = 0;
266 
267 protected Q_SLOTS:
268 
269  void slotAboutToShowUndoMenu();
270  void slotAboutToShowRedoMenu();
271 
272  void slotSelected(bool);
273 
274  void slotLoadingProgress(const QString& filePath, float progress);
275  void slotSavingProgress(const QString& filePath, float progress);
276 
277  void slotNameLabelCancelButtonPressed();
278 
279  void slotComponentsInfo() override;
280 
281  virtual void slotPrepareToLoad();
282  virtual void slotLoadingStarted(const QString& filename);
283  virtual void slotLoadingFinished(const QString& filename, bool success);
284  virtual void slotSavingStarted(const QString& filename);
285  virtual void slotFileOriginChanged(const QString& filePath);
286  virtual void slotDiscardChanges();
287  virtual void slotOpenOriginal();
288 
289  virtual bool saveOrSaveAs();
290 
291  virtual bool saveAs() = 0;
292  virtual bool save() = 0;
293  virtual bool saveNewVersion() = 0;
294  virtual bool saveCurrentVersion() = 0;
295  virtual bool saveNewVersionAs() = 0;
296  virtual bool saveNewVersionInFormat(const QString&) = 0;
297  virtual void slotFileWithDefaultApplication() = 0;
298  virtual void slotDeleteCurrentItem() = 0;
299  virtual void slotBackward() = 0;
300  virtual void slotForward() = 0;
301  virtual void slotFirst() = 0;
302  virtual void slotLast() = 0;
303  virtual void slotUpdateItemInfo() = 0;
304  virtual void slotChanged() = 0;
305  virtual void slotContextMenu() = 0;
306  virtual void slotRevert() = 0;
307  virtual void slotAddedDropedItems(QDropEvent* e) = 0;
308  virtual void slotOpenWith(QAction* action = nullptr) = 0;
309 
310 private Q_SLOTS:
311 
312  void slotSetUnderExposureIndicator(bool);
313  void slotSetOverExposureIndicator(bool);
314  void slotColorManagementOptionsChanged();
315  void slotToggleColorManagedView();
316  void slotSoftProofingOptions();
317  void slotUpdateSoftProofingState();
318  void slotSavingFinished(const QString& filename, bool success);
319  void slotZoomTo100Percents();
320  void slotZoomChanged(bool isMax, bool isMin, double zoom);
321  void slotSelectionChanged(const QRect& sel);
322  void slotSelectionSetText(const QRect& sel);
323  void slotToggleFitToWindow();
324  void slotToggleOffFitToWindow();
325  void slotFitToSelect();
326  void slotIncreaseZoom();
327  void slotDecreaseZoom();
328  void slotCloseTool();
329  void slotApplyTool();
330  void slotUndoStateChanged();
331  void slotThemeChanged();
332  void slotToggleRightSideBar() override;
333  void slotPreviousRightSideBarTab() override;
334  void slotNextRightSideBarTab() override;
335  void slotToolDone();
336 
337  void slotRotateLeftIntoQue();
338  void slotRotateRightIntoQue();
339  void slotFlipHIntoQue();
340  void slotFlipVIntoQue();
341 
342 private:
343 
344  void enterWaitingLoop();
345  void quitWaitingLoop();
346  void showSideBars(bool visible) override;
347  void showThumbBar(bool visible) override;
348  void customizedFullScreenMode(bool set) override;
349  bool thumbbarVisibility() const override;
350  void setColorManagedViewIndicatorToolTip(bool available, bool cmv);
351  void setUnderExposureToolTip(bool uei);
352  void setOverExposureToolTip(bool oei);
353 
354  void setToolStartProgress(const QString& toolName);
355  void setToolProgress(int progress);
356  void setToolStopProgress();
357 
358  void setToolInfoMessage(const QString& txt);
359 
360  bool startingSaveVersion(const QUrl& url, bool subversion, bool saveAs, const QString& format);
361 
362  void setPreviewModeMask(int mask);
363  PreviewToolBar::PreviewMode previewMode() const;
364 
365  bool showFileSaveDialog(const QUrl& initialUrl, QUrl& newURL);
366 
373  void setupTempSaveFile(const QUrl& url);
374 
383  QString selectValidSavingFormat(const QUrl& targetUrl);
384 
385  void addAction2ContextMenu(const QString& actionName, bool addDisabled = false);
386 
387 private:
388 
389  class Private;
390  Private* const d;
391 
392  friend class EditorToolIface;
393 };
394 
395 } // namespace Digikam
396 
397 #endif // DIGIKAM_IMAGE_EDITOR_WINDOW_H
Definition: canvas.h:56
Definition: dexpanderbox.h:66
Definition: dimagehistory.h:49
Definition: dxmlguiwindow.h:98
Definition: editorstackview.h:42
Definition: editortooliface.h:45
Definition: editortool.h:50
Definition: editorwindow_p.h:164
Definition: editorwindow.h:78
static const QString CONFIG_GROUP_NAME
Definition: editorwindow.h:91
QSplitter * m_vSplitter
Definition: editorwindow.h:126
QAction * m_firstAction
Definition: editorwindow.h:143
QAction * m_openVersionAction
Definition: editorwindow.h:128
QString m_formatForRAWVersioning
Definition: editorwindow.h:165
virtual void addServicesMenu()=0
void slotSetup() override=0
QAction * m_fileDeleteAction
Definition: editorwindow.h:138
QAction * m_revertAction
Definition: editorwindow.h:136
SidebarSplitter * m_splitter
Definition: editorwindow.h:125
QAction * m_saveNewVersionAsAction
Definition: editorwindow.h:133
virtual void setupConnections()=0
QAction * m_closeToolAction
Definition: editorwindow.h:146
virtual bool saveCurrentVersion()=0
StatusProgressBar * m_nameLabel
Definition: editorwindow.h:159
virtual bool saveNewVersion()=0
virtual bool saveAs()=0
virtual bool saveNewVersionAs()=0
virtual Sidebar * rightSideBar() const =0
virtual void slotChanged()=0
QAction * m_discardChangesAction
Definition: editorwindow.h:137
EditorStackView * m_stackView
Definition: editorwindow.h:157
QMenu * m_servicesMenu
Definition: editorwindow.h:154
void signalSelectionChanged(const QRect &)
QPointer< QProgressDialog > m_savingProgressDialog
Definition: editorwindow.h:161
QAction * m_exportAction
Definition: editorwindow.h:135
QAction * m_lastAction
Definition: editorwindow.h:142
virtual void setupUserArea()=0
void signalPreviewModeChanged(int)
virtual void slotRevert()=0
QString m_formatForSubversions
Definition: editorwindow.h:166
QMenu * m_saveNewVersionInFormatAction
Definition: editorwindow.h:134
QColor m_bgColor
Definition: editorwindow.h:123
QAction * m_showBarAction
Definition: editorwindow.h:148
virtual void slotFileWithDefaultApplication()=0
virtual void setupActions()=0
IOFileSettings * m_IOFileSettings
Definition: editorwindow.h:160
QAction * m_forwardAction
Definition: editorwindow.h:139
bool m_setExifOrientationTag
Definition: editorwindow.h:117
virtual bool save()=0
virtual bool saveNewVersionInFormat(const QString &)=0
Canvas * m_canvas
Definition: editorwindow.h:158
virtual QUrl saveDestinationUrl()=0
virtual void slotDeleteCurrentItem()=0
QMenu * m_contextMenu
Definition: editorwindow.h:153
KToolBarPopupAction * m_saveNewVersionAction
Definition: editorwindow.h:131
virtual void slotOpenWith(QAction *action=nullptr)=0
KToolBarPopupAction * m_undoAction
Definition: editorwindow.h:150
QAction * m_saveAsAction
Definition: editorwindow.h:130
SaveAskMode
Definition: editorwindow.h:174
@ AlwaysSaveAs
Definition: editorwindow.h:177
@ AskIfNeeded
Definition: editorwindow.h:175
@ OverwriteWithoutAsking
Definition: editorwindow.h:176
QVector< TransformType > m_transformQue
NOTE: using QVector to store transforms.
Definition: editorwindow.h:169
virtual void saveVersionIsComplete()=0
virtual void slotLast()=0
virtual ThumbBarDock * thumbBar() const =0
QAction * m_saveCurrentVersionAction
Definition: editorwindow.h:132
QAction * m_saveAction
Definition: editorwindow.h:129
virtual void slotBackward()=0
virtual void slotForward()=0
KToolBarPopupAction * m_redoAction
Definition: editorwindow.h:151
virtual void slotUpdateItemInfo()=0
virtual void saveAsIsComplete()=0
bool m_actionEnabledState
Definition: editorwindow.h:119
bool m_nonDestructive
Definition: editorwindow.h:116
virtual void saveIsComplete()=0
SavingContext m_savingContext
Definition: editorwindow.h:163
virtual void slotAddedDropedItems(QDropEvent *e)=0
QAction * m_serviceAction
Definition: editorwindow.h:155
DAdjustableLabel * m_resLabel
Definition: editorwindow.h:121
virtual void slotContextMenu()=0
bool m_editingOriginalImage
Definition: editorwindow.h:118
virtual void slotFirst()=0
QAction * m_backwardAction
Definition: editorwindow.h:140
virtual void slotSetupICC()=0
TransformType
Definition: editorwindow.h:84
@ RotateLeft
Definition: editorwindow.h:85
@ FlipHorizontal
Definition: editorwindow.h:87
@ RotateRight
Definition: editorwindow.h:86
QAction * m_applyToolAction
Definition: editorwindow.h:145
Definition: exposurecontainer.h:39
Definition: iofilesettings.h:36
PreviewMode
Definition: previewtoolbar.h:50
Definition: savingcontext.h:43
Definition: sidebar.h:480
Definition: sidebar.h:333
Definition: statusprogressbar.h:43
Definition: thumbbardock.h:84
Definition: versionfileoperation.h:72
Definition: versionmanager.h:46
Definition: datefolderview.cpp:43