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