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;
54
55class MainWindow : public QMainWindow
56{
57 Q_OBJECT
58
59public:
60 enum LayoutMode {
61 Custom = 0,
62 Logging,
63 Editing,
64 Effects,
65 Color,
66 Audio,
67 PlayerOnly
68 };
69
70 static MainWindow &singleton();
71 ~MainWindow();
72 void open(Mlt::Producer *producer);
73 bool continueModified();
74 bool continueJobsRunning();
75 QUndoStack *undoStack() const;
76 bool saveXML(const QString &filename, bool withRelativePaths = true);
77 static void changeTheme(const QString &theme);
78 PlaylistDock *playlistDock() const
79 {
80 return m_playlistDock;
81 }
82 FilterController *filterController() const
83 {
84 return m_filterController;
85 }
86 Mlt::Playlist *playlist() const;
87 bool isPlaylistValid() const;
88 Mlt::Producer *multitrack() const;
89 bool isMultitrackValid() const;
90 void doAutosave();
91 void setFullScreen(bool isFullScreen);
92 QString untitledFileName() const;
93 void setProfile(const QString &profile_name);
94 QString fileName() const
95 {
96 return m_currentFile;
97 }
98 bool isSourceClipMyProject(QString resource = MLT.resource(), bool withDialog = true);
99 bool keyframesDockIsVisible() const;
100
101 void keyPressEvent(QKeyEvent *);
102 void keyReleaseEvent(QKeyEvent *);
103 void hideSetDataDirectory();
104 QMenu *customProfileMenu() const
105 {
106 return m_customProfileMenu;
107 }
108 QAction *actionAddCustomProfile() const;
109 QAction *actionProfileRemove() const;
110 QActionGroup *profileGroup() const
111 {
112 return m_profileGroup;
113 }
114 void buildVideoModeMenu(QMenu *topMenu, QMenu *&customMenu, QActionGroup *group, QAction *addAction,
115 QAction *removeAction);
116 void newProject(const QString &filename, bool isProjectFolder = false);
117 void addCustomProfile(const QString &name, QMenu *menu, QAction *action, QActionGroup *group);
118 void removeCustomProfiles(const QStringList &profiles, QDir &dir, QMenu *menu, QAction *action);
119 QUuid timelineClipUuid(int trackIndex, int clipIndex);
120 void replaceInTimeline(const QUuid &uuid, Mlt::Producer &producer);
121 void replaceAllByHash(const QString &hash, Mlt::Producer &producer, bool isProxy = false);
122 bool isClipboardNewer() const
123 {
124 return m_clipboardUpdatedAt > m_sourceUpdatedAt;
125 }
126 int mltIndexForTrack(int trackIndex) const;
127 int bottomVideoTrackIndex() const;
128 void cropSource(const QRectF &rect);
129 void getMarkerRange(int position, int *start, int *end);
130 void getSelectionRange(int *start, int *end);
131
132signals:
133 void audioChannelsChanged();
134 void producerOpened(bool withReopen = true);
135 void profileChanged();
136 void openFailed(QString);
137 void aboutToShutDown();
138 void renameRequested();
139 void serviceInChanged(int delta, Mlt::Service *);
140 void serviceOutChanged(int delta, Mlt::Service *);
141
142protected:
143 MainWindow();
144 bool eventFilter(QObject *target, QEvent *event);
145 void dragEnterEvent(QDragEnterEvent *);
146 void dropEvent(QDropEvent *);
147 void closeEvent(QCloseEvent *);
148 void showEvent(QShowEvent *);
149 void hideEvent(QHideEvent *event);
150
151private:
152 void connectFocusSignals();
153 void registerDebugCallback();
154 void connectUISignals();
155 void setupAndConnectUndoStack();
156 void setupAndConnectPlayerWidget();
157 void setupLayoutSwitcher();
158 void centerLayoutInRemainingToolbarSpace();
159 void setupAndConnectDocks();
160 void setupMenuFile();
161 void setupMenuView();
162 void connectVideoWidgetSignals();
163 void setupSettingsMenu();
164 void setupOpenOtherMenu();
165 void setupActions();
166 QAction *addProfile(QActionGroup *actionGroup, const QString &desc, const QString &name);
167 QAction *addLayout(QActionGroup *actionGroup, const QString &name);
168 void readPlayerSettings();
169 void readWindowSettings();
170 void writeSettings();
171 void configureVideoWidget();
172 void setCurrentFile(const QString &filename);
173 void changeAudioChannels(bool checked, int channels);
174 void changeDeinterlacer(bool checked, const char *method);
175 void changeInterpolation(bool checked, const char *method);
176 bool checkAutoSave(QString &url);
177 bool saveRepairedXmlFile(MltXmlChecker &checker, QString &fileName);
178 void setAudioChannels(int channels);
179 void showSaveError();
180 void setPreviewScale(int scale);
181 void setVideoModeMenu();
182 void resetVideoModeMenu();
183 void resetDockCorners();
184 void showIncompatibleProjectMessage(const QString &shotcutVersion);
185 void restartAfterChangeTheme();
186 void backup();
187 void backupPeriodically();
188
189 Ui::MainWindow *ui;
190 Player *m_player;
191 QDockWidget *m_propertiesDock;
192 RecentDock *m_recentDock;
193 EncodeDock *m_encodeDock;
194 JobsDock *m_jobsDock;
195 PlaylistDock *m_playlistDock;
196 TimelineDock *m_timelineDock;
197 QString m_currentFile;
198 bool m_isKKeyPressed;
199 QUndoStack *m_undoStack;
200 QDockWidget *m_historyDock;
201 QActionGroup *m_profileGroup;
202 QActionGroup *m_externalGroup;
203 QActionGroup *m_keyerGroup;
204 QActionGroup *m_layoutGroup;
205 QActionGroup *m_previewScaleGroup;
206 FiltersDock *m_filtersDock;
207 FilterController *m_filterController;
208 ScopeController *m_scopeController;
209 QMenu *m_customProfileMenu;
210 QMenu *m_keyerMenu;
211 QStringList m_multipleFiles;
212 bool m_multipleFilesLoading;
213 bool m_isPlaylistLoaded;
214 QActionGroup *m_languagesGroup;
215 QSharedPointer<AutoSaveFile> m_autosaveFile;
216 QMutex m_autosaveMutex;
217 QTimer m_autosaveTimer;
218 int m_exitCode;
219 QScopedPointer<QAction> m_statusBarAction;
220 QNetworkAccessManager m_network;
221 QString m_upgradeUrl;
222 KeyframesDock *m_keyframesDock;
223 QDateTime m_clipboardUpdatedAt;
224 QDateTime m_sourceUpdatedAt;
225 MarkersDock *m_markersDock;
226 NotesDock *m_notesDock;
227 std::unique_ptr<QWidget> m_producerWidget;
228
229public slots:
230 bool isCompatibleWithGpuMode(MltXmlChecker &checker);
231 bool isXmlRepaired(MltXmlChecker &checker, QString &fileName);
232 bool open(QString url, const Mlt::Properties * = nullptr, 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, int timeoutSeconds = 5,
242 QPalette::ColorRole role = QPalette::ToolTipBase);
243 void onStatusMessageClicked();
244 void seekPlaylist(int start);
245 void seekTimeline(int position, bool seekPlayer = true);
246 void seekKeyframes(int position);
247 QWidget *loadProducerWidget(Mlt::Producer *producer);
248 void onProducerOpened(bool withReopen = true);
249 void onGpuNotSupported();
250 void onShuttle(float x);
251 void onPropertiesDockTriggered(bool checked = true);
252 bool on_actionSave_triggered();
253
254private slots:
255 void showUpgradePrompt();
256 void on_actionAbout_Shotcut_triggered();
257 void on_actionOpenOther_triggered();
258 void onProducerChanged();
259 bool on_actionSave_As_triggered();
260 void onEncodeTriggered(bool checked = true);
261 void onCaptureStateChanged(bool started);
262 void onJobsDockTriggered(bool = true);
263 void onRecentDockTriggered(bool checked = true);
264 void onPlaylistDockTriggered(bool checked = true);
265 void onTimelineDockTriggered(bool checked = true);
266 void onHistoryDockTriggered(bool checked = true);
267 void onFiltersDockTriggered(bool checked = true);
268 void onKeyframesDockTriggered(bool checked = true);
269 void onMarkersDockTriggered(bool = true);
270 void onNotesDockTriggered(bool = true);
271 void onPlaylistCreated();
272 void onPlaylistLoaded();
273 void onPlaylistCleared();
274 void onPlaylistClosed();
275 void onPlaylistModified();
276 void onMultitrackCreated();
277 void onMultitrackClosed();
278 void onMultitrackModified();
279 void onMultitrackDurationChanged();
280 void onNoteModified();
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 onKeyerTriggered(QAction *);
310 void onProfileTriggered(QAction *);
311 void onProfileChanged();
312 void on_actionAddCustomProfile_triggered();
313 void processMultipleFiles();
314 void processSingleFile();
315 void onLanguageTriggered(QAction *);
316 void on_actionSystemTheme_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 onAutosaveTimeout();
330 void onFocusChanged(QWidget *old, QWidget *now) const;
331 void onFocusObjectChanged(QObject *obj) const;
332 void onFocusWindowChanged(QWindow *window) const;
333 void onTimelineClipSelected();
334 void onAddAllToTimeline(Mlt::Playlist *playlist, bool skipProxy);
335 void on_actionScrubAudio_triggered(bool checked);
336#if !defined(Q_OS_MAC)
337 void onDrawingMethodTriggered(QAction *);
338#endif
339 void on_actionResources_triggered();
340 void on_actionApplicationLog_triggered();
341 void on_actionClose_triggered();
342 void onPlayerTabIndexChanged(int index);
343 void onUpgradeCheckFinished(QNetworkReply *reply);
344 void onUpgradeTriggered();
345 void onClipCopied();
346 void on_actionExportEDL_triggered();
347 void on_actionExportFrame_triggered();
348 void onVideoWidgetImageReady();
349 void on_actionAppDataSet_triggered();
350 void on_actionAppDataShow_triggered();
351 void on_actionNew_triggered();
352 void on_actionKeyboardShortcuts_triggered();
353 void on_actionLayoutLogging_triggered();
354 void on_actionLayoutEditing_triggered();
355 void on_actionLayoutEffects_triggered();
356 void on_actionLayoutColor_triggered();
357 void on_actionLayoutAudio_triggered();
358 void on_actionLayoutPlayer_triggered();
359 void on_actionLayoutPlaylist_triggered();
360 void on_actionLayoutClip_triggered();
361 void on_actionLayoutAdd_triggered();
362 void onLayoutTriggered(QAction *);
363 void on_actionProfileRemove_triggered();
364 void on_actionLayoutRemove_triggered();
365 void on_actionOpenOther2_triggered();
366 void onOpenOtherTriggered(QWidget *widget);
367 void onOpenOtherFinished(int result);
368 void onOpenOtherTriggered();
369 void on_actionClearRecentOnExit_toggled(bool arg1);
370 void onSceneGraphInitialized();
371 void on_actionShowTextUnderIcons_toggled(bool b);
372 void on_actionShowSmallIcons_toggled(bool b);
373 void onPlaylistInChanged(int in);
374 void onPlaylistOutChanged(int out);
375 void on_actionPreviewNone_triggered(bool checked);
376 void on_actionPreview360_triggered(bool checked);
377 void on_actionPreview540_triggered(bool checked);
378 void on_actionPreview720_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};
397
398#define MAIN MainWindow::singleton()
399
400#endif // MAINWINDOW_H