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