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