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