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