1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
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. *
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. *
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 ***************************************************************************/
24 #include <QDockWidget>
27 #include <QProgressBar>
32 #include <KXmlGuiWindow>
34 #include <KListWidget>
37 #include <KRecentFilesAction>
39 #include <kautosavefile.h>
40 #include <KActionCategory>
42 #include "effectslist.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"
55 class EffectsListView;
56 class EffectStackView;
57 class TransitionSettings;
60 class CustomTrackView;
64 class JogShuttleAction;
65 #endif /* NO_JOGSHUTTLE */
73 class KActionCollection;
75 class AbstractAudioScopeWidget;
79 class MainWindow : public KXmlGuiWindow
82 Q_CLASSINFO("D-Bus Interface", "org.kdenlive.MainWindow")
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
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();
98 /** @brief Locates the MLT environment.
99 * @param mltPath (optional) path to MLT environment
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());
106 static EffectsList videoEffects;
107 static EffectsList audioEffects;
108 static EffectsList customEffects;
109 static EffectsList transitions;
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,
116 virtual bool queryClose();
118 /** @brief Reports a message in the status bar when an error occurs. */
119 virtual void customEvent(QEvent *e);
121 /** @brief Enables live search in the timeline. */
122 virtual void keyPressEvent(QKeyEvent *ke);
124 /** @brief Stops the active monitor when the window gets hidden. */
125 virtual void hideEvent(QHideEvent *e);
127 /** @brief Filters key events to the live search. */
128 bool eventFilter(QObject *obj, QEvent *ev);
130 /** @brief Saves the file and the window properties when saving the session. */
131 virtual void saveProperties(KConfigGroup &config);
133 /** @brief Restores the window and the file when a session is loaded. */
134 virtual void readProperties(const KConfigGroup &config);
137 KTabWidget* m_timelineArea;
138 QProgressBar *m_statusProgressBar;
140 /** @brief Sets up all the actions and attaches them to the collection. */
142 KdenliveDoc *m_activeDocument;
143 TrackView *m_activeTimeline;
144 MonitorManager *m_monitorManager;
146 QDockWidget *m_projectListDock;
147 ProjectList *m_projectList;
149 QDockWidget *m_effectListDock;
150 EffectsListView *m_effectList;
151 //KListWidget *m_effectList;
153 QDockWidget *m_notesDock;
154 NotesWidget *m_notesWidget;
156 QDockWidget *m_effectStackDock;
157 EffectStackView *m_effectStack;
159 QDockWidget *m_transitionConfigDock;
160 TransitionSettings *m_transitionConfig;
162 QDockWidget *m_clipMonitorDock;
163 Monitor *m_clipMonitor;
165 QDockWidget *m_projectMonitorDock;
166 Monitor *m_projectMonitor;
168 QDockWidget *m_recMonitorDock;
169 RecMonitor *m_recMonitor;
171 QDockWidget *m_vectorscopeDock;
172 Vectorscope *m_vectorscope;
174 QDockWidget *m_waveformDock;
175 Waveform *m_waveform;
177 QDockWidget *m_RGBParadeDock;
178 RGBParade *m_RGBParade;
180 QDockWidget *m_histogramDock;
181 Histogram *m_histogram;
183 QDockWidget *m_audiosignalDock;
184 AudioSignal *m_audiosignal;
186 QDockWidget *m_audioSpectrumDock;
187 AudioSpectrum *m_audioSpectrum;
189 QDockWidget *m_spectrogramDock;
190 Spectrogram *m_spectrogram;
192 QDockWidget *m_undoViewDock;
193 QUndoView *m_undoView;
194 QUndoGroup *m_commandStack;
196 KComboBox *m_timecodeFormat;
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;
202 KActionCategory *m_effectActions;
203 QMenu *m_effectsMenu;
204 QMenu *m_transitionsMenu;
205 QMenu *m_timelineContextMenu;
206 QMenu *m_timelineContextClipMenu;
207 QMenu *m_timelineContextTransitionMenu;
210 /** Actions used in the stopmotion widget */
211 KActionCategory *m_stopmotion_actions;
213 /** Action names that can be used in the slotDoAction() slot, with their i18n() names */
214 QStringList m_action_names;
217 /** @brief Shortcut to remove the focus from any element.
219 * It allows to get out of e.g. text input fields and to press another
221 QShortcut* m_shortcutRemoveFocus;
223 RenderWidget *m_renderWidget;
225 #ifndef NO_JOGSHUTTLE
226 JogShuttle *m_jogProcess;
227 JogShuttleAction* m_jogShuttle;
228 #endif /* NO_JOGSHUTTLE */
230 KRecentFilesAction *m_fileOpenRecent;
231 KAction *m_fileRevert;
232 KAction *m_projectSearch;
233 KAction *m_projectSearchNext;
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;
259 KSelectAction *m_loadLayout;
260 StatusBarMessageLabel *m_messageLabel;
261 QActionGroup *m_clipTypeGroup;
262 KActionCollection *m_effectsActionCollection;
264 bool m_findActivated;
265 QString m_findString;
270 #ifndef NO_JOGSHUTTLE
271 void activateShuttleDevice();
272 #endif /* NO_JOGSHUTTLE */
273 void connectDocumentInfo(KdenliveDoc *doc);
275 void doOpenFile(const KUrl &url, KAutoSaveFile *stale);
276 void recoverFiles(QList<KAutoSaveFile *> staleFiles);
278 /** @brief Loads static and dynamic plugins.
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
284 void populateMenus(QObject *plugin);
285 void addToMenu(QObject *plugin, const QStringList &texts,
286 QMenu *menu, const char *member,
287 QActionGroup *actionGroup);
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);
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);
304 /** @brief Populates the "load layout" menu. */
307 StopmotionWidget *m_stopmotion;
311 /** @brief Prepares opening @param url.
313 * Checks if already open and whether backup exists */
314 void openFile(const KUrl &url);
315 void slotGotProgressInfo(const QString &message, int progress);
316 void slotReloadEffects();
317 Q_SCRIPTABLE void setRenderingProgress(const QString &url, int progress);
318 Q_SCRIPTABLE void setRenderingFinished(const QString &url, int status, const QString &error);
322 void newFile(bool showProjectSettings = true, bool force = false);
323 void activateDocument();
324 void connectDocument(TrackView*, KdenliveDoc*);
326 /** @brief Shows file open dialog. */
330 /** @brief Checks whether a URL is available to save to.
331 * @return Whether the file was saved. */
334 /** @brief Shows a save file dialog for saving the project.
335 * @return Whether the file was saved. */
338 /** @brief Set properties to match outputFileName and save the document.
339 * @param outputFileName The URL to save to / The document's URL.
340 * @return Whether we had success. */
341 bool saveFileAs(const QString &outputFileName);
343 /** @brief Shows the shortcut dialog. */
345 void slotPreferences(int page = -1, int option = -1);
347 /** @brief Reflects setting changes to the GUI. */
348 void updateConfiguration();
349 void slotConnectMonitors();
350 void slotRaiseMonitor(AbstractMonitor *monitor);
351 void slotUpdateClip(const QString &id);
352 void slotUpdateMousePosition(int pos);
353 void slotAddEffect(const QDomElement effect);
354 void slotEditProfiles();
355 void slotDetectAudioDriver();
356 void slotEditProjectSettings();
357 /** @brief Change current document MLT profile. */
358 void slotUpdateProjectProfile(const QString &profile);
359 void slotDisplayActionMessage(QAction *a);
361 /** @brief Turns automatic splitting of audio and video on/off. */
362 void slotSwitchSplitAudio();
363 void slotSwitchVideoThumbs();
364 void slotSwitchAudioThumbs();
365 void slotSwitchMarkersComments();
366 void slotSwitchSnap();
367 void slotRenderProject();
368 void slotFullScreen();
369 void slotUpdateDocumentState(bool modified);
371 /** @brief Sets the timeline zoom slider to @param value.
373 * Also disables zoomIn and zoomOut actions if they cannot be used at the moment. */
374 void slotSetZoom(int value);
375 /** @brief Decreases the timeline zoom level by 1. */
377 /** @brief Increases the timeline zoom level by 1. */
379 /** @brief Makes the timeline zoom level fit the timeline content. */
381 /** @brief Updates the zoom slider tooltip to fit @param zoomlevel. */
382 void slotUpdateZoomSliderToolTip(int zoomlevel);
384 /** @brief Displays the zoom slider tooltip.
385 * @param zoomlevel (optional) The zoom level to show in the tooltip.
387 * Adopted from Dolphin (src/statusbar/dolphinstatusbar.cpp) */
388 void slotShowZoomSliderToolTip(int zoomlevel = -1);
389 /** @brief Close currently opened document. Returns false if something went wrong (cannot save modifications, ...). */
390 bool closeCurrentDocument(bool saveChanges = true);
391 /** @brief Deletes item in timeline, project tree or effect stack depending on focus. */
392 void slotDeleteItem();
393 void slotAddClipMarker();
394 void slotDeleteClipMarker();
395 void slotDeleteAllClipMarkers();
396 void slotEditClipMarker();
398 /** @brief Adds marker or auide at the current position without showing the marker dialog.
400 * Adds a marker if clip monitor is active, otherwise a guide.
401 * The comment is set to the current position (therefore not dialog).
402 * This can be useful to mark something during playback. */
403 void slotAddMarkerGuideQuickly();
404 void slotCutTimelineClip();
405 void slotInsertClipOverwrite();
406 void slotSelectTimelineClip();
407 void slotSelectTimelineTransition();
408 void slotDeselectTimelineClip();
409 void slotDeselectTimelineTransition();
410 void slotSelectAddTimelineClip();
411 void slotSelectAddTimelineTransition();
412 void slotAddVideoEffect(QAction *result);
413 void slotAddTransition(QAction *result);
414 void slotAddProjectClip(KUrl url);
415 void slotShowClipProperties(DocClipBase *clip);
416 void slotShowClipProperties(QList <DocClipBase *>cliplist, QMap<QString, QString> commonproperties);
417 void slotActivateEffectStackView(ClipItem* item = NULL, int ix = -1, bool raise = true);
418 void slotActivateTransitionView(Transition *);
419 void slotChangeTool(QAction * action);
420 void slotChangeEdit(QAction * action);
421 void slotSetTool(PROJECTTOOL tool);
422 void slotSnapForward();
423 void slotSnapRewind();
424 void slotClipStart();
426 void slotZoneStart();
431 void slotSelectClipInTimeline();
432 void slotClipInTimeline(const QString &clipId);
434 void slotInsertSpace();
435 void slotRemoveSpace();
437 void slotEditGuide();
438 void slotDeleteGuide();
439 void slotDeleteAllGuides();
440 void slotGuidesUpdated();
444 void slotPasteEffects();
446 void slotAdjustClipMonitor();
447 void slotAdjustProjectMonitor();
448 void slotSaveZone(Render *render, QPoint zone, DocClipBase *baseClip = NULL, KUrl path = KUrl());
450 void slotSetInPoint();
451 void slotSetOutPoint();
452 void slotResizeItemStart();
453 void slotResizeItemEnd();
454 void configureNotifications();
455 void slotInsertTrack(int ix = 0);
456 void slotDeleteTrack(int ix = 0);
457 /** @brief Shows the configure tracks dialog and updates transitions afterwards. */
458 void slotConfigTrack(int ix = -1);
459 void slotGetNewLumaStuff();
460 void slotGetNewTitleStuff();
461 void slotGetNewRenderStuff();
462 void slotGetNewMltProfileStuff();
463 void slotAutoTransition();
464 void slotRunWizard();
465 /** @brief Lets the sampleplugin create a generator. */
467 void slotZoneMoved(int start, int end);
468 void slotDvdWizard(const QString &url = QString(), const QString &profile = "dv_pal");
469 void slotGroupClips();
470 void slotUnGroupClips();
471 void slotEditItemDuration();
472 void slotClipInProjectTree();
473 //void slotClipToProjectTree();
474 void slotSplitAudio();
475 void slotUpdateClipType(QAction *action);
476 void slotShowTimeline(bool show);
477 void slotMaximizeCurrent(bool show);
478 void slotTranscode(KUrl::List urls = KUrl::List());
479 void slotTranscodeClip();
480 /** @brief Archive project: creates a copy of the project file with all clips in a new folder. */
481 void slotArchiveProject();
482 void slotSetDocumentRenderProfile(QMap <QString, QString> props);
483 void slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile);
485 /** @brief Switches between displaying frames or timecode.
486 * @param ix 0 = display timecode, 1 = display frames. */
487 void slotUpdateTimecodeFormat(int ix);
489 /** @brief Removes the focus of anything. */
490 void slotRemoveFocus();
491 void slotCleanProject();
492 void slotUpdateClipMarkers(DocClipBase *clip);
495 void slotUpdateTrackInfo();
497 /** @brief Changes the color scheme. */
498 void slotChangePalette(QAction *action, const QString &themename = QString());
499 void slotSwitchMonitors();
500 void slotCheckRenderStatus();
501 void slotInsertZoneToTree();
502 void slotInsertZoneToTimeline();
504 /** @brief Deletes items from timeline and document.
505 * @param ids The ids of the clips to delete.
506 * @param folderids The names and ids of the folders to delete. */
507 void slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids);
508 void slotShowTitleBars(bool show);
509 void slotSwitchTitles();
510 /** @brief Update the capture folder if user asked a change. */
511 void slotUpdateCaptureFolder();
513 /** @brief Apply new properties to a clip */
514 void slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload);
516 /** @brief Delete a clip from current project */
517 void slotDeleteClip(const QString &id);
519 /** @brief Saves the widgets layout */
520 void slotSaveLayout(QAction*);
521 void slotLoadLayout(QAction*);
523 /** @brief The monitor informs that it needs (or not) to have frames sent by the renderer. */
524 void slotMonitorRequestRenderFrame(bool request);
525 /** @brief Check if someone needs the render frame sent. */
526 void slotUpdateGfxScopeFrameRequest();
527 /** @brief Check if someone needs the render frame sent. */
528 void slotDoUpdateGfxScopeFrameRequest();
529 void slotUpdateAudioScopeFrameRequest();
530 void slotDoUpdateAudioScopeFrameRequest();
531 /** @brief When switching between monitors, update the visible scopes. */
532 void slotUpdateColorScopes();
533 /** @brief Active monitor deleted, clear scopes. */
534 void slotClearColorScopes();
535 /** @brief Switch current monitor to fullscreen. */
536 void slotSwitchFullscreen();
537 /** @brief Open the stopmotion dialog. */
538 void slotOpenStopmotion();
539 /** @brief Implements all the actions that are int he ActionsCollection. */
540 void slotDoAction(const QString& action_name);
541 /** @brief Update project because the use of proxy clips was enabled / disabled. */
542 void slotUpdateProxySettings();
543 /** @brief Insert current project's timecode into the notes widget. */
544 void slotInsertNotesTimecode();
545 /** @brief Open the project's backupdialog. */
546 void slotOpenBackupDialog(const KUrl url = KUrl());
547 /** @brief Make sure to block clip monitor before deleting a clip's producer. */
548 void slotBlockClipMonitor(const QString id);
549 /** @brief Disable proxies for this project. */
550 void slotDisableProxies();
552 void slotElapsedTime();
555 Q_SCRIPTABLE void abortRenderJob(const QString &url);