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