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