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