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