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