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 KdenliveDoc *m_activeDocument;
125 TrackView *m_activeTimeline;
126 MonitorManager *m_monitorManager;
128 QDockWidget *m_projectListDock;
129 ProjectList *m_projectList;
131 QDockWidget *m_effectListDock;
132 EffectsListView *m_effectList;
133 //KListWidget *m_effectList;
135 QDockWidget *m_effectStackDock;
136 EffectStackView *m_effectStack;
138 QDockWidget *m_transitionConfigDock;
139 TransitionSettings *m_transitionConfig;
141 QDockWidget *m_clipMonitorDock;
142 Monitor *m_clipMonitor;
144 QDockWidget *m_projectMonitorDock;
145 Monitor *m_projectMonitor;
147 QDockWidget *m_recMonitorDock;
148 RecMonitor *m_recMonitor;
150 QDockWidget *m_undoViewDock;
151 QUndoView *m_undoView;
152 QUndoGroup *m_commandStack;
154 KComboBox *m_timecodeFormat;
156 QMenu *m_customEffectsMenu;
157 QMenu *m_timelineContextMenu;
158 QMenu *m_timelineContextClipMenu;
159 QMenu *m_timelineContextTransitionMenu;
162 /** @brief Shortcut to remove the focus from any element.
164 * It allows to get out of e.g. text input fields and to press another
166 QShortcut* m_shortcutRemoveFocus;
168 RenderWidget *m_renderWidget;
170 #ifndef NO_JOGSHUTTLE
171 JogShuttle *m_jogProcess;
172 #endif /* NO_JOGSHUTTLE */
174 KRecentFilesAction *m_fileOpenRecent;
175 KAction *m_fileRevert;
176 KAction *m_projectSearch;
177 KAction *m_projectSearchNext;
179 KAction *m_buttonAudioThumbs;
180 KAction *m_buttonVideoThumbs;
181 KAction *m_buttonShowMarkers;
182 KAction *m_buttonFitZoom;
183 KAction *m_normalEditTool;
184 KAction *m_overwriteEditTool;
185 KAction *m_insertEditTool;
186 KAction *m_buttonSelectTool;
187 KAction *m_buttonRazorTool;
188 KAction *m_buttonSpacerTool;
189 KAction *m_buttonSnap;
190 KAction *m_saveAction;
191 KAction *m_closeAction;
192 QSlider *m_zoomSlider;
195 StatusBarMessageLabel *m_messageLabel;
196 QActionGroup *m_clipTypeGroup;
198 bool m_findActivated;
199 QString m_findString;
204 #ifndef NO_JOGSHUTTLE
205 void activateShuttleDevice();
206 void slotShuttleAction(int code);
207 #endif /* NO_JOGSHUTTLE */
208 void connectDocumentInfo(KdenliveDoc *doc);
210 void doOpenFile(const KUrl &url, KAutoSaveFile *stale);
211 void recoverFiles(QList<KAutoSaveFile *> staleFiles);
213 void populateMenus(QObject *plugin);
214 void addToMenu(QObject *plugin, const QStringList &texts,
215 QMenu *menu, const char *member,
216 QActionGroup *actionGroup);
218 int getNewStuff(const QString &configFile = QString());
219 QStringList m_pluginFileNames;
220 QByteArray m_timelineState;
221 void loadTranscoders();
222 QPixmap createSchemePreviewIcon(const KSharedConfigPtr &config);
225 void openFile(const KUrl &url);
226 void slotGotProgressInfo(const QString &message, int progress);
227 Q_SCRIPTABLE void setRenderingProgress(const QString &url, int progress);
228 Q_SCRIPTABLE void setRenderingFinished(const QString &url, int status, const QString &error);
231 void newFile(bool showProjectSettings = true, bool force = false);
233 void activateDocument();
234 void connectDocument(TrackView*, KdenliveDoc*);
239 bool saveFileAs(const QString &outputFileName);
240 void slotPreferences(int page = -1, int option = -1);
241 void updateConfiguration();
242 void slotConnectMonitors();
243 void slotRaiseMonitor(bool clipMonitor);
244 void slotUpdateClip(const QString &id);
245 void slotUpdateMousePosition(int pos);
246 void slotAddEffect(const QDomElement effect, GenTime pos = GenTime(), int track = -1);
247 void slotEditProfiles();
248 void slotDetectAudioDriver();
249 void slotEditProjectSettings();
250 void slotDisplayActionMessage(QAction *a);
251 void slotSwitchVideoThumbs();
252 void slotSwitchAudioThumbs();
253 void slotSwitchMarkersComments();
254 void slotSwitchSnap();
255 void slotRenderProject();
256 void slotFullScreen();
257 void slotUpdateDocumentState(bool modified);
261 void closeCurrentDocument(bool saveChanges = true);
262 /** @brief Delete item in timeline, project tree or effect stack depending on focus. */
263 void slotDeleteItem();
264 void slotAddClipMarker();
265 void slotDeleteClipMarker();
266 void slotDeleteAllClipMarkers();
267 void slotEditClipMarker();
268 void slotCutTimelineClip();
269 void slotInsertClipOverwrite();
270 void slotSelectTimelineClip();
271 void slotSelectTimelineTransition();
272 void slotDeselectTimelineClip();
273 void slotDeselectTimelineTransition();
274 void slotSelectAddTimelineClip();
275 void slotSelectAddTimelineTransition();
276 void slotAddVideoEffect(QAction *result);
277 void slotAddAudioEffect(QAction *result);
278 void slotAddCustomEffect(QAction *result);
279 void slotAddTransition(QAction *result);
280 void slotAddProjectClip(KUrl url);
281 #ifndef NO_JOGSHUTTLE
282 void slotShuttleButton(int code);
283 #endif /* NO_JOGSHUTTLE */
284 void slotShowClipProperties(DocClipBase *clip);
285 void slotShowClipProperties(QList <DocClipBase *>cliplist, QMap<QString, QString> commonproperties);
286 void slotActivateEffectStackView();
287 void slotActivateTransitionView(Transition *);
288 void slotChangeTool(QAction * action);
289 void slotChangeEdit(QAction * action);
290 void slotSetTool(PROJECTTOOL tool);
291 void slotSnapForward();
292 void slotSnapRewind();
293 void slotClipStart();
295 void slotZoneStart();
300 void slotSelectClipInTimeline();
301 void slotClipInTimeline(const QString &clipId);
303 void slotInsertSpace();
304 void slotRemoveSpace();
306 void slotEditGuide();
307 void slotDeleteGuide();
308 void slotDeleteAllGuides();
309 void slotGuidesUpdated();
313 void slotPasteEffects();
314 void slotReloadEffects();
316 void slotAdjustClipMonitor();
317 void slotAdjustProjectMonitor();
318 void slotSaveZone(Render *render, QPoint zone);
320 void slotSetInPoint();
321 void slotSetOutPoint();
322 void slotResizeItemStart();
323 void slotResizeItemEnd();
324 void configureNotifications();
325 void slotInsertTrack(int ix = 0);
326 void slotDeleteTrack(int ix = 0);
327 void slotChangeTrack(int ix = 0);
328 void slotGetNewLumaStuff();
329 void slotGetNewTitleStuff();
330 void slotGetNewRenderStuff();
331 void slotGetNewMltProfileStuff();
332 void slotAutoTransition();
333 void slotRunWizard();
335 void slotZoneMoved(int start, int end);
336 void slotUpdatePreviewSettings();
337 void slotDvdWizard(const QString &url = QString(), const QString &profile = "dv_pal");
338 void slotGroupClips();
339 void slotUnGroupClips();
340 void slotEditItemDuration();
341 void slotClipInProjectTree();
342 void slotSplitAudio();
343 void slotUpdateClipType(QAction *action);
344 void slotShowTimeline(bool show);
345 void slotMaximizeCurrent(bool show);
346 void slotTranscode(KUrl::List urls = KUrl::List());
347 void slotTranscodeClip();
348 void slotSetDocumentRenderProfile(const QString &dest, const QString &group, const QString &name, const QString &file);
349 void slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile);
350 void slotUpdateTimecodeFormat(int ix);
351 /** Removes the focus of anything */
352 void slotRemoveFocus();
353 void slotCleanProject();
354 void slotSetZoom(int value);
355 void slotUpdateClipMarkers(DocClipBase *clip);
358 void slotUpdateTrackInfo();
359 /** @brief Changes the color scheme. */
360 void slotChangePalette(QAction *action, const QString &themename = QString());
361 void slotSwitchMonitors();
362 void slotCheckRenderStatus();
363 void slotInsertZoneToTree();
364 void slotInsertZoneToTimeline();
365 void slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids);
366 void slotShowTitleBars(bool show);
367 void slotSwitchTitles();
370 Q_SCRIPTABLE void abortRenderJob(const QString &url);