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 */
65 class MainWindow : public KXmlGuiWindow
68 Q_CLASSINFO("D-Bus Interface", "org.kdenlive.MainWindow")
72 /** @brief Initialises the main window.
73 * @param MltPath (optional) path to MLT environment
74 * @param Url (optional) file to open
76 * If Url is present, it will be opened, otherwhise, if openlastproject is
77 * set, latest project will be opened. If no file is open after trying this,
78 * a default new file will be created. */
79 explicit MainWindow(const QString &MltPath = QString(),
80 const KUrl &Url = KUrl(), QWidget *parent = 0);
82 /** @brief Locates the MLT environment.
83 * @param mltPath (optional) path to MLT environment
85 * It tries to set the paths of the MLT profiles and renderer, using
86 * mltPath, MLT_PREFIX, searching for the binary `melt`, or asking to the
87 * user. It doesn't fill any list of profiles, while its name suggests so. */
88 void parseProfiles(const QString &mltPath = QString());
90 static EffectsList videoEffects;
91 static EffectsList audioEffects;
92 static EffectsList customEffects;
93 static EffectsList transitions;
96 /** @brief Closes the window.
97 * @return false if the user presses "Cancel" on a confirmation dialog or
98 * the operation requested (starting waiting jobs or saving file) fails,
100 virtual bool queryClose();
102 /** @brief Reports a message in the status bar when an error occurs. */
103 virtual void customEvent(QEvent *e);
105 /** @brief Enables live search in the timeline. */
106 virtual void keyPressEvent(QKeyEvent *ke);
108 /** @brief Stops the active monitor when the window gets hidden. */
109 virtual void hideEvent(QHideEvent *e);
111 /** @brief Filters key events to the live search. */
112 bool eventFilter(QObject *obj, QEvent *ev);
114 /** @brief Saves the file and the window properties when saving the session. */
115 virtual void saveProperties(KConfigGroup &config);
117 /** @brief Restores the window and the file when a session is loaded. */
118 virtual void readProperties(const KConfigGroup &config);
121 KTabWidget* m_timelineArea;
122 QProgressBar *m_statusProgressBar;
124 /** @brief Sets up all the actions and attaches them to the collection. */
126 KdenliveDoc *m_activeDocument;
127 TrackView *m_activeTimeline;
128 MonitorManager *m_monitorManager;
130 QDockWidget *m_projectListDock;
131 ProjectList *m_projectList;
133 QDockWidget *m_effectListDock;
134 EffectsListView *m_effectList;
135 //KListWidget *m_effectList;
137 QDockWidget *m_effectStackDock;
138 EffectStackView *m_effectStack;
140 QDockWidget *m_transitionConfigDock;
141 TransitionSettings *m_transitionConfig;
143 QDockWidget *m_clipMonitorDock;
144 Monitor *m_clipMonitor;
146 QDockWidget *m_projectMonitorDock;
147 Monitor *m_projectMonitor;
149 QDockWidget *m_recMonitorDock;
150 RecMonitor *m_recMonitor;
152 QDockWidget *m_undoViewDock;
153 QUndoView *m_undoView;
154 QUndoGroup *m_commandStack;
156 KComboBox *m_timecodeFormat;
158 QMenu *m_videoEffectsMenu;
159 QMenu *m_audioEffectsMenu;
160 QMenu *m_customEffectsMenu;
161 QMenu *m_transitionsMenu;
162 QMenu *m_timelineContextMenu;
163 QMenu *m_timelineContextClipMenu;
164 QMenu *m_timelineContextTransitionMenu;
167 /** @brief Shortcut to remove the focus from any element.
169 * It allows to get out of e.g. text input fields and to press another
171 QShortcut* m_shortcutRemoveFocus;
173 RenderWidget *m_renderWidget;
175 #ifndef NO_JOGSHUTTLE
176 JogShuttle *m_jogProcess;
177 #endif /* NO_JOGSHUTTLE */
179 KRecentFilesAction *m_fileOpenRecent;
180 KAction *m_fileRevert;
181 KAction *m_projectSearch;
182 KAction *m_projectSearchNext;
184 KAction **m_videoEffects;
185 KAction **m_audioEffects;
186 KAction **m_customEffects;
187 KAction **m_transitions;
188 KAction *m_buttonAudioThumbs;
189 KAction *m_buttonVideoThumbs;
190 KAction *m_buttonShowMarkers;
191 KAction *m_buttonFitZoom;
192 KAction *m_normalEditTool;
193 KAction *m_overwriteEditTool;
194 KAction *m_insertEditTool;
195 KAction *m_buttonSelectTool;
196 KAction *m_buttonRazorTool;
197 KAction *m_buttonSpacerTool;
198 KAction *m_buttonSnap;
199 KAction *m_saveAction;
200 KAction *m_closeAction;
201 QSlider *m_zoomSlider;
206 StatusBarMessageLabel *m_messageLabel;
207 QActionGroup *m_clipTypeGroup;
209 bool m_findActivated;
210 QString m_findString;
215 #ifndef NO_JOGSHUTTLE
216 void activateShuttleDevice();
217 void slotShuttleAction(int code);
218 #endif /* NO_JOGSHUTTLE */
219 void connectDocumentInfo(KdenliveDoc *doc);
221 void doOpenFile(const KUrl &url, KAutoSaveFile *stale);
222 void recoverFiles(QList<KAutoSaveFile *> staleFiles);
224 void populateMenus(QObject *plugin);
225 void addToMenu(QObject *plugin, const QStringList &texts,
226 QMenu *menu, const char *member,
227 QActionGroup *actionGroup);
230 /** @brief Instantiates a "Get Hot New Stuff" dialog.
231 * @param configFile configuration file for KNewStuff
232 * @return number of installed items */
233 int getNewStuff(const QString &configFile = QString());
234 QStringList m_pluginFileNames;
235 QByteArray m_timelineState;
236 void loadTranscoders();
237 QPixmap createSchemePreviewIcon(const KSharedConfigPtr &config);
238 /** @brief Checks that the Kdenlive mime type is correctly installed.
239 * @return The mimetype */
240 QString getMimeType();
243 void openFile(const KUrl &url);
244 void slotGotProgressInfo(const QString &message, int progress);
245 Q_SCRIPTABLE void setRenderingProgress(const QString &url, int progress);
246 Q_SCRIPTABLE void setRenderingFinished(const QString &url, int status, const QString &error);
249 void newFile(bool showProjectSettings = true, bool force = false);
251 void activateDocument();
252 void connectDocument(TrackView*, KdenliveDoc*);
255 /** @brief Checks whether a URL is available to save to.
256 * @return Whether the file was saved. */
258 /** @brief Shows a save file dialog for saving the project.
259 * @return Whether the file was saved. */
261 /** @brief Set properties to match outputFileName and save the document.
262 * @param outputFileName The URL to save to / The document's URL.
263 * @return Whether we had success. */
264 bool saveFileAs(const QString &outputFileName);
265 void slotPreferences(int page = -1, int option = -1);
266 void updateConfiguration();
267 void slotConnectMonitors();
268 void slotRaiseMonitor(bool clipMonitor);
269 void slotUpdateClip(const QString &id);
270 void slotUpdateMousePosition(int pos);
271 void slotAddEffect(const QDomElement effect, GenTime pos = GenTime(), int track = -1);
272 void slotEditProfiles();
273 void slotDetectAudioDriver();
274 void slotEditProjectSettings();
275 void slotDisplayActionMessage(QAction *a);
276 void slotSwitchVideoThumbs();
277 void slotSwitchAudioThumbs();
278 void slotSwitchMarkersComments();
279 void slotSwitchSnap();
280 void slotRenderProject();
281 void slotFullScreen();
282 void slotUpdateDocumentState(bool modified);
284 /** @brief Sets the timeline zoom slider to @param value.
286 * Also disables zoomIn and zoomOut actions if they cannot be used at the moment. */
287 void slotSetZoom(int value);
288 /** @brief Decreases the timeline zoom level by 1. */
290 /** @brief Increases the timeline zoom level by 1. */
292 /** @brief Makes the timeline zoom level fit the timeline content. */
294 /** @brief Updates the zoom slider tooltip to fit @param zoomlevel. */
295 void slotUpdateZoomSliderToolTip(int zoomlevel);
296 /** @brief Displays the zoom slider tooltip.
297 * @param zoomlevel (optional) The zoom level to show in the tooltip.
299 * Adopted from Dolphin (src/statusbar/dolphinstatusbar.cpp) */
300 void slotShowZoomSliderToolTip(int zoomlevel = -1);
302 void closeCurrentDocument(bool saveChanges = true);
303 /** @brief Deletes item in timeline, project tree or effect stack depending on focus. */
304 void slotDeleteItem();
305 void slotAddClipMarker();
306 void slotDeleteClipMarker();
307 void slotDeleteAllClipMarkers();
308 void slotEditClipMarker();
309 void slotCutTimelineClip();
310 void slotInsertClipOverwrite();
311 void slotSelectTimelineClip();
312 void slotSelectTimelineTransition();
313 void slotDeselectTimelineClip();
314 void slotDeselectTimelineTransition();
315 void slotSelectAddTimelineClip();
316 void slotSelectAddTimelineTransition();
317 void slotAddVideoEffect(QAction *result);
318 void slotAddAudioEffect(QAction *result);
319 void slotAddCustomEffect(QAction *result);
320 void slotAddTransition(QAction *result);
321 void slotAddProjectClip(KUrl url);
322 #ifndef NO_JOGSHUTTLE
323 void slotShuttleButton(int code);
324 #endif /* NO_JOGSHUTTLE */
325 void slotShowClipProperties(DocClipBase *clip);
326 void slotShowClipProperties(QList <DocClipBase *>cliplist, QMap<QString, QString> commonproperties);
327 void slotActivateEffectStackView();
328 void slotActivateTransitionView(Transition *);
329 void slotChangeTool(QAction * action);
330 void slotChangeEdit(QAction * action);
331 void slotSetTool(PROJECTTOOL tool);
332 void slotSnapForward();
333 void slotSnapRewind();
334 void slotClipStart();
336 void slotZoneStart();
341 void slotSelectClipInTimeline();
342 void slotClipInTimeline(const QString &clipId);
344 void slotInsertSpace();
345 void slotRemoveSpace();
347 void slotEditGuide();
348 void slotDeleteGuide();
349 void slotDeleteAllGuides();
350 void slotGuidesUpdated();
354 void slotPasteEffects();
355 void slotReloadEffects();
357 void slotAdjustClipMonitor();
358 void slotAdjustProjectMonitor();
359 void slotSaveZone(Render *render, QPoint zone);
361 void slotSetInPoint();
362 void slotSetOutPoint();
363 void slotResizeItemStart();
364 void slotResizeItemEnd();
365 void configureNotifications();
366 void slotInsertTrack(int ix = 0);
367 void slotDeleteTrack(int ix = 0);
368 void slotChangeTrack(int ix = 0);
369 void slotGetNewLumaStuff();
370 void slotGetNewTitleStuff();
371 void slotGetNewRenderStuff();
372 void slotGetNewMltProfileStuff();
373 void slotAutoTransition();
374 void slotRunWizard();
375 /** @brief Lets the sampleplugin create a generator. */
377 void slotZoneMoved(int start, int end);
378 void slotUpdatePreviewSettings();
379 void slotDvdWizard(const QString &url = QString(), const QString &profile = "dv_pal");
380 void slotGroupClips();
381 void slotUnGroupClips();
382 void slotEditItemDuration();
383 void slotClipInProjectTree();
384 void slotSplitAudio();
385 void slotUpdateClipType(QAction *action);
386 void slotShowTimeline(bool show);
387 void slotMaximizeCurrent(bool show);
388 void slotTranscode(KUrl::List urls = KUrl::List());
389 void slotTranscodeClip();
390 void slotSetDocumentRenderProfile(const QString &dest, const QString &group, const QString &name, const QString &file);
391 void slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile);
392 /** @brief Switches between displaying frames or timecode.
393 * @param ix 0 = display timecode, 1 = display frames. */
394 void slotUpdateTimecodeFormat(int ix);
395 /** @brief Removes the focus of anything. */
396 void slotRemoveFocus();
397 void slotCleanProject();
398 void slotUpdateClipMarkers(DocClipBase *clip);
401 void slotUpdateTrackInfo();
403 /** @brief Changes the color scheme. */
404 void slotChangePalette(QAction *action, const QString &themename = QString());
405 void slotSwitchMonitors();
406 void slotCheckRenderStatus();
407 void slotInsertZoneToTree();
408 void slotInsertZoneToTimeline();
409 /** @brief Deletes items from timeline and document.
410 * @param ids The ids of the clips to delete.
411 * @param folderids The names and ids of the folders to delete. */
412 void slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids);
413 void slotShowTitleBars(bool show);
414 void slotSwitchTitles();
417 Q_SCRIPTABLE void abortRenderJob(const QString &url);