]> git.sesse.net Git - kdenlive/blob - src/mainwindow.h
Fix "save zone" saving proxy instead of real clip:
[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 #include <KActionCategory>
41
42 #include "effectslist.h"
43 #include "gentime.h"
44 #include "definitions.h"
45 #include "statusbarmessagelabel.h"
46 #include "dvdwizard.h"
47 #include "stopmotion/stopmotion.h"
48 #include "noteswidget.h"
49 #include "ui_backupdialog_ui.h"
50
51 class KdenliveDoc;
52 class TrackView;
53 class MonitorManager;
54 class ProjectList;
55 class EffectsListView;
56 class EffectStackView;
57 class TransitionSettings;
58 class Monitor;
59 class RecMonitor;
60 class CustomTrackView;
61 class RenderWidget;
62 #ifndef NO_JOGSHUTTLE
63 class JogShuttle;
64 class JogShuttleAction;
65 #endif /* NO_JOGSHUTTLE */
66 class DocClipBase;
67 class Render;
68 class Transition;
69 class Histogram;
70 class Vectorscope;
71 class Waveform;
72 class RGBParade;
73 class KActionCollection;
74 class AudioSignal;
75 class AbstractAudioScopeWidget;
76 class AudioSpectrum;
77 class Spectrogram;
78
79 class MainWindow : public KXmlGuiWindow
80 {
81     Q_OBJECT
82     Q_CLASSINFO("D-Bus Interface", "org.kdenlive.MainWindow")
83
84 public:
85
86     /** @brief Initialises the main window.
87      * @param MltPath (optional) path to MLT environment
88      * @param Url (optional) file to open
89      * @param clipsToLoad (optional) a comma separated list of clips to import in project
90      *
91      * If Url is present, it will be opened, otherwhise, if openlastproject is
92      * set, latest project will be opened. If no file is open after trying this,
93      * a default new file will be created. */
94     explicit MainWindow(const QString &MltPath = QString(),
95                         const KUrl &Url = KUrl(), const QString & clipsToLoad = QString(), QWidget *parent = 0);
96     virtual ~MainWindow();
97
98     /** @brief Locates the MLT environment.
99      * @param mltPath (optional) path to MLT environment
100      *
101      * It tries to set the paths of the MLT profiles and renderer, using
102      * mltPath, MLT_PREFIX, searching for the binary `melt`, or asking to the
103      * user. It doesn't fill any list of profiles, while its name suggests so. */
104     void parseProfiles(const QString &mltPath = QString());
105
106     static EffectsList videoEffects;
107     static EffectsList audioEffects;
108     static EffectsList customEffects;
109     static EffectsList transitions;
110 protected:
111
112     /** @brief Closes the window.
113      * @return false if the user presses "Cancel" on a confirmation dialog or
114      *     the operation requested (starting waiting jobs or saving file) fails,
115      *     true otherwise */
116     virtual bool queryClose();
117
118     /** @brief Reports a message in the status bar when an error occurs. */
119     virtual void customEvent(QEvent *e);
120
121     /** @brief Enables live search in the timeline. */
122     virtual void keyPressEvent(QKeyEvent *ke);
123
124     /** @brief Stops the active monitor when the window gets hidden. */
125     virtual void hideEvent(QHideEvent *e);
126
127     /** @brief Filters key events to the live search. */
128     bool eventFilter(QObject *obj, QEvent *ev);
129
130     /** @brief Saves the file and the window properties when saving the session. */
131     virtual void saveProperties(KConfigGroup &config);
132
133     /** @brief Restores the window and the file when a session is loaded. */
134     virtual void readProperties(const KConfigGroup &config);
135
136 private:
137     KTabWidget* m_timelineArea;
138     QProgressBar *m_statusProgressBar;
139
140     /** @brief Sets up all the actions and attaches them to the collection. */
141     void setupActions();
142     KdenliveDoc *m_activeDocument;
143     TrackView *m_activeTimeline;
144     MonitorManager *m_monitorManager;
145
146     QDockWidget *m_projectListDock;
147     ProjectList *m_projectList;
148
149     QDockWidget *m_effectListDock;
150     EffectsListView *m_effectList;
151     //KListWidget *m_effectList;
152
153     QDockWidget *m_notesDock;
154     NotesWidget *m_notesWidget;
155
156     QDockWidget *m_effectStackDock;
157     EffectStackView *m_effectStack;
158
159     QDockWidget *m_transitionConfigDock;
160     TransitionSettings *m_transitionConfig;
161
162     QDockWidget *m_clipMonitorDock;
163     Monitor *m_clipMonitor;
164
165     QDockWidget *m_projectMonitorDock;
166     Monitor *m_projectMonitor;
167
168     QDockWidget *m_recMonitorDock;
169     RecMonitor *m_recMonitor;
170
171     QDockWidget *m_vectorscopeDock;
172     Vectorscope *m_vectorscope;
173
174     QDockWidget *m_waveformDock;
175     Waveform *m_waveform;
176
177     QDockWidget *m_RGBParadeDock;
178     RGBParade *m_RGBParade;
179
180     QDockWidget *m_histogramDock;
181     Histogram *m_histogram;
182
183     QDockWidget *m_audiosignalDock;
184     AudioSignal *m_audiosignal;
185
186     QDockWidget *m_audioSpectrumDock;
187     AudioSpectrum *m_audioSpectrum;
188
189     QDockWidget *m_spectrogramDock;
190     Spectrogram *m_spectrogram;
191
192     QDockWidget *m_undoViewDock;
193     QUndoView *m_undoView;
194     QUndoGroup *m_commandStack;
195
196     KComboBox *m_timecodeFormat;
197
198     /** This list holds all the scopes used in Kdenlive, allowing to manage some global settings */
199     QList <QDockWidget *> m_gfxScopesList;
200     QList <AbstractAudioScopeWidget *> m_audioScopesList;
201
202     KActionCategory *m_effectActions;
203     QMenu *m_effectsMenu;
204     QMenu *m_transitionsMenu;
205     QMenu *m_timelineContextMenu;
206     QMenu *m_timelineContextClipMenu;
207     QMenu *m_timelineContextTransitionMenu;
208     KUrl m_startUrl;
209
210     /** Actions used in the stopmotion widget */
211     KActionCategory *m_stopmotion_actions;
212     
213     /** Action names that can be used in the slotDoAction() slot, with their i18n() names */
214     QStringList m_action_names;
215
216
217     /** @brief Shortcut to remove the focus from any element.
218      *
219      * It allows to get out of e.g. text input fields and to press another
220      * shortcut. */
221     QShortcut* m_shortcutRemoveFocus;
222
223     RenderWidget *m_renderWidget;
224
225 #ifndef NO_JOGSHUTTLE
226     JogShuttle *m_jogProcess;
227     JogShuttleAction* m_jogShuttle;
228 #endif /* NO_JOGSHUTTLE */
229
230     KRecentFilesAction *m_fileOpenRecent;
231     KAction *m_fileRevert;
232     KAction *m_projectSearch;
233     KAction *m_projectSearchNext;
234
235     KAction **m_videoEffects;
236     KAction **m_audioEffects;
237     KAction **m_customEffects;
238     KAction **m_transitions;
239     KAction *m_buttonAudioThumbs;
240     KAction *m_buttonVideoThumbs;
241     KAction *m_buttonShowMarkers;
242     KAction *m_buttonFitZoom;
243     KAction *m_buttonAutomaticSplitAudio;
244     KAction *m_normalEditTool;
245     KAction *m_overwriteEditTool;
246     KAction *m_insertEditTool;
247     KAction *m_buttonSelectTool;
248     KAction *m_buttonRazorTool;
249     KAction *m_buttonSpacerTool;
250     KAction *m_buttonSnap;
251     KAction *m_saveAction;
252     KAction *m_closeAction;
253     QSlider *m_zoomSlider;
254     KAction *m_zoomIn;
255     KAction *m_zoomOut;
256     KAction *m_loopZone;
257     KAction *m_playZone;
258     KAction *m_loopClip;
259     KSelectAction *m_loadLayout;
260     StatusBarMessageLabel *m_messageLabel;
261     QActionGroup *m_clipTypeGroup;
262     KActionCollection *m_effectsActionCollection;
263
264     bool m_findActivated;
265     QString m_findString;
266     QTimer m_findTimer;
267
268     void readOptions();
269     void saveOptions();
270 #ifndef NO_JOGSHUTTLE
271     void activateShuttleDevice();
272 #endif /* NO_JOGSHUTTLE */
273     void connectDocumentInfo(KdenliveDoc *doc);
274     void findAhead();
275     void doOpenFile(const KUrl &url, KAutoSaveFile *stale);
276     void recoverFiles(QList<KAutoSaveFile *> staleFiles);
277
278     /** @brief Loads static and dynamic plugins.
279      *
280      * It scans static plugins as well as the filesystem: it doesn't load more
281      * than one plugin per file name, to avoid duplication due to conflicting
282      * installations. */
283     void loadPlugins();
284     void populateMenus(QObject *plugin);
285     void addToMenu(QObject *plugin, const QStringList &texts,
286                    QMenu *menu, const char *member,
287                    QActionGroup *actionGroup);
288     void aboutPlugins();
289
290     /** @brief Instantiates a "Get Hot New Stuff" dialog.
291      * @param configFile configuration file for KNewStuff
292      * @return number of installed items */
293     int getNewStuff(const QString &configFile = QString());
294     QStringList m_pluginFileNames;
295     QByteArray m_timelineState;
296     void loadTranscoders();
297     QPixmap createSchemePreviewIcon(const KSharedConfigPtr &config);
298
299     /** @brief Checks that the Kdenlive mime type is correctly installed.
300     * @param open If set to true, this will return the mimetype allowed for file opening (adds .tar.gz format)
301     * @return The mimetype */
302     QString getMimeType(bool open = true);
303
304     /** @brief Populates the "load layout" menu. */
305     void loadLayouts();
306
307     StopmotionWidget *m_stopmotion;
308
309 public slots:
310     /** @brief Prepares opening @param url.
311     *
312     * Checks if already open and whether backup exists */
313     void openFile(const KUrl &url);
314     void slotGotProgressInfo(const QString &message, int progress);
315     void slotReloadEffects();
316     Q_SCRIPTABLE void setRenderingProgress(const QString &url, int progress);
317     Q_SCRIPTABLE void setRenderingFinished(const QString &url, int status, const QString &error);
318
319
320 private slots:
321     void newFile(bool showProjectSettings = true, bool force = false);
322     void activateDocument();
323     void connectDocument(TrackView*, KdenliveDoc*);
324
325     /** @brief Shows file open dialog. */
326     void openFile();
327     void openLastFile();
328
329     /** @brief Checks whether a URL is available to save to.
330     * @return Whether the file was saved. */
331     bool saveFile();
332
333     /** @brief Shows a save file dialog for saving the project.
334     * @return Whether the file was saved. */
335     bool saveFileAs();
336
337     /** @brief Set properties to match outputFileName and save the document.
338     * @param outputFileName The URL to save to / The document's URL.
339     * @return Whether we had success. */
340     bool saveFileAs(const QString &outputFileName);
341
342     /** @brief Shows the shortcut dialog. */
343     void slotEditKeys();
344     void slotPreferences(int page = -1, int option = -1);
345
346     /** @brief Reflects setting changes to the GUI. */
347     void updateConfiguration();
348     void slotConnectMonitors();
349     void slotRaiseMonitor(AbstractMonitor *monitor);
350     void slotUpdateClip(const QString &id);
351     void slotUpdateMousePosition(int pos);
352     void slotAddEffect(const QDomElement effect);
353     void slotEditProfiles();
354     void slotDetectAudioDriver();
355     void slotEditProjectSettings();
356     /** @brief Change current document MLT profile. */
357     void slotUpdateProjectProfile(const QString &profile);
358     void slotDisplayActionMessage(QAction *a);
359
360     /** @brief Turns automatic splitting of audio and video on/off. */
361     void slotSwitchSplitAudio();
362     void slotSwitchVideoThumbs();
363     void slotSwitchAudioThumbs();
364     void slotSwitchMarkersComments();
365     void slotSwitchSnap();
366     void slotRenderProject();
367     void slotFullScreen();
368     void slotUpdateDocumentState(bool modified);
369
370     /** @brief Sets the timeline zoom slider to @param value.
371     *
372     * Also disables zoomIn and zoomOut actions if they cannot be used at the moment. */
373     void slotSetZoom(int value);
374     /** @brief Decreases the timeline zoom level by 1. */
375     void slotZoomIn();
376     /** @brief Increases the timeline zoom level by 1. */
377     void slotZoomOut();
378     /** @brief Makes the timeline zoom level fit the timeline content. */
379     void slotFitZoom();
380     /** @brief Updates the zoom slider tooltip to fit @param zoomlevel. */
381     void slotUpdateZoomSliderToolTip(int zoomlevel);
382
383     /** @brief Displays the zoom slider tooltip.
384     * @param zoomlevel (optional) The zoom level to show in the tooltip.
385     *
386     * Adopted from Dolphin (src/statusbar/dolphinstatusbar.cpp) */
387     void slotShowZoomSliderToolTip(int zoomlevel = -1);
388     /** @brief Close currently opened document. Returns false if something went wrong (cannot save modifications, ...). */
389     bool closeCurrentDocument(bool saveChanges = true);
390     /** @brief Deletes item in timeline, project tree or effect stack depending on focus. */
391     void slotDeleteItem();
392     void slotAddClipMarker();
393     void slotDeleteClipMarker();
394     void slotDeleteAllClipMarkers();
395     void slotEditClipMarker();
396
397     /** @brief Adds marker or auide at the current position without showing the marker dialog.
398      *
399      * Adds a marker if clip monitor is active, otherwise a guide.
400      * The comment is set to the current position (therefore not dialog).
401      * This can be useful to mark something during playback. */
402     void slotAddMarkerGuideQuickly();
403     void slotCutTimelineClip();
404     void slotInsertClipOverwrite();
405     void slotSelectTimelineClip();
406     void slotSelectTimelineTransition();
407     void slotDeselectTimelineClip();
408     void slotDeselectTimelineTransition();
409     void slotSelectAddTimelineClip();
410     void slotSelectAddTimelineTransition();
411     void slotAddVideoEffect(QAction *result);
412     void slotAddTransition(QAction *result);
413     void slotAddProjectClip(KUrl url);
414     void slotShowClipProperties(DocClipBase *clip);
415     void slotShowClipProperties(QList <DocClipBase *>cliplist, QMap<QString, QString> commonproperties);
416     void slotActivateEffectStackView(ClipItem* item = NULL, int ix = -1, bool raise = true);
417     void slotActivateTransitionView(Transition *);
418     void slotChangeTool(QAction * action);
419     void slotChangeEdit(QAction * action);
420     void slotSetTool(PROJECTTOOL tool);
421     void slotSnapForward();
422     void slotSnapRewind();
423     void slotClipStart();
424     void slotClipEnd();
425     void slotZoneStart();
426     void slotZoneEnd();
427     void slotFind();
428     void findTimeout();
429     void slotFindNext();
430     void slotSelectClipInTimeline();
431     void slotClipInTimeline(const QString &clipId);
432
433     void slotInsertSpace();
434     void slotRemoveSpace();
435     void slotAddGuide();
436     void slotEditGuide();
437     void slotDeleteGuide();
438     void slotDeleteAllGuides();
439     void slotGuidesUpdated();
440
441     void slotCopy();
442     void slotPaste();
443     void slotPasteEffects();
444
445     void slotAdjustClipMonitor();
446     void slotAdjustProjectMonitor();
447     void slotSaveZone(Render *render, QPoint zone, DocClipBase *baseClip = NULL, KUrl path = KUrl());
448
449     void slotSetInPoint();
450     void slotSetOutPoint();
451     void slotResizeItemStart();
452     void slotResizeItemEnd();
453     void configureNotifications();
454     void slotInsertTrack(int ix = 0);
455     void slotDeleteTrack(int ix = 0);
456     /** @brief Shows the configure tracks dialog and updates transitions afterwards. */
457     void slotConfigTrack(int ix = -1);
458     void slotGetNewLumaStuff();
459     void slotGetNewTitleStuff();
460     void slotGetNewRenderStuff();
461     void slotGetNewMltProfileStuff();
462     void slotAutoTransition();
463     void slotRunWizard();
464     /** @brief Lets the sampleplugin create a generator.  */
465     void generateClip();
466     void slotZoneMoved(int start, int end);
467     void slotDvdWizard(const QString &url = QString(), const QString &profile = "dv_pal");
468     void slotGroupClips();
469     void slotUnGroupClips();
470     void slotEditItemDuration();
471     void slotClipInProjectTree();
472     //void slotClipToProjectTree();
473     void slotSplitAudio();
474     void slotUpdateClipType(QAction *action);
475     void slotShowTimeline(bool show);
476     void slotMaximizeCurrent(bool show);
477     void slotTranscode(KUrl::List urls = KUrl::List());
478     void slotTranscodeClip();
479     /** @brief Archive project: creates a copy of the project file with all clips in a new folder. */
480     void slotArchiveProject();
481     void slotSetDocumentRenderProfile(QMap <QString, QString> props);
482     void slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile);
483
484     /** @brief Switches between displaying frames or timecode.
485     * @param ix 0 = display timecode, 1 = display frames. */
486     void slotUpdateTimecodeFormat(int ix);
487
488     /** @brief Removes the focus of anything. */
489     void slotRemoveFocus();
490     void slotCleanProject();
491     void slotUpdateClipMarkers(DocClipBase *clip);
492     void slotRevert();
493     void slotShutdown();
494     void slotUpdateTrackInfo();
495
496     /** @brief Changes the color scheme. */
497     void slotChangePalette(QAction *action, const QString &themename = QString());
498     void slotSwitchMonitors();
499     void slotCheckRenderStatus();
500     void slotInsertZoneToTree();
501     void slotInsertZoneToTimeline();
502
503     /** @brief Deletes items from timeline and document.
504     * @param ids The ids of the clips to delete.
505     * @param folderids The names and ids of the folders to delete. */
506     void slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids);
507     void slotShowTitleBars(bool show);
508     void slotSwitchTitles();
509     /** @brief Update the capture folder if user asked a change. */
510     void slotUpdateCaptureFolder();
511
512     /** @brief Apply new properties to a clip */
513     void slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload);
514
515     /** @brief Delete a clip from current project */
516     void slotDeleteClip(const QString &id);
517
518     /** @brief Saves the widgets layout */
519     void slotSaveLayout(QAction*);
520     void slotLoadLayout(QAction*);
521
522     /** @brief The monitor informs that it needs (or not) to have frames sent by the renderer. */
523     void slotMonitorRequestRenderFrame(bool request);
524     /** @brief Check if someone needs the render frame sent. */
525     void slotUpdateGfxScopeFrameRequest();
526     /** @brief Check if someone needs the render frame sent. */
527     void slotDoUpdateGfxScopeFrameRequest();
528     void slotUpdateAudioScopeFrameRequest();
529     void slotDoUpdateAudioScopeFrameRequest();
530     /** @brief When switching between monitors, update the visible scopes. */
531     void slotUpdateColorScopes();
532     /** @brief Active monitor deleted, clear scopes. */
533     void slotClearColorScopes();
534     /** @brief Switch current monitor to fullscreen. */
535     void slotSwitchFullscreen();
536     /** @brief Open the stopmotion dialog. */
537     void slotOpenStopmotion();
538     /** @brief Implements all the actions that are int he ActionsCollection. */
539     void slotDoAction(const QString& action_name);
540     /** @brief Update project because the use of proxy clips was enabled / disabled. */
541     void slotUpdateProxySettings();
542     /** @brief Insert current project's timecode into the notes widget. */
543     void slotInsertNotesTimecode();
544     /** @brief Open the project's backupdialog. */
545     void slotOpenBackupDialog(const KUrl url = KUrl());
546
547 signals:
548     Q_SCRIPTABLE void abortRenderJob(const QString &url);
549 };
550
551
552 #endif