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);
87 /** @brief Locates the MLT environment.
88 * @param mltPath (optional) path to MLT environment
90 * It tries to set the paths of the MLT profiles and renderer, using
91 * mltPath, MLT_PREFIX, searching for the binary `melt`, or asking to the
92 * user. It doesn't fill any list of profiles, while its name suggests so. */
93 void parseProfiles(const QString &mltPath = QString());
95 static EffectsList videoEffects;
96 static EffectsList audioEffects;
97 static EffectsList customEffects;
98 static EffectsList transitions;
101 /** @brief Closes the window.
102 * @return false if the user presses "Cancel" on a confirmation dialog or
103 * the operation requested (starting waiting jobs or saving file) fails,
105 virtual bool queryClose();
107 /** @brief Reports a message in the status bar when an error occurs. */
108 virtual void customEvent(QEvent *e);
110 /** @brief Enables live search in the timeline. */
111 virtual void keyPressEvent(QKeyEvent *ke);
113 /** @brief Stops the active monitor when the window gets hidden. */
114 virtual void hideEvent(QHideEvent *e);
116 /** @brief Filters key events to the live search. */
117 bool eventFilter(QObject *obj, QEvent *ev);
119 /** @brief Saves the file and the window properties when saving the session. */
120 virtual void saveProperties(KConfigGroup &config);
122 /** @brief Restores the window and the file when a session is loaded. */
123 virtual void readProperties(const KConfigGroup &config);
126 KTabWidget* m_timelineArea;
127 QProgressBar *m_statusProgressBar;
129 /** @brief Sets up all the actions and attaches them to the collection. */
131 KdenliveDoc *m_activeDocument;
132 TrackView *m_activeTimeline;
133 MonitorManager *m_monitorManager;
135 QDockWidget *m_projectListDock;
136 ProjectList *m_projectList;
138 QDockWidget *m_effectListDock;
139 EffectsListView *m_effectList;
140 //KListWidget *m_effectList;
142 QDockWidget *m_effectStackDock;
143 EffectStackView *m_effectStack;
145 QDockWidget *m_transitionConfigDock;
146 TransitionSettings *m_transitionConfig;
148 QDockWidget *m_clipMonitorDock;
149 Monitor *m_clipMonitor;
151 QDockWidget *m_projectMonitorDock;
152 Monitor *m_projectMonitor;
154 QDockWidget *m_recMonitorDock;
155 RecMonitor *m_recMonitor;
157 QDockWidget *m_vectorscopeDock;
158 Vectorscope *m_vectorscope;
160 QDockWidget *m_waveformDock;
161 Waveform *m_waveform;
163 QDockWidget *m_RGBParadeDock;
164 RGBParade *m_RGBParade;
166 QDockWidget *m_histogramDock;
167 Histogram *m_histogram;
169 QDockWidget *m_undoViewDock;
170 QUndoView *m_undoView;
171 QUndoGroup *m_commandStack;
173 KComboBox *m_timecodeFormat;
175 QMenu *m_videoEffectsMenu;
176 QMenu *m_audioEffectsMenu;
177 QMenu *m_customEffectsMenu;
178 QMenu *m_transitionsMenu;
179 QMenu *m_timelineContextMenu;
180 QMenu *m_timelineContextClipMenu;
181 QMenu *m_timelineContextTransitionMenu;
184 /** @brief Shortcut to remove the focus from any element.
186 * It allows to get out of e.g. text input fields and to press another
188 QShortcut* m_shortcutRemoveFocus;
190 RenderWidget *m_renderWidget;
192 #ifndef NO_JOGSHUTTLE
193 JogShuttle *m_jogProcess;
194 #endif /* NO_JOGSHUTTLE */
196 KRecentFilesAction *m_fileOpenRecent;
197 KAction *m_fileRevert;
198 KAction *m_projectSearch;
199 KAction *m_projectSearchNext;
201 KAction **m_videoEffects;
202 KAction **m_audioEffects;
203 KAction **m_customEffects;
204 KAction **m_transitions;
205 KAction *m_buttonAudioThumbs;
206 KAction *m_buttonVideoThumbs;
207 KAction *m_buttonShowMarkers;
208 KAction *m_buttonFitZoom;
209 KAction *m_buttonAutomaticSplitAudio;
210 KAction *m_normalEditTool;
211 KAction *m_overwriteEditTool;
212 KAction *m_insertEditTool;
213 KAction *m_buttonSelectTool;
214 KAction *m_buttonRazorTool;
215 KAction *m_buttonSpacerTool;
216 KAction *m_buttonSnap;
217 KAction *m_saveAction;
218 KAction *m_closeAction;
219 QSlider *m_zoomSlider;
224 StatusBarMessageLabel *m_messageLabel;
225 QActionGroup *m_clipTypeGroup;
226 KActionCollection *m_effectsActionCollection;
228 bool m_findActivated;
229 QString m_findString;
234 #ifndef NO_JOGSHUTTLE
235 void activateShuttleDevice();
236 void slotShuttleAction(int code);
237 #endif /* NO_JOGSHUTTLE */
238 void connectDocumentInfo(KdenliveDoc *doc);
240 void doOpenFile(const KUrl &url, KAutoSaveFile *stale);
241 void recoverFiles(QList<KAutoSaveFile *> staleFiles);
243 /** @brief Loads static and dynamic plugins.
245 * It scans static plugins as well as the filesystem: it doesn't load more
246 * than one plugin per file name, to avoid duplication due to conflicting
249 void populateMenus(QObject *plugin);
250 void addToMenu(QObject *plugin, const QStringList &texts,
251 QMenu *menu, const char *member,
252 QActionGroup *actionGroup);
255 /** @brief Instantiates a "Get Hot New Stuff" dialog.
256 * @param configFile configuration file for KNewStuff
257 * @return number of installed items */
258 int getNewStuff(const QString &configFile = QString());
259 QStringList m_pluginFileNames;
260 QByteArray m_timelineState;
261 void loadTranscoders();
262 QPixmap createSchemePreviewIcon(const KSharedConfigPtr &config);
264 /** @brief Checks that the Kdenlive mime type is correctly installed.
265 * @return The mimetype */
266 QString getMimeType();
269 /** @brief Prepares opening @param url.
271 * Checks if already open and whether backup exists */
272 void openFile(const KUrl &url);
273 void slotGotProgressInfo(const QString &message, int progress);
274 Q_SCRIPTABLE void setRenderingProgress(const QString &url, int progress);
275 Q_SCRIPTABLE void setRenderingFinished(const QString &url, int status, const QString &error);
278 void newFile(bool showProjectSettings = true, bool force = false);
280 void activateDocument();
281 void connectDocument(TrackView*, KdenliveDoc*);
283 /** @brief Shows file open dialog. */
287 /** @brief Checks whether a URL is available to save to.
288 * @return Whether the file was saved. */
291 /** @brief Shows a save file dialog for saving the project.
292 * @return Whether the file was saved. */
295 /** @brief Set properties to match outputFileName and save the document.
296 * @param outputFileName The URL to save to / The document's URL.
297 * @return Whether we had success. */
298 bool saveFileAs(const QString &outputFileName);
300 /** @brief Shows the shortcut dialog. */
302 void slotPreferences(int page = -1, int option = -1);
304 /** @brief Reflects setting changes to the GUI. */
305 void updateConfiguration();
306 void slotConnectMonitors();
307 void slotRaiseMonitor(bool clipMonitor);
308 void slotUpdateClip(const QString &id);
309 void slotUpdateMousePosition(int pos);
310 void slotAddEffect(const QDomElement effect, GenTime pos = GenTime(), int track = -1);
311 void slotEditProfiles();
312 void slotDetectAudioDriver();
313 void slotEditProjectSettings();
314 void slotDisplayActionMessage(QAction *a);
316 /** @brief Turns automatic splitting of audio and video on/off. */
317 void slotSwitchSplitAudio();
318 void slotSwitchVideoThumbs();
319 void slotSwitchAudioThumbs();
320 void slotSwitchMarkersComments();
321 void slotSwitchSnap();
322 void slotRenderProject();
323 void slotFullScreen();
324 void slotUpdateDocumentState(bool modified);
326 /** @brief Sets the timeline zoom slider to @param value.
328 * Also disables zoomIn and zoomOut actions if they cannot be used at the moment. */
329 void slotSetZoom(int value);
330 /** @brief Decreases the timeline zoom level by 1. */
332 /** @brief Increases the timeline zoom level by 1. */
334 /** @brief Makes the timeline zoom level fit the timeline content. */
336 /** @brief Updates the zoom slider tooltip to fit @param zoomlevel. */
337 void slotUpdateZoomSliderToolTip(int zoomlevel);
339 /** @brief Displays the zoom slider tooltip.
340 * @param zoomlevel (optional) The zoom level to show in the tooltip.
342 * Adopted from Dolphin (src/statusbar/dolphinstatusbar.cpp) */
343 void slotShowZoomSliderToolTip(int zoomlevel = -1);
345 void closeCurrentDocument(bool saveChanges = true);
346 /** @brief Deletes item in timeline, project tree or effect stack depending on focus. */
347 void slotDeleteItem();
348 void slotAddClipMarker();
349 void slotDeleteClipMarker();
350 void slotDeleteAllClipMarkers();
351 void slotEditClipMarker();
352 void slotCutTimelineClip();
353 void slotInsertClipOverwrite();
354 void slotSelectTimelineClip();
355 void slotSelectTimelineTransition();
356 void slotDeselectTimelineClip();
357 void slotDeselectTimelineTransition();
358 void slotSelectAddTimelineClip();
359 void slotSelectAddTimelineTransition();
360 void slotAddVideoEffect(QAction *result);
361 void slotAddAudioEffect(QAction *result);
362 void slotAddCustomEffect(QAction *result);
363 void slotAddTransition(QAction *result);
364 void slotAddProjectClip(KUrl url);
365 #ifndef NO_JOGSHUTTLE
366 void slotShuttleButton(int code);
367 #endif /* NO_JOGSHUTTLE */
368 void slotShowClipProperties(DocClipBase *clip);
369 void slotShowClipProperties(QList <DocClipBase *>cliplist, QMap<QString, QString> commonproperties);
370 void slotActivateEffectStackView();
371 void slotActivateTransitionView(Transition *);
372 void slotChangeTool(QAction * action);
373 void slotChangeEdit(QAction * action);
374 void slotSetTool(PROJECTTOOL tool);
375 void slotSnapForward();
376 void slotSnapRewind();
377 void slotClipStart();
379 void slotZoneStart();
384 void slotSelectClipInTimeline();
385 void slotClipInTimeline(const QString &clipId);
387 void slotInsertSpace();
388 void slotRemoveSpace();
390 void slotEditGuide();
391 void slotDeleteGuide();
392 void slotDeleteAllGuides();
393 void slotGuidesUpdated();
397 void slotPasteEffects();
398 void slotReloadEffects();
400 void slotAdjustClipMonitor();
401 void slotAdjustProjectMonitor();
402 void slotSaveZone(Render *render, QPoint zone);
404 void slotSetInPoint();
405 void slotSetOutPoint();
406 void slotResizeItemStart();
407 void slotResizeItemEnd();
408 void configureNotifications();
409 void slotInsertTrack(int ix = 0);
410 void slotDeleteTrack(int ix = 0);
411 /** @brief Shows the configure tracks dialog and updates transitions afterwards. */
412 void slotConfigTrack(int ix = -1);
413 void slotGetNewLumaStuff();
414 void slotGetNewTitleStuff();
415 void slotGetNewRenderStuff();
416 void slotGetNewMltProfileStuff();
417 void slotAutoTransition();
418 void slotRunWizard();
419 /** @brief Lets the sampleplugin create a generator. */
421 void slotZoneMoved(int start, int end);
422 void slotUpdatePreviewSettings();
423 void slotDvdWizard(const QString &url = QString(), const QString &profile = "dv_pal");
424 void slotGroupClips();
425 void slotUnGroupClips();
426 void slotEditItemDuration();
427 void slotClipInProjectTree();
428 //void slotClipToProjectTree();
429 void slotSplitAudio();
430 void slotUpdateClipType(QAction *action);
431 void slotShowTimeline(bool show);
432 void slotMaximizeCurrent(bool show);
433 void slotTranscode(KUrl::List urls = KUrl::List());
434 void slotTranscodeClip();
435 void slotSetDocumentRenderProfile(const QString &dest, const QString &group, const QString &name, const QString &file, bool renderZone, bool renderGuide, int startGuide, int endGuide);
436 void slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile);
438 /** @brief Switches between displaying frames or timecode.
439 * @param ix 0 = display timecode, 1 = display frames. */
440 void slotUpdateTimecodeFormat(int ix);
442 /** @brief Removes the focus of anything. */
443 void slotRemoveFocus();
444 void slotCleanProject();
445 void slotUpdateClipMarkers(DocClipBase *clip);
448 void slotUpdateTrackInfo();
450 /** @brief Changes the color scheme. */
451 void slotChangePalette(QAction *action, const QString &themename = QString());
452 void slotSwitchMonitors();
453 void slotCheckRenderStatus();
454 void slotInsertZoneToTree();
455 void slotInsertZoneToTimeline();
457 /** @brief Deletes items from timeline and document.
458 * @param ids The ids of the clips to delete.
459 * @param folderids The names and ids of the folders to delete. */
460 void slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids);
461 void slotShowTitleBars(bool show);
462 void slotSwitchTitles();
465 Q_SCRIPTABLE void abortRenderJob(const QString &url);