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