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
82 * If Url is present, it will be opened, otherwhise, if openlastproject is
83 * set, latest project will be opened. If no file is open after trying this,
84 * a default new file will be created. */
85 explicit MainWindow(const QString &MltPath = QString(),
86 const KUrl &Url = KUrl(), QWidget *parent = 0);
87 virtual ~MainWindow();
89 /** @brief Locates the MLT environment.
90 * @param mltPath (optional) path to MLT environment
92 * It tries to set the paths of the MLT profiles and renderer, using
93 * mltPath, MLT_PREFIX, searching for the binary `melt`, or asking to the
94 * user. It doesn't fill any list of profiles, while its name suggests so. */
95 void parseProfiles(const QString &mltPath = QString());
97 static EffectsList videoEffects;
98 static EffectsList audioEffects;
99 static EffectsList customEffects;
100 static EffectsList transitions;
103 /** @brief Closes the window.
104 * @return false if the user presses "Cancel" on a confirmation dialog or
105 * the operation requested (starting waiting jobs or saving file) fails,
107 virtual bool queryClose();
109 /** @brief Reports a message in the status bar when an error occurs. */
110 virtual void customEvent(QEvent *e);
112 /** @brief Enables live search in the timeline. */
113 virtual void keyPressEvent(QKeyEvent *ke);
115 /** @brief Stops the active monitor when the window gets hidden. */
116 virtual void hideEvent(QHideEvent *e);
118 /** @brief Filters key events to the live search. */
119 bool eventFilter(QObject *obj, QEvent *ev);
121 /** @brief Saves the file and the window properties when saving the session. */
122 virtual void saveProperties(KConfigGroup &config);
124 /** @brief Restores the window and the file when a session is loaded. */
125 virtual void readProperties(const KConfigGroup &config);
128 KTabWidget* m_timelineArea;
129 QProgressBar *m_statusProgressBar;
131 /** @brief Sets up all the actions and attaches them to the collection. */
133 KdenliveDoc *m_activeDocument;
134 TrackView *m_activeTimeline;
135 MonitorManager *m_monitorManager;
137 QDockWidget *m_projectListDock;
138 ProjectList *m_projectList;
140 QDockWidget *m_effectListDock;
141 EffectsListView *m_effectList;
142 //KListWidget *m_effectList;
144 QDockWidget *m_effectStackDock;
145 EffectStackView *m_effectStack;
147 QDockWidget *m_transitionConfigDock;
148 TransitionSettings *m_transitionConfig;
150 QDockWidget *m_clipMonitorDock;
151 Monitor *m_clipMonitor;
153 QDockWidget *m_projectMonitorDock;
154 Monitor *m_projectMonitor;
156 QDockWidget *m_recMonitorDock;
157 RecMonitor *m_recMonitor;
159 QDockWidget *m_vectorscopeDock;
160 Vectorscope *m_vectorscope;
162 QDockWidget *m_waveformDock;
163 Waveform *m_waveform;
165 QDockWidget *m_RGBParadeDock;
166 RGBParade *m_RGBParade;
168 QDockWidget *m_histogramDock;
169 Histogram *m_histogram;
171 QDockWidget *m_undoViewDock;
172 QUndoView *m_undoView;
173 QUndoGroup *m_commandStack;
175 KComboBox *m_timecodeFormat;
177 /** This list holds all the scopes used in Kdenlive, allowing to manage some global settings */
178 QList <QDockWidget *> m_scopesList;
180 QMenu *m_videoEffectsMenu;
181 QMenu *m_audioEffectsMenu;
182 QMenu *m_customEffectsMenu;
183 QMenu *m_transitionsMenu;
184 QMenu *m_timelineContextMenu;
185 QMenu *m_timelineContextClipMenu;
186 QMenu *m_timelineContextTransitionMenu;
189 /** @brief Shortcut to remove the focus from any element.
191 * It allows to get out of e.g. text input fields and to press another
193 QShortcut* m_shortcutRemoveFocus;
195 RenderWidget *m_renderWidget;
197 #ifndef NO_JOGSHUTTLE
198 JogShuttle *m_jogProcess;
199 #endif /* NO_JOGSHUTTLE */
201 KRecentFilesAction *m_fileOpenRecent;
202 KAction *m_fileRevert;
203 KAction *m_projectSearch;
204 KAction *m_projectSearchNext;
206 KAction **m_videoEffects;
207 KAction **m_audioEffects;
208 KAction **m_customEffects;
209 KAction **m_transitions;
210 KAction *m_buttonAudioThumbs;
211 KAction *m_buttonVideoThumbs;
212 KAction *m_buttonShowMarkers;
213 KAction *m_buttonFitZoom;
214 KAction *m_buttonAutomaticSplitAudio;
215 KAction *m_normalEditTool;
216 KAction *m_overwriteEditTool;
217 KAction *m_insertEditTool;
218 KAction *m_buttonSelectTool;
219 KAction *m_buttonRazorTool;
220 KAction *m_buttonSpacerTool;
221 KAction *m_buttonSnap;
222 KAction *m_saveAction;
223 KAction *m_closeAction;
224 QSlider *m_zoomSlider;
229 StatusBarMessageLabel *m_messageLabel;
230 QActionGroup *m_clipTypeGroup;
231 KActionCollection *m_effectsActionCollection;
233 bool m_findActivated;
234 QString m_findString;
239 #ifndef NO_JOGSHUTTLE
240 void activateShuttleDevice();
241 void slotShuttleAction(int code);
242 #endif /* NO_JOGSHUTTLE */
243 void connectDocumentInfo(KdenliveDoc *doc);
245 void doOpenFile(const KUrl &url, KAutoSaveFile *stale);
246 void recoverFiles(QList<KAutoSaveFile *> staleFiles);
248 /** @brief Loads static and dynamic plugins.
250 * It scans static plugins as well as the filesystem: it doesn't load more
251 * than one plugin per file name, to avoid duplication due to conflicting
254 void populateMenus(QObject *plugin);
255 void addToMenu(QObject *plugin, const QStringList &texts,
256 QMenu *menu, const char *member,
257 QActionGroup *actionGroup);
260 /** @brief Instantiates a "Get Hot New Stuff" dialog.
261 * @param configFile configuration file for KNewStuff
262 * @return number of installed items */
263 int getNewStuff(const QString &configFile = QString());
264 QStringList m_pluginFileNames;
265 QByteArray m_timelineState;
266 void loadTranscoders();
267 QPixmap createSchemePreviewIcon(const KSharedConfigPtr &config);
269 /** @brief Checks that the Kdenlive mime type is correctly installed.
270 * @return The mimetype */
271 QString getMimeType();
274 /** @brief Prepares opening @param url.
276 * Checks if already open and whether backup exists */
277 void openFile(const KUrl &url);
278 void slotGotProgressInfo(const QString &message, int progress);
279 Q_SCRIPTABLE void setRenderingProgress(const QString &url, int progress);
280 Q_SCRIPTABLE void setRenderingFinished(const QString &url, int status, const QString &error);
283 void newFile(bool showProjectSettings = true, bool force = false);
285 void activateDocument();
286 void connectDocument(TrackView*, KdenliveDoc*);
288 /** @brief Shows file open dialog. */
292 /** @brief Checks whether a URL is available to save to.
293 * @return Whether the file was saved. */
296 /** @brief Shows a save file dialog for saving the project.
297 * @return Whether the file was saved. */
300 /** @brief Set properties to match outputFileName and save the document.
301 * @param outputFileName The URL to save to / The document's URL.
302 * @return Whether we had success. */
303 bool saveFileAs(const QString &outputFileName);
305 /** @brief Shows the shortcut dialog. */
307 void slotPreferences(int page = -1, int option = -1);
309 /** @brief Reflects setting changes to the GUI. */
310 void updateConfiguration();
311 void slotConnectMonitors();
312 void slotRaiseMonitor(bool clipMonitor);
313 void slotUpdateClip(const QString &id);
314 void slotUpdateMousePosition(int pos);
315 void slotAddEffect(const QDomElement effect);
316 void slotEditProfiles();
317 void slotDetectAudioDriver();
318 void slotEditProjectSettings();
319 void slotDisplayActionMessage(QAction *a);
321 /** @brief Turns automatic splitting of audio and video on/off. */
322 void slotSwitchSplitAudio();
323 void slotSwitchVideoThumbs();
324 void slotSwitchAudioThumbs();
325 void slotSwitchMarkersComments();
326 void slotSwitchSnap();
327 void slotRenderProject();
328 void slotFullScreen();
329 void slotUpdateDocumentState(bool modified);
331 /** @brief Sets the timeline zoom slider to @param value.
333 * Also disables zoomIn and zoomOut actions if they cannot be used at the moment. */
334 void slotSetZoom(int value);
335 /** @brief Decreases the timeline zoom level by 1. */
337 /** @brief Increases the timeline zoom level by 1. */
339 /** @brief Makes the timeline zoom level fit the timeline content. */
341 /** @brief Updates the zoom slider tooltip to fit @param zoomlevel. */
342 void slotUpdateZoomSliderToolTip(int zoomlevel);
344 /** @brief Displays the zoom slider tooltip.
345 * @param zoomlevel (optional) The zoom level to show in the tooltip.
347 * Adopted from Dolphin (src/statusbar/dolphinstatusbar.cpp) */
348 void slotShowZoomSliderToolTip(int zoomlevel = -1);
349 /** @brief Close currently opened document. Returns false if something went wrong (cannot save modifications, ...). */
350 bool closeCurrentDocument(bool saveChanges = true);
351 /** @brief Deletes item in timeline, project tree or effect stack depending on focus. */
352 void slotDeleteItem();
353 void slotAddClipMarker();
354 void slotDeleteClipMarker();
355 void slotDeleteAllClipMarkers();
356 void slotEditClipMarker();
357 void slotCutTimelineClip();
358 void slotInsertClipOverwrite();
359 void slotSelectTimelineClip();
360 void slotSelectTimelineTransition();
361 void slotDeselectTimelineClip();
362 void slotDeselectTimelineTransition();
363 void slotSelectAddTimelineClip();
364 void slotSelectAddTimelineTransition();
365 void slotAddVideoEffect(QAction *result);
366 void slotAddAudioEffect(QAction *result);
367 void slotAddCustomEffect(QAction *result);
368 void slotAddTransition(QAction *result);
369 void slotAddProjectClip(KUrl url);
370 #ifndef NO_JOGSHUTTLE
371 void slotShuttleButton(int code);
372 #endif /* NO_JOGSHUTTLE */
373 void slotShowClipProperties(DocClipBase *clip);
374 void slotShowClipProperties(QList <DocClipBase *>cliplist, QMap<QString, QString> commonproperties);
375 void slotActivateEffectStackView();
376 void slotActivateTransitionView(Transition *);
377 void slotChangeTool(QAction * action);
378 void slotChangeEdit(QAction * action);
379 void slotSetTool(PROJECTTOOL tool);
380 void slotSnapForward();
381 void slotSnapRewind();
382 void slotClipStart();
384 void slotZoneStart();
389 void slotSelectClipInTimeline();
390 void slotClipInTimeline(const QString &clipId);
392 void slotInsertSpace();
393 void slotRemoveSpace();
395 void slotEditGuide();
396 void slotDeleteGuide();
397 void slotDeleteAllGuides();
398 void slotGuidesUpdated();
402 void slotPasteEffects();
403 void slotReloadEffects();
405 void slotAdjustClipMonitor();
406 void slotAdjustProjectMonitor();
407 void slotSaveZone(Render *render, QPoint zone);
409 void slotSetInPoint();
410 void slotSetOutPoint();
411 void slotResizeItemStart();
412 void slotResizeItemEnd();
413 void configureNotifications();
414 void slotInsertTrack(int ix = 0);
415 void slotDeleteTrack(int ix = 0);
416 /** @brief Shows the configure tracks dialog and updates transitions afterwards. */
417 void slotConfigTrack(int ix = -1);
418 void slotGetNewLumaStuff();
419 void slotGetNewTitleStuff();
420 void slotGetNewRenderStuff();
421 void slotGetNewMltProfileStuff();
422 void slotAutoTransition();
423 void slotRunWizard();
424 /** @brief Lets the sampleplugin create a generator. */
426 void slotZoneMoved(int start, int end);
427 void slotUpdatePreviewSettings();
428 void slotDvdWizard(const QString &url = QString(), const QString &profile = "dv_pal");
429 void slotGroupClips();
430 void slotUnGroupClips();
431 void slotEditItemDuration();
432 void slotClipInProjectTree();
433 //void slotClipToProjectTree();
434 void slotSplitAudio();
435 void slotUpdateClipType(QAction *action);
436 void slotShowTimeline(bool show);
437 void slotMaximizeCurrent(bool show);
438 void slotTranscode(KUrl::List urls = KUrl::List());
439 void slotTranscodeClip();
440 void slotSetDocumentRenderProfile(QMap <QString, QString> props);
441 void slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile);
443 /** @brief Switches between displaying frames or timecode.
444 * @param ix 0 = display timecode, 1 = display frames. */
445 void slotUpdateTimecodeFormat(int ix);
447 /** @brief Removes the focus of anything. */
448 void slotRemoveFocus();
449 void slotCleanProject();
450 void slotUpdateClipMarkers(DocClipBase *clip);
453 void slotUpdateTrackInfo();
455 /** @brief Changes the color scheme. */
456 void slotChangePalette(QAction *action, const QString &themename = QString());
457 void slotSwitchMonitors();
458 void slotCheckRenderStatus();
459 void slotInsertZoneToTree();
460 void slotInsertZoneToTimeline();
462 /** @brief Deletes items from timeline and document.
463 * @param ids The ids of the clips to delete.
464 * @param folderids The names and ids of the folders to delete. */
465 void slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids);
466 void slotShowTitleBars(bool show);
467 void slotSwitchTitles();
469 /** @brief The monitor informs that it needs (or not) to have frames sent by the renderer. */
470 void slotMonitorRequestRenderFrame(bool request);
471 /** @brief Check if someone needs the render frame sent. */
472 void slotUpdateScopeFrameRequest();
473 /** @brief Check if someone needs the render frame sent. */
474 void slotDoUpdateScopeFrameRequest();
475 /** @brief When switching between monitors, update the visible scopes. */
476 void slotUpdateColorScopes();
479 Q_SCRIPTABLE void abortRenderJob(const QString &url);