]> git.sesse.net Git - kdenlive/blob - src/mainwindow.h
7cd9bc7c632c6e9b4c4ccf5bbb3afee0bc87fc17
[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     /** Constructor
72      * \param MltPath path to MLT environment
73      * \param Url Url to open
74      * \param parent Std. widget parent
75      *
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());
81
82     static EffectsList videoEffects;
83     static EffectsList audioEffects;
84     static EffectsList customEffects;
85     static EffectsList transitions;
86 protected:
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);
93     /**
94      * This function is called when it is time for the app to save its
95      * properties for session management purposes.
96      */
97     virtual void saveProperties(KConfigGroup &config);
98
99     /**
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
103      */
104     virtual void readProperties(const KConfigGroup &config);
105
106 private:
107     KTabWidget* m_timelineArea;
108     QProgressBar *m_statusProgressBar;
109     void setupActions();
110     KdenliveDoc *m_activeDocument;
111     TrackView *m_activeTimeline;
112     MonitorManager *m_monitorManager;
113
114     QDockWidget *m_projectListDock;
115     ProjectList *m_projectList;
116
117     QDockWidget *m_effectListDock;
118     EffectsListView *m_effectList;
119     //KListWidget *m_effectList;
120
121     QDockWidget *m_effectStackDock;
122     EffectStackView *m_effectStack;
123
124     QDockWidget *m_transitionConfigDock;
125     TransitionSettings *m_transitionConfig;
126
127     QDockWidget *m_clipMonitorDock;
128     Monitor *m_clipMonitor;
129
130     QDockWidget *m_projectMonitorDock;
131     Monitor *m_projectMonitor;
132
133     QDockWidget *m_recMonitorDock;
134     RecMonitor *m_recMonitor;
135
136     QDockWidget *m_undoViewDock;
137     QUndoView *m_undoView;
138     QUndoGroup *m_commandStack;
139
140     KComboBox *m_timecodeFormat;
141
142     QMenu *m_customEffectsMenu;
143     QMenu *m_timelineContextMenu;
144     QMenu *m_timelineContextClipMenu;
145     QMenu *m_timelineContextTransitionMenu;
146     KUrl m_startUrl;
147
148     /**
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.
151      */
152     QShortcut* m_shortcutRemoveFocus;
153
154     RenderWidget *m_renderWidget;
155
156 #ifndef NO_JOGSHUTTLE
157     JogShuttle *m_jogProcess;
158 #endif /* NO_JOGSHUTTLE */
159
160     KRecentFilesAction *m_fileOpenRecent;
161     KAction *m_fileRevert;
162     KAction *m_projectSearch;
163     KAction *m_projectSearchNext;
164
165     KAction *m_buttonAudioThumbs;
166     KAction *m_buttonVideoThumbs;
167     KAction *m_buttonShowMarkers;
168     KAction *m_buttonFitZoom;
169     KAction *m_overwriteModeTool;
170     KAction *m_insertModeTool;
171     KAction *m_buttonSelectTool;
172     KAction *m_buttonRazorTool;
173     KAction *m_buttonSpacerTool;
174     KAction *m_buttonSnap;
175     KAction *m_saveAction;
176     KAction *m_closeAction;
177     QSlider *m_zoomSlider;
178     KAction *m_loopZone;
179     KAction *m_playZone;
180     StatusBarMessageLabel *m_messageLabel;
181     QActionGroup *m_clipTypeGroup;
182
183     bool m_findActivated;
184     QString m_findString;
185     QTimer m_findTimer;
186
187     void readOptions();
188     void saveOptions();
189 #ifndef NO_JOGSHUTTLE
190     void activateShuttleDevice();
191     void slotShuttleAction(int code);
192 #endif /* NO_JOGSHUTTLE */
193     void connectDocumentInfo(KdenliveDoc *doc);
194     void findAhead();
195     void doOpenFile(const KUrl &url, KAutoSaveFile *stale);
196     void recoverFiles(QList<KAutoSaveFile *> staleFiles);
197     void loadPlugins();
198     void populateMenus(QObject *plugin);
199     void addToMenu(QObject *plugin, const QStringList &texts,
200                    QMenu *menu, const char *member,
201                    QActionGroup *actionGroup);
202     void aboutPlugins();
203     QStringList m_pluginFileNames;
204     QByteArray m_timelineState;
205     void loadTranscoders();
206     QPixmap createSchemePreviewIcon(const KSharedConfigPtr &config);
207
208 public slots:
209     void openFile(const KUrl &url);
210     void slotGotProgressInfo(const QString &message, int progress);
211     Q_SCRIPTABLE void setRenderingProgress(const QString &url, int progress);
212     Q_SCRIPTABLE void setRenderingFinished(const QString &url, int status, const QString &error);
213
214 private slots:
215     void newFile(bool showProjectSettings = true);
216     void queryQuit();
217     void activateDocument();
218     void connectDocument(TrackView*, KdenliveDoc*);
219     void openFile();
220     void openLastFile();
221     bool saveFile();
222     bool saveFileAs();
223     bool saveFileAs(const QString &outputFileName);
224     void slotPreferences(int page = -1, int option = -1);
225     void updateConfiguration();
226     void slotConnectMonitors();
227     void slotRaiseMonitor(bool clipMonitor);
228     void slotUpdateClip(const QString &id);
229     void slotUpdateMousePosition(int pos);
230     void slotAddEffect(const QDomElement effect, GenTime pos = GenTime(), int track = -1);
231     void slotEditProfiles();
232     void slotDetectAudioDriver();
233     void slotEditProjectSettings();
234     void slotDisplayActionMessage(QAction *a);
235     void slotSwitchVideoThumbs();
236     void slotSwitchAudioThumbs();
237     void slotSwitchMarkersComments();
238     void slotSwitchSnap();
239     void slotRenderProject();
240     void slotFullScreen();
241     void slotUpdateDocumentState(bool modified);
242     void slotZoomIn();
243     void slotZoomOut();
244     void slotFitZoom();
245     void closeCurrentDocument(bool saveChanges = true);
246     void slotDeleteTimelineClip();
247     void slotAddClipMarker();
248     void slotDeleteClipMarker();
249     void slotDeleteAllClipMarkers();
250     void slotEditClipMarker();
251     void slotCutTimelineClip();
252     void slotSelectTimelineClip();
253     void slotSelectTimelineTransition();
254     void slotDeselectTimelineClip();
255     void slotDeselectTimelineTransition();
256     void slotSelectAddTimelineClip();
257     void slotSelectAddTimelineTransition();
258     void slotAddVideoEffect(QAction *result);
259     void slotAddAudioEffect(QAction *result);
260     void slotAddCustomEffect(QAction *result);
261     void slotAddTransition(QAction *result);
262     void slotAddProjectClip(KUrl url);
263 #ifndef NO_JOGSHUTTLE
264     void slotShuttleButton(int code);
265 #endif /* NO_JOGSHUTTLE */
266     void slotShowClipProperties(DocClipBase *clip);
267     void slotActivateEffectStackView();
268     void slotActivateTransitionView(Transition *);
269     void slotChangeTool(QAction * action);
270     void slotChangeEdit(QAction * action);
271     void slotSetTool(PROJECTTOOL tool);
272     void slotSnapForward();
273     void slotSnapRewind();
274     void slotClipStart();
275     void slotClipEnd();
276     void slotZoneStart();
277     void slotZoneEnd();
278     void slotFind();
279     void findTimeout();
280     void slotFindNext();
281
282     void slotInsertSpace();
283     void slotRemoveSpace();
284     void slotAddGuide();
285     void slotEditGuide();
286     void slotDeleteGuide();
287     void slotDeleteAllGuides();
288     void slotGuidesUpdated();
289
290     void slotCopy();
291     void slotPaste();
292     void slotPasteEffects();
293     void slotReloadEffects();
294
295     void slotAdjustClipMonitor();
296     void slotAdjustProjectMonitor();
297     void slotSaveZone(Render *render, QPoint zone);
298
299     void slotSetInPoint();
300     void slotSetOutPoint();
301     void slotResizeItemStart();
302     void slotResizeItemEnd();
303     void configureNotifications();
304     void slotInsertTrack(int ix = 0);
305     void slotDeleteTrack(int ix = 0);
306     void slotChangeTrack(int ix = 0);
307     void slotGetNewLumaStuff();
308     void slotGetNewRenderStuff();
309     void slotGetNewMltProfileStuff();
310     void slotAutoTransition();
311     void slotRunWizard();
312     void generateClip();
313     void slotZoneMoved(int start, int end);
314     void slotUpdatePreviewSettings();
315     void slotDvdWizard(const QString &url = QString(), const QString &profile = "dv_pal");
316     void slotGroupClips();
317     void slotUnGroupClips();
318     void slotSplitAudio();
319     void slotUpdateClipType(QAction *action);
320     void slotShowTimeline(bool show);
321     void slotMaximizeCurrent(bool show);
322     void slotTranscode(KUrl::List urls = KUrl::List());
323     void slotTranscodeClip();
324     void slotSetDocumentRenderProfile(const QString &dest, const QString &name, const QString &file);
325     void slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile);
326     void slotUpdateTimecodeFormat(int ix);
327     /** Removes the focus of anything */
328     void slotRemoveFocus();
329     void slotCleanProject();
330     void slotSetZoom(int value);
331     void slotUpdateClipMarkers(DocClipBase *clip);
332     void slotRevert();
333     void slotShutdown();
334     void slotUpdateTrackInfo();
335     /** \brief Change color scheme */
336     void slotChangePalette(QAction *action, const QString &themename = QString());
337
338 signals:
339     Q_SCRIPTABLE void abortRenderJob(const QString &url);
340 };
341
342
343 #endif