]> git.sesse.net Git - kdenlive/blob - src/mainwindow.h
Add zoom in/out buttons to status bar
[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
124     /** @brief Sets up all the actions and attaches them to the collection. */
125     void setupActions();
126     KdenliveDoc *m_activeDocument;
127     TrackView *m_activeTimeline;
128     MonitorManager *m_monitorManager;
129
130     QDockWidget *m_projectListDock;
131     ProjectList *m_projectList;
132
133     QDockWidget *m_effectListDock;
134     EffectsListView *m_effectList;
135     //KListWidget *m_effectList;
136
137     QDockWidget *m_effectStackDock;
138     EffectStackView *m_effectStack;
139
140     QDockWidget *m_transitionConfigDock;
141     TransitionSettings *m_transitionConfig;
142
143     QDockWidget *m_clipMonitorDock;
144     Monitor *m_clipMonitor;
145
146     QDockWidget *m_projectMonitorDock;
147     Monitor *m_projectMonitor;
148
149     QDockWidget *m_recMonitorDock;
150     RecMonitor *m_recMonitor;
151
152     QDockWidget *m_undoViewDock;
153     QUndoView *m_undoView;
154     QUndoGroup *m_commandStack;
155
156     KComboBox *m_timecodeFormat;
157
158     QMenu *m_videoEffectsMenu;
159     QMenu *m_audioEffectsMenu;
160     QMenu *m_customEffectsMenu;
161     QMenu *m_transitionsMenu;
162     QMenu *m_timelineContextMenu;
163     QMenu *m_timelineContextClipMenu;
164     QMenu *m_timelineContextTransitionMenu;
165     KUrl m_startUrl;
166
167     /** @brief Shortcut to remove the focus from any element.
168      *
169      * It allows to get out of e.g. text input fields and to press another
170      * shortcut. */
171     QShortcut* m_shortcutRemoveFocus;
172
173     RenderWidget *m_renderWidget;
174
175 #ifndef NO_JOGSHUTTLE
176     JogShuttle *m_jogProcess;
177 #endif /* NO_JOGSHUTTLE */
178
179     KRecentFilesAction *m_fileOpenRecent;
180     KAction *m_fileRevert;
181     KAction *m_projectSearch;
182     KAction *m_projectSearchNext;
183
184     KAction **m_videoEffects;
185     KAction **m_audioEffects;
186     KAction **m_customEffects;
187     KAction **m_transitions;
188     KAction *m_buttonAudioThumbs;
189     KAction *m_buttonVideoThumbs;
190     KAction *m_buttonShowMarkers;
191     KAction *m_buttonFitZoom;
192     KAction *m_normalEditTool;
193     KAction *m_overwriteEditTool;
194     KAction *m_insertEditTool;
195     KAction *m_buttonSelectTool;
196     KAction *m_buttonRazorTool;
197     KAction *m_buttonSpacerTool;
198     KAction *m_buttonSnap;
199     KAction *m_saveAction;
200     KAction *m_closeAction;
201     QSlider *m_zoomSlider;
202     KAction *m_zoomIn;
203     KAction *m_zoomOut;
204     KAction *m_loopZone;
205     KAction *m_playZone;
206     StatusBarMessageLabel *m_messageLabel;
207     QActionGroup *m_clipTypeGroup;
208
209     bool m_findActivated;
210     QString m_findString;
211     QTimer m_findTimer;
212
213     void readOptions();
214     void saveOptions();
215 #ifndef NO_JOGSHUTTLE
216     void activateShuttleDevice();
217     void slotShuttleAction(int code);
218 #endif /* NO_JOGSHUTTLE */
219     void connectDocumentInfo(KdenliveDoc *doc);
220     void findAhead();
221     void doOpenFile(const KUrl &url, KAutoSaveFile *stale);
222     void recoverFiles(QList<KAutoSaveFile *> staleFiles);
223     void loadPlugins();
224     void populateMenus(QObject *plugin);
225     void addToMenu(QObject *plugin, const QStringList &texts,
226                    QMenu *menu, const char *member,
227                    QActionGroup *actionGroup);
228     void aboutPlugins();
229
230     /** @brief Instantiates a "Get Hot New Stuff" dialog.
231      * @param configFile configuration file for KNewStuff
232      * @return number of installed items */
233     int getNewStuff(const QString &configFile = QString());
234     QStringList m_pluginFileNames;
235     QByteArray m_timelineState;
236     void loadTranscoders();
237     QPixmap createSchemePreviewIcon(const KSharedConfigPtr &config);
238
239 public slots:
240     void openFile(const KUrl &url);
241     void slotGotProgressInfo(const QString &message, int progress);
242     Q_SCRIPTABLE void setRenderingProgress(const QString &url, int progress);
243     Q_SCRIPTABLE void setRenderingFinished(const QString &url, int status, const QString &error);
244
245 private slots:
246     void newFile(bool showProjectSettings = true, bool force = false);
247     void queryQuit();
248     void activateDocument();
249     void connectDocument(TrackView*, KdenliveDoc*);
250     void openFile();
251     void openLastFile();
252     /** @brief Checks whether a URL is available to save to.
253     * @return Whether the file was saved. */
254     bool saveFile();
255     /** @brief Shows a save file dialog for saving the project.
256     * @return Whether the file was saved. */
257     bool saveFileAs();
258     /** @brief Set properties to match outputFileName and save the document.
259     * @param outputFileName The URL to save to / The document's URL.
260     * @return Whether we had success. */
261     bool saveFileAs(const QString &outputFileName);
262     void slotPreferences(int page = -1, int option = -1);
263     void updateConfiguration();
264     void slotConnectMonitors();
265     void slotRaiseMonitor(bool clipMonitor);
266     void slotUpdateClip(const QString &id);
267     void slotUpdateMousePosition(int pos);
268     void slotAddEffect(const QDomElement effect, GenTime pos = GenTime(), int track = -1);
269     void slotEditProfiles();
270     void slotDetectAudioDriver();
271     void slotEditProjectSettings();
272     void slotDisplayActionMessage(QAction *a);
273     void slotSwitchVideoThumbs();
274     void slotSwitchAudioThumbs();
275     void slotSwitchMarkersComments();
276     void slotSwitchSnap();
277     void slotRenderProject();
278     void slotFullScreen();
279     void slotUpdateDocumentState(bool modified);
280     void slotZoomIn();
281     void slotZoomOut();
282     void slotFitZoom();
283     void closeCurrentDocument(bool saveChanges = true);
284     /** @brief Delete item in timeline, project tree or effect stack depending on focus. */
285     void slotDeleteItem();
286     void slotAddClipMarker();
287     void slotDeleteClipMarker();
288     void slotDeleteAllClipMarkers();
289     void slotEditClipMarker();
290     void slotCutTimelineClip();
291     void slotInsertClipOverwrite();
292     void slotSelectTimelineClip();
293     void slotSelectTimelineTransition();
294     void slotDeselectTimelineClip();
295     void slotDeselectTimelineTransition();
296     void slotSelectAddTimelineClip();
297     void slotSelectAddTimelineTransition();
298     void slotAddVideoEffect(QAction *result);
299     void slotAddAudioEffect(QAction *result);
300     void slotAddCustomEffect(QAction *result);
301     void slotAddTransition(QAction *result);
302     void slotAddProjectClip(KUrl url);
303 #ifndef NO_JOGSHUTTLE
304     void slotShuttleButton(int code);
305 #endif /* NO_JOGSHUTTLE */
306     void slotShowClipProperties(DocClipBase *clip);
307     void slotShowClipProperties(QList <DocClipBase *>cliplist, QMap<QString, QString> commonproperties);
308     void slotActivateEffectStackView();
309     void slotActivateTransitionView(Transition *);
310     void slotChangeTool(QAction * action);
311     void slotChangeEdit(QAction * action);
312     void slotSetTool(PROJECTTOOL tool);
313     void slotSnapForward();
314     void slotSnapRewind();
315     void slotClipStart();
316     void slotClipEnd();
317     void slotZoneStart();
318     void slotZoneEnd();
319     void slotFind();
320     void findTimeout();
321     void slotFindNext();
322     void slotSelectClipInTimeline();
323     void slotClipInTimeline(const QString &clipId);
324
325     void slotInsertSpace();
326     void slotRemoveSpace();
327     void slotAddGuide();
328     void slotEditGuide();
329     void slotDeleteGuide();
330     void slotDeleteAllGuides();
331     void slotGuidesUpdated();
332
333     void slotCopy();
334     void slotPaste();
335     void slotPasteEffects();
336     void slotReloadEffects();
337
338     void slotAdjustClipMonitor();
339     void slotAdjustProjectMonitor();
340     void slotSaveZone(Render *render, QPoint zone);
341
342     void slotSetInPoint();
343     void slotSetOutPoint();
344     void slotResizeItemStart();
345     void slotResizeItemEnd();
346     void configureNotifications();
347     void slotInsertTrack(int ix = 0);
348     void slotDeleteTrack(int ix = 0);
349     void slotChangeTrack(int ix = 0);
350     void slotGetNewLumaStuff();
351     void slotGetNewTitleStuff();
352     void slotGetNewRenderStuff();
353     void slotGetNewMltProfileStuff();
354     void slotAutoTransition();
355     void slotRunWizard();
356     void generateClip();
357     void slotZoneMoved(int start, int end);
358     void slotUpdatePreviewSettings();
359     void slotDvdWizard(const QString &url = QString(), const QString &profile = "dv_pal");
360     void slotGroupClips();
361     void slotUnGroupClips();
362     void slotEditItemDuration();
363     void slotClipInProjectTree();
364     void slotSplitAudio();
365     void slotUpdateClipType(QAction *action);
366     void slotShowTimeline(bool show);
367     void slotMaximizeCurrent(bool show);
368     void slotTranscode(KUrl::List urls = KUrl::List());
369     void slotTranscodeClip();
370     void slotSetDocumentRenderProfile(const QString &dest, const QString &group, const QString &name, const QString &file);
371     void slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile);
372     void slotUpdateTimecodeFormat(int ix);
373     /** Removes the focus of anything */
374     void slotRemoveFocus();
375     void slotCleanProject();
376     void slotSetZoom(int value);
377     void slotUpdateClipMarkers(DocClipBase *clip);
378     void slotRevert();
379     void slotShutdown();
380     void slotUpdateTrackInfo();
381
382     /** @brief Changes the color scheme. */
383     void slotChangePalette(QAction *action, const QString &themename = QString());
384     void slotSwitchMonitors();
385     void slotCheckRenderStatus();
386     void slotInsertZoneToTree();
387     void slotInsertZoneToTimeline();
388     void slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids);
389     void slotShowTitleBars(bool show);
390     void slotSwitchTitles();
391
392 signals:
393     Q_SCRIPTABLE void abortRenderJob(const QString &url);
394 };
395
396
397 #endif