CuteLogger
Fast and simple logging solution for Qt based applications
mainwindow.h
1 /*
2  * Copyright (c) 2011-2018 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 <QRunnable>
29 #include "mltcontroller.h"
30 #include "mltxmlchecker.h"
31 
32 #define EXIT_RESTART (42)
33 
34 namespace Ui {
35  class MainWindow;
36 }
37 class Player;
38 class RecentDock;
39 class EncodeDock;
40 class JobsDock;
41 class PlaylistDock;
42 class QUndoStack;
43 class QActionGroup;
44 class FilterController;
45 class ScopeController;
46 class FiltersDock;
47 class HtmlEditor;
48 class TimelineDock;
49 class AutoSaveFile;
50 class QNetworkReply;
51 class KeyframesDock;
52 
53 class AppendTask : public QObject, public QRunnable
54 {
55  Q_OBJECT
56 public:
57  AppendTask(const QStringList& filenames)
58  : QRunnable()
59  , filenames(filenames)
60  {}
61  void run();
62 
63 signals:
64  void appendToPlaylist(QString);
65  void done();
66 
67 private:
68  const QStringList filenames;
69 };
70 
71 class MainWindow : public QMainWindow
72 {
73  Q_OBJECT
74 
75 public:
76  static MainWindow& singleton();
77  ~MainWindow();
78  void open(Mlt::Producer* producer);
79  bool continueModified();
80  bool continueJobsRunning();
81  QUndoStack* undoStack() const;
82  void saveXML(const QString& filename, bool withRelativePaths = true);
83  static void changeTheme(const QString& theme);
84  PlaylistDock* playlistDock() const { return m_playlistDock; }
85  FilterController* filterController() const { return m_filterController; }
86  HtmlEditor* htmlEditor() const { return m_htmlEditor.data(); }
87  Mlt::Playlist* playlist() const;
88  Mlt::Producer* multitrack() const;
89  bool isMultitrackValid() const;
90  void doAutosave();
91  void setFullScreen(bool isFullScreen);
92  QString removeFileScheme(QUrl& url);
93  QString untitledFileName() const;
94  QString getFileHash(const QString& path) const;
95  QString getHash(Mlt::Properties& properties) const;
96  void setProfile(const QString& profile_name);
97  QString fileName() const { return m_currentFile; }
98  bool isSourceClipMyProject(QString resource = MLT.resource());
99  bool keyframesDockIsVisible() const;
100 
101  void keyPressEvent(QKeyEvent*);
102  void keyReleaseEvent(QKeyEvent *);
103  void hideSetDataDirectory();
104 
105 signals:
106  void audioChannelsChanged();
107  void producerOpened();
108  void profileChanged();
109  void openFailed(QString);
110  void aboutToShutDown();
111 
112 protected:
113  MainWindow();
114  bool eventFilter(QObject* target, QEvent* event);
115  void dragEnterEvent(QDragEnterEvent*);
116  void dropEvent(QDropEvent*);
117  void closeEvent(QCloseEvent*);
118  void showEvent(QShowEvent*);
119 
120 private:
121  void setupSettingsMenu();
122  void setupOpenOtherMenu();
123  QAction *addProfile(QActionGroup* actionGroup, const QString& desc, const QString& name);
124  QAction *addLayout(QActionGroup* actionGroup, const QString& name);
125  void readPlayerSettings();
126  void readWindowSettings();
127  void writeSettings();
128  void configureVideoWidget();
129  void setCurrentFile(const QString &filename);
130  void changeAudioChannels(bool checked, int channels);
131  void changeDeinterlacer(bool checked, const char* method);
132  void changeInterpolation(bool checked, const char* method);
133  bool checkAutoSave(QString &url);
134  void stepLeftBySeconds(int sec);
135  bool saveRepairedXmlFile(MltXmlChecker& checker, QString& fileName);
136  void setAudioChannels(int channels);
137 
138  Ui::MainWindow* ui;
139  Player* m_player;
140  QDockWidget* m_propertiesDock;
141  RecentDock* m_recentDock;
142  EncodeDock* m_encodeDock;
143  JobsDock* m_jobsDock;
144  PlaylistDock* m_playlistDock;
145  TimelineDock* m_timelineDock;
146  QString m_currentFile;
147  bool m_isKKeyPressed;
148  QUndoStack* m_undoStack;
149  QDockWidget* m_historyDock;
150  QActionGroup* m_profileGroup;
151  QActionGroup* m_externalGroup;
152  QActionGroup* m_keyerGroup;
153  QActionGroup* m_layoutGroup;
154  FiltersDock* m_filtersDock;
155  FilterController* m_filterController;
156  ScopeController* m_scopeController;
157  QMenu* m_customProfileMenu;
158  QMenu* m_keyerMenu;
159  QStringList m_multipleFiles;
160  bool m_isPlaylistLoaded;
161  QActionGroup* m_languagesGroup;
162  QScopedPointer<HtmlEditor> m_htmlEditor;
163  QSharedPointer<AutoSaveFile> m_autosaveFile;
164  QMutex m_autosaveMutex;
165  QTimer m_autosaveTimer;
166  int m_exitCode;
167  int m_navigationPosition;
168  QScopedPointer<QAction> m_statusBarAction;
169  QNetworkAccessManager m_network;
170  QString m_upgradeUrl;
171  KeyframesDock* m_keyframesDock;
172 
173 #ifdef WITH_LIBLEAP
174  LeapListener m_leapListener;
175 #endif
176 
177 public slots:
178  bool isCompatibleWithGpuMode(MltXmlChecker& checker);
179  bool isXmlRepaired(MltXmlChecker& checker, QString& fileName);
180  void updateAutoSave();
181  void open(QString url, const Mlt::Properties* = 0);
182  void openMultiple(const QStringList& paths);
183  void openMultiple(const QList<QUrl>& urls);
184  void openVideo();
185  void openCut(Mlt::Producer* producer);
186  void hideProducer();
187  void closeProducer();
188  void showStatusMessage(QAction* action, int timeoutSeconds = 5);
189  void showStatusMessage(const QString& message, int timeoutSeconds = 5);
190  void seekPlaylist(int start);
191  void seekTimeline(int position);
192  void seekKeyframes(int position);
193  QWidget* loadProducerWidget(Mlt::Producer* producer);
194  void onProducerOpened();
195  void onGpuNotSupported();
196  void editHTML(const QString& fileName);
197  void stepLeftOneFrame();
198  void stepRightOneFrame();
199  void stepLeftOneSecond();
200  void stepRightOneSecond();
201  void setInToCurrent(bool ripple);
202  void setOutToCurrent(bool ripple);
203  void onShuttle(float x);
204  void onPropertiesDockTriggered(bool checked = true);
205  bool on_actionSave_triggered();
206 
207 private slots:
208  void showUpgradePrompt();
209  void on_actionAbout_Shotcut_triggered();
210  void on_actionOpenOther_triggered();
211  void onProducerChanged();
212  bool on_actionSave_As_triggered();
213  void onEncodeTriggered(bool checked = true);
214  void onCaptureStateChanged(bool started);
215  void onJobsDockTriggered(bool);
216  void onRecentDockTriggered(bool checked = true);
217  void onPlaylistDockTriggered(bool checked = true);
218  void onTimelineDockTriggered(bool checked = true);
219  void onHistoryDockTriggered(bool checked = true);
220  void onFiltersDockTriggered(bool checked = true);
221  void onKeyframesDockTriggered(bool checked = true);
222  void onPlaylistCreated();
223  void onPlaylistLoaded();
224  void onPlaylistCleared();
225  void onPlaylistClosed();
226  void onPlaylistModified();
227  void onMultitrackCreated();
228  void onMultitrackClosed();
229  void onMultitrackModified();
230  void onMultitrackDurationChanged();
231  void onCutModified();
232  void onProducerModified();
233  void onFilterModelChanged();
234  void updateMarkers();
235  void updateThumbnails();
236  void on_actionUndo_triggered();
237  void on_actionRedo_triggered();
238  void on_actionFAQ_triggered();
239  void on_actionForum_triggered();
240  void on_actionEnter_Full_Screen_triggered();
241  void on_actionRealtime_triggered(bool checked);
242  void on_actionProgressive_triggered(bool checked);
243  void on_actionChannels1_triggered(bool checked);
244  void on_actionChannels2_triggered(bool checked);
245  void on_actionChannels6_triggered(bool checked);
246  void on_actionOneField_triggered(bool checked);
247  void on_actionLinearBlend_triggered(bool checked);
248  void on_actionYadifTemporal_triggered(bool checked);
249  void on_actionYadifSpatial_triggered(bool checked);
250  void on_actionNearest_triggered(bool checked);
251  void on_actionBilinear_triggered(bool checked);
252  void on_actionBicubic_triggered(bool checked);
253  void on_actionHyper_triggered(bool checked);
254  void on_actionJack_triggered(bool checked);
255  void on_actionGPU_triggered(bool checked);
256  void onExternalTriggered(QAction*);
257  void onKeyerTriggered(QAction*);
258  void onProfileTriggered(QAction*);
259  void onProfileChanged();
260  void on_actionAddCustomProfile_triggered();
261  void processMultipleFiles();
262  void onLanguageTriggered(QAction*);
263  void on_actionSystemTheme_triggered();
264  void on_actionFusionDark_triggered();
265  void on_actionFusionLight_triggered();
266  void on_actionTutorials_triggered();
267  void on_actionRestoreLayout_triggered();
268  void on_actionShowTitleBars_triggered(bool checked);
269  void on_actionShowToolbar_triggered(bool checked);
270  void onToolbarVisibilityChanged(bool visible);
271  void on_menuExternal_aboutToShow();
272  void on_actionUpgrade_triggered();
273  void on_actionOpenXML_triggered();
274  void onAutosaveTimeout();
275  void on_actionGammaSRGB_triggered(bool checked);
276  void on_actionGammaRec709_triggered(bool checked);
277  void onFocusChanged(QWidget *old, QWidget * now) const;
278  void onFocusObjectChanged(QObject *obj) const;
279  void onFocusWindowChanged(QWindow *window) const;
280  void onTimelineClipSelected();
281  void onAddAllToTimeline(Mlt::Playlist* playlist);
282  void on_actionScrubAudio_triggered(bool checked);
283 #ifdef Q_OS_WIN
284  void onDrawingMethodTriggered(QAction*);
285 #endif
286  void on_actionApplicationLog_triggered();
287  void on_actionClose_triggered();
288  void onPlayerTabIndexChanged(int index);
289  void onUpgradeCheckFinished(QNetworkReply* reply);
290  void onUpgradeTriggered();
291  void onTimelineSelectionChanged();
292  void on_actionCut_triggered();
293  void on_actionCopy_triggered();
294  void on_actionPaste_triggered();
295  void onClipCopied();
296  void on_actionExportEDL_triggered();
297  void on_actionExportFrame_triggered();
298  void onGLWidgetImageReady();
299  void on_actionAppDataSet_triggered();
300  void on_actionAppDataShow_triggered();
301  void on_actionNew_triggered();
302  void on_actionKeyboardShortcuts_triggered();
303  void on_actionLayoutPlayer_triggered();
304  void on_actionLayoutPlaylist_triggered();
305  void on_actionLayoutTimeline_triggered();
306  void on_actionLayoutClip_triggered();
307  void on_actionLayoutAdd_triggered();
308  void onLayoutTriggered(QAction*);
309  void on_actionProfileRemove_triggered();
310  void on_actionLayoutRemove_triggered();
311  void onAppendToPlaylist(const QString& xml);
312  void onAppendTaskDone();
313  void on_actionOpenOther2_triggered();
314  void onOpenOtherTriggered(QWidget* widget);
315  void onOpenOtherTriggered();
316  void on_actionClearRecentOnExit_toggled(bool arg1);
317 };
318 
319 #define MAIN MainWindow::singleton()
320 
321 #endif // MAINWINDOW_H
Definition: addencodepresetdialog.h:24