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