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
174 Ui::MainWindow *ui;
175 Player *m_player;
176 QDockWidget *m_propertiesDock;
177 RecentDock *m_recentDock;
178 EncodeDock *m_encodeDock;
179 JobsDock *m_jobsDock;
180 PlaylistDock *m_playlistDock;
181 TimelineDock *m_timelineDock;
182 QString m_currentFile;
183 bool m_isKKeyPressed;
184 QUndoStack *m_undoStack;
185 QDockWidget *m_historyDock;
186 QActionGroup *m_profileGroup;
187 QActionGroup *m_externalGroup;
188 QActionGroup *m_decklinkGammaGroup{nullptr};
189 QActionGroup *m_keyerGroup;
190 QActionGroup *m_layoutGroup;
191 QActionGroup *m_previewScaleGroup;
192 FiltersDock *m_filtersDock;
193 FilterController *m_filterController;
194 ScopeController *m_scopeController;
195 QMenu *m_customProfileMenu;
196 QMenu *m_decklinkGammaMenu{nullptr};
197 QMenu *m_keyerMenu;
198 QStringList m_multipleFiles;
199 bool m_multipleFilesLoading;
200 bool m_isPlaylistLoaded;
201 QActionGroup *m_languagesGroup;
202 QSharedPointer<AutoSaveFile> m_autosaveFile;
203 QMutex m_autosaveMutex;
204 QTimer m_autosaveTimer;
205 int m_exitCode;
206 QScopedPointer<QAction> m_statusBarAction;
207 QNetworkAccessManager m_network;
208 QString m_upgradeUrl;
209 KeyframesDock *m_keyframesDock;
210 QDateTime m_clipboardUpdatedAt;
211 QDateTime m_sourceUpdatedAt;
212 MarkersDock *m_markersDock;
213 NotesDock *m_notesDock;
214 SubtitlesDock *m_subtitlesDock;
215 std::unique_ptr<QWidget> m_producerWidget;
216 FilesDock *m_filesDock;
217
218public slots:
219 bool isCompatibleWithGpuMode(MltXmlChecker &checker);
220 bool isXmlRepaired(MltXmlChecker &checker, QString &fileName);
221 bool open(QString url,
222 const Mlt::Properties * = nullptr,
223 bool play = true,
224 bool skipConvert = false);
225 void openMultiple(const QStringList &paths);
226 void openMultiple(const QList<QUrl> &urls);
227 void openVideo();
228 void openCut(Mlt::Producer *producer, bool play = false);
229 void hideProducer();
230 void closeProducer();
231 void showStatusMessage(QAction *action, int timeoutSeconds = 5);
232 void showStatusMessage(const QString &message,
233 int timeoutSeconds = 5,
234 QPalette::ColorRole role = QPalette::ToolTipBase);
235 void onStatusMessageClicked();
236 void seekPlaylist(int start);
237 void seekTimeline(int position, bool seekPlayer = true);
238 void seekKeyframes(int position);
239 QWidget *loadProducerWidget(Mlt::Producer *producer);
240 void onProducerOpened(bool withReopen = true);
241 void onGpuNotSupported();
242 void onShuttle(float x);
243 void onPropertiesDockTriggered(bool checked = true);
244 void onFiltersDockTriggered(bool checked = true);
245 bool on_actionSave_triggered();
246 void onCreateOrEditFilterOnOutput(Mlt::Filter *filter, const QStringList &key_properties);
247 void showSettingsMenu() const;
248
249private slots:
250 void showUpgradePrompt();
251 void on_actionAbout_Shotcut_triggered();
252 void on_actionOpenOther_triggered();
253 void onProducerChanged();
254 bool on_actionSave_As_triggered();
255 void onEncodeTriggered(bool checked = true);
256 void onCaptureStateChanged(bool started);
257 void onJobsDockTriggered(bool = true);
258 void onRecentDockTriggered(bool checked = true);
259 void onPlaylistDockTriggered(bool checked = true);
260 void onTimelineDockTriggered(bool checked = true);
261 void onHistoryDockTriggered(bool checked = true);
262 void onKeyframesDockTriggered(bool checked = true);
263 void onMarkersDockTriggered(bool = true);
264 void onNotesDockTriggered(bool = true);
265 void onSubtitlesDockTriggered(bool = true);
266 void onFilesDockTriggered(bool = true);
267 void onPlaylistCreated();
268 void onPlaylistLoaded();
269 void onPlaylistCleared();
270 void onPlaylistClosed();
271 void onPlaylistModified();
272 void onMultitrackCreated();
273 void onMultitrackClosed();
274 void onMultitrackModified();
275 void onMultitrackDurationChanged();
276 void onNoteModified();
277 void onSubtitleModified();
278 void onCutModified();
279 void onProducerModified();
280 void onFilterModelChanged();
281 void updateMarkers();
282 void updateThumbnails();
283 void on_actionUndo_triggered();
284 void on_actionRedo_triggered();
285 void on_actionFAQ_triggered();
286 void on_actionForum_triggered();
287 void on_actionEnterFullScreen_triggered();
288 void on_actionRealtime_triggered(bool checked);
289 void on_actionProgressive_triggered(bool checked);
290 void on_actionChannels1_triggered(bool checked);
291 void on_actionChannels2_triggered(bool checked);
292 void on_actionChannels4_triggered(bool checked);
293 void on_actionChannels6_triggered(bool checked);
294 void on_actionOneField_triggered(bool checked);
295 void on_actionLinearBlend_triggered(bool checked);
296 void on_actionYadifTemporal_triggered(bool checked);
297 void on_actionYadifSpatial_triggered(bool checked);
298 void on_actionBwdif_triggered(bool checked);
299 void on_actionNearest_triggered(bool checked);
300 void on_actionBilinear_triggered(bool checked);
301 void on_actionBicubic_triggered(bool checked);
302 void on_actionHyper_triggered(bool checked);
303 void on_actionJack_triggered(bool checked);
304 void on_actionGPU_triggered(bool checked);
305 void onExternalTriggered(QAction *);
306 void onDecklinkGammaTriggered(QAction *);
307 void onKeyerTriggered(QAction *);
308 void onProfileTriggered(QAction *);
309 void onProfileChanged();
310 void on_actionAddCustomProfile_triggered();
311 void processMultipleFiles();
312 void processSingleFile();
313 void onLanguageTriggered(QAction *);
314 void on_actionSystemTheme_triggered();
315 void on_actionFusionDark_triggered();
316 void on_actionJobPriorityLow_triggered();
317 void on_actionJobPriorityNormal_triggered();
318 void on_actionFusionLight_triggered();
319 void on_actionTutorials_triggered();
320 void on_actionRestoreLayout_triggered();
321 void on_actionShowTitleBars_triggered(bool checked);
322 void on_actionShowToolbar_triggered(bool checked);
323 void onToolbarVisibilityChanged(bool visible);
324 void on_menuExternal_aboutToShow();
325 void on_actionUpgrade_triggered();
326 void on_actionOpenXML_triggered();
327 void on_actionShowProjectFolder_triggered();
328 void onAutosaveTimeout();
329 void onFocusChanged(QWidget *old, QWidget *now) const;
330 void onFocusObjectChanged(QObject *obj) const;
331 void onFocusWindowChanged(QWindow *window) const;
332 void onTimelineClipSelected();
333 void onAddAllToTimeline(Mlt::Playlist *playlist, bool skipProxy, bool emptyTrack);
334 void on_actionScrubAudio_triggered(bool checked);
335#if !defined(Q_OS_MAC)
336 void onDrawingMethodTriggered(QAction *);
337#endif
338 void on_actionResources_triggered();
339 void on_actionApplicationLog_triggered();
340 void on_actionClose_triggered();
341 void onPlayerTabIndexChanged(int index);
342 void onUpgradeCheckFinished(QNetworkReply *reply);
343 void onUpgradeTriggered();
344 void onClipCopied();
345 void on_actionExportEDL_triggered();
346 void on_actionExportFrame_triggered();
347 void onVideoWidgetImageReady();
348 void on_actionAppDataSet_triggered();
349 void on_actionAppDataShow_triggered();
350 void on_actionNew_triggered();
351 void on_actionKeyboardShortcuts_triggered();
352 void on_actionLayoutLogging_triggered();
353 void on_actionLayoutEditing_triggered();
354 void on_actionLayoutEffects_triggered();
355 void on_actionLayoutColor_triggered();
356 void on_actionLayoutAudio_triggered();
357 void on_actionLayoutPlayer_triggered();
358 void on_actionLayoutPlaylist_triggered();
359 void on_actionLayoutClip_triggered();
360 void on_actionLayoutAdd_triggered();
361 void onLayoutTriggered(QAction *);
362 void on_actionProfileRemove_triggered();
363 void on_actionLayoutRemove_triggered();
364 void on_actionOpenOther2_triggered();
365 void onOpenOtherTriggered(QWidget *widget);
366 void onOpenOtherFinished(int result);
367 void onOpenOtherTriggered();
368 void on_actionClearRecentOnExit_toggled(bool arg1);
369 void onSceneGraphInitialized();
370 void on_actionShowTextUnderIcons_toggled(bool b);
371 void on_actionShowSmallIcons_toggled(bool b);
372 void onPlaylistInChanged(int in);
373 void onPlaylistOutChanged(int out);
374 void on_actionPreviewNone_triggered(bool checked);
375 void on_actionPreview360_triggered(bool checked);
376 void on_actionPreview540_triggered(bool checked);
377 void on_actionPreview720_triggered(bool checked);
378 void on_actionPreview1080_triggered(bool checked);
379 void on_actionTopics_triggered();
380 void on_actionSync_triggered();
381 void on_actionUseProxy_triggered(bool checked);
382 void on_actionProxyStorageSet_triggered();
383 void on_actionProxyStorageShow_triggered();
384 void on_actionProxyUseProjectFolder_triggered(bool checked);
385 void on_actionProxyUseHardware_triggered(bool checked);
386 void on_actionProxyConfigureHardware_triggered();
387 void updateLayoutSwitcher();
388 void clearCurrentLayout();
389 void onClipboardChanged();
390 void sourceUpdated();
391 void resetSourceUpdated();
392 void on_actionExportChapters_triggered();
393 void on_actionAudioVideoDevice_triggered();
394 void on_actionReset_triggered();
395 void on_actionBackupSave_triggered();
396 void on_actionPauseAfterSeek_triggered(bool checked);
397};
398
399#define MAIN MainWindow::singleton()
400
401#endif // MAINWINDOW_H