digiKam
editorwindow_p.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 private data.
8  *
9  * Copyright (C) 2006-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_WINDOW_PRIVATE_H
25 #define DIGIKAM_IMAGE_EDITOR_WINDOW_PRIVATE_H
26 
27 #include "editorwindow.h"
28 
29 // C++ includes
30 
31 #include <cmath>
32 
33 // Qt includes
34 
35 #include <QApplication>
36 #include <QByteArray>
37 #include <QCursor>
38 #include <QDir>
39 #include <QEasingCurve>
40 #include <QEventLoop>
41 #include <QFile>
42 #include <QFileInfo>
43 #include <QGridLayout>
44 #include <QGroupBox>
45 #include <QHBoxLayout>
46 #include <QImageReader>
47 #include <QKeyEvent>
48 #include <QLabel>
49 #include <QLayout>
50 #include <QPointer>
51 #include <QProgressBar>
52 #include <QSplitter>
53 #include <QTimer>
54 #include <QToolButton>
55 #include <QVBoxLayout>
56 #include <QWidgetAction>
57 #include <QButtonGroup>
58 #include <QLineEdit>
59 #include <QKeySequence>
60 #include <QPushButton>
61 #include <QAction>
62 #include <QMenuBar>
63 #include <QStatusBar>
64 #include <QMenu>
65 #include <QIcon>
66 #include <QList>
67 #include <QString>
68 
69 // KDE includes
70 
71 // Pragma directives to reduce warnings from KDE header files.
72 #if defined(Q_CC_GNU)
73 # pragma GCC diagnostic push
74 # pragma GCC diagnostic ignored "-Wdeprecated-declarations"
75 #endif
76 
77 #if defined(Q_CC_CLANG)
78 # pragma clang diagnostic push
79 # pragma clang diagnostic ignored "-Wmismatched-tags"
80 # pragma clang diagnostic ignored "-Wdeprecated-declarations"
81 #endif
82 
83 #include <klocalizedstring.h>
84 #include <kactioncategory.h>
85 #include <kactioncollection.h>
86 #include <ktoolbarpopupaction.h>
87 #include <kwindowsystem.h>
88 #include <kxmlguifactory.h>
89 #include <kconfiggroup.h>
90 #include <kservice.h>
91 #include <ksharedconfig.h>
92 
93 #ifdef HAVE_KIO
94 # include <kopenwithdialog.h>
95 #endif
96 
97 #include <kservicetype.h>
98 #include <kservicetypetrader.h>
99 
100 // Restore warnings
101 #if defined(Q_CC_GNU)
102 # pragma GCC diagnostic pop
103 #endif
104 
105 #if defined(Q_CC_CLANG)
106 # pragma clang diagnostic pop
107 #endif
108 
109 // Local includes
110 
111 #include "digikam_config.h"
112 #include "digikam_debug.h"
113 #include "digikam_globals.h"
114 #include "dmessagebox.h"
115 #include "actioncategorizedview.h"
116 #include "canvas.h"
117 #include "categorizeditemmodel.h"
118 #include "colorcorrectiondlg.h"
119 #include "editorcore.h"
120 #include "dlogoaction.h"
121 #include "dmetadata.h"
122 #include "dzoombar.h"
123 #include "drawdecoderwidget.h"
124 #include "editorstackview.h"
125 #include "editortool.h"
126 #include "editortoolsettings.h"
127 #include "editortooliface.h"
128 #include "exposurecontainer.h"
129 #include "dfileoperations.h"
130 #include "dservicemenu.h"
131 #include "filereadwritelock.h"
132 #include "filesaveoptionsbox.h"
133 #include "filesaveoptionsdlg.h"
134 #include "iccpostloadingmanager.h"
135 #include "iccsettings.h"
136 #include "iccsettingscontainer.h"
137 #include "icctransform.h"
138 #include "imagedialog.h"
139 #include "iofilesettings.h"
140 #include "metaenginesettings.h"
141 #include "libsinfodlg.h"
142 #include "loadingcacheinterface.h"
143 #include "jpegsettings.h"
144 #include "pngsettings.h"
145 #include "savingcontext.h"
146 #include "sidebar.h"
147 #include "softproofdialog.h"
148 #include "statusprogressbar.h"
149 #include "thememanager.h"
150 #include "thumbnailsize.h"
151 #include "thumbnailloadthread.h"
153 #include "undostate.h"
154 #include "dfiledialog.h"
155 #include "dexpanderbox.h"
156 #include "imageiface.h"
157 #include "versionmanager.h"
158 #include "dnotificationpopup.h"
159 
160 namespace Digikam
161 {
162 
163 class Q_DECL_HIDDEN EditorWindow::Private
164 {
165 public:
166 
168  : cmViewIndicator (nullptr),
169  underExposureIndicator (nullptr),
170  overExposureIndicator (nullptr),
171  infoLabel (nullptr),
172  copyAction (nullptr),
173  cropAction (nullptr),
174  flipHorizAction (nullptr),
175  flipVertAction (nullptr),
176  rotateLeftAction (nullptr),
177  rotateRightAction (nullptr),
178  selectAllAction (nullptr),
179  selectNoneAction (nullptr),
180  softProofOptionsAction (nullptr),
181  zoomFitToSelectAction (nullptr),
182  zoomMinusAction (nullptr),
183  zoomPlusAction (nullptr),
184  zoomTo100percents (nullptr),
185  openWithAction (nullptr),
186  waitingLoop (nullptr),
187  currentWindowModalDialog (nullptr),
188  zoomFitToWindowAction (nullptr),
189  viewCMViewAction (nullptr),
190  viewSoftProofAction (nullptr),
191  viewUnderExpoAction (nullptr),
192  viewOverExpoAction (nullptr),
193  selectToolsActionView (nullptr),
194  ICCSettings (nullptr),
195  zoomBar (nullptr),
196  previewToolBar (nullptr),
197  exposureSettings (nullptr),
198  toolIface (nullptr)
199  {
200  }
201 
203  {
204  }
205 
206  void legacyUpdateSplitterState(KConfigGroup& group);
207  void plugNewVersionInFormatAction(EditorWindow* const q,
208  QMenu* const menuAction,
209  const QString& text,
210  const QString& format);
211 
212 public:
213 
214  static const QString configAutoZoomEntry;
215  static const QString configBackgroundColorEntry;
216  static const QString configJpegCompressionEntry;
217  static const QString configJpegSubSamplingEntry;
218  static const QString configPngCompressionEntry;
219  static const QString configTiffCompressionEntry;
220  static const QString configJpeg2000CompressionEntry;
221  static const QString configJpeg2000LossLessEntry;
222  static const QString configPgfCompressionEntry;
223  static const QString configPgfLossLessEntry;
224  static const QString configHeifCompressionEntry;
225  static const QString configHeifLossLessEntry;
226  static const QString configSplitterStateEntry;
227  static const QString configUnderExposureColorEntry;
228  static const QString configUnderExposureIndicatorEntry;
229  static const QString configUnderExposurePercentsEntry;
230  static const QString configOverExposureColorEntry;
231  static const QString configOverExposureIndicatorEntry;
232  static const QString configOverExposurePercentsEntry;
233  static const QString configExpoIndicatorModeEntry;
234  static const QString configUseRawImportToolEntry;
235  static const QString configRawImportToolIidEntry;
237  static const QString configVerticalSplitterSizesEntry;
238  static const QString configVerticalSplitterStateEntry;
239 
240  QToolButton* cmViewIndicator;
242  QToolButton* overExposureIndicator;
243 
245 
246  QAction* copyAction;
247  QAction* cropAction;
248  QAction* flipHorizAction;
249  QAction* flipVertAction;
252  QAction* selectAllAction;
256  QAction* zoomMinusAction;
257  QAction* zoomPlusAction;
259  QAction* openWithAction;
260 
261  QEventLoop* waitingLoop;
263 
269 
271 
273 
276 
278 
280 
282 
284 
285  QMap<QString, KService::Ptr> servicesMap;
286 };
287 
288 const QString EditorWindow::Private::configAutoZoomEntry(QLatin1String("AutoZoom"));
289 const QString EditorWindow::Private::configBackgroundColorEntry(QLatin1String("BackgroundColor"));
290 const QString EditorWindow::Private::configJpegCompressionEntry(QLatin1String("JPEGCompression"));
291 const QString EditorWindow::Private::configJpegSubSamplingEntry(QLatin1String("JPEGSubSampling"));
292 const QString EditorWindow::Private::configPngCompressionEntry(QLatin1String("PNGCompression"));
293 const QString EditorWindow::Private::configTiffCompressionEntry(QLatin1String("TIFFCompression"));
294 const QString EditorWindow::Private::configJpeg2000CompressionEntry(QLatin1String("JPEG2000Compression"));
295 const QString EditorWindow::Private::configJpeg2000LossLessEntry(QLatin1String("JPEG2000LossLess"));
296 const QString EditorWindow::Private::configPgfCompressionEntry(QLatin1String("PGFCompression"));
297 const QString EditorWindow::Private::configPgfLossLessEntry(QLatin1String("PGFLossLess"));
298 const QString EditorWindow::Private::configHeifCompressionEntry(QLatin1String("HEIFCompression"));
299 const QString EditorWindow::Private::configHeifLossLessEntry(QLatin1String("HEIFLossLess"));
300 const QString EditorWindow::Private::configSplitterStateEntry(QLatin1String("SplitterState"));
301 const QString EditorWindow::Private::configUnderExposureColorEntry(QLatin1String("UnderExposureColor"));
302 const QString EditorWindow::Private::configUnderExposureIndicatorEntry(QLatin1String("UnderExposureIndicator"));
303 const QString EditorWindow::Private::configUnderExposurePercentsEntry(QLatin1String("UnderExposurePercentsEntry"));
304 const QString EditorWindow::Private::configOverExposureColorEntry(QLatin1String("OverExposureColor"));
305 const QString EditorWindow::Private::configOverExposureIndicatorEntry(QLatin1String("OverExposureIndicator"));
306 const QString EditorWindow::Private::configOverExposurePercentsEntry(QLatin1String("OverExposurePercentsEntry"));
307 const QString EditorWindow::Private::configExpoIndicatorModeEntry(QLatin1String("ExpoIndicatorMode"));
308 const QString EditorWindow::Private::configUseRawImportToolEntry(QLatin1String("UseRawImportTool"));
309 const QString EditorWindow::Private::configRawImportToolIidEntry(QLatin1String("RawImportToolIid"));
310 const QString EditorWindow::Private::configUseThemeBackgroundColorEntry(QLatin1String("UseThemeBackgroundColor"));
311 const QString EditorWindow::Private::configVerticalSplitterSizesEntry(QLatin1String("Vertical Splitter Sizes"));
312 const QString EditorWindow::Private::configVerticalSplitterStateEntry(QLatin1String("Vertical Splitter State"));
313 
315 {
316  // Check if the thumbnail size in the config file is splitter based (the
317  // old method), and convert to dock based if needed.
318 
319  if (group.hasKey(configSplitterStateEntry))
320  {
321  // Read splitter state from config file
322 
323  QByteArray state;
324  state = QByteArray::fromBase64(group.readEntry(configSplitterStateEntry, state));
325 
326  // Do a cheap check: a splitter state with 3 windows is always 34 bytes.
327 
328  if (state.count() == 34)
329  {
330  // Read the state in streamwise fashion.
331 
332  QDataStream stream(state);
333 
334  // The first 8 bytes are resp. the magic number and the version
335  // (which should be 0, otherwise it's not saved with an older
336  // digiKam version). Then follows the list of window sizes.
337 
338  qint32 marker;
339  qint32 version = -1;
340  QList<int> sizesList;
341 
342  stream >> marker;
343  stream >> version;
344 
345  if (version == 0)
346  {
347  stream >> sizesList;
348 
349  if (sizesList.count() == 3)
350  {
351  qCDebug(DIGIKAM_GENERAL_LOG) << "Found splitter based config, converting to dockbar";
352 
353  // Remove the first entry (the thumbbar) and write the rest
354  // back. Then it should be fine.
355 
356  sizesList.removeFirst();
357  QByteArray newData;
358  QDataStream newStream(&newData, QIODevice::WriteOnly);
359  newStream << marker;
360  newStream << version;
361  newStream << sizesList;
362  char s[24];
363  int numBytes = stream.readRawData(s, 24);
364  newStream.writeRawData(s, numBytes);
365  group.writeEntry(configSplitterStateEntry, newData.toBase64());
366  }
367  }
368  }
369  }
370 }
371 
373  QMenu* const menuAction,
374  const QString& text,
375  const QString& format)
376 {
377  QAction* const action = new QAction(text, q);
378 
379  connect(action, &QAction::triggered,
380  q, [q, format]()
381  {
382  q->saveNewVersionInFormat(format);
383  }
384  );
385 
386  menuAction->addAction(action);
387 }
388 
389 } // namespace Digikam
390 
391 #endif // DIGIKAM_IMAGE_EDITOR_WINDOW_PRIVATE_H
Definition: actioncategorizedview.h:42
Definition: dexpanderbox.h:66
Definition: dzoombar.h:42
Definition: editortooliface.h:45
Definition: editorwindow_p.h:164
QAction * zoomFitToWindowAction
Definition: editorwindow_p.h:264
static const QString configJpeg2000LossLessEntry
Definition: editorwindow_p.h:221
EditorToolIface * toolIface
Definition: editorwindow_p.h:279
DZoomBar * zoomBar
Definition: editorwindow_p.h:274
ActionCategorizedView * selectToolsActionView
Definition: editorwindow_p.h:270
PreviewToolBar * previewToolBar
Definition: editorwindow_p.h:275
QAction * viewSoftProofAction
Definition: editorwindow_p.h:266
QAction * viewOverExpoAction
Definition: editorwindow_p.h:268
QAction * softProofOptionsAction
Definition: editorwindow_p.h:254
static const QString configVerticalSplitterStateEntry
Definition: editorwindow_p.h:238
static const QString configJpeg2000CompressionEntry
Definition: editorwindow_p.h:220
static const QString configPgfCompressionEntry
Definition: editorwindow_p.h:222
QAction * flipVertAction
Definition: editorwindow_p.h:249
QAction * copyAction
Definition: editorwindow_p.h:246
static const QString configHeifLossLessEntry
Definition: editorwindow_p.h:225
static const QString configPngCompressionEntry
Definition: editorwindow_p.h:218
QAction * rotateLeftAction
Definition: editorwindow_p.h:250
ExposureSettingsContainer * exposureSettings
Definition: editorwindow_p.h:277
void legacyUpdateSplitterState(KConfigGroup &group)
Definition: editorwindow_p.h:314
QToolButton * cmViewIndicator
Definition: editorwindow_p.h:240
QAction * selectNoneAction
Definition: editorwindow_p.h:253
QDialog * currentWindowModalDialog
Definition: editorwindow_p.h:262
QAction * zoomFitToSelectAction
Definition: editorwindow_p.h:255
QMap< QString, KService::Ptr > servicesMap
Definition: editorwindow_p.h:285
QAction * cropAction
Definition: editorwindow_p.h:247
static const QString configVerticalSplitterSizesEntry
Definition: editorwindow_p.h:237
static const QString configHeifCompressionEntry
Definition: editorwindow_p.h:224
DAdjustableLabel * infoLabel
Definition: editorwindow_p.h:244
void plugNewVersionInFormatAction(EditorWindow *const q, QMenu *const menuAction, const QString &text, const QString &format)
Definition: editorwindow_p.h:372
static const QString configRawImportToolIidEntry
Definition: editorwindow_p.h:235
static const QString configJpegSubSamplingEntry
Definition: editorwindow_p.h:217
QAction * zoomPlusAction
Definition: editorwindow_p.h:257
Private()
Definition: editorwindow_p.h:167
static const QString configBackgroundColorEntry
Definition: editorwindow_p.h:215
QToolButton * underExposureIndicator
Definition: editorwindow_p.h:241
static const QString configOverExposureIndicatorEntry
Definition: editorwindow_p.h:231
QAction * openWithAction
Definition: editorwindow_p.h:259
static const QString configJpegCompressionEntry
Definition: editorwindow_p.h:216
QAction * viewCMViewAction
Definition: editorwindow_p.h:265
static const QString configPgfLossLessEntry
Definition: editorwindow_p.h:223
QAction * flipHorizAction
Definition: editorwindow_p.h:248
static const QString configOverExposurePercentsEntry
Definition: editorwindow_p.h:232
ICCSettingsContainer * ICCSettings
Definition: editorwindow_p.h:272
static const QString configUnderExposureColorEntry
Definition: editorwindow_p.h:227
QAction * zoomTo100percents
Definition: editorwindow_p.h:258
static const QString configOverExposureColorEntry
Definition: editorwindow_p.h:230
QList< int > fullscreenSizeBackup
Definition: editorwindow_p.h:283
QAction * viewUnderExpoAction
Definition: editorwindow_p.h:267
QAction * rotateRightAction
Definition: editorwindow_p.h:251
QEventLoop * waitingLoop
Definition: editorwindow_p.h:261
static const QString configUseThemeBackgroundColorEntry
Definition: editorwindow_p.h:236
static const QString configExpoIndicatorModeEntry
Definition: editorwindow_p.h:233
VersionManager defaultVersionManager
Definition: editorwindow_p.h:281
static const QString configUnderExposureIndicatorEntry
Definition: editorwindow_p.h:228
QAction * selectAllAction
Definition: editorwindow_p.h:252
QAction * zoomMinusAction
Definition: editorwindow_p.h:256
~Private()
Definition: editorwindow_p.h:202
static const QString configTiffCompressionEntry
Definition: editorwindow_p.h:219
static const QString configAutoZoomEntry
Definition: editorwindow_p.h:214
static const QString configSplitterStateEntry
Definition: editorwindow_p.h:226
static const QString configUnderExposurePercentsEntry
Definition: editorwindow_p.h:229
static const QString configUseRawImportToolEntry
Definition: editorwindow_p.h:234
QToolButton * overExposureIndicator
Definition: editorwindow_p.h:242
Definition: editorwindow.h:78
virtual bool saveNewVersionInFormat(const QString &)=0
Definition: exposurecontainer.h:39
Definition: iccsettingscontainer.h:44
Definition: previewtoolbar.h:44
Definition: versionmanager.h:46
Definition: datefolderview.cpp:43