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