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