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