]> git.sesse.net Git - kdenlive/blob - src/mainwindow.h
Fix parts of Kdenlive not responding to color theme change
[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 #include <KActionCategory>
41
42 #include "effectslist.h"
43 #include "gentime.h"
44 #include "definitions.h"
45 #include "statusbarmessagelabel.h"
46 #include "dvdwizard.h"
47 #include "stopmotion/stopmotion.h"
48 #include "noteswidget.h"
49 #include "ui_backupdialog_ui.h"
50
51 class KdenliveDoc;
52 class TrackView;
53 class MonitorManager;
54 class ProjectList;
55 class EffectsListView;
56 class EffectStackView;
57 class EffectStackView2;
58 class TransitionSettings;
59 class Monitor;
60 class RecMonitor;
61 class CustomTrackView;
62 class RenderWidget;
63 #ifdef USE_JOGSHUTTLE
64 class JogShuttle;
65 class JogShuttleAction;
66 #endif
67 class DocClipBase;
68 class Render;
69 class Transition;
70 class ScopeManager;
71 class Histogram;
72 class Vectorscope;
73 class Waveform;
74 class RGBParade;
75 class KActionCollection;
76 class AudioSignal;
77 class AbstractAudioScopeWidget;
78 class AudioSpectrum;
79 class Spectrogram;
80
81 class MainWindow : public KXmlGuiWindow
82 {
83     Q_OBJECT
84     Q_CLASSINFO("D-Bus Interface", "org.kdenlive.MainWindow")
85
86 public:
87
88     /** @brief Initialises the main window.
89      * @param MltPath (optional) path to MLT environment
90      * @param Url (optional) file to open
91      * @param clipsToLoad (optional) a comma separated list of clips to import in project
92      *
93      * If Url is present, it will be opened, otherwhise, if openlastproject is
94      * set, latest project will be opened. If no file is open after trying this,
95      * a default new file will be created. */
96     explicit MainWindow(const QString &MltPath = QString(),
97                         const KUrl &Url = KUrl(), const QString & clipsToLoad = QString(), QWidget *parent = 0);
98     virtual ~MainWindow();
99
100     /** @brief Locates the MLT environment.
101      * @param mltPath (optional) path to MLT environment
102      *
103      * It tries to set the paths of the MLT profiles and renderer, using
104      * mltPath, MLT_PREFIX, searching for the binary `melt`, or asking to the
105      * user. It doesn't fill any list of profiles, while its name suggests so. */
106     void parseProfiles(const QString &mltPath = QString());
107
108     static EffectsList videoEffects;
109     static EffectsList audioEffects;
110     static EffectsList customEffects;
111     static EffectsList transitions;
112 protected:
113
114     /** @brief Closes the window.
115      * @return false if the user presses "Cancel" on a confirmation dialog or
116      *     the operation requested (starting waiting jobs or saving file) fails,
117      *     true otherwise */
118     virtual bool queryClose();
119
120     /** @brief Reports a message in the status bar when an error occurs. */
121     virtual void customEvent(QEvent *e);
122
123     /** @brief Enables live search in the timeline. */
124     virtual void keyPressEvent(QKeyEvent *ke);
125
126     /** @brief Stops the active monitor when the window gets hidden. */
127     virtual void hideEvent(QHideEvent *e);
128
129     /** @brief Filters key events to the live search. */
130     bool eventFilter(QObject *obj, QEvent *ev);
131
132     /** @brief Saves the file and the window properties when saving the session. */
133     virtual void saveProperties(KConfigGroup &config);
134
135     /** @brief Restores the window and the file when a session is loaded. */
136     virtual void readProperties(const KConfigGroup &config);
137
138 private:
139     KTabWidget* m_timelineArea;
140     QProgressBar *m_statusProgressBar;
141
142     ScopeManager *m_scopeManager;
143
144     /** @brief Sets up all the actions and attaches them to the collection. */
145     void setupActions();
146     KdenliveDoc *m_activeDocument;
147     TrackView *m_activeTimeline;
148     MonitorManager *m_monitorManager;
149
150     QDockWidget *m_projectListDock;
151     ProjectList *m_projectList;
152
153     QDockWidget *m_effectListDock;
154     EffectsListView *m_effectList;
155     //KListWidget *m_effectList;
156
157     QDockWidget *m_notesDock;
158     NotesWidget *m_notesWidget;
159
160     QDockWidget *m_effectStackDock;
161     EffectStackView2 *m_effectStack;
162
163     QDockWidget *m_transitionConfigDock;
164     TransitionSettings *m_transitionConfig;
165
166     QDockWidget *m_clipMonitorDock;
167     Monitor *m_clipMonitor;
168
169     QDockWidget *m_projectMonitorDock;
170     Monitor *m_projectMonitor;
171
172     QDockWidget *m_recMonitorDock;
173     RecMonitor *m_recMonitor;
174
175     QDockWidget *m_vectorscopeDock;
176     Vectorscope *m_vectorscope;
177
178     QDockWidget *m_waveformDock;
179     Waveform *m_waveform;
180
181     QDockWidget *m_RGBParadeDock;
182     RGBParade *m_RGBParade;
183
184     QDockWidget *m_histogramDock;
185     Histogram *m_histogram;
186
187     QDockWidget *m_audiosignalDock;
188     AudioSignal *m_audiosignal;
189
190     QDockWidget *m_audioSpectrumDock;
191     AudioSpectrum *m_audioSpectrum;
192
193     QDockWidget *m_spectrogramDock;
194     Spectrogram *m_spectrogram;
195
196     QDockWidget *m_undoViewDock;
197     QUndoView *m_undoView;
198     QUndoGroup *m_commandStack;
199
200     KComboBox *m_timecodeFormat;
201
202     /** This list holds all the scopes used in Kdenlive, allowing to manage some global settings */
203     QList <QDockWidget *> m_gfxScopesList;
204
205     KActionCategory *m_effectActions;
206     QMenu *m_effectsMenu;
207     QMenu *m_transitionsMenu;
208     QMenu *m_timelineContextMenu;
209     QMenu *m_timelineContextClipMenu;
210     QMenu *m_timelineContextTransitionMenu;
211     KUrl m_startUrl;
212
213     /** Actions used in the stopmotion widget */
214     KActionCategory *m_stopmotion_actions;
215
216     /** Action names that can be used in the slotDoAction() slot, with their i18n() names */
217     QStringList m_action_names;
218
219
220     /** @brief Shortcut to remove the focus from any element.
221      *
222      * It allows to get out of e.g. text input fields and to press another
223      * shortcut. */
224     QShortcut* m_shortcutRemoveFocus;
225
226     RenderWidget *m_renderWidget;
227
228 #ifdef USE_JOGSHUTTLE
229     JogShuttle *m_jogProcess;
230     JogShuttleAction* m_jogShuttle;
231 #endif
232
233     KRecentFilesAction *m_fileOpenRecent;
234     KAction *m_fileRevert;
235     KAction *m_projectSearch;
236     KAction *m_projectSearchNext;
237
238     KAction **m_videoEffects;
239     KAction **m_audioEffects;
240     KAction **m_customEffects;
241     KAction **m_transitions;
242     KAction *m_buttonAudioThumbs;
243     KAction *m_buttonVideoThumbs;
244     KAction *m_buttonShowMarkers;
245     KAction *m_buttonFitZoom;
246     KAction *m_buttonAutomaticSplitAudio;
247     KAction *m_normalEditTool;
248     KAction *m_overwriteEditTool;
249     KAction *m_insertEditTool;
250     KAction *m_buttonSelectTool;
251     KAction *m_buttonRazorTool;
252     KAction *m_buttonSpacerTool;
253     KAction *m_buttonSnap;
254     KAction *m_saveAction;
255     KAction *m_closeAction;
256     QSlider *m_zoomSlider;
257     KAction *m_zoomIn;
258     KAction *m_zoomOut;
259     KAction *m_loopZone;
260     KAction *m_playZone;
261     KAction *m_loopClip;
262     KSelectAction *m_loadLayout;
263     StatusBarMessageLabel *m_messageLabel;
264     QActionGroup *m_clipTypeGroup;
265     KActionCollection *m_effectsActionCollection;
266     KActionCollection *m_tracksActionCollection;
267
268     bool m_findActivated;
269     QString m_findString;
270     QTimer m_findTimer;
271
272     void readOptions();
273     void saveOptions();
274 #ifdef USE_JOGSHUTTLE
275     void activateShuttleDevice();
276 #endif
277     void connectDocumentInfo(KdenliveDoc *doc);
278     void findAhead();
279     void doOpenFile(const KUrl &url, KAutoSaveFile *stale);
280     void recoverFiles(QList<KAutoSaveFile *> staleFiles, const KUrl &originUrl);
281
282     /** @brief Loads static and dynamic plugins.
283      *
284      * It scans static plugins as well as the filesystem: it doesn't load more
285      * than one plugin per file name, to avoid duplication due to conflicting
286      * installations. */
287     void loadPlugins();
288     void populateMenus(QObject *plugin);
289     void addToMenu(QObject *plugin, const QStringList &texts,
290                    QMenu *menu, const char *member,
291                    QActionGroup *actionGroup);
292     void aboutPlugins();
293
294     /** @brief Instantiates a "Get Hot New Stuff" dialog.
295      * @param configFile configuration file for KNewStuff
296      * @return number of installed items */
297     int getNewStuff(const QString &configFile = QString());
298     QStringList m_pluginFileNames;
299     QByteArray m_timelineState;
300     void loadTranscoders();
301     void loadStabilize();
302     QPixmap createSchemePreviewIcon(const KSharedConfigPtr &config);
303
304     /** @brief Checks that the Kdenlive mime type is correctly installed.
305     * @param open If set to true, this will return the mimetype allowed for file opening (adds .tar.gz format)
306     * @return The mimetype */
307     QString getMimeType(bool open = true);
308
309     /** @brief Populates the "load layout" menu. */
310     void loadLayouts();
311
312     StopmotionWidget *m_stopmotion;
313     QTime m_timer;
314     
315     /** @brief Update statusbar stylesheet (in case of color theme change). */
316     void setStatusBarStyleSheet(const QPalette &p);
317
318 public slots:
319     /** @brief Prepares opening @param url.
320     *
321     * Checks if already open and whether backup exists */
322     void openFile(const KUrl &url);
323     void slotGotProgressInfo(const QString &message, int progress);
324     void slotReloadEffects();
325     Q_SCRIPTABLE void setRenderingProgress(const QString &url, int progress);
326     Q_SCRIPTABLE void setRenderingFinished(const QString &url, int status, const QString &error);
327
328
329 private slots:
330     void newFile(bool showProjectSettings = true, bool force = false);
331     void activateDocument();
332     void connectDocument(TrackView*, KdenliveDoc*);
333
334     /** @brief Shows file open dialog. */
335     void openFile();
336     void openLastFile();
337
338     /** @brief Checks whether a URL is available to save to.
339     * @return Whether the file was saved. */
340     bool saveFile();
341
342     /** @brief Shows a save file dialog for saving the project.
343     * @return Whether the file was saved. */
344     bool saveFileAs();
345
346     /** @brief Set properties to match outputFileName and save the document.
347     * @param outputFileName The URL to save to / The document's URL.
348     * @return Whether we had success. */
349     bool saveFileAs(const QString &outputFileName);
350
351     /** @brief Shows the shortcut dialog. */
352     void slotEditKeys();
353     void slotPreferences(int page = -1, int option = -1);
354
355     /** @brief Reflects setting changes to the GUI. */
356     void updateConfiguration();
357     void slotConnectMonitors();
358     void slotUpdateClip(const QString &id);
359     void slotUpdateMousePosition(int pos);
360     void slotAddEffect(const QDomElement effect);
361     void slotEditProfiles();
362     void slotDetectAudioDriver();
363     void slotEditProjectSettings();
364     /** @brief Change current document MLT profile. */
365     void slotUpdateProjectProfile(const QString &profile);
366     void slotDisplayActionMessage(QAction *a);
367
368     /** @brief Turns automatic splitting of audio and video on/off. */
369     void slotSwitchSplitAudio();
370     void slotSwitchVideoThumbs();
371     void slotSwitchAudioThumbs();
372     void slotSwitchMarkersComments();
373     void slotSwitchSnap();
374     void slotRenderProject();
375     void slotFullScreen();
376     void slotUpdateDocumentState(bool modified);
377
378     /** @brief Sets the timeline zoom slider to @param value.
379     *
380     * Also disables zoomIn and zoomOut actions if they cannot be used at the moment. */
381     void slotSetZoom(int value);
382     /** @brief Decreases the timeline zoom level by 1. */
383     void slotZoomIn();
384     /** @brief Increases the timeline zoom level by 1. */
385     void slotZoomOut();
386     /** @brief Makes the timeline zoom level fit the timeline content. */
387     void slotFitZoom();
388     /** @brief Updates the zoom slider tooltip to fit @param zoomlevel. */
389     void slotUpdateZoomSliderToolTip(int zoomlevel);
390
391     /** @brief Displays the zoom slider tooltip.
392     * @param zoomlevel (optional) The zoom level to show in the tooltip.
393     *
394     * Adopted from Dolphin (src/statusbar/dolphinstatusbar.cpp) */
395     void slotShowZoomSliderToolTip(int zoomlevel = -1);
396     /** @brief Close currently opened document. Returns false if something went wrong (cannot save modifications, ...). */
397     bool closeCurrentDocument(bool saveChanges = true);
398     /** @brief Deletes item in timeline, project tree or effect stack depending on focus. */
399     void slotDeleteItem();
400     void slotAddClipMarker();
401     void slotDeleteClipMarker();
402     void slotDeleteAllClipMarkers();
403     void slotEditClipMarker();
404
405     /** @brief Adds marker or auide at the current position without showing the marker dialog.
406      *
407      * Adds a marker if clip monitor is active, otherwise a guide.
408      * The comment is set to the current position (therefore not dialog).
409      * This can be useful to mark something during playback. */
410     void slotAddMarkerGuideQuickly();
411     void slotCutTimelineClip();
412     void slotInsertClipOverwrite();
413     void slotSelectTimelineClip();
414     void slotSelectTimelineTransition();
415     void slotDeselectTimelineClip();
416     void slotDeselectTimelineTransition();
417     void slotSelectAddTimelineClip();
418     void slotSelectAddTimelineTransition();
419     void slotAddVideoEffect(QAction *result);
420     void slotAddTransition(QAction *result);
421     void slotAddProjectClip(KUrl url, const QString &comment = QString());
422     void slotAddProjectClipList(KUrl::List urls);
423     void slotShowClipProperties(DocClipBase *clip);
424     void slotShowClipProperties(QList <DocClipBase *>cliplist, QMap<QString, QString> commonproperties);
425     void slotActivateEffectStackView(ClipItem* item = NULL, int ix = -1, bool raise = true);
426     void slotActivateTransitionView(Transition *);
427     void slotChangeTool(QAction * action);
428     void slotChangeEdit(QAction * action);
429     void slotSetTool(PROJECTTOOL tool);
430     void slotSnapForward();
431     void slotSnapRewind();
432     void slotClipStart();
433     void slotClipEnd();
434     void slotZoneStart();
435     void slotZoneEnd();
436     void slotFind();
437     void findTimeout();
438     void slotFindNext();
439     void slotSelectClipInTimeline();
440     void slotClipInTimeline(const QString &clipId);
441
442     void slotInsertSpace();
443     void slotRemoveSpace();
444     void slotAddGuide();
445     void slotEditGuide();
446     void slotDeleteGuide();
447     void slotDeleteAllGuides();
448     void slotGuidesUpdated();
449
450     void slotCopy();
451     void slotPaste();
452     void slotPasteEffects();
453
454     void slotAdjustClipMonitor();
455     void slotAdjustProjectMonitor();
456     void slotSaveZone(Render *render, QPoint zone, DocClipBase *baseClip = NULL, KUrl path = KUrl());
457
458     void slotSetInPoint();
459     void slotSetOutPoint();
460     void slotResizeItemStart();
461     void slotResizeItemEnd();
462     void configureNotifications();
463     void slotInsertTrack(int ix = -1);
464     void slotDeleteTrack(int ix = -1);
465     /** @brief Shows the configure tracks dialog and updates transitions afterwards. */
466     void slotConfigTrack(int ix = -1);
467     /** @brief Select all clips in active track. */
468     void slotSelectTrack();
469     /** @brief Select all clips in timeline. */
470     void slotSelectAllTracks();
471     void slotGetNewLumaStuff();
472     void slotGetNewTitleStuff();
473     void slotGetNewRenderStuff();
474     void slotGetNewMltProfileStuff();
475     void slotAutoTransition();
476     void slotRunWizard();
477     /** @brief Lets the sampleplugin create a generator.  */
478     void generateClip();
479     void slotZoneMoved(int start, int end);
480     void slotDvdWizard(const QString &url = QString(), const QString &profile = "dv_pal");
481     void slotGroupClips();
482     void slotUnGroupClips();
483     void slotEditItemDuration();
484     void slotClipInProjectTree();
485     //void slotClipToProjectTree();
486     void slotSplitAudio();
487     void slotUpdateClipType(QAction *action);
488     void slotShowTimeline(bool show);
489     void slotMaximizeCurrent(bool show);
490     void slotTranscode(KUrl::List urls = KUrl::List());
491     void slotStabilize();
492     void slotTranscodeClip();
493     /** @brief Archive project: creates a copy of the project file with all clips in a new folder. */
494     void slotArchiveProject();
495     void slotSetDocumentRenderProfile(QMap <QString, QString> props);
496     void slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile);
497
498     /** @brief Switches between displaying frames or timecode.
499     * @param ix 0 = display timecode, 1 = display frames. */
500     void slotUpdateTimecodeFormat(int ix);
501
502     /** @brief Removes the focus of anything. */
503     void slotRemoveFocus();
504     void slotCleanProject();
505     void slotUpdateClipMarkers(DocClipBase *clip);
506     void slotRevert();
507     void slotShutdown();
508     void slotUpdateTrackInfo();
509
510     /** @brief Changes the color scheme. */
511     void slotChangePalette(QAction *action, const QString &themename = QString());
512     void slotSwitchMonitors();
513     void slotCheckRenderStatus();
514     void slotInsertZoneToTree();
515     void slotInsertZoneToTimeline();
516
517     /** @brief Deletes items from timeline and document.
518     * @param ids The ids of the clips to delete.
519     * @param folderids The names and ids of the folders to delete. */
520     void slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids);
521     void slotShowTitleBars(bool show);
522     void slotSwitchTitles();
523     /** @brief Update the capture folder if user asked a change. */
524     void slotUpdateCaptureFolder();
525
526     /** @brief Apply new properties to a clip */
527     void slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload);
528
529     /** @brief Delete a clip from current project */
530     void slotDeleteClip(const QString &id);
531
532     /** @brief Saves the widgets layout */
533     void slotSaveLayout(QAction*);
534     void slotLoadLayout(QAction*);
535
536     /** @brief The monitor informs that it needs (or not) to have frames sent by the renderer. */
537     void slotMonitorRequestRenderFrame(bool request);
538     /** @brief Open the stopmotion dialog. */
539     void slotOpenStopmotion();
540     /** @brief Implements all the actions that are int he ActionsCollection. */
541     void slotDoAction(const QString& action_name);
542     /** @brief Update project because the use of proxy clips was enabled / disabled. */
543     void slotUpdateProxySettings();
544     /** @brief Insert current project's timecode into the notes widget. */
545     void slotInsertNotesTimecode();
546     /** @brief Open the project's backupdialog. */
547     void slotOpenBackupDialog(const KUrl url = KUrl());
548     /** @brief Disable proxies for this project. */
549     void slotDisableProxies();
550
551     void slotElapsedTime();
552     /** @brief Open the online services search dialog. */
553     void slotDownloadResources();
554     
555     void slotChangePalette();
556
557 signals:
558     Q_SCRIPTABLE void abortRenderJob(const QString &url);
559 };
560
561
562 #endif