1 /*******************************************************************************
2 **
3 ** Photivo
4 **
5 ** Copyright (C) 2008 Jos De Laender <jos.de_laender@telenet.be>
6 ** Copyright (C) 2009,2010 Michael Munzert <mail@mm-log.com>
7 ** Copyright (C) 2013 Alexander Tzyganenko <tz@fast-report.com>
8 **
9 ** This file is part of Photivo.
10 **
11 ** Photivo is free software: you can redistribute it and/or modify
12 ** it under the terms of the GNU General Public License version 3
13 ** as published by the Free Software Foundation.
14 **
15 ** Photivo is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ** GNU General Public License for more details.
19 **
20 ** You should have received a copy of the GNU General Public License
21 ** along with Photivo.  If not, see <http://www.gnu.org/licenses/>.
22 **
23 *******************************************************************************/
24 
25 #ifndef DLMAINWINDOW_H
26 #define DLMAINWINDOW_H
27 
28 #include "ui_ptMainWindow.h"
29 
30 #include "ptCurve.h"
31 #include "ptCurveWindow.h"
32 #include "ptInput.h"
33 #include "ptChoice.h"
34 #include "ptCheck.h"
35 #include "ptGroupBox.h"
36 #include "ptVisibleToolsView.h"
37 
38 #include "ptTempFilterBase.h"
39 
40 #include <exiv2/exif.hpp>
41 #pragma GCC diagnostic push
42 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
43 #include <exiv2/image.hpp>
44 #pragma GCC diagnostic pop
45 #include <exiv2/exiv2.hpp>
46 
47 #include <memory>
48 using std::unique_ptr;
49 
50 #include <QTimer>
51 
52 //==============================================================================
53 
54 class ptMainWindow : public QMainWindow, public Ui::ptMainWindow {
55 
56 Q_OBJECT
57 
58 public:
59   // Constructor.
60   ptMainWindow(const QString         Title);
61   // Destructor.
62   ~ptMainWindow();
63 
64   // Populate Translations combobox
65   void PopulateTranslationsCombobox(const QStringList UiLanguages, const int LangIdx);
66 
67   // Get the current active tab expressed in pt*Tab from Constants.h.
68   // -1 on error.
69   short GetCurrentTab();
70 
71   // Show or hide the toolboxes
72   void UpdateToolBoxes();
73 
74   // Update some settings from the GuiSettings.
75   // (after a dcraw calculation for instance).
76   void UpdateSettings(void);
77 
78   // Update the file info GUI element on info tab
79   void UpdateFilenameInfo(const QStringList FileNameList);
80 
81   // Update the exif info gui element.
82   void UpdateExifInfo(Exiv2::ExifData ExifData);
83 
84   // Set visible/enabled states for crop tool widgets
85   void UpdateCropToolUI();
86 
87   // Moved tools
88   void ShowActiveTools();
89   void ShowAllTools();
90   void ShowFavouriteTools();
91   void CleanUpMovedTools();
92 
93   // Set visible status for lensfun widgets
94   void UpdateLfunDistUI();
95   void UpdateLfunCAUI();
96   void UpdateLfunVignetteUI();
97 
98   void UpdateLiquidRescaleUI();
99 
100   void UpdateGradualBlurUI();
101 
102   // Visible tools
103   void ApplyVisibleTools();
104   void UpdateVisibleTools();
105   void LoadUISettings(const QString &fileName);
106   void SaveUISettings(const QString &fileName) const;
107 
108   // Make and model are remembered because in
109   // case of change the choice of white balances must be redone.
110   QString              m_CameraMake;
111   QString              m_CameraModel;
112 
113   // Resize timer
114   QTimer* m_ResizeTimer;
115   // Event0 timer (create event at t=0)
116   QTimer* m_Event0Timer;
117   QTimer* m_SearchInputTimer;
118 
119   // ToolBoxes
120   QMap<QString, ptTempFilterBase*>* m_GroupBox;
121   QList<QString>*             m_GroupBoxesOrdered;
122   QList<QVBoxLayout*>*        m_TabLayouts;
123   QList<QWidget*>*            m_MovedTools;
124   QIcon                       m_StatusIcon;
125   QList<QWidget*>             m_ActiveTabs;
126 
127   // Desktop
128   QDesktopWidget* m_DesktopWidget;
129 
130   QDockWidget* ControlsDockWidget;
131 
132   void OnToolBoxesEnabledTriggered(const bool Enabled);
133 
134 //--------------------------------------
135 
136 protected:
137   void closeEvent(QCloseEvent * Event);
138   void resizeEvent(QResizeEvent * Event);
139   void keyPressEvent(QKeyEvent * Event);
140   void wheelEvent(QWheelEvent * Event);
141   void dragEnterEvent(QDragEnterEvent* Event);
142   void dropEvent(QDropEvent* Event);
143   bool eventFilter(QObject *obj, QEvent *event);
144 
145 #ifdef Q_OS_WIN
146   // reimplementation needed for Win 7 taskbar features
147   virtual bool winEvent(MSG *message, long *result);
148 #endif
149 
150 //--------------------------------------
151 
152 private:
153   QTabBar*  Tabbar;
154   QAction*  m_AtnSavePipe;
155   QAction*  m_AtnSaveFull;
156   QAction*  m_AtnSaveSettings;
157   QAction*  m_AtnSaveJobfile;
158   QAction*  m_AtnSendToBatch;
159   QAction*  m_AtnGimpSavePipe;
160   QAction*  m_AtnGimpSaveFull;
161   QAction*  m_AtnMenuFullReset;
162   QAction*  m_AtnMenuUserReset;
163   QAction*  m_AtnMenuOpenPreset;
164   QAction*  m_AtnMenuOpenSettings;
165   short     m_ContextMenuOnTab;
166   QAction*  m_AtnShowTools;
167   ptUIState FUIState;
168 
169   ptVisibleToolsModel  *m_VisibleToolsModel;
170   ptCurveWindow        *FSpotCurveWindow;  // raw pointer because managed by Qt parent mechanism
171 
172   void AnalyzeToolBoxStructure();
173   void ShowMovedTools(const QString ATitle);
174   void InitVisibleTools();
175   void ToggleLocalAdjustWidgets(const bool AEnabled, const int ARow);
176   void ToggleSpotRepairWidgets(const bool AEnabled);
177 
178   /*! We switch to the respective UI state. */
179   void SwitchUIState(const ptUIState AState);
180 //--------------------------------------
181 
182 public slots:
183   // Toggle file manager window
184   void OpenBatchWindow();
185   void CloseBatchWindow();
186   void OpenFileMgrWindow();
187   void CloseFileMgrWindow();
188   void OtherInstanceMessage(const QString &msg);
189 
190   // Represent and set settings values fomr the UI
191   void Settings_2_Form();
192   void Form_2_Settings();
193 
194 //--------------------------------------
195 
196 private slots:
197   void ResizeTimerExpired();
198   void Event0TimerExpired();
199   void SaveMenuPipe();
200   void SaveMenuFull();
201   void SaveMenuSettings();
202   void SaveMenuJobfile();
203   void SaveMenuBatch();
204   void GimpSaveMenuPipe();
205   void GimpSaveMenuFull();
206   void MenuFullReset();
207   void MenuUserReset();
208   void MenuOpenPreset();
209   void MenuOpenSettings();
210   void ShowToolsOnTab();
211   void StartSearchTimer(QString);
212   void Search();
213   void OnTranslationChoiceChanged(int idx);
214 
215   void OnTagsEditTextChanged();
216 
217   void OnInputChanged(QVariant Value);
218 
219   void on_ProcessingTabBook_currentChanged(const int Index);
220 
221   void OnToGimpButtonClicked();
222 
223   void OnPreviewModeButtonClicked();
224 
225   void OnSearchResetButtonClicked();
226   void OnSearchActiveToolsButtonClicked();
227   void OnSearchAllToolsButtonClicked();
228   void OnSearchFavouriteToolsButtonClicked();
229 
230   void OnRunButtonClicked();
231   void OnResetButtonClicked();
232 
233   void OnBackgroundColorButtonClicked();
234 
235   void OnOpenFileButtonClicked();
236   void OnOpenSettingsFileButtonClicked();
237   void OnOpenPresetFileButtonClicked();
238   void OnSpotWBButtonClicked();
239 
240   void OnZoomFitButtonClicked();
241   void OnZoomInButtonClicked();
242   void OnZoomOutButtonClicked();
243   void OnZoomFullButtonClicked();
244   void OnBatchButtonClicked();
245   void OnFileMgrButtonClicked();
246   void OnFullScreenButtonClicked();
247   void OnLoadStyleButtonClicked();
248 
249   void OnPreviousImageButtonClicked();
250   void OnNextImageButtonClicked();
251 
252   void OnTabProcessingButtonClicked();
253   void OnTabSettingsButtonClicked();
254   void OnTabInfoButtonClicked();
255 
256   void OnCameraColorProfileButtonClicked();
257   void OnPreviewColorProfileButtonClicked();
258   void OnOutputColorProfileButtonClicked();
259   void OnGimpExecCommandButtonClicked();
260 
261   void OnStartupSettingsButtonClicked();
262 
263   void OnRotateLeftButtonClicked();
264   void OnRotateRightButtonClicked();
265   void OnRotateAngleButtonClicked();
266 
267   void OnMakeCropButtonClicked();
268   void OnConfirmCropButtonClicked();
269   void OnCancelCropButtonClicked();
270   void OnCropOrientationButtonClicked();
271   void OnCropCenterHorButtonClicked();
272   void OnCropCenterVertButtonClicked();
273 
274   void OnOutputColorProfileResetButtonClicked();
275   void OnWritePipeButtonClicked();
276 
277   void OnVisibleToolsDiscardButtonClicked();
278   void OnVisibleToolsLoadButtonClicked();
279   void OnVisibleToolsSaveButtonClicked();
280 };
281 
282 #endif
283