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