]> git.sesse.net Git - kdenlive/blob - src/mainwindow.h
Cleanup: remove duplicate monitor code, allow fullscreen for record monitor
[kdenlive] / src / mainwindow.h
1 /***************************************************************************
2  *   Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
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 2 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, write to the                         *
16  *   Free Software Foundation, Inc.,                                       *
17  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
18  ***************************************************************************/
19
20
21 #ifndef MAINWINDOW_H
22 #define MAINWINDOW_H
23
24 #include <QDockWidget>
25 #include <QUndoView>
26 #include <QLabel>
27 #include <QProgressBar>
28 #include <QEvent>
29 #include <QTimer>
30 #include <QShortcut>
31
32 #include <KXmlGuiWindow>
33 #include <KTextEdit>
34 #include <KListWidget>
35 #include <KTabWidget>
36 #include <KUndoStack>
37 #include <KRecentFilesAction>
38 #include <KComboBox>
39 #include <kautosavefile.h>
40 #include <KActionCategory>
41
42 #include "effectslist.h"
43 #include "gentime.h"
44 #include "definitions.h"
45 #include "statusbarmessagelabel.h"
46 #include "dvdwizard.h"
47 #include "stopmotion/stopmotion.h"
48 #include "noteswidget.h"
49 #include "ui_backupdialog_ui.h"
50
51 class KdenliveDoc;
52 class TrackView;
53 class MonitorManager;
54 class ProjectList;
55 class EffectsListView;
56 class EffectStackView;
57 class TransitionSettings;
58 class Monitor;
59 class RecMonitor;
60 class CustomTrackView;
61 class RenderWidget;
62 #ifdef USE_JOGSHUTTLE
63 class JogShuttle;
64 class JogShuttleAction;
65 #endif
66 class DocClipBase;
67 class Render;
68 class Transition;
69 class ScopeManager;
70 class Histogram;
71 class Vectorscope;
72 class Waveform;
73 class RGBParade;
74 class KActionCollection;
75 class AudioSignal;
76 class AbstractAudioScopeWidget;
77 class AudioSpectrum;
78 class Spectrogram;
79
80 class MainWindow : public KXmlGuiWindow
81 {
82     Q_OBJECT
83     Q_CLASSINFO("D-Bus Interface", "org.kdenlive.MainWindow")
84
85 public:
86
87     /** @brief Initialises the main window.
88      * @param MltPath (optional) path to MLT environment
89      * @param Url (optional) file to open
90      * @param clipsToLoad (optional) a comma separated list of clips to import in project
91      *
92      * If Url is present, it will be opened, otherwhise, if openlastproject is
93      * set, latest project will be opened. If no file is open after trying this,
94      * a default new file will be created. */
95     explicit MainWindow(const QString &MltPath = QString(),
96                         const KUrl &Url = KUrl(), const QString & clipsToLoad = QString(), QWidget *parent = 0);
97     virtual ~MainWindow();
98
99     /** @brief Locates the MLT environment.
100      * @param mltPath (optional) path to MLT environment
101      *
102      * It tries to set the paths of the MLT profiles and renderer, using
103      * mltPath, MLT_PREFIX, searching for the binary `melt`, or asking to the
104      * user. It doesn't fill any list of profiles, while its name suggests so. */
105     void parseProfiles(const QString &mltPath = QString());
106
107     static EffectsList videoEffects;
108     static EffectsList audioEffects;
109     static EffectsList customEffects;
110     static EffectsList transitions;
111 protected:
112
113     /** @brief Closes the window.
114      * @return false if the user presses "Cancel" on a confirmation dialog or
115      *     the operation requested (starting waiting jobs or saving file) fails,
116      *     true otherwise */
117     virtual bool queryClose();
118
119     /** @brief Reports a message in the status bar when an error occurs. */
120     virtual void customEvent(QEvent *e);
121
122     /** @brief Enables live search in the timeline. */
123     virtual void keyPressEvent(QKeyEvent *ke);
124
125     /** @brief Stops the active monitor when the window gets hidden. */
126     virtual void hideEvent(QHideEvent *e);
127
128     /** @brief Filters key events to the live search. */
129     bool eventFilter(QObject *obj, QEvent *ev);
130
131     /** @brief Saves the file and the window properties when saving the session. */
132     virtual void saveProperties(KConfigGroup &config);
133
134     /** @brief Restores the window and the file when a session is loaded. */
135     virtual void readProperties(const KConfigGroup &config);
136
137 private:
138     KTabWidget* m_timelineArea;
139     QProgressBar *m_statusProgressBar;
140
141     ScopeManager *m_scopeManager;
142
143     /** @brief Sets up all the actions and attaches them to the collection. */
144     void setupActions();
145     KdenliveDoc *m_activeDocument;
146     TrackView *m_activeTimeline;
147     MonitorManager *m_monitorManager;
148
149     QDockWidget *m_projectListDock;
150     ProjectList *m_projectList;
151
152     QDockWidget *m_effectListDock;
153     EffectsListView *m_effectList;
154     //KListWidget *m_effectList;
155
156     QDockWidget *m_notesDock;
157     NotesWidget *m_notesWidget;
158
159     QDockWidget *m_effectStackDock;
160     EffectStackView *m_effectStack;
161
162     QDockWidget *m_transitionConfigDock;
163     TransitionSettings *m_transitionConfig;
164
165     QDockWidget *m_clipMonitorDock;
166     Monitor *m_clipMonitor;
167
168     QDockWidget *m_projectMonitorDock;
169     Monitor *m_projectMonitor;
170
171     QDockWidget *m_recMonitorDock;
172     RecMonitor *m_recMonitor;
173
174     QDockWidget *m_vectorscopeDock;
175     Vectorscope *m_vectorscope;
176
177     QDockWidget *m_waveformDock;
178     Waveform *m_waveform;
179
180     QDockWidget *m_RGBParadeDock;
181     RGBParade *m_RGBParade;
182
183     QDockWidget *m_histogramDock;
184     Histogram *m_histogram;
185
186     QDockWidget *m_audiosignalDock;
187     AudioSignal *m_audiosignal;
188
189     QDockWidget *m_audioSpectrumDock;
190     AudioSpectrum *m_audioSpectrum;
191
192     QDockWidget *m_spectrogramDock;
193     Spectrogram *m_spectrogram;
194
195     QDockWidget *m_undoViewDock;
196     QUndoView *m_undoView;
197     QUndoGroup *m_commandStack;
198
199     KComboBox *m_timecodeFormat;
200
201     /** This list holds all the scopes used in Kdenlive, allowing to manage some global settings */
202     QList <QDockWidget *> m_gfxScopesList;
203
204     KActionCategory *m_effectActions;
205     QMenu *m_effectsMenu;
206     QMenu *m_transitionsMenu;
207     QMenu *m_timelineContextMenu;
208     QMenu *m_timelineContextClipMenu;
209     QMenu *m_timelineContextTransitionMenu;
210     KUrl m_startUrl;
211
212     /** Actions used in the stopmotion widget */
213     KActionCategory *m_stopmotion_actions;
214
215     /** Action names that can be used in the slotDoAction() slot, with their i18n() names */
216     QStringList m_action_names;
217
218
219     /** @brief Shortcut to remove the focus from any element.
220      *
221      * It allows to get out of e.g. text input fields and to press another
222      * shortcut. */
223     QShortcut* m_shortcutRemoveFocus;
224
225     RenderWidget *m_renderWidget;
226
227 #ifdef USE_JOGSHUTTLE
228     JogShuttle *m_jogProcess;
229     JogShuttleAction* m_jogShuttle;
230 #endif
231
232     KRecentFilesAction *m_fileOpenRecent;
233     KAction *m_fileRevert;
234     KAction *m_projectSearch;
235     KAction *m_projectSearchNext;
236
237     KAction **m_videoEffects;
238     KAction **m_audioEffects;
239     KAction **m_customEffects;
240     KAction **m_transitions;
241     KAction *m_buttonAudioThumbs;
242     KAction *m_buttonVideoThumbs;
243     KAction *m_buttonShowMarkers;
244     KAction *m_buttonFitZoom;
245     KAction *m_buttonAutomaticSplitAudio;
246     KAction *m_normalEditTool;
247     KAction *m_overwriteEditTool;
248     KAction *m_insertEditTool;
249     KAction *m_buttonSelectTool;
250     KAction *m_buttonRazorTool;
251     KAction *m_buttonSpacerTool;
252     KAction *m_buttonSnap;
253     KAction *m_saveAction;
254     KAction *m_closeAction;
255     QSlider *m_zoomSlider;
256     KAction *m_zoomIn;
257     KAction *m_zoomOut;
258     KAction *m_loopZone;
259     KAction *m_playZone;
260     KAction *m_loopClip;
261     KSelectAction *m_loadLayout;
262     StatusBarMessageLabel *m_messageLabel;
263     QActionGroup *m_clipTypeGroup;
264     KActionCollection *m_effectsActionCollection;
265     KActionCollection *m_tracksActionCollection;
266
267     bool m_findActivated;
268     QString m_findString;
269     QTimer m_findTimer;
270
271     void readOptions();
272     void saveOptions();
273 #ifdef USE_JOGSHUTTLE
274     void activateShuttleDevice();
275 #endif
276     void connectDocumentInfo(KdenliveDoc *doc);
277     void findAhead();
278     void doOpenFile(const KUrl &url, KAutoSaveFile *stale);
279     void recoverFiles(QList<KAutoSaveFile *> staleFiles, const KUrl &originUrl);
280
281     /** @brief Loads static and dynamic plugins.
282      *
283      * It scans static plugins as well as the filesystem: it doesn't load more
284      * than one plugin per file name, to avoid duplication due to conflicting
285      * installations. */
286     void loadPlugins();
287     void populateMenus(QObject *plugin);
288     void addToMenu(QObject *plugin, const QStringList &texts,
289                    QMenu *menu, const char *member,
290                    QActionGroup *actionGroup);
291     void aboutPlugins();
292
293     /** @brief Instantiates a "Get Hot New Stuff" dialog.
294      * @param configFile configuration file for KNewStuff
295      * @return number of installed items */
296     int getNewStuff(const QString &configFile = QString());
297     QStringList m_pluginFileNames;
298     QByteArray m_timelineState;
299     void loadTranscoders();
300     void loadStabilize();
301     QPixmap createSchemePreviewIcon(const KSharedConfigPtr &config);
302
303     /** @brief Checks that the Kdenlive mime type is correctly installed.
304     * @param open If set to true, this will return the mimetype allowed for file opening (adds .tar.gz format)
305     * @return The mimetype */
306     QString getMimeType(bool open = true);
307
308     /** @brief Populates the "load layout" menu. */
309     void loadLayouts();
310
311     StopmotionWidget *m_stopmotion;
312     QTime m_timer;
313
314 public slots:
315     /** @brief Prepares opening @param url.
316     *
317     * Checks if already open and whether backup exists */
318     void openFile(const KUrl &url);
319     void slotGotProgressInfo(const QString &message, int progress);
320     void slotReloadEffects();
321     Q_SCRIPTABLE void setRenderingProgress(const QString &url, int progress);
322     Q_SCRIPTABLE void setRenderingFinished(const QString &url, int status, const QString &error);
323
324
325 private slots:
326     void newFile(bool showProjectSettings = true, bool force = false);
327     void activateDocument();
328     void connectDocument(TrackView*, KdenliveDoc*);
329
330     /** @brief Shows file open dialog. */
331     void openFile();
332     void openLastFile();
333
334     /** @brief Checks whether a URL is available to save to.
335     * @return Whether the file was saved. */
336     bool saveFile();
337
338     /** @brief Shows a save file dialog for saving the project.
339     * @return Whether the file was saved. */
340     bool saveFileAs();
341
342     /** @brief Set properties to match outputFileName and save the document.
343     * @param outputFileName The URL to save to / The document's URL.
344     * @return Whether we had success. */
345     bool saveFileAs(const QString &outputFileName);
346
347     /** @brief Shows the shortcut dialog. */
348     void slotEditKeys();
349     void slotPreferences(int page = -1, int option = -1);
350
351     /** @brief Reflects setting changes to the GUI. */
352     void updateConfiguration();
353     void slotConnectMonitors();
354     void slotUpdateClip(const QString &id);
355     void slotUpdateMousePosition(int pos);
356     void slotAddEffect(const QDomElement effect);
357     void slotEditProfiles();
358     void slotDetectAudioDriver();
359     void slotEditProjectSettings();
360     /** @brief Change current document MLT profile. */
361     void slotUpdateProjectProfile(const QString &profile);
362     void slotDisplayActionMessage(QAction *a);
363
364     /** @brief Turns automatic splitting of audio and video on/off. */
365     void slotSwitchSplitAudio();
366     void slotSwitchVideoThumbs();
367     void slotSwitchAudioThumbs();
368     void slotSwitchMarkersComments();
369     void slotSwitchSnap();
370     void slotRenderProject();
371     void slotFullScreen();
372     void slotUpdateDocumentState(bool modified);
373
374     /** @brief Sets the timeline zoom slider to @param value.
375     *
376     * Also disables zoomIn and zoomOut actions if they cannot be used at the moment. */
377     void slotSetZoom(int value);
378     /** @brief Decreases the timeline zoom level by 1. */
379     void slotZoomIn();
380     /** @brief Increases the timeline zoom level by 1. */
381     void slotZoomOut();
382     /** @brief Makes the timeline zoom level fit the timeline content. */
383     void slotFitZoom();
384     /** @brief Updates the zoom slider tooltip to fit @param zoomlevel. */
385     void slotUpdateZoomSliderToolTip(int zoomlevel);
386
387     /** @brief Displays the zoom slider tooltip.
388     * @param zoomlevel (optional) The zoom level to show in the tooltip.
389     *
390     * Adopted from Dolphin (src/statusbar/dolphinstatusbar.cpp) */
391     void slotShowZoomSliderToolTip(int zoomlevel = -1);
392     /** @brief Close currently opened document. Returns false if something went wrong (cannot save modifications, ...). */
393     bool closeCurrentDocument(bool saveChanges = true);
394     /** @brief Deletes item in timeline, project tree or effect stack depending on focus. */
395     void slotDeleteItem();
396     void slotAddClipMarker();
397     void slotDeleteClipMarker();
398     void slotDeleteAllClipMarkers();
399     void slotEditClipMarker();
400
401     /** @brief Adds marker or auide at the current position without showing the marker dialog.
402      *
403      * Adds a marker if clip monitor is active, otherwise a guide.
404      * The comment is set to the current position (therefore not dialog).
405      * This can be useful to mark something during playback. */
406     void slotAddMarkerGuideQuickly();
407     void slotCutTimelineClip();
408     void slotInsertClipOverwrite();
409     void slotSelectTimelineClip();
410     void slotSelectTimelineTransition();
411     void slotDeselectTimelineClip();
412     void slotDeselectTimelineTransition();
413     void slotSelectAddTimelineClip();
414     void slotSelectAddTimelineTransition();
415     void slotAddVideoEffect(QAction *result);
416     void slotAddTransition(QAction *result);
417     void slotAddProjectClip(KUrl url, const QString &comment = QString());
418     void slotAddProjectClipList(KUrl::List urls);
419     void slotShowClipProperties(DocClipBase *clip);
420     void slotShowClipProperties(QList <DocClipBase *>cliplist, QMap<QString, QString> commonproperties);
421     void slotActivateEffectStackView(ClipItem* item = NULL, int ix = -1, bool raise = true);
422     void slotActivateTransitionView(Transition *);
423     void slotChangeTool(QAction * action);
424     void slotChangeEdit(QAction * action);
425     void slotSetTool(PROJECTTOOL tool);
426     void slotSnapForward();
427     void slotSnapRewind();
428     void slotClipStart();
429     void slotClipEnd();
430     void slotZoneStart();
431     void slotZoneEnd();
432     void slotFind();
433     void findTimeout();
434     void slotFindNext();
435     void slotSelectClipInTimeline();
436     void slotClipInTimeline(const QString &clipId);
437
438     void slotInsertSpace();
439     void slotRemoveSpace();
440     void slotAddGuide();
441     void slotEditGuide();
442     void slotDeleteGuide();
443     void slotDeleteAllGuides();
444     void slotGuidesUpdated();
445
446     void slotCopy();
447     void slotPaste();
448     void slotPasteEffects();
449
450     void slotAdjustClipMonitor();
451     void slotAdjustProjectMonitor();
452     void slotSaveZone(Render *render, QPoint zone, DocClipBase *baseClip = NULL, KUrl path = KUrl());
453
454     void slotSetInPoint();
455     void slotSetOutPoint();
456     void slotResizeItemStart();
457     void slotResizeItemEnd();
458     void configureNotifications();
459     void slotInsertTrack(int ix = -1);
460     void slotDeleteTrack(int ix = -1);
461     /** @brief Shows the configure tracks dialog and updates transitions afterwards. */
462     void slotConfigTrack(int ix = -1);
463     /** @brief Select all clips in active track. */
464     void slotSelectTrack();
465     /** @brief Select all clips in timeline. */
466     void slotSelectAllTracks();
467     void slotGetNewLumaStuff();
468     void slotGetNewTitleStuff();
469     void slotGetNewRenderStuff();
470     void slotGetNewMltProfileStuff();
471     void slotAutoTransition();
472     void slotRunWizard();
473     /** @brief Lets the sampleplugin create a generator.  */
474     void generateClip();
475     void slotZoneMoved(int start, int end);
476     void slotDvdWizard(const QString &url = QString(), const QString &profile = "dv_pal");
477     void slotGroupClips();
478     void slotUnGroupClips();
479     void slotEditItemDuration();
480     void slotClipInProjectTree();
481     //void slotClipToProjectTree();
482     void slotSplitAudio();
483     void slotUpdateClipType(QAction *action);
484     void slotShowTimeline(bool show);
485     void slotMaximizeCurrent(bool show);
486     void slotTranscode(KUrl::List urls = KUrl::List());
487     void slotStabilize();
488     void slotTranscodeClip();
489     /** @brief Archive project: creates a copy of the project file with all clips in a new folder. */
490     void slotArchiveProject();
491     void slotSetDocumentRenderProfile(QMap <QString, QString> props);
492     void slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile);
493
494     /** @brief Switches between displaying frames or timecode.
495     * @param ix 0 = display timecode, 1 = display frames. */
496     void slotUpdateTimecodeFormat(int ix);
497
498     /** @brief Removes the focus of anything. */
499     void slotRemoveFocus();
500     void slotCleanProject();
501     void slotUpdateClipMarkers(DocClipBase *clip);
502     void slotRevert();
503     void slotShutdown();
504     void slotUpdateTrackInfo();
505
506     /** @brief Changes the color scheme. */
507     void slotChangePalette(QAction *action, const QString &themename = QString());
508     void slotSwitchMonitors();
509     void slotCheckRenderStatus();
510     void slotInsertZoneToTree();
511     void slotInsertZoneToTimeline();
512
513     /** @brief Deletes items from timeline and document.
514     * @param ids The ids of the clips to delete.
515     * @param folderids The names and ids of the folders to delete. */
516     void slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids);
517     void slotShowTitleBars(bool show);
518     void slotSwitchTitles();
519     /** @brief Update the capture folder if user asked a change. */
520     void slotUpdateCaptureFolder();
521
522     /** @brief Apply new properties to a clip */
523     void slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload);
524
525     /** @brief Delete a clip from current project */
526     void slotDeleteClip(const QString &id);
527
528     /** @brief Saves the widgets layout */
529     void slotSaveLayout(QAction*);
530     void slotLoadLayout(QAction*);
531
532     /** @brief The monitor informs that it needs (or not) to have frames sent by the renderer. */
533     void slotMonitorRequestRenderFrame(bool request);
534     /** @brief Open the stopmotion dialog. */
535     void slotOpenStopmotion();
536     /** @brief Implements all the actions that are int he ActionsCollection. */
537     void slotDoAction(const QString& action_name);
538     /** @brief Update project because the use of proxy clips was enabled / disabled. */
539     void slotUpdateProxySettings();
540     /** @brief Insert current project's timecode into the notes widget. */
541     void slotInsertNotesTimecode();
542     /** @brief Open the project's backupdialog. */
543     void slotOpenBackupDialog(const KUrl url = KUrl());
544     /** @brief Disable proxies for this project. */
545     void slotDisableProxies();
546
547     void slotElapsedTime();
548     /** @brief Open the online services search dialog. */
549     void slotDownloadResources();
550
551 signals:
552     Q_SCRIPTABLE void abortRenderJob(const QString &url);
553 };
554
555
556 #endif