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