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"
53 class EffectsListView;
54 class EffectStackView;
55 class TransitionSettings;
58 class CustomTrackView;
62 class JogShuttleAction;
63 #endif /* NO_JOGSHUTTLE */
71 class KActionCollection;
76 class MainWindow : public KXmlGuiWindow
79 Q_CLASSINFO("D-Bus Interface", "org.kdenlive.MainWindow")
83 /** @brief Initialises the main window.
84 * @param MltPath (optional) path to MLT environment
85 * @param Url (optional) file to open
86 * @param clipsToLoad (optional) a comma separated list of clips to import in project
88 * If Url is present, it will be opened, otherwhise, if openlastproject is
89 * set, latest project will be opened. If no file is open after trying this,
90 * a default new file will be created. */
91 explicit MainWindow(const QString &MltPath = QString(),
92 const KUrl &Url = KUrl(), const QString & clipsToLoad = QString(), QWidget *parent = 0);
93 virtual ~MainWindow();
95 /** @brief Locates the MLT environment.
96 * @param mltPath (optional) path to MLT environment
98 * It tries to set the paths of the MLT profiles and renderer, using
99 * mltPath, MLT_PREFIX, searching for the binary `melt`, or asking to the
100 * user. It doesn't fill any list of profiles, while its name suggests so. */
101 void parseProfiles(const QString &mltPath = QString());
103 static EffectsList videoEffects;
104 static EffectsList audioEffects;
105 static EffectsList customEffects;
106 static EffectsList transitions;
109 /** @brief Closes the window.
110 * @return false if the user presses "Cancel" on a confirmation dialog or
111 * the operation requested (starting waiting jobs or saving file) fails,
113 virtual bool queryClose();
115 /** @brief Reports a message in the status bar when an error occurs. */
116 virtual void customEvent(QEvent *e);
118 /** @brief Enables live search in the timeline. */
119 virtual void keyPressEvent(QKeyEvent *ke);
121 /** @brief Stops the active monitor when the window gets hidden. */
122 virtual void hideEvent(QHideEvent *e);
124 /** @brief Filters key events to the live search. */
125 bool eventFilter(QObject *obj, QEvent *ev);
127 /** @brief Saves the file and the window properties when saving the session. */
128 virtual void saveProperties(KConfigGroup &config);
130 /** @brief Restores the window and the file when a session is loaded. */
131 virtual void readProperties(const KConfigGroup &config);
134 KTabWidget* m_timelineArea;
135 QProgressBar *m_statusProgressBar;
137 /** @brief Sets up all the actions and attaches them to the collection. */
139 KdenliveDoc *m_activeDocument;
140 TrackView *m_activeTimeline;
141 MonitorManager *m_monitorManager;
143 QDockWidget *m_projectListDock;
144 ProjectList *m_projectList;
146 QDockWidget *m_effectListDock;
147 EffectsListView *m_effectList;
148 //KListWidget *m_effectList;
150 QDockWidget *m_notesDock;
151 KTextEdit *m_notesWidget;
153 QDockWidget *m_effectStackDock;
154 EffectStackView *m_effectStack;
156 QDockWidget *m_transitionConfigDock;
157 TransitionSettings *m_transitionConfig;
159 QDockWidget *m_clipMonitorDock;
160 Monitor *m_clipMonitor;
162 QDockWidget *m_projectMonitorDock;
163 Monitor *m_projectMonitor;
165 QDockWidget *m_recMonitorDock;
166 RecMonitor *m_recMonitor;
168 QDockWidget *m_vectorscopeDock;
169 Vectorscope *m_vectorscope;
171 QDockWidget *m_waveformDock;
172 Waveform *m_waveform;
174 QDockWidget *m_RGBParadeDock;
175 RGBParade *m_RGBParade;
177 QDockWidget *m_histogramDock;
178 Histogram *m_histogram;
180 QDockWidget *m_audiosignalDock;
181 AudioSignal *m_audiosignal;
183 QDockWidget *m_audioSpectrumDock;
184 AudioSpectrum *m_audioSpectrum;
186 QDockWidget *m_spectrogramDock;
187 Spectrogram *m_spectrogram;
189 QDockWidget *m_undoViewDock;
190 QUndoView *m_undoView;
191 QUndoGroup *m_commandStack;
193 KComboBox *m_timecodeFormat;
195 /** This list holds all the scopes used in Kdenlive, allowing to manage some global settings */
196 QList <QDockWidget *> m_scopesList;
198 QMenu *m_videoEffectsMenu;
199 QMenu *m_audioEffectsMenu;
200 QMenu *m_customEffectsMenu;
201 QMenu *m_transitionsMenu;
202 QMenu *m_timelineContextMenu;
203 QMenu *m_timelineContextClipMenu;
204 QMenu *m_timelineContextTransitionMenu;
207 /** Actions used in the stopmotion widget */
208 KActionCategory *m_stopmotion_actions;
210 /** Action names that can be used in the slotDoAction() slot, with their i18n() names */
211 QStringList m_action_names;
214 /** @brief Shortcut to remove the focus from any element.
216 * It allows to get out of e.g. text input fields and to press another
218 QShortcut* m_shortcutRemoveFocus;
220 RenderWidget *m_renderWidget;
222 #ifndef NO_JOGSHUTTLE
223 JogShuttle *m_jogProcess;
224 JogShuttleAction* m_jogShuttle;
225 #endif /* NO_JOGSHUTTLE */
227 KRecentFilesAction *m_fileOpenRecent;
228 KAction *m_fileRevert;
229 KAction *m_projectSearch;
230 KAction *m_projectSearchNext;
232 KAction **m_videoEffects;
233 KAction **m_audioEffects;
234 KAction **m_customEffects;
235 KAction **m_transitions;
236 KAction *m_buttonAudioThumbs;
237 KAction *m_buttonVideoThumbs;
238 KAction *m_buttonShowMarkers;
239 KAction *m_buttonFitZoom;
240 KAction *m_buttonAutomaticSplitAudio;
241 KAction *m_normalEditTool;
242 KAction *m_overwriteEditTool;
243 KAction *m_insertEditTool;
244 KAction *m_buttonSelectTool;
245 KAction *m_buttonRazorTool;
246 KAction *m_buttonSpacerTool;
247 KAction *m_buttonSnap;
248 KAction *m_saveAction;
249 KAction *m_closeAction;
250 QSlider *m_zoomSlider;
256 StatusBarMessageLabel *m_messageLabel;
257 QActionGroup *m_clipTypeGroup;
258 KActionCollection *m_effectsActionCollection;
260 bool m_findActivated;
261 QString m_findString;
266 #ifndef NO_JOGSHUTTLE
267 void activateShuttleDevice();
268 #endif /* NO_JOGSHUTTLE */
269 void connectDocumentInfo(KdenliveDoc *doc);
271 void doOpenFile(const KUrl &url, KAutoSaveFile *stale);
272 void recoverFiles(QList<KAutoSaveFile *> staleFiles);
274 /** @brief Loads static and dynamic plugins.
276 * It scans static plugins as well as the filesystem: it doesn't load more
277 * than one plugin per file name, to avoid duplication due to conflicting
280 void populateMenus(QObject *plugin);
281 void addToMenu(QObject *plugin, const QStringList &texts,
282 QMenu *menu, const char *member,
283 QActionGroup *actionGroup);
286 /** @brief Instantiates a "Get Hot New Stuff" dialog.
287 * @param configFile configuration file for KNewStuff
288 * @return number of installed items */
289 int getNewStuff(const QString &configFile = QString());
290 QStringList m_pluginFileNames;
291 QByteArray m_timelineState;
292 void loadTranscoders();
293 QPixmap createSchemePreviewIcon(const KSharedConfigPtr &config);
295 /** @brief Checks that the Kdenlive mime type is correctly installed.
296 * @return The mimetype */
297 QString getMimeType();
299 /** @brief Populates the "load layout" menu. */
302 StopmotionWidget *m_stopmotion;
305 /** @brief Prepares opening @param url.
307 * Checks if already open and whether backup exists */
308 void openFile(const KUrl &url);
309 void slotGotProgressInfo(const QString &message, int progress);
310 void slotReloadEffects();
311 Q_SCRIPTABLE void setRenderingProgress(const QString &url, int progress);
312 Q_SCRIPTABLE void setRenderingFinished(const QString &url, int status, const QString &error);
316 void newFile(bool showProjectSettings = true, bool force = false);
318 void activateDocument();
319 void connectDocument(TrackView*, KdenliveDoc*);
321 /** @brief Shows file open dialog. */
325 /** @brief Checks whether a URL is available to save to.
326 * @return Whether the file was saved. */
329 /** @brief Shows a save file dialog for saving the project.
330 * @return Whether the file was saved. */
333 /** @brief Set properties to match outputFileName and save the document.
334 * @param outputFileName The URL to save to / The document's URL.
335 * @return Whether we had success. */
336 bool saveFileAs(const QString &outputFileName);
338 /** @brief Shows the shortcut dialog. */
340 void slotPreferences(int page = -1, int option = -1);
342 /** @brief Reflects setting changes to the GUI. */
343 void updateConfiguration();
344 void slotConnectMonitors();
345 void slotRaiseMonitor(bool clipMonitor);
346 void slotUpdateClip(const QString &id);
347 void slotUpdateMousePosition(int pos);
348 void slotAddEffect(const QDomElement effect);
349 void slotEditProfiles();
350 void slotDetectAudioDriver();
351 void slotEditProjectSettings();
352 /** @brief Change current document MLT profile. */
353 void slotUpdateProjectProfile(const QString &profile);
354 void slotDisplayActionMessage(QAction *a);
356 /** @brief Turns automatic splitting of audio and video on/off. */
357 void slotSwitchSplitAudio();
358 void slotSwitchVideoThumbs();
359 void slotSwitchAudioThumbs();
360 void slotSwitchMarkersComments();
361 void slotSwitchSnap();
362 void slotRenderProject();
363 void slotFullScreen();
364 void slotUpdateDocumentState(bool modified);
366 /** @brief Sets the timeline zoom slider to @param value.
368 * Also disables zoomIn and zoomOut actions if they cannot be used at the moment. */
369 void slotSetZoom(int value);
370 /** @brief Decreases the timeline zoom level by 1. */
372 /** @brief Increases the timeline zoom level by 1. */
374 /** @brief Makes the timeline zoom level fit the timeline content. */
376 /** @brief Updates the zoom slider tooltip to fit @param zoomlevel. */
377 void slotUpdateZoomSliderToolTip(int zoomlevel);
379 /** @brief Displays the zoom slider tooltip.
380 * @param zoomlevel (optional) The zoom level to show in the tooltip.
382 * Adopted from Dolphin (src/statusbar/dolphinstatusbar.cpp) */
383 void slotShowZoomSliderToolTip(int zoomlevel = -1);
384 /** @brief Close currently opened document. Returns false if something went wrong (cannot save modifications, ...). */
385 bool closeCurrentDocument(bool saveChanges = true);
386 /** @brief Deletes item in timeline, project tree or effect stack depending on focus. */
387 void slotDeleteItem();
388 void slotAddClipMarker();
389 void slotDeleteClipMarker();
390 void slotDeleteAllClipMarkers();
391 void slotEditClipMarker();
393 /** @brief Adds marker or auide at the current position without showing the marker dialog.
395 * Adds a marker if clip monitor is active, otherwise a guide.
396 * The comment is set to the current position (therefore not dialog).
397 * This can be useful to mark something during playback. */
398 void slotAddMarkerGuideQuickly();
399 void slotCutTimelineClip();
400 void slotInsertClipOverwrite();
401 void slotSelectTimelineClip();
402 void slotSelectTimelineTransition();
403 void slotDeselectTimelineClip();
404 void slotDeselectTimelineTransition();
405 void slotSelectAddTimelineClip();
406 void slotSelectAddTimelineTransition();
407 void slotAddVideoEffect(QAction *result);
408 void slotAddAudioEffect(QAction *result);
409 void slotAddCustomEffect(QAction *result);
410 void slotAddTransition(QAction *result);
411 void slotAddProjectClip(KUrl url);
412 void slotShowClipProperties(DocClipBase *clip);
413 void slotShowClipProperties(QList <DocClipBase *>cliplist, QMap<QString, QString> commonproperties);
414 void slotActivateEffectStackView();
415 void slotActivateTransitionView(Transition *);
416 void slotChangeTool(QAction * action);
417 void slotChangeEdit(QAction * action);
418 void slotSetTool(PROJECTTOOL tool);
419 void slotSnapForward();
420 void slotSnapRewind();
421 void slotClipStart();
423 void slotZoneStart();
428 void slotSelectClipInTimeline();
429 void slotClipInTimeline(const QString &clipId);
431 void slotInsertSpace();
432 void slotRemoveSpace();
434 void slotEditGuide();
435 void slotDeleteGuide();
436 void slotDeleteAllGuides();
437 void slotGuidesUpdated();
441 void slotPasteEffects();
443 void slotAdjustClipMonitor();
444 void slotAdjustProjectMonitor();
445 void slotSaveZone(Render *render, QPoint zone);
447 void slotSetInPoint();
448 void slotSetOutPoint();
449 void slotResizeItemStart();
450 void slotResizeItemEnd();
451 void configureNotifications();
452 void slotInsertTrack(int ix = 0);
453 void slotDeleteTrack(int ix = 0);
454 /** @brief Shows the configure tracks dialog and updates transitions afterwards. */
455 void slotConfigTrack(int ix = -1);
456 void slotGetNewLumaStuff();
457 void slotGetNewTitleStuff();
458 void slotGetNewRenderStuff();
459 void slotGetNewMltProfileStuff();
460 void slotAutoTransition();
461 void slotRunWizard();
462 /** @brief Lets the sampleplugin create a generator. */
464 void slotZoneMoved(int start, int end);
465 void slotDvdWizard(const QString &url = QString(), const QString &profile = "dv_pal");
466 void slotGroupClips();
467 void slotUnGroupClips();
468 void slotEditItemDuration();
469 void slotClipInProjectTree();
470 //void slotClipToProjectTree();
471 void slotSplitAudio();
472 void slotUpdateClipType(QAction *action);
473 void slotShowTimeline(bool show);
474 void slotMaximizeCurrent(bool show);
475 void slotTranscode(KUrl::List urls = KUrl::List());
476 void slotTranscodeClip();
477 void slotSetDocumentRenderProfile(QMap <QString, QString> props);
478 void slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile);
480 /** @brief Switches between displaying frames or timecode.
481 * @param ix 0 = display timecode, 1 = display frames. */
482 void slotUpdateTimecodeFormat(int ix);
484 /** @brief Removes the focus of anything. */
485 void slotRemoveFocus();
486 void slotCleanProject();
487 void slotUpdateClipMarkers(DocClipBase *clip);
490 void slotUpdateTrackInfo();
492 /** @brief Changes the color scheme. */
493 void slotChangePalette(QAction *action, const QString &themename = QString());
494 void slotSwitchMonitors();
495 void slotCheckRenderStatus();
496 void slotInsertZoneToTree();
497 void slotInsertZoneToTimeline();
499 /** @brief Deletes items from timeline and document.
500 * @param ids The ids of the clips to delete.
501 * @param folderids The names and ids of the folders to delete. */
502 void slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids);
503 void slotShowTitleBars(bool show);
504 void slotSwitchTitles();
505 /** @brief Update the capture folder if user asked a change. */
506 void slotUpdateCaptureFolder();
508 /** @brief Apply new properties to a clip */
509 void slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload);
511 /** @brief Delete a clip from current project */
512 void slotDeleteClip(const QString &id);
514 /** @brief Saves the widgets layout */
515 void slotSaveLayout(QAction*);
516 void slotLoadLayout(QAction*);
518 /** @brief The monitor informs that it needs (or not) to have frames sent by the renderer. */
519 void slotMonitorRequestRenderFrame(bool request);
520 /** @brief Check if someone needs the render frame sent. */
521 void slotUpdateScopeFrameRequest();
522 /** @brief Check if someone needs the render frame sent. */
523 void slotDoUpdateScopeFrameRequest();
524 /** @brief When switching between monitors, update the visible scopes. */
525 void slotUpdateColorScopes();
526 /** @brief Switch current monitor to fullscreen. */
527 void slotSwitchFullscreen();
528 /** @brief Open the stopmotion dialog. */
529 void slotOpenStopmotion();
530 /** @brief Implements all the actions that are int he ActionsCollection. */
531 void slotDoAction(const QString& action_name);
534 Q_SCRIPTABLE void abortRenderJob(const QString &url);