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