mainwindow.h 9.32 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/***************************************************************************
 *   Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
 ***************************************************************************/


Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
21 22
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
23

Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
24
#include <QDockWidget>
25
#include <QUndoView>
26
#include <QLabel>
27
#include <QProgressBar>
28
#include <QEvent>
29
#include <QTimer>
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
30 31 32 33 34

#include <KXmlGuiWindow>
#include <KTextEdit>
#include <KListWidget>
#include <KTabWidget>
35
#include <KUndoStack>
36
#include <KRecentFilesAction>
37
#include <KComboBox>
38
#include <kautosavefile.h>
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
39

40 41
#include "effectslist.h"
#include "gentime.h"
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
42
#include "definitions.h"
43
#include "statusbarmessagelabel.h"
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
44

45 46 47 48 49 50 51 52 53 54 55
class KdenliveDoc;
class TrackView;
class MonitorManager;
class ProjectList;
class EffectsListView;
class EffectStackView;
class TransitionSettings;
class Monitor;
class RecMonitor;
class CustomTrackView;
class RenderWidget;
56
#ifndef NO_JOGSHUTTLE
57
class JogShuttle;
58
#endif /* NO_JOGSHUTTLE */
59
class DocClipBase;
60
class Render;
61
class Transition;
62

63 64
class MainWindow : public KXmlGuiWindow {
    Q_OBJECT
65
    Q_CLASSINFO("D-Bus Interface", "org.kdenlive.MainWindow")
66 67

public:
68 69 70 71 72 73 74 75 76
    /** Constructor
     * \param MltPath path to MLT environment
     * \param Url Url to open
     * \param parent Std. widget parent
     *
     * The constructor inits the main window. If Url is present, it will be opened.
     * If Url is not present, and openLastproject is set, last project will be set
     * If no file is open after trying this, a default "newfile" will be created. */
    MainWindow(const QString &MltPath = QString(), const KUrl & Url = KUrl(), QWidget *parent = 0);
77
    void parseProfiles(const QString &mltPath = QString());
78

Marco Gittler's avatar
Marco Gittler committed
79 80 81 82
    static EffectsList videoEffects;
    static EffectsList audioEffects;
    static EffectsList customEffects;
    static EffectsList transitions;
83
protected:
84
    virtual bool queryClose();
85
    virtual void customEvent(QEvent * e);
86
    virtual void keyPressEvent(QKeyEvent *ke);
87 88
    /** Override hideEvent to get events when the mainwindow gets hidden */
    virtual void hideEvent(QHideEvent *e);
89
    bool eventFilter(QObject *obj, QEvent *ev);
90 91 92 93 94 95 96 97 98 99 100 101
    /**
     * This function is called when it is time for the app to save its
     * properties for session management purposes.
     */
    void saveProperties(KConfig *);

    /**
     * This function is called when this app is restored.  The KConfig
     * object points to the session management config file that was saved
     * with @ref saveProperties
     */
    void readProperties(KConfig *);
102 103

private:
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
104
    KTabWidget* m_timelineArea;
105
    QProgressBar *statusProgressBar;
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
106
    void setupActions();
107
    KdenliveDoc *m_activeDocument;
108
    TrackView *m_activeTimeline;
109
    MonitorManager *m_monitorManager;
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
110 111 112 113 114

    QDockWidget *projectListDock;
    ProjectList *m_projectList;

    QDockWidget *effectListDock;
115 116
    EffectsListView *m_effectList;
    //KListWidget *m_effectList;
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
117 118

    QDockWidget *effectStackDock;
Marco Gittler's avatar
Marco Gittler committed
119
    EffectStackView *effectStack;
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
120 121

    QDockWidget *transitionConfigDock;
122
    TransitionSettings *transitionConfig;
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
123 124 125 126 127 128

    QDockWidget *clipMonitorDock;
    Monitor *m_clipMonitor;

    QDockWidget *projectMonitorDock;
    Monitor *m_projectMonitor;
129

130 131 132
    QDockWidget *recMonitorDock;
    RecMonitor *m_recMonitor;

133 134
    QDockWidget *undoViewDock;
    QUndoView *m_undoView;
135
    QUndoGroup *m_commandStack;
136

137 138
    KComboBox *m_timecodeFormat;

139 140 141
    QDockWidget *overviewDock;
    CustomTrackView *m_overView;

142
    QMenu *m_customEffectsMenu;
143 144 145 146
    QMenu *m_timelineContextMenu;
    QMenu *m_timelineContextClipMenu;
    QMenu *m_timelineContextTransitionMenu;

Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
147
    RenderWidget *m_renderWidget;
148

149
#ifndef NO_JOGSHUTTLE
150
    JogShuttle *m_jogProcess;
151
#endif /* NO_JOGSHUTTLE */
152

153
    KRecentFilesAction *m_fileOpenRecent;
154
    KAction *m_projectSearch;
155
    KAction *m_projectSearchNext;
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
156

157 158 159 160 161 162
    KAction *m_buttonAudioThumbs;
    KAction *m_buttonVideoThumbs;
    KAction *m_buttonShowMarkers;
    KAction *m_buttonFitZoom;
    KAction *m_buttonSelectTool;
    KAction *m_buttonRazorTool;
163
    KAction *m_buttonSpacerTool;
164
    KAction *m_buttonSnap;
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
165
    QActionGroup *m_toolGroup;
166
    KAction *m_saveAction;
167
    KAction *m_closeAction;
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
168
    QSlider *m_zoomSlider;
169 170
    QAction *m_loopZone;
    QAction *m_playZone;
171
    StatusBarMessageLabel *m_messageLabel;
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
172

173 174 175
    bool m_findActivated;
    QString m_findString;
    QTimer m_findTimer;
176
    bool m_initialized;
177

178 179
    void readOptions();
    void saveOptions();
180
#ifndef NO_JOGSHUTTLE
181 182
    void activateShuttleDevice();
    void slotShuttleAction(int code);
183
#endif /* NO_JOGSHUTTLE */
184
    void connectDocumentInfo(KdenliveDoc *doc);
185
    void findAhead();
186 187
    void doOpenFile(const KUrl &url, KAutoSaveFile *stale);
    void recoverFiles(QList<KAutoSaveFile *> staleFiles);
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
188 189 190
    void loadPlugins();
    void populateMenus(QObject *plugin);
    void addToMenu(QObject *plugin, const QStringList &texts,
191 192
                   QMenu *menu, const char *member,
                   QActionGroup *actionGroup);
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
193 194
    void aboutPlugins();
    QStringList m_pluginFileNames;
195

196
public slots:
197
    void openFile(const KUrl &url);
198
    void slotGotProgressInfo(const QString &message, int progress);
199
    Q_SCRIPTABLE void setRenderingProgress(const QString &url, int progress);
200

201
private slots:
202
    void newFile(bool showProjectSettings = true);
203
    void queryQuit();
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
204
    void activateDocument();
205
    void connectDocument(TrackView*, KdenliveDoc*);
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
206
    void openFile();
207
    void openLastFile();
208 209 210
    bool saveFile();
    bool saveFileAs();
    bool saveFileAs(const QString &outputFileName);
211
    void slotPreferences(int page = -1, int option = -1);
212
    void updateConfiguration();
213 214
    void slotConnectMonitors();
    void slotRaiseMonitor(bool clipMonitor);
215
    void slotSetClipDuration(const QString &id, int duration);
216
    void slotUpdateMousePosition(int pos);
217
    void slotAddEffect(QDomElement effect, GenTime pos = GenTime(), int track = -1);
218
    void slotEditProfiles();
219
    void slotEditProjectSettings();
220
    void slotDisplayActionMessage(QAction *a);
221 222
    void slotSwitchVideoThumbs();
    void slotSwitchAudioThumbs();
223
    void slotSwitchMarkersComments();
224
    void slotSwitchSnap();
225
    void slotRenderProject();
226
    void slotDoRender(const QString &dest, const QString &render, const QStringList &overlay_args, const QStringList &avformat_args, bool zoneOnly, bool playAfter, double guideStart, double guideEnd, bool resizeProfile);
227
    void slotFullScreen();
228
    void slotUpdateDocumentState(bool modified);
229 230
    void slotZoomIn();
    void slotZoomOut();
231
    void slotFitZoom();
232
    void closeCurrentDocument();
233
    void slotDeleteTimelineClip();
234
    void slotAddClipMarker();
235
    void slotDeleteClipMarker();
236
    void slotDeleteAllClipMarkers();
237
    void slotEditClipMarker();
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
238
    void slotCutTimelineClip();
239 240 241
    void slotAddVideoEffect(QAction *result);
    void slotAddAudioEffect(QAction *result);
    void slotAddCustomEffect(QAction *result);
242
    void slotAddTransition(QAction *result);
243
    void slotAddProjectClip(KUrl url);
244
#ifndef NO_JOGSHUTTLE
245
    void slotShuttleButton(int code);
246
#endif /* NO_JOGSHUTTLE */
247
    void slotShowClipProperties(DocClipBase *clip);
248
    void slotActivateEffectStackView();
249
    void slotActivateTransitionView(Transition *);
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
250 251
    void slotChangeTool(QAction * action);
    void slotSetTool(PROJECTTOOL tool);
252 253
    void slotSnapForward();
    void slotSnapRewind();
254 255
    void slotClipStart();
    void slotClipEnd();
256 257
    void slotFind();
    void findTimeout();
258
    void slotFindNext();
259

260
    void slotInsertSpace();
261
    void slotRemoveSpace();
262 263 264 265
    void slotAddGuide();
    void slotEditGuide();
    void slotDeleteGuide();
    void slotDeleteAllGuides();
266
    void slotGuidesUpdated();
267 268 269

    void slotCopy();
    void slotPaste();
270
    void slotPasteEffects();
271
    void slotReloadEffects();
272
    void slotChangeClipSpeed();
273 274 275

    void slotAdjustClipMonitor();
    void slotAdjustProjectMonitor();
276
    void slotSaveZone(Render *render, QPoint zone);
277 278 279

    void slotSetInPoint();
    void slotSetOutPoint();
280
    void configureNotifications();
281 282
    void slotInsertTrack(int ix = 0);
    void slotDeleteTrack(int ix = 0);
283
    void slotChangeTrack(int ix = 0);
284
    void slotGetNewStuff();
285
    void slotAutoTransition();
286
    void slotRunWizard();
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
287
    void generateClip();
288
    void slotZoneMoved(int start, int end);
289
    void slotUpdatePreviewSettings();
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
290
};
291

292

Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
293
#endif