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