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