]> git.sesse.net Git - kdenlive/blob - src/mainwindow.h
- mainwindow.cpp: possibly avoid a step when locating MLT environment in parseProfiles()
[kdenlive] / src / mainwindow.h
1 /***************************************************************************
2  *   Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
3  *                                                                         *
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.                                   *
8  *                                                                         *
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.                          *
13  *                                                                         *
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  ***************************************************************************/
19
20
21 #ifndef MAINWINDOW_H
22 #define MAINWINDOW_H
23
24 #include <QDockWidget>
25 #include <QUndoView>
26 #include <QLabel>
27 #include <QProgressBar>
28 #include <QEvent>
29 #include <QTimer>
30 #include <QShortcut>
31
32 #include <KXmlGuiWindow>
33 #include <KTextEdit>
34 #include <KListWidget>
35 #include <KTabWidget>
36 #include <KUndoStack>
37 #include <KRecentFilesAction>
38 #include <KComboBox>
39 #include <kautosavefile.h>
40
41 #include "effectslist.h"
42 #include "gentime.h"
43 #include "definitions.h"
44 #include "statusbarmessagelabel.h"
45 #include "dvdwizard.h"
46
47 class KdenliveDoc;
48 class TrackView;
49 class MonitorManager;
50 class ProjectList;
51 class EffectsListView;
52 class EffectStackView;
53 class TransitionSettings;
54 class Monitor;
55 class RecMonitor;
56 class CustomTrackView;
57 class RenderWidget;
58 #ifndef NO_JOGSHUTTLE
59 class JogShuttle;
60 #endif /* NO_JOGSHUTTLE */
61 class DocClipBase;
62 class Render;
63 class Transition;
64
65 class MainWindow : public KXmlGuiWindow
66 {
67     Q_OBJECT
68     Q_CLASSINFO("D-Bus Interface", "org.kdenlive.MainWindow")
69
70 public:
71
72     /** @brief Initialises the main window.
73      * @param MltPath (optional) path to MLT environment
74      * @param Url (optional) file to open
75      *
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);
81
82     /** @brief Locates the MLT environment.
83      * @param mltPath (optional) path to MLT environment
84      *
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());
89
90     static EffectsList videoEffects;
91     static EffectsList audioEffects;
92     static EffectsList customEffects;
93     static EffectsList transitions;
94 protected:
95
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,
99      *     true otherwise */
100     virtual bool queryClose();
101
102     /** @brief Reports a message in the status bar when an error occurs. */
103     virtual void customEvent(QEvent *e);
104
105     /** @brief Enables live search in the timeline. */
106     virtual void keyPressEvent(QKeyEvent *ke);
107
108     /** @brief Stops the active monitor when the window gets hidden. */
109     virtual void hideEvent(QHideEvent *e);
110
111     /** @brief Filters key events to the live search. */
112     bool eventFilter(QObject *obj, QEvent *ev);
113
114     /** @brief Saves the file and the window properties when saving the session. */
115     virtual void saveProperties(KConfigGroup &config);
116
117     /** @brief Restores the window and the file when a session is loaded. */
118     virtual void readProperties(const KConfigGroup &config);
119
120 private:
121     KTabWidget* m_timelineArea;
122     QProgressBar *m_statusProgressBar;
123     void setupActions();
124     KdenliveDoc *m_activeDocument;
125     TrackView *m_activeTimeline;
126     MonitorManager *m_monitorManager;
127
128     QDockWidget *m_projectListDock;
129     ProjectList *m_projectList;
130
131     QDockWidget *m_effectListDock;
132     EffectsListView *m_effectList;
133     //KListWidget *m_effectList;
134
135     QDockWidget *m_effectStackDock;
136     EffectStackView *m_effectStack;
137
138     QDockWidget *m_transitionConfigDock;
139     TransitionSettings *m_transitionConfig;
140
141     QDockWidget *m_clipMonitorDock;
142     Monitor *m_clipMonitor;
143
144     QDockWidget *m_projectMonitorDock;
145     Monitor *m_projectMonitor;
146
147     QDockWidget *m_recMonitorDock;
148     RecMonitor *m_recMonitor;
149
150     QDockWidget *m_undoViewDock;
151     QUndoView *m_undoView;
152     QUndoGroup *m_commandStack;
153
154     KComboBox *m_timecodeFormat;
155
156     QMenu *m_customEffectsMenu;
157     QMenu *m_timelineContextMenu;
158     QMenu *m_timelineContextClipMenu;
159     QMenu *m_timelineContextTransitionMenu;
160     KUrl m_startUrl;
161
162     /** @brief Shortcut to remove the focus from any element.
163      *
164      * It allows to get out of e.g. text input fields and to press another
165      * shortcut. */
166     QShortcut* m_shortcutRemoveFocus;
167
168     RenderWidget *m_renderWidget;
169
170 #ifndef NO_JOGSHUTTLE
171     JogShuttle *m_jogProcess;
172 #endif /* NO_JOGSHUTTLE */
173
174     KRecentFilesAction *m_fileOpenRecent;
175     KAction *m_fileRevert;
176     KAction *m_projectSearch;
177     KAction *m_projectSearchNext;
178
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;
193     KAction *m_loopZone;
194     KAction *m_playZone;
195     StatusBarMessageLabel *m_messageLabel;
196     QActionGroup *m_clipTypeGroup;
197
198     bool m_findActivated;
199     QString m_findString;
200     QTimer m_findTimer;
201
202     void readOptions();
203     void saveOptions();
204 #ifndef NO_JOGSHUTTLE
205     void activateShuttleDevice();
206     void slotShuttleAction(int code);
207 #endif /* NO_JOGSHUTTLE */
208     void connectDocumentInfo(KdenliveDoc *doc);
209     void findAhead();
210     void doOpenFile(const KUrl &url, KAutoSaveFile *stale);
211     void recoverFiles(QList<KAutoSaveFile *> staleFiles);
212     void loadPlugins();
213     void populateMenus(QObject *plugin);
214     void addToMenu(QObject *plugin, const QStringList &texts,
215                    QMenu *menu, const char *member,
216                    QActionGroup *actionGroup);
217     void aboutPlugins();
218     int getNewStuff(const QString &configFile = QString());
219     QStringList m_pluginFileNames;
220     QByteArray m_timelineState;
221     void loadTranscoders();
222     QPixmap createSchemePreviewIcon(const KSharedConfigPtr &config);
223
224 public slots:
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);
229
230 private slots:
231     void newFile(bool showProjectSettings = true, bool force = false);
232     void queryQuit();
233     void activateDocument();
234     void connectDocument(TrackView*, KdenliveDoc*);
235     void openFile();
236     void openLastFile();
237     bool saveFile();
238     bool saveFileAs();
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);
258     void slotZoomIn();
259     void slotZoomOut();
260     void slotFitZoom();
261     void closeCurrentDocument(bool saveChanges = true);
262     void slotDeleteTimelineClip();
263     void slotAddClipMarker();
264     void slotDeleteClipMarker();
265     void slotDeleteAllClipMarkers();
266     void slotEditClipMarker();
267     void slotCutTimelineClip();
268     void slotInsertClipOverwrite();
269     void slotSelectTimelineClip();
270     void slotSelectTimelineTransition();
271     void slotDeselectTimelineClip();
272     void slotDeselectTimelineTransition();
273     void slotSelectAddTimelineClip();
274     void slotSelectAddTimelineTransition();
275     void slotAddVideoEffect(QAction *result);
276     void slotAddAudioEffect(QAction *result);
277     void slotAddCustomEffect(QAction *result);
278     void slotAddTransition(QAction *result);
279     void slotAddProjectClip(KUrl url);
280 #ifndef NO_JOGSHUTTLE
281     void slotShuttleButton(int code);
282 #endif /* NO_JOGSHUTTLE */
283     void slotShowClipProperties(DocClipBase *clip);
284     void slotShowClipProperties(QList <DocClipBase *>cliplist, QMap<QString, QString> commonproperties);
285     void slotActivateEffectStackView();
286     void slotActivateTransitionView(Transition *);
287     void slotChangeTool(QAction * action);
288     void slotChangeEdit(QAction * action);
289     void slotSetTool(PROJECTTOOL tool);
290     void slotSnapForward();
291     void slotSnapRewind();
292     void slotClipStart();
293     void slotClipEnd();
294     void slotZoneStart();
295     void slotZoneEnd();
296     void slotFind();
297     void findTimeout();
298     void slotFindNext();
299     void slotSelectClipInTimeline();
300     void slotClipInTimeline(const QString &clipId);
301
302     void slotInsertSpace();
303     void slotRemoveSpace();
304     void slotAddGuide();
305     void slotEditGuide();
306     void slotDeleteGuide();
307     void slotDeleteAllGuides();
308     void slotGuidesUpdated();
309
310     void slotCopy();
311     void slotPaste();
312     void slotPasteEffects();
313     void slotReloadEffects();
314
315     void slotAdjustClipMonitor();
316     void slotAdjustProjectMonitor();
317     void slotSaveZone(Render *render, QPoint zone);
318
319     void slotSetInPoint();
320     void slotSetOutPoint();
321     void slotResizeItemStart();
322     void slotResizeItemEnd();
323     void configureNotifications();
324     void slotInsertTrack(int ix = 0);
325     void slotDeleteTrack(int ix = 0);
326     void slotChangeTrack(int ix = 0);
327     void slotGetNewLumaStuff();
328     void slotGetNewTitleStuff();
329     void slotGetNewRenderStuff();
330     void slotGetNewMltProfileStuff();
331     void slotAutoTransition();
332     void slotRunWizard();
333     void generateClip();
334     void slotZoneMoved(int start, int end);
335     void slotUpdatePreviewSettings();
336     void slotDvdWizard(const QString &url = QString(), const QString &profile = "dv_pal");
337     void slotGroupClips();
338     void slotUnGroupClips();
339     void slotEditItemDuration();
340     void slotClipInProjectTree();
341     void slotSplitAudio();
342     void slotUpdateClipType(QAction *action);
343     void slotShowTimeline(bool show);
344     void slotMaximizeCurrent(bool show);
345     void slotTranscode(KUrl::List urls = KUrl::List());
346     void slotTranscodeClip();
347     void slotSetDocumentRenderProfile(const QString &dest, const QString &group, const QString &name, const QString &file);
348     void slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile);
349     void slotUpdateTimecodeFormat(int ix);
350     /** Removes the focus of anything */
351     void slotRemoveFocus();
352     void slotCleanProject();
353     void slotSetZoom(int value);
354     void slotUpdateClipMarkers(DocClipBase *clip);
355     void slotRevert();
356     void slotShutdown();
357     void slotUpdateTrackInfo();
358     /** @brief Changes the color scheme. */
359     void slotChangePalette(QAction *action, const QString &themename = QString());
360     void slotSwitchMonitors();
361     void slotCheckRenderStatus();
362     void slotInsertZoneToTree();
363     void slotInsertZoneToTimeline();
364     void slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids);
365     void slotShowTitleBars(bool show);
366     void slotSwitchTitles();
367
368 signals:
369     Q_SCRIPTABLE void abortRenderJob(const QString &url);
370 };
371
372
373 #endif