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