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 * \param MltPath path to MLT environment
73 * \param Url Url to open
74 * \param parent Std. widget parent
76 * The constructor inits the main window. If Url is present, it will be opened.
77 * If Url is not present, and openLastproject is set, last project will be set
78 * If no file is open after trying this, a default "newfile" will be created. */
79 explicit MainWindow(const QString &MltPath = QString(), const KUrl & Url = KUrl(), QWidget *parent = 0);
80 void parseProfiles(const QString &mltPath = QString());
82 static EffectsList videoEffects;
83 static EffectsList audioEffects;
84 static EffectsList customEffects;
85 static EffectsList transitions;
87 virtual bool queryClose();
88 virtual void customEvent(QEvent * e);
89 virtual void keyPressEvent(QKeyEvent *ke);
90 /** Override hideEvent to get events when the mainwindow gets hidden */
91 virtual void hideEvent(QHideEvent *e);
92 bool eventFilter(QObject *obj, QEvent *ev);
94 * This function is called when it is time for the app to save its
95 * properties for session management purposes.
97 virtual void saveProperties(KConfigGroup &config);
100 * This function is called when this app is restored. The KConfig
101 * object points to the session management config file that was saved
102 * with @ref saveProperties
104 virtual void readProperties(const KConfigGroup &config);
107 KTabWidget* m_timelineArea;
108 QProgressBar *m_statusProgressBar;
110 KdenliveDoc *m_activeDocument;
111 TrackView *m_activeTimeline;
112 MonitorManager *m_monitorManager;
114 QDockWidget *m_projectListDock;
115 ProjectList *m_projectList;
117 QDockWidget *m_effectListDock;
118 EffectsListView *m_effectList;
119 //KListWidget *m_effectList;
121 QDockWidget *m_effectStackDock;
122 EffectStackView *m_effectStack;
124 QDockWidget *m_transitionConfigDock;
125 TransitionSettings *m_transitionConfig;
127 QDockWidget *m_clipMonitorDock;
128 Monitor *m_clipMonitor;
130 QDockWidget *m_projectMonitorDock;
131 Monitor *m_projectMonitor;
133 QDockWidget *m_recMonitorDock;
134 RecMonitor *m_recMonitor;
136 QDockWidget *m_undoViewDock;
137 QUndoView *m_undoView;
138 QUndoGroup *m_commandStack;
140 KComboBox *m_timecodeFormat;
142 QMenu *m_customEffectsMenu;
143 QMenu *m_timelineContextMenu;
144 QMenu *m_timelineContextClipMenu;
145 QMenu *m_timelineContextTransitionMenu;
149 * Shortcut to remove the focus of any element. Allows to get out
150 * of e.g. text input fields and to press another shortcut.
152 QShortcut* m_shortcutRemoveFocus;
154 RenderWidget *m_renderWidget;
156 #ifndef NO_JOGSHUTTLE
157 JogShuttle *m_jogProcess;
158 #endif /* NO_JOGSHUTTLE */
160 KRecentFilesAction *m_fileOpenRecent;
161 KAction *m_fileRevert;
162 KAction *m_projectSearch;
163 KAction *m_projectSearchNext;
165 KAction *m_buttonAudioThumbs;
166 KAction *m_buttonVideoThumbs;
167 KAction *m_buttonShowMarkers;
168 KAction *m_buttonFitZoom;
169 KAction *m_normalEditTool;
170 KAction *m_overwriteEditTool;
171 KAction *m_insertEditTool;
172 KAction *m_buttonSelectTool;
173 KAction *m_buttonRazorTool;
174 KAction *m_buttonSpacerTool;
175 KAction *m_buttonSnap;
176 KAction *m_saveAction;
177 KAction *m_closeAction;
178 QSlider *m_zoomSlider;
181 StatusBarMessageLabel *m_messageLabel;
182 QActionGroup *m_clipTypeGroup;
184 bool m_findActivated;
185 QString m_findString;
190 #ifndef NO_JOGSHUTTLE
191 void activateShuttleDevice();
192 void slotShuttleAction(int code);
193 #endif /* NO_JOGSHUTTLE */
194 void connectDocumentInfo(KdenliveDoc *doc);
196 void doOpenFile(const KUrl &url, KAutoSaveFile *stale);
197 void recoverFiles(QList<KAutoSaveFile *> staleFiles);
199 void populateMenus(QObject *plugin);
200 void addToMenu(QObject *plugin, const QStringList &texts,
201 QMenu *menu, const char *member,
202 QActionGroup *actionGroup);
204 int getNewStuff(const QString &configFile = QString());
205 QStringList m_pluginFileNames;
206 QByteArray m_timelineState;
207 void loadTranscoders();
208 QPixmap createSchemePreviewIcon(const KSharedConfigPtr &config);
211 void openFile(const KUrl &url);
212 void slotGotProgressInfo(const QString &message, int progress);
213 Q_SCRIPTABLE void setRenderingProgress(const QString &url, int progress);
214 Q_SCRIPTABLE void setRenderingFinished(const QString &url, int status, const QString &error);
217 void newFile(bool showProjectSettings = true, bool force = false);
219 void activateDocument();
220 void connectDocument(TrackView*, KdenliveDoc*);
225 bool saveFileAs(const QString &outputFileName);
226 void slotPreferences(int page = -1, int option = -1);
227 void updateConfiguration();
228 void slotConnectMonitors();
229 void slotRaiseMonitor(bool clipMonitor);
230 void slotUpdateClip(const QString &id);
231 void slotUpdateMousePosition(int pos);
232 void slotAddEffect(const QDomElement effect, GenTime pos = GenTime(), int track = -1);
233 void slotEditProfiles();
234 void slotDetectAudioDriver();
235 void slotEditProjectSettings();
236 void slotDisplayActionMessage(QAction *a);
237 void slotSwitchVideoThumbs();
238 void slotSwitchAudioThumbs();
239 void slotSwitchMarkersComments();
240 void slotSwitchSnap();
241 void slotRenderProject();
242 void slotFullScreen();
243 void slotUpdateDocumentState(bool modified);
247 void closeCurrentDocument(bool saveChanges = true);
248 void slotDeleteTimelineClip();
249 void slotAddClipMarker();
250 void slotDeleteClipMarker();
251 void slotDeleteAllClipMarkers();
252 void slotEditClipMarker();
253 void slotCutTimelineClip();
254 void slotInsertClipOverwrite();
255 void slotSelectTimelineClip();
256 void slotSelectTimelineTransition();
257 void slotDeselectTimelineClip();
258 void slotDeselectTimelineTransition();
259 void slotSelectAddTimelineClip();
260 void slotSelectAddTimelineTransition();
261 void slotAddVideoEffect(QAction *result);
262 void slotAddAudioEffect(QAction *result);
263 void slotAddCustomEffect(QAction *result);
264 void slotAddTransition(QAction *result);
265 void slotAddProjectClip(KUrl url);
266 #ifndef NO_JOGSHUTTLE
267 void slotShuttleButton(int code);
268 #endif /* NO_JOGSHUTTLE */
269 void slotShowClipProperties(DocClipBase *clip);
270 void slotShowClipProperties(QList <DocClipBase *>cliplist, QMap<QString, QString> commonproperties);
271 void slotActivateEffectStackView();
272 void slotActivateTransitionView(Transition *);
273 void slotChangeTool(QAction * action);
274 void slotChangeEdit(QAction * action);
275 void slotSetTool(PROJECTTOOL tool);
276 void slotSnapForward();
277 void slotSnapRewind();
278 void slotClipStart();
280 void slotZoneStart();
286 void slotInsertSpace();
287 void slotRemoveSpace();
289 void slotEditGuide();
290 void slotDeleteGuide();
291 void slotDeleteAllGuides();
292 void slotGuidesUpdated();
296 void slotPasteEffects();
297 void slotReloadEffects();
299 void slotAdjustClipMonitor();
300 void slotAdjustProjectMonitor();
301 void slotSaveZone(Render *render, QPoint zone);
303 void slotSetInPoint();
304 void slotSetOutPoint();
305 void slotResizeItemStart();
306 void slotResizeItemEnd();
307 void configureNotifications();
308 void slotInsertTrack(int ix = 0);
309 void slotDeleteTrack(int ix = 0);
310 void slotChangeTrack(int ix = 0);
311 void slotGetNewLumaStuff();
312 void slotGetNewTitleStuff();
313 void slotGetNewRenderStuff();
314 void slotGetNewMltProfileStuff();
315 void slotAutoTransition();
316 void slotRunWizard();
318 void slotZoneMoved(int start, int end);
319 void slotUpdatePreviewSettings();
320 void slotDvdWizard(const QString &url = QString(), const QString &profile = "dv_pal");
321 void slotGroupClips();
322 void slotUnGroupClips();
323 void slotEditItemDuration();
324 void slotSplitAudio();
325 void slotUpdateClipType(QAction *action);
326 void slotShowTimeline(bool show);
327 void slotMaximizeCurrent(bool show);
328 void slotTranscode(KUrl::List urls = KUrl::List());
329 void slotTranscodeClip();
330 void slotSetDocumentRenderProfile(const QString &dest, const QString &group, const QString &name, const QString &file);
331 void slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile);
332 void slotUpdateTimecodeFormat(int ix);
333 /** Removes the focus of anything */
334 void slotRemoveFocus();
335 void slotCleanProject();
336 void slotSetZoom(int value);
337 void slotUpdateClipMarkers(DocClipBase *clip);
340 void slotUpdateTrackInfo();
341 /** \brief Change color scheme */
342 void slotChangePalette(QAction *action, const QString &themename = QString());
343 void slotSwitchMonitors();
344 void slotCheckRenderStatus();
345 void slotInsertZoneToTree();
346 void slotInsertZoneToTimeline();
347 void slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids);
348 void slotShowTitleBars(bool show);
349 void slotSwitchTitles();
352 Q_SCRIPTABLE void abortRenderJob(const QString &url);