CuteLogger
Fast and simple logging solution for Qt based applications
mainwindow.h
1 /*
2  * Copyright (c) 2011-2020 Meltytech, LLC
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef MAINWINDOW_H
19 #define MAINWINDOW_H
20 
21 #include <QMainWindow>
22 #include <QMutex>
23 #include <QTimer>
24 #include <QUrl>
25 #include <QNetworkAccessManager>
26 #include <QScopedPointer>
27 #include <QSharedPointer>
28 #include "mltcontroller.h"
29 #include "mltxmlchecker.h"
30 
31 #define EXIT_RESTART (42)
32 
33 namespace Ui {
34  class MainWindow;
35 }
36 class Player;
37 class RecentDock;
38 class EncodeDock;
39 class JobsDock;
40 class PlaylistDock;
41 class QUndoStack;
42 class QActionGroup;
43 class FilterController;
44 class ScopeController;
45 class FiltersDock;
46 class HtmlEditor;
47 class TimelineDock;
48 class AutoSaveFile;
49 class QNetworkReply;
50 class KeyframesDock;
51 
52 class MainWindow : public QMainWindow
53 {
54  Q_OBJECT
55 
56 public:
57  enum LayoutMode {
58  Custom = 0,
59  Logging,
60  Editing,
61  Effects,
62  Color,
63  Audio,
64  PlayerOnly
65  };
66 
67  static MainWindow& singleton();
68  ~MainWindow();
69  void open(Mlt::Producer* producer);
70  bool continueModified();
71  bool continueJobsRunning();
72  QUndoStack* undoStack() const;
73  bool saveXML(const QString& filename, bool withRelativePaths = true);
74  static void changeTheme(const QString& theme);
75  PlaylistDock* playlistDock() const { return m_playlistDock; }
76  FilterController* filterController() const { return m_filterController; }
77  HtmlEditor* htmlEditor() const { return m_htmlEditor.data(); }
78  Mlt::Playlist* playlist() const;
79  bool isPlaylistValid() const;
80  Mlt::Producer* multitrack() const;
81  bool isMultitrackValid() const;
82  void doAutosave();
83  void setFullScreen(bool isFullScreen);
84  QString removeFileScheme(QUrl& url);
85  QString untitledFileName() const;
86  void setProfile(const QString& profile_name);
87  QString fileName() const { return m_currentFile; }
88  bool isSourceClipMyProject(QString resource = MLT.resource(), bool withDialog = true);
89  bool keyframesDockIsVisible() const;
90 
91  void keyPressEvent(QKeyEvent*);
92  void keyReleaseEvent(QKeyEvent *);
93  void hideSetDataDirectory();
94  QMenu* customProfileMenu() const { return m_customProfileMenu; }
95  QAction* actionAddCustomProfile() const;
96  QAction* actionProfileRemove() const;
97  QActionGroup* profileGroup() const { return m_profileGroup; }
98  void buildVideoModeMenu(QMenu *topMenu, QMenu *&customMenu, QActionGroup* group, QAction *addAction, QAction *removeAction);
99  void newProject(const QString& filename, bool isProjectFolder = false);
100  void addCustomProfile(const QString& name, QMenu* menu, QAction* action, QActionGroup* group);
101  void removeCustomProfiles(const QStringList& profiles, QDir &dir, QMenu* menu, QAction* action);
102  QUuid timelineClipUuid(int trackIndex, int clipIndex);
103  void replaceInTimeline(const QUuid& uuid, Mlt::Producer& producer);
104  Mlt::ClipInfo* timelineClipInfoByUuid(const QUuid& uuid, int& trackIndex, int& clipIndex);
105  void replaceAllByHash(const QString& hash, Mlt::Producer& producer, bool isProxy = false);
106 
107 signals:
108  void audioChannelsChanged();
109  void producerOpened(bool withReopen = true);
110  void profileChanged();
111  void openFailed(QString);
112  void aboutToShutDown();
113  void renameRequested();
114 
115 protected:
116  MainWindow();
117  bool eventFilter(QObject* target, QEvent* event);
118  void dragEnterEvent(QDragEnterEvent*);
119  void dropEvent(QDropEvent*);
120  void closeEvent(QCloseEvent*);
121  void showEvent(QShowEvent*);
122 
123 private:
124  void setupSettingsMenu();
125  void setupOpenOtherMenu();
126  QAction *addProfile(QActionGroup* actionGroup, const QString& desc, const QString& name);
127  QAction *addLayout(QActionGroup* actionGroup, const QString& name);
128  void readPlayerSettings();
129  void readWindowSettings();
130  void writeSettings();
131  void configureVideoWidget();
132  void setCurrentFile(const QString &filename);
133  void changeAudioChannels(bool checked, int channels);
134  void changeDeinterlacer(bool checked, const char* method);
135  void changeInterpolation(bool checked, const char* method);
136  bool checkAutoSave(QString &url);
137  void stepLeftBySeconds(int sec);
138  bool saveRepairedXmlFile(MltXmlChecker& checker, QString& fileName);
139  void setAudioChannels(int channels);
140  void showSaveError();
141  void setPreviewScale(int scale);
142  void setVideoModeMenu();
143  void resetVideoModeMenu();
144  void resetDockCorners();
145 
146  Ui::MainWindow* ui;
147  Player* m_player;
148  QDockWidget* m_propertiesDock;
149  RecentDock* m_recentDock;
150  EncodeDock* m_encodeDock;
151  JobsDock* m_jobsDock;
152  PlaylistDock* m_playlistDock;
153  TimelineDock* m_timelineDock;
154  QString m_currentFile;
155  bool m_isKKeyPressed;
156  QUndoStack* m_undoStack;
157  QDockWidget* m_historyDock;
158  QActionGroup* m_profileGroup;
159  QActionGroup* m_externalGroup;
160  QActionGroup* m_keyerGroup;
161  QActionGroup* m_layoutGroup;
162  QActionGroup* m_previewScaleGroup;
163  FiltersDock* m_filtersDock;
164  FilterController* m_filterController;
165  ScopeController* m_scopeController;
166  QMenu* m_customProfileMenu;
167  QMenu* m_keyerMenu;
168  QStringList m_multipleFiles;
169  bool m_isPlaylistLoaded;
170  QActionGroup* m_languagesGroup;
171  QScopedPointer<HtmlEditor> m_htmlEditor;
172  QSharedPointer<AutoSaveFile> m_autosaveFile;
173  QMutex m_autosaveMutex;
174  QTimer m_autosaveTimer;
175  int m_exitCode;
176  int m_navigationPosition;
177  QScopedPointer<QAction> m_statusBarAction;
178  QNetworkAccessManager m_network;
179  QString m_upgradeUrl;
180  KeyframesDock* m_keyframesDock;
181 
182 #ifdef WITH_LIBLEAP
183  LeapListener m_leapListener;
184 #endif
185 
186 public slots:
187  bool isCompatibleWithGpuMode(MltXmlChecker& checker);
188  bool isXmlRepaired(MltXmlChecker& checker, QString& fileName);
189  void updateAutoSave();
190  void open(QString url, const Mlt::Properties* = nullptr, bool play = true);
191  void openMultiple(const QStringList& paths);
192  void openMultiple(const QList<QUrl>& urls);
193  void openVideo();
194  void openCut(Mlt::Producer* producer, bool play = false);
195  void hideProducer();
196  void closeProducer();
197  void showStatusMessage(QAction* action, int timeoutSeconds = 5);
198  void showStatusMessage(const QString& message, int timeoutSeconds = 5);
199  void seekPlaylist(int start);
200  void seekTimeline(int position, bool seekPlayer = true);
201  void seekKeyframes(int position);
202  QWidget* loadProducerWidget(Mlt::Producer* producer);
203  void onProducerOpened(bool withReopen = true);
204  void onGpuNotSupported();
205  void editHTML(const QString& fileName);
206  void stepLeftOneFrame();
207  void stepRightOneFrame();
208  void stepLeftOneSecond();
209  void stepRightOneSecond();
210  void setInToCurrent(bool ripple);
211  void setOutToCurrent(bool ripple);
212  void onShuttle(float x);
213  void onPropertiesDockTriggered(bool checked = true);
214  bool on_actionSave_triggered();
215 
216 private slots:
217  void showUpgradePrompt();
218  void on_actionAbout_Shotcut_triggered();
219  void on_actionOpenOther_triggered();
220  void onProducerChanged();
221  bool on_actionSave_As_triggered();
222  void onEncodeTriggered(bool checked = true);
223  void onCaptureStateChanged(bool started);
224  void onJobsDockTriggered(bool = true);
225  void onRecentDockTriggered(bool checked = true);
226  void onPlaylistDockTriggered(bool checked = true);
227  void onTimelineDockTriggered(bool checked = true);
228  void onHistoryDockTriggered(bool checked = true);
229  void onFiltersDockTriggered(bool checked = true);
230  void onKeyframesDockTriggered(bool checked = true);
231  void onPlaylistCreated();
232  void onPlaylistLoaded();
233  void onPlaylistCleared();
234  void onPlaylistClosed();
235  void onPlaylistModified();
236  void onMultitrackCreated();
237  void onMultitrackClosed();
238  void onMultitrackModified();
239  void onMultitrackDurationChanged();
240  void onCutModified();
241  void onProducerModified();
242  void onFilterModelChanged();
243  void updateMarkers();
244  void updateThumbnails();
245  void on_actionUndo_triggered();
246  void on_actionRedo_triggered();
247  void on_actionFAQ_triggered();
248  void on_actionForum_triggered();
249  void on_actionEnter_Full_Screen_triggered();
250  void on_actionRealtime_triggered(bool checked);
251  void on_actionProgressive_triggered(bool checked);
252  void on_actionChannels1_triggered(bool checked);
253  void on_actionChannels2_triggered(bool checked);
254  void on_actionChannels6_triggered(bool checked);
255  void on_actionOneField_triggered(bool checked);
256  void on_actionLinearBlend_triggered(bool checked);
257  void on_actionYadifTemporal_triggered(bool checked);
258  void on_actionYadifSpatial_triggered(bool checked);
259  void on_actionNearest_triggered(bool checked);
260  void on_actionBilinear_triggered(bool checked);
261  void on_actionBicubic_triggered(bool checked);
262  void on_actionHyper_triggered(bool checked);
263  void on_actionJack_triggered(bool checked);
264  void on_actionGPU_triggered(bool checked);
265  void onExternalTriggered(QAction*);
266  void onKeyerTriggered(QAction*);
267  void onProfileTriggered(QAction*);
268  void onProfileChanged();
269  void on_actionAddCustomProfile_triggered();
270  void processMultipleFiles();
271  void onLanguageTriggered(QAction*);
272  void on_actionSystemTheme_triggered();
273  void on_actionFusionDark_triggered();
274  void on_actionFusionLight_triggered();
275  void on_actionTutorials_triggered();
276  void on_actionRestoreLayout_triggered();
277  void on_actionShowTitleBars_triggered(bool checked);
278  void on_actionShowToolbar_triggered(bool checked);
279  void onToolbarVisibilityChanged(bool visible);
280  void on_menuExternal_aboutToShow();
281  void on_actionUpgrade_triggered();
282  void on_actionOpenXML_triggered();
283  void onAutosaveTimeout();
284  void on_actionGammaSRGB_triggered(bool checked);
285  void on_actionGammaRec709_triggered(bool checked);
286  void onFocusChanged(QWidget *old, QWidget * now) const;
287  void onFocusObjectChanged(QObject *obj) const;
288  void onFocusWindowChanged(QWindow *window) const;
289  void onTimelineClipSelected();
290  void onAddAllToTimeline(Mlt::Playlist* playlist, bool skipProxy);
291  void on_actionScrubAudio_triggered(bool checked);
292 #if !defined(Q_OS_MAC)
293  void onDrawingMethodTriggered(QAction*);
294 #endif
295  void on_actionApplicationLog_triggered();
296  void on_actionClose_triggered();
297  void onPlayerTabIndexChanged(int index);
298  void onUpgradeCheckFinished(QNetworkReply* reply);
299  void onUpgradeTriggered();
300  void onTimelineSelectionChanged();
301  void on_actionCut_triggered();
302  void on_actionCopy_triggered();
303  void on_actionPaste_triggered();
304  void onClipCopied();
305  void on_actionExportEDL_triggered();
306  void on_actionExportFrame_triggered();
307  void onGLWidgetImageReady();
308  void on_actionAppDataSet_triggered();
309  void on_actionAppDataShow_triggered();
310  void on_actionNew_triggered();
311  void on_actionKeyboardShortcuts_triggered();
312  void on_actionLayoutLogging_triggered();
313  void on_actionLayoutEditing_triggered();
314  void on_actionLayoutEffects_triggered();
315  void on_actionLayoutColor_triggered();
316  void on_actionLayoutAudio_triggered();
317  void on_actionLayoutPlayer_triggered();
318  void on_actionLayoutPlaylist_triggered();
319  void on_actionLayoutClip_triggered();
320  void on_actionLayoutAdd_triggered();
321  void onLayoutTriggered(QAction*);
322  void on_actionProfileRemove_triggered();
323  void on_actionLayoutRemove_triggered();
324  void on_actionOpenOther2_triggered();
325  void onOpenOtherTriggered(QWidget* widget);
326  void onOpenOtherTriggered();
327  void on_actionClearRecentOnExit_toggled(bool arg1);
328  void onSceneGraphInitialized();
329  void on_actionShowTextUnderIcons_toggled(bool b);
330  void on_actionShowSmallIcons_toggled(bool b);
331  void onPlaylistInChanged(int in);
332  void onPlaylistOutChanged(int out);
333  void on_actionPreviewNone_triggered(bool checked);
334  void on_actionPreview360_triggered(bool checked);
335  void on_actionPreview540_triggered(bool checked);
336  void on_actionPreview720_triggered(bool checked);
337  void on_actionTopics_triggered();
338  void on_actionSync_triggered();
339  void on_actionUseProxy_triggered(bool checked);
340  void on_actionProxyStorageSet_triggered();
341  void on_actionProxyStorageShow_triggered();
342  void on_actionProxyUseProjectFolder_triggered(bool checked);
343  void on_actionProxyUseHardware_triggered(bool checked);
344  void on_actionProxyConfigureHardware_triggered();
345  void updateLayoutSwitcher();
346  void clearCurrentLayout();
347 };
348 
349 #define MAIN MainWindow::singleton()
350 
351 #endif // MAINWINDOW_H