]> git.sesse.net Git - kdenlive/blob - src/mainwindow.h
The save file dialog should appear again if we don't want to overwrite the selected...
[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     /** @brief Checks whether a URL is available to save to.
238     * @return Whether the file was saved. */
239     bool saveFile();
240     /** @brief Shows a save file dialog for saving the project.
241     * @return Whether the file was saved. */
242     bool saveFileAs();
243     /** @brief Set properties to match outputFileName and save the document.
244     * @param outputFileName The URL to save to / The document's URL.
245     * @return Whether we had success. */
246     bool saveFileAs(const QString &outputFileName);
247     void slotPreferences(int page = -1, int option = -1);
248     void updateConfiguration();
249     void slotConnectMonitors();
250     void slotRaiseMonitor(bool clipMonitor);
251     void slotUpdateClip(const QString &id);
252     void slotUpdateMousePosition(int pos);
253     void slotAddEffect(const QDomElement effect, GenTime pos = GenTime(), int track = -1);
254     void slotEditProfiles();
255     void slotDetectAudioDriver();
256     void slotEditProjectSettings();
257     void slotDisplayActionMessage(QAction *a);
258     void slotSwitchVideoThumbs();
259     void slotSwitchAudioThumbs();
260     void slotSwitchMarkersComments();
261     void slotSwitchSnap();
262     void slotRenderProject();
263     void slotFullScreen();
264     void slotUpdateDocumentState(bool modified);
265     void slotZoomIn();
266     void slotZoomOut();
267     void slotFitZoom();
268     void closeCurrentDocument(bool saveChanges = true);
269     /** @brief Delete item in timeline, project tree or effect stack depending on focus. */
270     void slotDeleteItem();
271     void slotAddClipMarker();
272     void slotDeleteClipMarker();
273     void slotDeleteAllClipMarkers();
274     void slotEditClipMarker();
275     void slotCutTimelineClip();
276     void slotInsertClipOverwrite();
277     void slotSelectTimelineClip();
278     void slotSelectTimelineTransition();
279     void slotDeselectTimelineClip();
280     void slotDeselectTimelineTransition();
281     void slotSelectAddTimelineClip();
282     void slotSelectAddTimelineTransition();
283     void slotAddVideoEffect(QAction *result);
284     void slotAddAudioEffect(QAction *result);
285     void slotAddCustomEffect(QAction *result);
286     void slotAddTransition(QAction *result);
287     void slotAddProjectClip(KUrl url);
288 #ifndef NO_JOGSHUTTLE
289     void slotShuttleButton(int code);
290 #endif /* NO_JOGSHUTTLE */
291     void slotShowClipProperties(DocClipBase *clip);
292     void slotShowClipProperties(QList <DocClipBase *>cliplist, QMap<QString, QString> commonproperties);
293     void slotActivateEffectStackView();
294     void slotActivateTransitionView(Transition *);
295     void slotChangeTool(QAction * action);
296     void slotChangeEdit(QAction * action);
297     void slotSetTool(PROJECTTOOL tool);
298     void slotSnapForward();
299     void slotSnapRewind();
300     void slotClipStart();
301     void slotClipEnd();
302     void slotZoneStart();
303     void slotZoneEnd();
304     void slotFind();
305     void findTimeout();
306     void slotFindNext();
307     void slotSelectClipInTimeline();
308     void slotClipInTimeline(const QString &clipId);
309
310     void slotInsertSpace();
311     void slotRemoveSpace();
312     void slotAddGuide();
313     void slotEditGuide();
314     void slotDeleteGuide();
315     void slotDeleteAllGuides();
316     void slotGuidesUpdated();
317
318     void slotCopy();
319     void slotPaste();
320     void slotPasteEffects();
321     void slotReloadEffects();
322
323     void slotAdjustClipMonitor();
324     void slotAdjustProjectMonitor();
325     void slotSaveZone(Render *render, QPoint zone);
326
327     void slotSetInPoint();
328     void slotSetOutPoint();
329     void slotResizeItemStart();
330     void slotResizeItemEnd();
331     void configureNotifications();
332     void slotInsertTrack(int ix = 0);
333     void slotDeleteTrack(int ix = 0);
334     void slotChangeTrack(int ix = 0);
335     void slotGetNewLumaStuff();
336     void slotGetNewTitleStuff();
337     void slotGetNewRenderStuff();
338     void slotGetNewMltProfileStuff();
339     void slotAutoTransition();
340     void slotRunWizard();
341     void generateClip();
342     void slotZoneMoved(int start, int end);
343     void slotUpdatePreviewSettings();
344     void slotDvdWizard(const QString &url = QString(), const QString &profile = "dv_pal");
345     void slotGroupClips();
346     void slotUnGroupClips();
347     void slotEditItemDuration();
348     void slotClipInProjectTree();
349     void slotSplitAudio();
350     void slotUpdateClipType(QAction *action);
351     void slotShowTimeline(bool show);
352     void slotMaximizeCurrent(bool show);
353     void slotTranscode(KUrl::List urls = KUrl::List());
354     void slotTranscodeClip();
355     void slotSetDocumentRenderProfile(const QString &dest, const QString &group, const QString &name, const QString &file);
356     void slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile);
357     void slotUpdateTimecodeFormat(int ix);
358     /** Removes the focus of anything */
359     void slotRemoveFocus();
360     void slotCleanProject();
361     void slotSetZoom(int value);
362     void slotUpdateClipMarkers(DocClipBase *clip);
363     void slotRevert();
364     void slotShutdown();
365     void slotUpdateTrackInfo();
366     /** @brief Changes the color scheme. */
367     void slotChangePalette(QAction *action, const QString &themename = QString());
368     void slotSwitchMonitors();
369     void slotCheckRenderStatus();
370     void slotInsertZoneToTree();
371     void slotInsertZoneToTimeline();
372     void slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids);
373     void slotShowTitleBars(bool show);
374     void slotSwitchTitles();
375
376 signals:
377     Q_SCRIPTABLE void abortRenderJob(const QString &url);
378 };
379
380
381 #endif