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