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"
48 #include "noteswidget.h"
49 #include "ui_backupdialog_ui.h"
55 class EffectsListView;
56 class EffectStackView;
57 class EffectStackView2;
58 class TransitionSettings;
61 class CustomTrackView;
65 class JogShuttleAction;
75 class KActionCollection;
77 class AbstractAudioScopeWidget;
81 class MainWindow : public KXmlGuiWindow
84 Q_CLASSINFO("D-Bus Interface", "org.kdenlive.MainWindow")
88 /** @brief Initialises the main window.
89 * @param MltPath (optional) path to MLT environment
90 * @param Url (optional) file to open
91 * @param clipsToLoad (optional) a comma separated list of clips to import in project
93 * If Url is present, it will be opened, otherwhise, if openlastproject is
94 * set, latest project will be opened. If no file is open after trying this,
95 * a default new file will be created. */
96 explicit MainWindow(const QString &MltPath = QString(),
97 const KUrl &Url = KUrl(), const QString & clipsToLoad = QString(), QWidget *parent = 0);
98 virtual ~MainWindow();
100 /** @brief Locates the MLT environment.
101 * @param mltPath (optional) path to MLT environment
103 * It tries to set the paths of the MLT profiles and renderer, using
104 * mltPath, MLT_PREFIX, searching for the binary `melt`, or asking to the
105 * user. It doesn't fill any list of profiles, while its name suggests so. */
106 void parseProfiles(const QString &mltPath = QString());
108 static EffectsList videoEffects;
109 static EffectsList audioEffects;
110 static EffectsList customEffects;
111 static EffectsList transitions;
114 /** @brief Closes the window.
115 * @return false if the user presses "Cancel" on a confirmation dialog or
116 * the operation requested (starting waiting jobs or saving file) fails,
118 virtual bool queryClose();
120 /** @brief Reports a message in the status bar when an error occurs. */
121 virtual void customEvent(QEvent *e);
123 /** @brief Enables live search in the timeline. */
124 virtual void keyPressEvent(QKeyEvent *ke);
126 /** @brief Stops the active monitor when the window gets hidden. */
127 virtual void hideEvent(QHideEvent *e);
129 /** @brief Filters key events to the live search. */
130 bool eventFilter(QObject *obj, QEvent *ev);
132 /** @brief Saves the file and the window properties when saving the session. */
133 virtual void saveProperties(KConfigGroup &config);
135 /** @brief Restores the window and the file when a session is loaded. */
136 virtual void readProperties(const KConfigGroup &config);
139 KTabWidget* m_timelineArea;
140 QProgressBar *m_statusProgressBar;
142 ScopeManager *m_scopeManager;
144 /** @brief Sets up all the actions and attaches them to the collection. */
146 KdenliveDoc *m_activeDocument;
147 TrackView *m_activeTimeline;
148 MonitorManager *m_monitorManager;
150 QDockWidget *m_projectListDock;
151 ProjectList *m_projectList;
153 QDockWidget *m_effectListDock;
154 EffectsListView *m_effectList;
155 //KListWidget *m_effectList;
157 QDockWidget *m_notesDock;
158 NotesWidget *m_notesWidget;
160 QDockWidget *m_effectStackDock;
161 EffectStackView2 *m_effectStack;
163 QDockWidget *m_transitionConfigDock;
164 TransitionSettings *m_transitionConfig;
166 QDockWidget *m_clipMonitorDock;
167 Monitor *m_clipMonitor;
169 QDockWidget *m_projectMonitorDock;
170 Monitor *m_projectMonitor;
172 QDockWidget *m_recMonitorDock;
173 RecMonitor *m_recMonitor;
175 QDockWidget *m_vectorscopeDock;
176 Vectorscope *m_vectorscope;
178 QDockWidget *m_waveformDock;
179 Waveform *m_waveform;
181 QDockWidget *m_RGBParadeDock;
182 RGBParade *m_RGBParade;
184 QDockWidget *m_histogramDock;
185 Histogram *m_histogram;
187 QDockWidget *m_audiosignalDock;
188 AudioSignal *m_audiosignal;
190 QDockWidget *m_audioSpectrumDock;
191 AudioSpectrum *m_audioSpectrum;
193 QDockWidget *m_spectrogramDock;
194 Spectrogram *m_spectrogram;
196 QDockWidget *m_undoViewDock;
197 QUndoView *m_undoView;
198 QUndoGroup *m_commandStack;
200 KComboBox *m_timecodeFormat;
202 /** This list holds all the scopes used in Kdenlive, allowing to manage some global settings */
203 QList <QDockWidget *> m_gfxScopesList;
205 KActionCategory *m_effectActions;
206 QMenu *m_effectsMenu;
207 QMenu *m_transitionsMenu;
208 QMenu *m_timelineContextMenu;
209 QMenu *m_timelineContextClipMenu;
210 QMenu *m_timelineContextTransitionMenu;
213 /** Actions used in the stopmotion widget */
214 KActionCategory *m_stopmotion_actions;
216 /** Action names that can be used in the slotDoAction() slot, with their i18n() names */
217 QStringList m_action_names;
220 /** @brief Shortcut to remove the focus from any element.
222 * It allows to get out of e.g. text input fields and to press another
224 QShortcut* m_shortcutRemoveFocus;
226 RenderWidget *m_renderWidget;
228 #ifdef USE_JOGSHUTTLE
229 JogShuttle *m_jogProcess;
230 JogShuttleAction* m_jogShuttle;
233 KRecentFilesAction *m_fileOpenRecent;
234 KAction *m_fileRevert;
235 KAction *m_projectSearch;
236 KAction *m_projectSearchNext;
238 KAction **m_videoEffects;
239 KAction **m_audioEffects;
240 KAction **m_customEffects;
241 KAction **m_transitions;
242 KAction *m_buttonAudioThumbs;
243 KAction *m_buttonVideoThumbs;
244 KAction *m_buttonShowMarkers;
245 KAction *m_buttonFitZoom;
246 KAction *m_buttonAutomaticSplitAudio;
247 KAction *m_normalEditTool;
248 KAction *m_overwriteEditTool;
249 KAction *m_insertEditTool;
250 KAction *m_buttonSelectTool;
251 KAction *m_buttonRazorTool;
252 KAction *m_buttonSpacerTool;
253 KAction *m_buttonSnap;
254 KAction *m_saveAction;
255 KAction *m_closeAction;
256 QSlider *m_zoomSlider;
262 KSelectAction *m_loadLayout;
263 StatusBarMessageLabel *m_messageLabel;
264 QActionGroup *m_clipTypeGroup;
265 KActionCollection *m_effectsActionCollection;
266 KActionCollection *m_tracksActionCollection;
268 bool m_findActivated;
269 QString m_findString;
274 #ifdef USE_JOGSHUTTLE
275 void activateShuttleDevice();
277 void connectDocumentInfo(KdenliveDoc *doc);
279 void doOpenFile(const KUrl &url, KAutoSaveFile *stale);
280 void recoverFiles(QList<KAutoSaveFile *> staleFiles, const KUrl &originUrl);
282 /** @brief Loads static and dynamic plugins.
284 * It scans static plugins as well as the filesystem: it doesn't load more
285 * than one plugin per file name, to avoid duplication due to conflicting
288 void populateMenus(QObject *plugin);
289 void addToMenu(QObject *plugin, const QStringList &texts,
290 QMenu *menu, const char *member,
291 QActionGroup *actionGroup);
294 /** @brief Instantiates a "Get Hot New Stuff" dialog.
295 * @param configFile configuration file for KNewStuff
296 * @return number of installed items */
297 int getNewStuff(const QString &configFile = QString());
298 QStringList m_pluginFileNames;
299 QByteArray m_timelineState;
300 void loadTranscoders();
301 void loadStabilize();
302 QPixmap createSchemePreviewIcon(const KSharedConfigPtr &config);
304 /** @brief Checks that the Kdenlive mime type is correctly installed.
305 * @param open If set to true, this will return the mimetype allowed for file opening (adds .tar.gz format)
306 * @return The mimetype */
307 QString getMimeType(bool open = true);
309 /** @brief Populates the "load layout" menu. */
312 StopmotionWidget *m_stopmotion;
315 /** @brief Update statusbar stylesheet (in case of color theme change). */
316 void setStatusBarStyleSheet(const QPalette &p);
319 /** @brief Prepares opening @param url.
321 * Checks if already open and whether backup exists */
322 void openFile(const KUrl &url);
323 void slotGotProgressInfo(const QString &message, int progress);
324 void slotReloadEffects();
325 Q_SCRIPTABLE void setRenderingProgress(const QString &url, int progress);
326 Q_SCRIPTABLE void setRenderingFinished(const QString &url, int status, const QString &error);
330 void newFile(bool showProjectSettings = true, bool force = false);
331 void activateDocument();
332 void connectDocument(TrackView*, KdenliveDoc*);
334 /** @brief Shows file open dialog. */
338 /** @brief Checks whether a URL is available to save to.
339 * @return Whether the file was saved. */
342 /** @brief Shows a save file dialog for saving the project.
343 * @return Whether the file was saved. */
346 /** @brief Set properties to match outputFileName and save the document.
347 * @param outputFileName The URL to save to / The document's URL.
348 * @return Whether we had success. */
349 bool saveFileAs(const QString &outputFileName);
351 /** @brief Shows the shortcut dialog. */
353 void slotPreferences(int page = -1, int option = -1);
355 /** @brief Reflects setting changes to the GUI. */
356 void updateConfiguration();
357 void slotConnectMonitors();
358 void slotUpdateClip(const QString &id);
359 void slotUpdateMousePosition(int pos);
360 void slotAddEffect(const QDomElement effect);
361 void slotEditProfiles();
362 void slotDetectAudioDriver();
363 void slotEditProjectSettings();
364 /** @brief Change current document MLT profile. */
365 void slotUpdateProjectProfile(const QString &profile);
366 void slotDisplayActionMessage(QAction *a);
368 /** @brief Turns automatic splitting of audio and video on/off. */
369 void slotSwitchSplitAudio();
370 void slotSwitchVideoThumbs();
371 void slotSwitchAudioThumbs();
372 void slotSwitchMarkersComments();
373 void slotSwitchSnap();
374 void slotRenderProject();
375 void slotFullScreen();
376 void slotUpdateDocumentState(bool modified);
378 /** @brief Sets the timeline zoom slider to @param value.
380 * Also disables zoomIn and zoomOut actions if they cannot be used at the moment. */
381 void slotSetZoom(int value);
382 /** @brief Decreases the timeline zoom level by 1. */
384 /** @brief Increases the timeline zoom level by 1. */
386 /** @brief Makes the timeline zoom level fit the timeline content. */
388 /** @brief Updates the zoom slider tooltip to fit @param zoomlevel. */
389 void slotUpdateZoomSliderToolTip(int zoomlevel);
391 /** @brief Displays the zoom slider tooltip.
392 * @param zoomlevel (optional) The zoom level to show in the tooltip.
394 * Adopted from Dolphin (src/statusbar/dolphinstatusbar.cpp) */
395 void slotShowZoomSliderToolTip(int zoomlevel = -1);
396 /** @brief Close currently opened document. Returns false if something went wrong (cannot save modifications, ...). */
397 bool closeCurrentDocument(bool saveChanges = true);
398 /** @brief Deletes item in timeline, project tree or effect stack depending on focus. */
399 void slotDeleteItem();
400 void slotAddClipMarker();
401 void slotDeleteClipMarker();
402 void slotDeleteAllClipMarkers();
403 void slotEditClipMarker();
405 /** @brief Adds marker or auide at the current position without showing the marker dialog.
407 * Adds a marker if clip monitor is active, otherwise a guide.
408 * The comment is set to the current position (therefore not dialog).
409 * This can be useful to mark something during playback. */
410 void slotAddMarkerGuideQuickly();
411 void slotCutTimelineClip();
412 void slotInsertClipOverwrite();
413 void slotSelectTimelineClip();
414 void slotSelectTimelineTransition();
415 void slotDeselectTimelineClip();
416 void slotDeselectTimelineTransition();
417 void slotSelectAddTimelineClip();
418 void slotSelectAddTimelineTransition();
419 void slotAddVideoEffect(QAction *result);
420 void slotAddTransition(QAction *result);
421 void slotAddProjectClip(KUrl url, const QString &comment = QString());
422 void slotAddProjectClipList(KUrl::List urls);
423 void slotShowClipProperties(DocClipBase *clip);
424 void slotShowClipProperties(QList <DocClipBase *>cliplist, QMap<QString, QString> commonproperties);
425 void slotActivateEffectStackView(ClipItem* item = NULL, int ix = -1, bool raise = true);
426 void slotActivateTransitionView(Transition *);
427 void slotChangeTool(QAction * action);
428 void slotChangeEdit(QAction * action);
429 void slotSetTool(PROJECTTOOL tool);
430 void slotSnapForward();
431 void slotSnapRewind();
432 void slotClipStart();
434 void slotZoneStart();
439 void slotSelectClipInTimeline();
440 void slotClipInTimeline(const QString &clipId);
442 void slotInsertSpace();
443 void slotRemoveSpace();
445 void slotEditGuide();
446 void slotDeleteGuide();
447 void slotDeleteAllGuides();
448 void slotGuidesUpdated();
452 void slotPasteEffects();
454 void slotAdjustClipMonitor();
455 void slotAdjustProjectMonitor();
456 void slotSaveZone(Render *render, QPoint zone, DocClipBase *baseClip = NULL, KUrl path = KUrl());
458 void slotSetInPoint();
459 void slotSetOutPoint();
460 void slotResizeItemStart();
461 void slotResizeItemEnd();
462 void configureNotifications();
463 void slotInsertTrack(int ix = -1);
464 void slotDeleteTrack(int ix = -1);
465 /** @brief Shows the configure tracks dialog and updates transitions afterwards. */
466 void slotConfigTrack(int ix = -1);
467 /** @brief Select all clips in active track. */
468 void slotSelectTrack();
469 /** @brief Select all clips in timeline. */
470 void slotSelectAllTracks();
471 void slotGetNewLumaStuff();
472 void slotGetNewTitleStuff();
473 void slotGetNewRenderStuff();
474 void slotGetNewMltProfileStuff();
475 void slotAutoTransition();
476 void slotRunWizard();
477 /** @brief Lets the sampleplugin create a generator. */
479 void slotZoneMoved(int start, int end);
480 void slotDvdWizard(const QString &url = QString(), const QString &profile = "dv_pal");
481 void slotGroupClips();
482 void slotUnGroupClips();
483 void slotEditItemDuration();
484 void slotClipInProjectTree();
485 //void slotClipToProjectTree();
486 void slotSplitAudio();
487 void slotUpdateClipType(QAction *action);
488 void slotShowTimeline(bool show);
489 void slotMaximizeCurrent(bool show);
490 void slotTranscode(KUrl::List urls = KUrl::List());
491 void slotStabilize();
492 void slotTranscodeClip();
493 /** @brief Archive project: creates a copy of the project file with all clips in a new folder. */
494 void slotArchiveProject();
495 void slotSetDocumentRenderProfile(QMap <QString, QString> props);
496 void slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile);
498 /** @brief Switches between displaying frames or timecode.
499 * @param ix 0 = display timecode, 1 = display frames. */
500 void slotUpdateTimecodeFormat(int ix);
502 /** @brief Removes the focus of anything. */
503 void slotRemoveFocus();
504 void slotCleanProject();
505 void slotUpdateClipMarkers(DocClipBase *clip);
508 void slotUpdateTrackInfo();
510 /** @brief Changes the color scheme. */
511 void slotChangePalette(QAction *action, const QString &themename = QString());
512 void slotSwitchMonitors();
513 void slotCheckRenderStatus();
514 void slotInsertZoneToTree();
515 void slotInsertZoneToTimeline();
517 /** @brief Deletes items from timeline and document.
518 * @param ids The ids of the clips to delete.
519 * @param folderids The names and ids of the folders to delete. */
520 void slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids);
521 void slotShowTitleBars(bool show);
522 void slotSwitchTitles();
523 /** @brief Update the capture folder if user asked a change. */
524 void slotUpdateCaptureFolder();
526 /** @brief Apply new properties to a clip */
527 void slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload);
529 /** @brief Delete a clip from current project */
530 void slotDeleteClip(const QString &id);
532 /** @brief Saves the widgets layout */
533 void slotSaveLayout(QAction*);
534 void slotLoadLayout(QAction*);
536 /** @brief The monitor informs that it needs (or not) to have frames sent by the renderer. */
537 void slotMonitorRequestRenderFrame(bool request);
538 /** @brief Open the stopmotion dialog. */
539 void slotOpenStopmotion();
540 /** @brief Implements all the actions that are int he ActionsCollection. */
541 void slotDoAction(const QString& action_name);
542 /** @brief Update project because the use of proxy clips was enabled / disabled. */
543 void slotUpdateProxySettings();
544 /** @brief Insert current project's timecode into the notes widget. */
545 void slotInsertNotesTimecode();
546 /** @brief Open the project's backupdialog. */
547 void slotOpenBackupDialog(const KUrl url = KUrl());
548 /** @brief Disable proxies for this project. */
549 void slotDisableProxies();
551 void slotElapsedTime();
552 /** @brief Open the online services search dialog. */
553 void slotDownloadResources();
555 void slotChangePalette();
558 Q_SCRIPTABLE void abortRenderJob(const QString &url);