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