CuteLogger
Fast and simple logging solution for Qt based applications
mainwindow.h
1/*
2 * Copyright (c) 2011-2026 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 void turnOffHardwareDecoder();
116
117signals:
118 void audioChannelsChanged();
119 void processingModeChanged();
120 void producerOpened(bool withReopen = true);
121 void profileChanged();
122 void openFailed(QString);
123 void aboutToShutDown();
124 void renameRequested();
125 void serviceInChanged(int delta, Mlt::Service *);
126 void serviceOutChanged(int delta, Mlt::Service *);
127
128protected:
129 MainWindow();
130 bool eventFilter(QObject *target, QEvent *event);
131 void dragEnterEvent(QDragEnterEvent *);
132 void dropEvent(QDropEvent *);
133 void closeEvent(QCloseEvent *);
134 void showEvent(QShowEvent *);
135 void hideEvent(QHideEvent *event);
136
137private:
138 void connectFocusSignals();
139 void registerDebugCallback();
140 void connectUISignals();
141 void setupAndConnectUndoStack();
142 void setupAndConnectPlayerWidget();
143 void setupLayoutSwitcher();
144 void centerLayoutInRemainingToolbarSpace();
145 void setupAndConnectDocks();
146 void setupMenuFile();
147 void setupMenuView();
148 void connectVideoWidgetSignals();
149 void setupSettingsMenu();
150 void setupOpenOtherMenu();
151 void setupActions();
152 QAction *addProfile(QActionGroup *actionGroup, const QString &desc, const QString &name);
153 QAction *addLayout(QActionGroup *actionGroup, const QString &name);
154 void readPlayerSettings();
155 void readWindowSettings();
156 void writeSettings();
157 void configureVideoWidget();
158 void setCurrentFile(const QString &filename);
159 void updateWindowTitle();
160 void changeAudioChannels(bool checked, int channels);
161 void changeDeinterlacer(bool checked, const char *method);
162 void changeInterpolation(bool checked, const char *method);
163 bool checkAutoSave(QString &url);
164 bool saveConvertedXmlFile(MltXmlChecker &checker, QString &fileName);
165 bool saveRepairedXmlFile(MltXmlChecker &checker, QString &fileName);
166 void setAudioChannels(int channels);
167 void setProcessingMode(ShotcutSettings::ProcessingMode mode);
168 void showSaveError();
169 void setPreviewScale(int scale);
170 void setVideoModeMenu();
171 void resetVideoModeMenu();
172 void resetDockCorners();
173 void showIncompatibleProjectMessage(const QString &shotcutVersion);
174 void restartAfterChangeTheme();
175 void backup();
176 void backupPeriodically();
177 bool confirmProfileChange();
178 bool confirmRestartExternalMonitor();
179 void resetFilterMenuIfNeeded();
180
181 Ui::MainWindow *ui;
182 Player *m_player;
183 QDockWidget *m_propertiesDock;
184 RecentDock *m_recentDock;
185 EncodeDock *m_encodeDock;
186 JobsDock *m_jobsDock;
187 PlaylistDock *m_playlistDock;
188 TimelineDock *m_timelineDock;
189 QString m_currentFile;
190 bool m_isKKeyPressed;
191 QUndoStack *m_undoStack;
192 QDockWidget *m_historyDock;
193 QActionGroup *m_profileGroup;
194 QActionGroup *m_externalGroup;
195 QActionGroup *m_decklinkGammaGroup{nullptr};
196 QActionGroup *m_keyerGroup;
197 QActionGroup *m_layoutGroup;
198 QActionGroup *m_previewScaleGroup;
199 FiltersDock *m_filtersDock;
200 FilterController *m_filterController;
201 ScopeController *m_scopeController;
202 QMenu *m_customProfileMenu;
203 QMenu *m_decklinkGammaMenu{nullptr};
204 QMenu *m_keyerMenu;
205 QStringList m_multipleFiles;
206 bool m_multipleFilesLoading;
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 QDateTime m_lastBackupDateTime;
220 MarkersDock *m_markersDock;
221 NotesDock *m_notesDock;
222 SubtitlesDock *m_subtitlesDock;
223 std::unique_ptr<QWidget> m_producerWidget;
224 FilesDock *m_filesDock;
225 ScreenCapture *m_screenCapture;
226
227public slots:
228 bool isCompatibleWithProcessingMode(MltXmlChecker &checker, QString &fileName, bool &converted);
229 bool isXmlRepaired(MltXmlChecker &checker, QString &fileName);
230 bool open(QString url,
231 const Mlt::Properties * = nullptr,
232 bool play = true,
233 bool skipConvert = false);
234 void openMultiple(const QStringList &paths);
235 void openMultiple(const QList<QUrl> &urls);
236 void openVideo();
237 void openCut(Mlt::Producer *producer, bool play = false);
238 void hideProducer();
239 void closeProducer();
240 void showStatusMessage(QAction *action, int timeoutSeconds = 5);
241 void showStatusMessage(const QString &message,
242 int timeoutSeconds = 5,
243 QPalette::ColorRole role = QPalette::ToolTipBase);
244 void onStatusMessageClicked();
245 void seekPlaylist(int start);
246 void seekTimeline(int position, bool seekPlayer = true);
247 void seekKeyframes(int position);
248 QWidget *loadProducerWidget(Mlt::Producer *producer);
249 void onProducerOpened(bool withReopen = true);
250 void onGpuNotSupported();
251 void onShuttle(float x);
252 void onPropertiesDockTriggered(bool checked = true);
253 void onFiltersDockTriggered(bool checked = true);
254 bool on_actionSave_triggered();
255 void onCreateOrEditFilterOnOutput(Mlt::Filter *filter, const QStringList &key_properties);
256 void showSettingsMenu() const;
257
258private slots:
259 void showUpgradePrompt();
260 void on_actionAbout_Shotcut_triggered();
261 void on_actionOpenOther_triggered();
262 void onProducerChanged();
263 bool on_actionSave_As_triggered();
264 void onEncodeTriggered(bool checked = true);
265 void onCaptureStateChanged(bool started);
266 void onJobsDockTriggered(bool = true);
267 void onRecentDockTriggered(bool checked = true);
268 void onPlaylistDockTriggered(bool checked = true);
269 void onTimelineDockTriggered(bool checked = true);
270 void onHistoryDockTriggered(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 onFilesDockTriggered(bool = true);
276 void onPlaylistCreated();
277 void onPlaylistLoaded();
278 void onPlaylistCleared();
279 void onPlaylistClosed();
280 void onPlaylistModified();
281 void onMultitrackCreated();
282 void onMultitrackClosed();
283 void onMultitrackModified();
284 void onMultitrackDurationChanged();
285 void onNoteModified();
286 void onSubtitleModified();
287 void onCutModified();
288 void onProducerModified();
289 void onFilterModelChanged();
290 void updateMarkers();
291 void updateThumbnails();
292 void on_actionUndo_triggered();
293 void on_actionRedo_triggered();
294 void on_actionFAQ_triggered();
295 void on_actionForum_triggered();
296 void on_actionEnterFullScreen_triggered();
297 void on_actionRealtime_triggered(bool checked);
298 void on_actionProgressive_triggered(bool checked);
299 void on_actionChannels1_triggered(bool checked);
300 void on_actionChannels2_triggered(bool checked);
301 void on_actionChannels4_triggered(bool checked);
302 void on_actionChannels6_triggered(bool checked);
303 void on_actionOneField_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 onExternalTriggered(QAction *);
313 void onDecklinkGammaTriggered(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_actionSystemFusion_triggered();
323 void on_actionFusionDark_triggered();
324 void on_actionJobPriorityLow_triggered();
325 void on_actionJobPriorityNormal_triggered();
326 void on_actionFusionLight_triggered();
327 void on_actionTutorials_triggered();
328 void on_actionRestoreLayout_triggered();
329 void on_actionShowTitleBars_triggered(bool checked);
330 void on_actionShowToolbar_triggered(bool checked);
331 void onToolbarVisibilityChanged(bool visible);
332 void on_menuExternal_aboutToShow();
333 void on_actionUpgrade_triggered();
334 void on_actionOpenXML_triggered();
335 void on_actionShowProjectFolder_triggered();
336 void onAutosaveTimeout();
337 void onFocusChanged(QWidget *old, QWidget *now) const;
338 void onFocusObjectChanged(QObject *obj) const;
339 void onFocusWindowChanged(QWindow *window) const;
340 void onTimelineClipSelected();
341 void onAddAllToTimeline(Mlt::Playlist *playlist, bool skipProxy, bool emptyTrack);
342 void on_actionScrubAudio_triggered(bool checked);
343#if !defined(Q_OS_MAC)
344 void onDrawingMethodTriggered(QAction *);
345#endif
346 void on_actionResources_triggered();
347 void on_actionApplicationLog_triggered();
348 void on_actionClose_triggered();
349 void onPlayerTabIndexChanged(int index);
350 void onUpgradeCheckFinished(QNetworkReply *reply);
351 void onUpgradeTriggered();
352 void onClipCopied();
353 void on_actionExportEDL_triggered();
354 void on_actionExportFrame_triggered();
355 void onVideoWidgetImageReady();
356 void on_actionAppDataSet_triggered();
357 void on_actionAppDataShow_triggered();
358 void on_actionNew_triggered();
359 void on_actionScreenSnapshot_triggered();
360 void on_actionScreenRecording_triggered();
361 void on_actionKeyboardShortcuts_triggered();
362 void on_actionLayoutLogging_triggered();
363 void on_actionLayoutEditing_triggered();
364 void on_actionLayoutEffects_triggered();
365 void on_actionLayoutColor_triggered();
366 void on_actionLayoutAudio_triggered();
367 void on_actionLayoutPlayer_triggered();
368 void on_actionLayoutPlaylist_triggered();
369 void on_actionLayoutClip_triggered();
370 void on_actionLayoutAdd_triggered();
371 void onLayoutTriggered(QAction *);
372 void on_actionProfileRemove_triggered();
373 void on_actionLayoutRemove_triggered();
374 void on_actionOpenOther2_triggered();
375 void onOpenOtherTriggered(QWidget *widget);
376 void onOpenOtherFinished(int result);
377 void onOpenOtherTriggered();
378 void onHtmlGeneratorTriggered();
379 void on_actionClearRecentOnExit_toggled(bool arg1);
380 void onSceneGraphInitialized();
381 void on_actionShowTextUnderIcons_toggled(bool b);
382 void on_actionShowSmallIcons_toggled(bool b);
383 void onPlaylistInChanged(int in);
384 void onPlaylistOutChanged(int out);
385 void on_actionPreviewNone_triggered(bool checked);
386 void on_actionPreview360_triggered(bool checked);
387 void on_actionPreview540_triggered(bool checked);
388 void on_actionPreview720_triggered(bool checked);
389 void on_actionPreview1080_triggered(bool checked);
390 void on_actionPreviewHardwareDecoder_triggered(bool checked);
391 void on_actionTopics_triggered();
392 void on_actionSync_triggered();
393 void on_actionUseProxy_triggered(bool checked);
394 void on_actionProxyStorageSet_triggered();
395 void on_actionProxyStorageShow_triggered();
396 void on_actionProxyUseProjectFolder_triggered(bool checked);
397 void on_actionProxyUseHardware_triggered(bool checked);
398 void on_actionProxyConfigureHardware_triggered();
399 void updateLayoutSwitcher();
400 void clearCurrentLayout();
401 void onClipboardChanged();
402 void sourceUpdated();
403 void resetSourceUpdated();
404 void on_actionExportChapters_triggered();
405 void on_actionAudioVideoDevice_triggered();
406 void on_actionReset_triggered();
407 void on_actionBackupSave_triggered();
408 void on_actionPauseAfterSeek_triggered(bool checked);
409 void on_actionWhatsThis_triggered();
410};
411
412#define MAIN MainWindow::singleton()
413
414#endif // MAINWINDOW_H