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