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