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;
74 class KActionCollection;
76 class AbstractAudioScopeWidget;
80 class MainWindow : public KXmlGuiWindow
83 Q_CLASSINFO("D-Bus Interface", "org.kdenlive.MainWindow")
87 /** @brief Initialises the main window.
88 * @param MltPath (optional) path to MLT environment
89 * @param Url (optional) file to open
90 * @param clipsToLoad (optional) a comma separated list of clips to import in project
92 * If Url is present, it will be opened, otherwhise, if openlastproject is
93 * set, latest project will be opened. If no file is open after trying this,
94 * a default new file will be created. */
95 explicit MainWindow(const QString &MltPath = QString(),
96 const KUrl &Url = KUrl(), const QString & clipsToLoad = QString(), QWidget *parent = 0);
97 virtual ~MainWindow();
99 /** @brief Locates the MLT environment.
100 * @param mltPath (optional) path to MLT environment
102 * It tries to set the paths of the MLT profiles and renderer, using
103 * mltPath, MLT_PREFIX, searching for the binary `melt`, or asking to the
104 * user. It doesn't fill any list of profiles, while its name suggests so. */
105 void parseProfiles(const QString &mltPath = QString());
107 static EffectsList videoEffects;
108 static EffectsList audioEffects;
109 static EffectsList customEffects;
110 static EffectsList transitions;
113 /** @brief Closes the window.
114 * @return false if the user presses "Cancel" on a confirmation dialog or
115 * the operation requested (starting waiting jobs or saving file) fails,
117 virtual bool queryClose();
119 /** @brief Reports a message in the status bar when an error occurs. */
120 virtual void customEvent(QEvent *e);
122 /** @brief Enables live search in the timeline. */
123 virtual void keyPressEvent(QKeyEvent *ke);
125 /** @brief Stops the active monitor when the window gets hidden. */
126 virtual void hideEvent(QHideEvent *e);
128 /** @brief Filters key events to the live search. */
129 bool eventFilter(QObject *obj, QEvent *ev);
131 /** @brief Saves the file and the window properties when saving the session. */
132 virtual void saveProperties(KConfigGroup &config);
134 /** @brief Restores the window and the file when a session is loaded. */
135 virtual void readProperties(const KConfigGroup &config);
138 KTabWidget* m_timelineArea;
139 QProgressBar *m_statusProgressBar;
141 ScopeManager *m_scopeManager;
143 /** @brief Sets up all the actions and attaches them to the collection. */
145 KdenliveDoc *m_activeDocument;
146 TrackView *m_activeTimeline;
147 MonitorManager *m_monitorManager;
149 QDockWidget *m_projectListDock;
150 ProjectList *m_projectList;
152 QDockWidget *m_effectListDock;
153 EffectsListView *m_effectList;
154 //KListWidget *m_effectList;
156 QDockWidget *m_notesDock;
157 NotesWidget *m_notesWidget;
159 QDockWidget *m_effectStackDock;
160 EffectStackView *m_effectStack;
162 QDockWidget *m_transitionConfigDock;
163 TransitionSettings *m_transitionConfig;
165 QDockWidget *m_clipMonitorDock;
166 Monitor *m_clipMonitor;
168 QDockWidget *m_projectMonitorDock;
169 Monitor *m_projectMonitor;
171 QDockWidget *m_recMonitorDock;
172 RecMonitor *m_recMonitor;
174 QDockWidget *m_vectorscopeDock;
175 Vectorscope *m_vectorscope;
177 QDockWidget *m_waveformDock;
178 Waveform *m_waveform;
180 QDockWidget *m_RGBParadeDock;
181 RGBParade *m_RGBParade;
183 QDockWidget *m_histogramDock;
184 Histogram *m_histogram;
186 QDockWidget *m_audiosignalDock;
187 AudioSignal *m_audiosignal;
189 QDockWidget *m_audioSpectrumDock;
190 AudioSpectrum *m_audioSpectrum;
192 QDockWidget *m_spectrogramDock;
193 Spectrogram *m_spectrogram;
195 QDockWidget *m_undoViewDock;
196 QUndoView *m_undoView;
197 QUndoGroup *m_commandStack;
199 KComboBox *m_timecodeFormat;
201 /** This list holds all the scopes used in Kdenlive, allowing to manage some global settings */
202 QList <QDockWidget *> m_gfxScopesList;
204 KActionCategory *m_effectActions;
205 QMenu *m_effectsMenu;
206 QMenu *m_transitionsMenu;
207 QMenu *m_timelineContextMenu;
208 QMenu *m_timelineContextClipMenu;
209 QMenu *m_timelineContextTransitionMenu;
212 /** Actions used in the stopmotion widget */
213 KActionCategory *m_stopmotion_actions;
215 /** Action names that can be used in the slotDoAction() slot, with their i18n() names */
216 QStringList m_action_names;
219 /** @brief Shortcut to remove the focus from any element.
221 * It allows to get out of e.g. text input fields and to press another
223 QShortcut* m_shortcutRemoveFocus;
225 RenderWidget *m_renderWidget;
227 #ifdef USE_JOGSHUTTLE
228 JogShuttle *m_jogProcess;
229 JogShuttleAction* m_jogShuttle;
232 KRecentFilesAction *m_fileOpenRecent;
233 KAction *m_fileRevert;
234 KAction *m_projectSearch;
235 KAction *m_projectSearchNext;
237 KAction **m_videoEffects;
238 KAction **m_audioEffects;
239 KAction **m_customEffects;
240 KAction **m_transitions;
241 KAction *m_buttonAudioThumbs;
242 KAction *m_buttonVideoThumbs;
243 KAction *m_buttonShowMarkers;
244 KAction *m_buttonFitZoom;
245 KAction *m_buttonAutomaticSplitAudio;
246 KAction *m_normalEditTool;
247 KAction *m_overwriteEditTool;
248 KAction *m_insertEditTool;
249 KAction *m_buttonSelectTool;
250 KAction *m_buttonRazorTool;
251 KAction *m_buttonSpacerTool;
252 KAction *m_buttonSnap;
253 KAction *m_saveAction;
254 KAction *m_closeAction;
255 QSlider *m_zoomSlider;
261 KSelectAction *m_loadLayout;
262 StatusBarMessageLabel *m_messageLabel;
263 QActionGroup *m_clipTypeGroup;
264 KActionCollection *m_effectsActionCollection;
265 KActionCollection *m_tracksActionCollection;
267 bool m_findActivated;
268 QString m_findString;
273 #ifdef USE_JOGSHUTTLE
274 void activateShuttleDevice();
276 void connectDocumentInfo(KdenliveDoc *doc);
278 void doOpenFile(const KUrl &url, KAutoSaveFile *stale);
279 void recoverFiles(QList<KAutoSaveFile *> staleFiles, const KUrl &originUrl);
281 /** @brief Loads static and dynamic plugins.
283 * It scans static plugins as well as the filesystem: it doesn't load more
284 * than one plugin per file name, to avoid duplication due to conflicting
287 void populateMenus(QObject *plugin);
288 void addToMenu(QObject *plugin, const QStringList &texts,
289 QMenu *menu, const char *member,
290 QActionGroup *actionGroup);
293 /** @brief Instantiates a "Get Hot New Stuff" dialog.
294 * @param configFile configuration file for KNewStuff
295 * @return number of installed items */
296 int getNewStuff(const QString &configFile = QString());
297 QStringList m_pluginFileNames;
298 QByteArray m_timelineState;
299 void loadTranscoders();
300 void loadStabilize();
301 QPixmap createSchemePreviewIcon(const KSharedConfigPtr &config);
303 /** @brief Checks that the Kdenlive mime type is correctly installed.
304 * @param open If set to true, this will return the mimetype allowed for file opening (adds .tar.gz format)
305 * @return The mimetype */
306 QString getMimeType(bool open = true);
308 /** @brief Populates the "load layout" menu. */
311 StopmotionWidget *m_stopmotion;
315 /** @brief Prepares opening @param url.
317 * Checks if already open and whether backup exists */
318 void openFile(const KUrl &url);
319 void slotGotProgressInfo(const QString &message, int progress);
320 void slotReloadEffects();
321 Q_SCRIPTABLE void setRenderingProgress(const QString &url, int progress);
322 Q_SCRIPTABLE void setRenderingFinished(const QString &url, int status, const QString &error);
326 void newFile(bool showProjectSettings = true, bool force = false);
327 void activateDocument();
328 void connectDocument(TrackView*, KdenliveDoc*);
330 /** @brief Shows file open dialog. */
334 /** @brief Checks whether a URL is available to save to.
335 * @return Whether the file was saved. */
338 /** @brief Shows a save file dialog for saving the project.
339 * @return Whether the file was saved. */
342 /** @brief Set properties to match outputFileName and save the document.
343 * @param outputFileName The URL to save to / The document's URL.
344 * @return Whether we had success. */
345 bool saveFileAs(const QString &outputFileName);
347 /** @brief Shows the shortcut dialog. */
349 void slotPreferences(int page = -1, int option = -1);
351 /** @brief Reflects setting changes to the GUI. */
352 void updateConfiguration();
353 void slotConnectMonitors();
354 void slotUpdateClip(const QString &id);
355 void slotUpdateMousePosition(int pos);
356 void slotAddEffect(const QDomElement effect);
357 void slotEditProfiles();
358 void slotDetectAudioDriver();
359 void slotEditProjectSettings();
360 /** @brief Change current document MLT profile. */
361 void slotUpdateProjectProfile(const QString &profile);
362 void slotDisplayActionMessage(QAction *a);
364 /** @brief Turns automatic splitting of audio and video on/off. */
365 void slotSwitchSplitAudio();
366 void slotSwitchVideoThumbs();
367 void slotSwitchAudioThumbs();
368 void slotSwitchMarkersComments();
369 void slotSwitchSnap();
370 void slotRenderProject();
371 void slotFullScreen();
372 void slotUpdateDocumentState(bool modified);
374 /** @brief Sets the timeline zoom slider to @param value.
376 * Also disables zoomIn and zoomOut actions if they cannot be used at the moment. */
377 void slotSetZoom(int value);
378 /** @brief Decreases the timeline zoom level by 1. */
380 /** @brief Increases the timeline zoom level by 1. */
382 /** @brief Makes the timeline zoom level fit the timeline content. */
384 /** @brief Updates the zoom slider tooltip to fit @param zoomlevel. */
385 void slotUpdateZoomSliderToolTip(int zoomlevel);
387 /** @brief Displays the zoom slider tooltip.
388 * @param zoomlevel (optional) The zoom level to show in the tooltip.
390 * Adopted from Dolphin (src/statusbar/dolphinstatusbar.cpp) */
391 void slotShowZoomSliderToolTip(int zoomlevel = -1);
392 /** @brief Close currently opened document. Returns false if something went wrong (cannot save modifications, ...). */
393 bool closeCurrentDocument(bool saveChanges = true);
394 /** @brief Deletes item in timeline, project tree or effect stack depending on focus. */
395 void slotDeleteItem();
396 void slotAddClipMarker();
397 void slotDeleteClipMarker();
398 void slotDeleteAllClipMarkers();
399 void slotEditClipMarker();
401 /** @brief Adds marker or auide at the current position without showing the marker dialog.
403 * Adds a marker if clip monitor is active, otherwise a guide.
404 * The comment is set to the current position (therefore not dialog).
405 * This can be useful to mark something during playback. */
406 void slotAddMarkerGuideQuickly();
407 void slotCutTimelineClip();
408 void slotInsertClipOverwrite();
409 void slotSelectTimelineClip();
410 void slotSelectTimelineTransition();
411 void slotDeselectTimelineClip();
412 void slotDeselectTimelineTransition();
413 void slotSelectAddTimelineClip();
414 void slotSelectAddTimelineTransition();
415 void slotAddVideoEffect(QAction *result);
416 void slotAddTransition(QAction *result);
417 void slotAddProjectClip(KUrl url, const QString &comment = QString());
418 void slotAddProjectClipList(KUrl::List urls);
419 void slotShowClipProperties(DocClipBase *clip);
420 void slotShowClipProperties(QList <DocClipBase *>cliplist, QMap<QString, QString> commonproperties);
421 void slotActivateEffectStackView(ClipItem* item = NULL, int ix = -1, bool raise = true);
422 void slotActivateTransitionView(Transition *);
423 void slotChangeTool(QAction * action);
424 void slotChangeEdit(QAction * action);
425 void slotSetTool(PROJECTTOOL tool);
426 void slotSnapForward();
427 void slotSnapRewind();
428 void slotClipStart();
430 void slotZoneStart();
435 void slotSelectClipInTimeline();
436 void slotClipInTimeline(const QString &clipId);
438 void slotInsertSpace();
439 void slotRemoveSpace();
441 void slotEditGuide();
442 void slotDeleteGuide();
443 void slotDeleteAllGuides();
444 void slotGuidesUpdated();
448 void slotPasteEffects();
450 void slotAdjustClipMonitor();
451 void slotAdjustProjectMonitor();
452 void slotSaveZone(Render *render, QPoint zone, DocClipBase *baseClip = NULL, KUrl path = KUrl());
454 void slotSetInPoint();
455 void slotSetOutPoint();
456 void slotResizeItemStart();
457 void slotResizeItemEnd();
458 void configureNotifications();
459 void slotInsertTrack(int ix = -1);
460 void slotDeleteTrack(int ix = -1);
461 /** @brief Shows the configure tracks dialog and updates transitions afterwards. */
462 void slotConfigTrack(int ix = -1);
463 /** @brief Select all clips in active track. */
464 void slotSelectTrack();
465 /** @brief Select all clips in timeline. */
466 void slotSelectAllTracks();
467 void slotGetNewLumaStuff();
468 void slotGetNewTitleStuff();
469 void slotGetNewRenderStuff();
470 void slotGetNewMltProfileStuff();
471 void slotAutoTransition();
472 void slotRunWizard();
473 /** @brief Lets the sampleplugin create a generator. */
475 void slotZoneMoved(int start, int end);
476 void slotDvdWizard(const QString &url = QString(), const QString &profile = "dv_pal");
477 void slotGroupClips();
478 void slotUnGroupClips();
479 void slotEditItemDuration();
480 void slotClipInProjectTree();
481 //void slotClipToProjectTree();
482 void slotSplitAudio();
483 void slotUpdateClipType(QAction *action);
484 void slotShowTimeline(bool show);
485 void slotMaximizeCurrent(bool show);
486 void slotTranscode(KUrl::List urls = KUrl::List());
487 void slotStabilize();
488 void slotTranscodeClip();
489 /** @brief Archive project: creates a copy of the project file with all clips in a new folder. */
490 void slotArchiveProject();
491 void slotSetDocumentRenderProfile(QMap <QString, QString> props);
492 void slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile);
494 /** @brief Switches between displaying frames or timecode.
495 * @param ix 0 = display timecode, 1 = display frames. */
496 void slotUpdateTimecodeFormat(int ix);
498 /** @brief Removes the focus of anything. */
499 void slotRemoveFocus();
500 void slotCleanProject();
501 void slotUpdateClipMarkers(DocClipBase *clip);
504 void slotUpdateTrackInfo();
506 /** @brief Changes the color scheme. */
507 void slotChangePalette(QAction *action, const QString &themename = QString());
508 void slotSwitchMonitors();
509 void slotCheckRenderStatus();
510 void slotInsertZoneToTree();
511 void slotInsertZoneToTimeline();
513 /** @brief Deletes items from timeline and document.
514 * @param ids The ids of the clips to delete.
515 * @param folderids The names and ids of the folders to delete. */
516 void slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids);
517 void slotShowTitleBars(bool show);
518 void slotSwitchTitles();
519 /** @brief Update the capture folder if user asked a change. */
520 void slotUpdateCaptureFolder();
522 /** @brief Apply new properties to a clip */
523 void slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload);
525 /** @brief Delete a clip from current project */
526 void slotDeleteClip(const QString &id);
528 /** @brief Saves the widgets layout */
529 void slotSaveLayout(QAction*);
530 void slotLoadLayout(QAction*);
532 /** @brief The monitor informs that it needs (or not) to have frames sent by the renderer. */
533 void slotMonitorRequestRenderFrame(bool request);
534 /** @brief Open the stopmotion dialog. */
535 void slotOpenStopmotion();
536 /** @brief Implements all the actions that are int he ActionsCollection. */
537 void slotDoAction(const QString& action_name);
538 /** @brief Update project because the use of proxy clips was enabled / disabled. */
539 void slotUpdateProxySettings();
540 /** @brief Insert current project's timecode into the notes widget. */
541 void slotInsertNotesTimecode();
542 /** @brief Open the project's backupdialog. */
543 void slotOpenBackupDialog(const KUrl url = KUrl());
544 /** @brief Disable proxies for this project. */
545 void slotDisableProxies();
547 void slotElapsedTime();
548 /** @brief Open the online services search dialog. */
549 void slotDownloadResources();
552 Q_SCRIPTABLE void abortRenderJob(const QString &url);