CuteLogger
Fast and simple logging solution for Qt based applications
mainwindow.h
1/*
2 * Copyright (c) 2011-2023 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 <QDateTime>
29#include "mltcontroller.h"
30#include "mltxmlchecker.h"
31
32#define EXIT_RESTART (42)
33#define EXIT_RESET (43)
34
35namespace Ui {
36class MainWindow;
37}
38class Player;
39class RecentDock;
40class EncodeDock;
41class JobsDock;
42class PlaylistDock;
43class QUndoStack;
44class QActionGroup;
45class FilterController;
46class ScopeController;
47class FiltersDock;
48class TimelineDock;
49class AutoSaveFile;
50class QNetworkReply;
51class KeyframesDock;
52class MarkersDock;
53class NotesDock;
54
55class MainWindow : public QMainWindow
56{
57 Q_OBJECT
58
59public:
60 enum LayoutMode {
61 Custom = 0,
62 Logging,
63 Editing,
64 Effects,
65 Color,
66 Audio,
67 PlayerOnly
68 };
69
70 static MainWindow &singleton();
71 ~MainWindow();
72 void open(Mlt::Producer *producer);
73 bool continueModified();
74 bool continueJobsRunning();
75 QUndoStack *undoStack() const;
76 bool saveXML(const QString &filename, bool withRelativePaths = true);
77 static void changeTheme(const QString &theme);
78 PlaylistDock *playlistDock() const
79 {
80 return m_playlistDock;
81 }
82 FilterController *filterController() const
83 {
84 return m_filterController;
85 }
86 Mlt::Playlist *playlist() const;
87 bool isPlaylistValid() 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 void setProfile(const QString &profile_name);
95 QString fileName() const
96 {
97 return m_currentFile;
98 }
99 bool isSourceClipMyProject(QString resource = MLT.resource(), bool withDialog = true);
100 bool keyframesDockIsVisible() const;
101
102 void keyPressEvent(QKeyEvent *);
103 void keyReleaseEvent(QKeyEvent *);
104 void hideSetDataDirectory();
105 QMenu *customProfileMenu() const
106 {
107 return m_customProfileMenu;
108 }
109 QAction *actionAddCustomProfile() const;
110 QAction *actionProfileRemove() const;
111 QActionGroup *profileGroup() const
112 {
113 return m_profileGroup;
114 }
115 void buildVideoModeMenu(QMenu *topMenu, QMenu *&customMenu, QActionGroup *group, QAction *addAction,
116 QAction *removeAction);
117 void newProject(const QString &filename, bool isProjectFolder = false);
118 void addCustomProfile(const QString &name, QMenu *menu, QAction *action, QActionGroup *group);
119 void removeCustomProfiles(const QStringList &profiles, QDir &dir, QMenu *menu, QAction *action);
120 QUuid timelineClipUuid(int trackIndex, int clipIndex);
121 void replaceInTimeline(const QUuid &uuid, Mlt::Producer &producer);
122 void replaceAllByHash(const QString &hash, Mlt::Producer &producer, bool isProxy = false);
123 bool isClipboardNewer() const
124 {
125 return m_clipboardUpdatedAt > m_sourceUpdatedAt;
126 }
127 int mltIndexForTrack(int trackIndex) const;
128 int bottomVideoTrackIndex() const;
129
130signals:
131 void audioChannelsChanged();
132 void producerOpened(bool withReopen = true);
133 void profileChanged();
134 void openFailed(QString);
135 void aboutToShutDown();
136 void renameRequested();
137 void serviceInChanged(int delta, Mlt::Service *);
138 void serviceOutChanged(int delta, Mlt::Service *);
139
140protected:
141 MainWindow();
142 bool eventFilter(QObject *target, QEvent *event);
143 void dragEnterEvent(QDragEnterEvent *);
144 void dropEvent(QDropEvent *);
145 void closeEvent(QCloseEvent *);
146 void showEvent(QShowEvent *);
147 void hideEvent(QHideEvent *event);
148
149private:
150 void connectFocusSignals();
151 void registerDebugCallback();
152 void connectUISignals();
153 void setupAndConnectUndoStack();
154 void setupAndConnectPlayerWidget();
155 void setupLayoutSwitcher();
156 void centerLayoutInRemainingToolbarSpace();
157 void setupAndConnectDocks();
158 void setupMenuView();
159 void connectVideoWidgetSignals();
160 void setupSettingsMenu();
161 void setupOpenOtherMenu();
162 void setupActions();
163 QAction *addProfile(QActionGroup *actionGroup, const QString &desc, const QString &name);
164 QAction *addLayout(QActionGroup *actionGroup, const QString &name);
165 void readPlayerSettings();
166 void readWindowSettings();
167 void writeSettings();
168 void configureVideoWidget();
169 void setCurrentFile(const QString &filename);
170 void changeAudioChannels(bool checked, int channels);
171 void changeDeinterlacer(bool checked, const char *method);
172 void changeInterpolation(bool checked, const char *method);
173 bool checkAutoSave(QString &url);
174 bool saveRepairedXmlFile(MltXmlChecker &checker, QString &fileName);
175 void setAudioChannels(int channels);
176 void showSaveError();
177 void setPreviewScale(int scale);
178 void setVideoModeMenu();
179 void resetVideoModeMenu();
180 void resetDockCorners();
181 void showIncompatibleProjectMessage(const QString &shotcutVersion);
182 void restartAfterChangeTheme();
183
184 Ui::MainWindow *ui;
185 Player *m_player;
186 QDockWidget *m_propertiesDock;
187 RecentDock *m_recentDock;
188 EncodeDock *m_encodeDock;
189 JobsDock *m_jobsDock;
190 PlaylistDock *m_playlistDock;
191 TimelineDock *m_timelineDock;
192 QString m_currentFile;
193 bool m_isKKeyPressed;
194 QUndoStack *m_undoStack;
195 QDockWidget *m_historyDock;
196 QActionGroup *m_profileGroup;
197 QActionGroup *m_externalGroup;
198 QActionGroup *m_keyerGroup;
199 QActionGroup *m_layoutGroup;
200 QActionGroup *m_previewScaleGroup;
201 FiltersDock *m_filtersDock;
202 FilterController *m_filterController;
203 ScopeController *m_scopeController;
204 QMenu *m_customProfileMenu;
205 QMenu *m_keyerMenu;
206 QStringList m_multipleFiles;
207 bool m_isPlaylistLoaded;
208 QActionGroup *m_languagesGroup;
209 QSharedPointer<AutoSaveFile> m_autosaveFile;
210 QMutex m_autosaveMutex;
211 QTimer m_autosaveTimer;
212 int m_exitCode;
213 QScopedPointer<QAction> m_statusBarAction;
214 QNetworkAccessManager m_network;
215 QString m_upgradeUrl;
216 KeyframesDock *m_keyframesDock;
217 QDateTime m_clipboardUpdatedAt;
218 QDateTime m_sourceUpdatedAt;
219 MarkersDock *m_markersDock;
220 NotesDock *m_notesDock;
221 std::unique_ptr<QWidget> m_producerWidget;
222
223public slots:
224 bool isCompatibleWithGpuMode(MltXmlChecker &checker);
225 bool isXmlRepaired(MltXmlChecker &checker, QString &fileName);
226 bool open(QString url, const Mlt::Properties * = nullptr, bool play = true);
227 void openMultiple(const QStringList &paths);
228 void openMultiple(const QList<QUrl> &urls);
229 void openVideo();
230 void openCut(Mlt::Producer *producer, bool play = false);
231 void hideProducer();
232 void closeProducer();
233 void showStatusMessage(QAction *action, int timeoutSeconds = 5);
234 void showStatusMessage(const QString &message, int timeoutSeconds = 5,
235 QPalette::ColorRole role = QPalette::ToolTipBase);
236 void onStatusMessageClicked();
237 void seekPlaylist(int start);
238 void seekTimeline(int position, bool seekPlayer = true);
239 void seekKeyframes(int position);
240 QWidget *loadProducerWidget(Mlt::Producer *producer);
241 void onProducerOpened(bool withReopen = true);
242 void onGpuNotSupported();
243 void onShuttle(float x);
244 void onPropertiesDockTriggered(bool checked = true);
245 bool on_actionSave_triggered();
246
247private slots:
248 void showUpgradePrompt();
249 void on_actionAbout_Shotcut_triggered();
250 void on_actionOpenOther_triggered();
251 void onProducerChanged();
252 bool on_actionSave_As_triggered();
253 void onEncodeTriggered(bool checked = true);
254 void onCaptureStateChanged(bool started);
255 void onJobsDockTriggered(bool = true);
256 void onRecentDockTriggered(bool checked = true);
257 void onPlaylistDockTriggered(bool checked = true);
258 void onTimelineDockTriggered(bool checked = true);
259 void onHistoryDockTriggered(bool checked = true);
260 void onFiltersDockTriggered(bool checked = true);
261 void onKeyframesDockTriggered(bool checked = true);
262 void onMarkersDockTriggered(bool = true);
263 void onNotesDockTriggered(bool = true);
264 void onPlaylistCreated();
265 void onPlaylistLoaded();
266 void onPlaylistCleared();
267 void onPlaylistClosed();
268 void onPlaylistModified();
269 void onMultitrackCreated();
270 void onMultitrackClosed();
271 void onMultitrackModified();
272 void onMultitrackDurationChanged();
273 void onNoteModified();
274 void onCutModified();
275 void onProducerModified();
276 void onFilterModelChanged();
277 void updateMarkers();
278 void updateThumbnails();
279 void on_actionUndo_triggered();
280 void on_actionRedo_triggered();
281 void on_actionFAQ_triggered();
282 void on_actionForum_triggered();
283 void on_actionEnterFullScreen_triggered();
284 void on_actionRealtime_triggered(bool checked);
285 void on_actionProgressive_triggered(bool checked);
286 void on_actionChannels1_triggered(bool checked);
287 void on_actionChannels2_triggered(bool checked);
288 void on_actionChannels6_triggered(bool checked);
289 void on_actionOneField_triggered(bool checked);
290 void on_actionLinearBlend_triggered(bool checked);
291 void on_actionYadifTemporal_triggered(bool checked);
292 void on_actionYadifSpatial_triggered(bool checked);
293 void on_actionBwdif_triggered(bool checked);
294 void on_actionNearest_triggered(bool checked);
295 void on_actionBilinear_triggered(bool checked);
296 void on_actionBicubic_triggered(bool checked);
297 void on_actionHyper_triggered(bool checked);
298 void on_actionJack_triggered(bool checked);
299 void on_actionGPU_triggered(bool checked);
300 void onExternalTriggered(QAction *);
301 void onKeyerTriggered(QAction *);
302 void onProfileTriggered(QAction *);
303 void onProfileChanged();
304 void on_actionAddCustomProfile_triggered();
305 void processMultipleFiles();
306 void onLanguageTriggered(QAction *);
307 void on_actionSystemTheme_triggered();
308 void on_actionFusionDark_triggered();
309 void on_actionJobPriorityLow_triggered();
310 void on_actionJobPriorityNormal_triggered();
311 void on_actionFusionLight_triggered();
312 void on_actionTutorials_triggered();
313 void on_actionRestoreLayout_triggered();
314 void on_actionShowTitleBars_triggered(bool checked);
315 void on_actionShowToolbar_triggered(bool checked);
316 void onToolbarVisibilityChanged(bool visible);
317 void on_menuExternal_aboutToShow();
318 void on_actionUpgrade_triggered();
319 void on_actionOpenXML_triggered();
320 void onAutosaveTimeout();
321 void onFocusChanged(QWidget *old, QWidget *now) const;
322 void onFocusObjectChanged(QObject *obj) const;
323 void onFocusWindowChanged(QWindow *window) const;
324 void onTimelineClipSelected();
325 void onAddAllToTimeline(Mlt::Playlist *playlist, bool skipProxy);
326 void on_actionScrubAudio_triggered(bool checked);
327#if !defined(Q_OS_MAC)
328 void onDrawingMethodTriggered(QAction *);
329#endif
330 void on_actionApplicationLog_triggered();
331 void on_actionClose_triggered();
332 void onPlayerTabIndexChanged(int index);
333 void onUpgradeCheckFinished(QNetworkReply *reply);
334 void onUpgradeTriggered();
335 void onClipCopied();
336 void on_actionExportEDL_triggered();
337 void on_actionExportFrame_triggered();
338 void onVideoWidgetImageReady();
339 void on_actionAppDataSet_triggered();
340 void on_actionAppDataShow_triggered();
341 void on_actionNew_triggered();
342 void on_actionKeyboardShortcuts_triggered();
343 void on_actionLayoutLogging_triggered();
344 void on_actionLayoutEditing_triggered();
345 void on_actionLayoutEffects_triggered();
346 void on_actionLayoutColor_triggered();
347 void on_actionLayoutAudio_triggered();
348 void on_actionLayoutPlayer_triggered();
349 void on_actionLayoutPlaylist_triggered();
350 void on_actionLayoutClip_triggered();
351 void on_actionLayoutAdd_triggered();
352 void onLayoutTriggered(QAction *);
353 void on_actionProfileRemove_triggered();
354 void on_actionLayoutRemove_triggered();
355 void on_actionOpenOther2_triggered();
356 void onOpenOtherTriggered(QWidget *widget);
357 void onOpenOtherFinished(int result);
358 void onOpenOtherTriggered();
359 void on_actionClearRecentOnExit_toggled(bool arg1);
360 void onSceneGraphInitialized();
361 void on_actionShowTextUnderIcons_toggled(bool b);
362 void on_actionShowSmallIcons_toggled(bool b);
363 void onPlaylistInChanged(int in);
364 void onPlaylistOutChanged(int out);
365 void on_actionPreviewNone_triggered(bool checked);
366 void on_actionPreview360_triggered(bool checked);
367 void on_actionPreview540_triggered(bool checked);
368 void on_actionPreview720_triggered(bool checked);
369 void on_actionTopics_triggered();
370 void on_actionSync_triggered();
371 void on_actionUseProxy_triggered(bool checked);
372 void on_actionProxyStorageSet_triggered();
373 void on_actionProxyStorageShow_triggered();
374 void on_actionProxyUseProjectFolder_triggered(bool checked);
375 void on_actionProxyUseHardware_triggered(bool checked);
376 void on_actionProxyConfigureHardware_triggered();
377 void updateLayoutSwitcher();
378 void clearCurrentLayout();
379 void onClipboardChanged();
380 void sourceUpdated();
381 void resetSourceUpdated();
382 void on_actionExportChapters_triggered();
383 void on_actionAudioVideoDevice_triggered();
384 void on_actionReset_triggered();
385};
386
387#define MAIN MainWindow::singleton()
388
389#endif // MAINWINDOW_H