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