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;
70 class MainWindow : public KXmlGuiWindow
73 Q_CLASSINFO("D-Bus Interface", "org.kdenlive.MainWindow")
77 /** @brief Initialises the main window.
78 * @param MltPath (optional) path to MLT environment
79 * @param Url (optional) file to open
81 * If Url is present, it will be opened, otherwhise, if openlastproject is
82 * set, latest project will be opened. If no file is open after trying this,
83 * a default new file will be created. */
84 explicit MainWindow(const QString &MltPath = QString(),
85 const KUrl &Url = KUrl(), QWidget *parent = 0);
86 virtual ~MainWindow();
88 /** @brief Locates the MLT environment.
89 * @param mltPath (optional) path to MLT environment
91 * It tries to set the paths of the MLT profiles and renderer, using
92 * mltPath, MLT_PREFIX, searching for the binary `melt`, or asking to the
93 * user. It doesn't fill any list of profiles, while its name suggests so. */
94 void parseProfiles(const QString &mltPath = QString());
96 static EffectsList videoEffects;
97 static EffectsList audioEffects;
98 static EffectsList customEffects;
99 static EffectsList transitions;
102 /** @brief Closes the window.
103 * @return false if the user presses "Cancel" on a confirmation dialog or
104 * the operation requested (starting waiting jobs or saving file) fails,
106 virtual bool queryClose();
108 /** @brief Reports a message in the status bar when an error occurs. */
109 virtual void customEvent(QEvent *e);
111 /** @brief Enables live search in the timeline. */
112 virtual void keyPressEvent(QKeyEvent *ke);
114 /** @brief Stops the active monitor when the window gets hidden. */
115 virtual void hideEvent(QHideEvent *e);
117 /** @brief Filters key events to the live search. */
118 bool eventFilter(QObject *obj, QEvent *ev);
120 /** @brief Saves the file and the window properties when saving the session. */
121 virtual void saveProperties(KConfigGroup &config);
123 /** @brief Restores the window and the file when a session is loaded. */
124 virtual void readProperties(const KConfigGroup &config);
127 KTabWidget* m_timelineArea;
128 QProgressBar *m_statusProgressBar;
130 /** @brief Sets up all the actions and attaches them to the collection. */
132 KdenliveDoc *m_activeDocument;
133 TrackView *m_activeTimeline;
134 MonitorManager *m_monitorManager;
136 QDockWidget *m_projectListDock;
137 ProjectList *m_projectList;
139 QDockWidget *m_effectListDock;
140 EffectsListView *m_effectList;
141 //KListWidget *m_effectList;
143 QDockWidget *m_effectStackDock;
144 EffectStackView *m_effectStack;
146 QDockWidget *m_transitionConfigDock;
147 TransitionSettings *m_transitionConfig;
149 QDockWidget *m_clipMonitorDock;
150 Monitor *m_clipMonitor;
152 QDockWidget *m_projectMonitorDock;
153 Monitor *m_projectMonitor;
155 QDockWidget *m_recMonitorDock;
156 RecMonitor *m_recMonitor;
158 QDockWidget *m_vectorscopeDock;
159 Vectorscope *m_vectorscope;
161 QDockWidget *m_waveformDock;
162 Waveform *m_waveform;
164 QDockWidget *m_RGBParadeDock;
165 RGBParade *m_RGBParade;
167 QDockWidget *m_histogramDock;
168 Histogram *m_histogram;
170 QDockWidget *m_undoViewDock;
171 QUndoView *m_undoView;
172 QUndoGroup *m_commandStack;
174 KComboBox *m_timecodeFormat;
176 QMenu *m_videoEffectsMenu;
177 QMenu *m_audioEffectsMenu;
178 QMenu *m_customEffectsMenu;
179 QMenu *m_transitionsMenu;
180 QMenu *m_timelineContextMenu;
181 QMenu *m_timelineContextClipMenu;
182 QMenu *m_timelineContextTransitionMenu;
185 /** @brief Shortcut to remove the focus from any element.
187 * It allows to get out of e.g. text input fields and to press another
189 QShortcut* m_shortcutRemoveFocus;
191 RenderWidget *m_renderWidget;
193 #ifndef NO_JOGSHUTTLE
194 JogShuttle *m_jogProcess;
195 #endif /* NO_JOGSHUTTLE */
197 KRecentFilesAction *m_fileOpenRecent;
198 KAction *m_fileRevert;
199 KAction *m_projectSearch;
200 KAction *m_projectSearchNext;
202 KAction **m_videoEffects;
203 KAction **m_audioEffects;
204 KAction **m_customEffects;
205 KAction **m_transitions;
206 KAction *m_buttonAudioThumbs;
207 KAction *m_buttonVideoThumbs;
208 KAction *m_buttonShowMarkers;
209 KAction *m_buttonFitZoom;
210 KAction *m_buttonAutomaticSplitAudio;
211 KAction *m_normalEditTool;
212 KAction *m_overwriteEditTool;
213 KAction *m_insertEditTool;
214 KAction *m_buttonSelectTool;
215 KAction *m_buttonRazorTool;
216 KAction *m_buttonSpacerTool;
217 KAction *m_buttonSnap;
218 KAction *m_saveAction;
219 KAction *m_closeAction;
220 QSlider *m_zoomSlider;
225 StatusBarMessageLabel *m_messageLabel;
226 QActionGroup *m_clipTypeGroup;
227 KActionCollection *m_effectsActionCollection;
229 bool m_findActivated;
230 QString m_findString;
235 #ifndef NO_JOGSHUTTLE
236 void activateShuttleDevice();
237 void slotShuttleAction(int code);
238 #endif /* NO_JOGSHUTTLE */
239 void connectDocumentInfo(KdenliveDoc *doc);
241 void doOpenFile(const KUrl &url, KAutoSaveFile *stale);
242 void recoverFiles(QList<KAutoSaveFile *> staleFiles);
244 /** @brief Loads static and dynamic plugins.
246 * It scans static plugins as well as the filesystem: it doesn't load more
247 * than one plugin per file name, to avoid duplication due to conflicting
250 void populateMenus(QObject *plugin);
251 void addToMenu(QObject *plugin, const QStringList &texts,
252 QMenu *menu, const char *member,
253 QActionGroup *actionGroup);
256 /** @brief Instantiates a "Get Hot New Stuff" dialog.
257 * @param configFile configuration file for KNewStuff
258 * @return number of installed items */
259 int getNewStuff(const QString &configFile = QString());
260 QStringList m_pluginFileNames;
261 QByteArray m_timelineState;
262 void loadTranscoders();
263 QPixmap createSchemePreviewIcon(const KSharedConfigPtr &config);
265 /** @brief Checks that the Kdenlive mime type is correctly installed.
266 * @return The mimetype */
267 QString getMimeType();
270 /** @brief Prepares opening @param url.
272 * Checks if already open and whether backup exists */
273 void openFile(const KUrl &url);
274 void slotGotProgressInfo(const QString &message, int progress);
275 Q_SCRIPTABLE void setRenderingProgress(const QString &url, int progress);
276 Q_SCRIPTABLE void setRenderingFinished(const QString &url, int status, const QString &error);
279 void newFile(bool showProjectSettings = true, bool force = false);
281 void activateDocument();
282 void connectDocument(TrackView*, KdenliveDoc*);
284 /** @brief Shows file open dialog. */
288 /** @brief Checks whether a URL is available to save to.
289 * @return Whether the file was saved. */
292 /** @brief Shows a save file dialog for saving the project.
293 * @return Whether the file was saved. */
296 /** @brief Set properties to match outputFileName and save the document.
297 * @param outputFileName The URL to save to / The document's URL.
298 * @return Whether we had success. */
299 bool saveFileAs(const QString &outputFileName);
301 /** @brief Shows the shortcut dialog. */
303 void slotPreferences(int page = -1, int option = -1);
305 /** @brief Reflects setting changes to the GUI. */
306 void updateConfiguration();
307 void slotConnectMonitors();
308 void slotRaiseMonitor(bool clipMonitor);
309 void slotUpdateClip(const QString &id);
310 void slotUpdateMousePosition(int pos);
311 void slotAddEffect(const QDomElement effect, GenTime pos = GenTime(), int track = -1);
312 void slotEditProfiles();
313 void slotDetectAudioDriver();
314 void slotEditProjectSettings();
315 void slotDisplayActionMessage(QAction *a);
317 /** @brief Turns automatic splitting of audio and video on/off. */
318 void slotSwitchSplitAudio();
319 void slotSwitchVideoThumbs();
320 void slotSwitchAudioThumbs();
321 void slotSwitchMarkersComments();
322 void slotSwitchSnap();
323 void slotRenderProject();
324 void slotFullScreen();
325 void slotUpdateDocumentState(bool modified);
327 /** @brief Sets the timeline zoom slider to @param value.
329 * Also disables zoomIn and zoomOut actions if they cannot be used at the moment. */
330 void slotSetZoom(int value);
331 /** @brief Decreases the timeline zoom level by 1. */
333 /** @brief Increases the timeline zoom level by 1. */
335 /** @brief Makes the timeline zoom level fit the timeline content. */
337 /** @brief Updates the zoom slider tooltip to fit @param zoomlevel. */
338 void slotUpdateZoomSliderToolTip(int zoomlevel);
340 /** @brief Displays the zoom slider tooltip.
341 * @param zoomlevel (optional) The zoom level to show in the tooltip.
343 * Adopted from Dolphin (src/statusbar/dolphinstatusbar.cpp) */
344 void slotShowZoomSliderToolTip(int zoomlevel = -1);
346 void closeCurrentDocument(bool saveChanges = true);
347 /** @brief Deletes item in timeline, project tree or effect stack depending on focus. */
348 void slotDeleteItem();
349 void slotAddClipMarker();
350 void slotDeleteClipMarker();
351 void slotDeleteAllClipMarkers();
352 void slotEditClipMarker();
353 void slotCutTimelineClip();
354 void slotInsertClipOverwrite();
355 void slotSelectTimelineClip();
356 void slotSelectTimelineTransition();
357 void slotDeselectTimelineClip();
358 void slotDeselectTimelineTransition();
359 void slotSelectAddTimelineClip();
360 void slotSelectAddTimelineTransition();
361 void slotAddVideoEffect(QAction *result);
362 void slotAddAudioEffect(QAction *result);
363 void slotAddCustomEffect(QAction *result);
364 void slotAddTransition(QAction *result);
365 void slotAddProjectClip(KUrl url);
366 #ifndef NO_JOGSHUTTLE
367 void slotShuttleButton(int code);
368 #endif /* NO_JOGSHUTTLE */
369 void slotShowClipProperties(DocClipBase *clip);
370 void slotShowClipProperties(QList <DocClipBase *>cliplist, QMap<QString, QString> commonproperties);
371 void slotActivateEffectStackView();
372 void slotActivateTransitionView(Transition *);
373 void slotChangeTool(QAction * action);
374 void slotChangeEdit(QAction * action);
375 void slotSetTool(PROJECTTOOL tool);
376 void slotSnapForward();
377 void slotSnapRewind();
378 void slotClipStart();
380 void slotZoneStart();
385 void slotSelectClipInTimeline();
386 void slotClipInTimeline(const QString &clipId);
388 void slotInsertSpace();
389 void slotRemoveSpace();
391 void slotEditGuide();
392 void slotDeleteGuide();
393 void slotDeleteAllGuides();
394 void slotGuidesUpdated();
398 void slotPasteEffects();
399 void slotReloadEffects();
401 void slotAdjustClipMonitor();
402 void slotAdjustProjectMonitor();
403 void slotSaveZone(Render *render, QPoint zone);
405 void slotSetInPoint();
406 void slotSetOutPoint();
407 void slotResizeItemStart();
408 void slotResizeItemEnd();
409 void configureNotifications();
410 void slotInsertTrack(int ix = 0);
411 void slotDeleteTrack(int ix = 0);
412 /** @brief Shows the configure tracks dialog and updates transitions afterwards. */
413 void slotConfigTrack(int ix = -1);
414 void slotGetNewLumaStuff();
415 void slotGetNewTitleStuff();
416 void slotGetNewRenderStuff();
417 void slotGetNewMltProfileStuff();
418 void slotAutoTransition();
419 void slotRunWizard();
420 /** @brief Lets the sampleplugin create a generator. */
422 void slotZoneMoved(int start, int end);
423 void slotUpdatePreviewSettings();
424 void slotDvdWizard(const QString &url = QString(), const QString &profile = "dv_pal");
425 void slotGroupClips();
426 void slotUnGroupClips();
427 void slotEditItemDuration();
428 void slotClipInProjectTree();
429 //void slotClipToProjectTree();
430 void slotSplitAudio();
431 void slotUpdateClipType(QAction *action);
432 void slotShowTimeline(bool show);
433 void slotMaximizeCurrent(bool show);
434 void slotTranscode(KUrl::List urls = KUrl::List());
435 void slotTranscodeClip();
436 void slotSetDocumentRenderProfile(QMap <QString, QString> props);
437 void slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile);
439 /** @brief Switches between displaying frames or timecode.
440 * @param ix 0 = display timecode, 1 = display frames. */
441 void slotUpdateTimecodeFormat(int ix);
443 /** @brief Removes the focus of anything. */
444 void slotRemoveFocus();
445 void slotCleanProject();
446 void slotUpdateClipMarkers(DocClipBase *clip);
449 void slotUpdateTrackInfo();
451 /** @brief Changes the color scheme. */
452 void slotChangePalette(QAction *action, const QString &themename = QString());
453 void slotSwitchMonitors();
454 void slotCheckRenderStatus();
455 void slotInsertZoneToTree();
456 void slotInsertZoneToTimeline();
458 /** @brief Deletes items from timeline and document.
459 * @param ids The ids of the clips to delete.
460 * @param folderids The names and ids of the folders to delete. */
461 void slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids);
462 void slotShowTitleBars(bool show);
463 void slotSwitchTitles();
466 Q_SCRIPTABLE void abortRenderJob(const QString &url);