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