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