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