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