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