]> git.sesse.net Git - kdenlive/blob - src/mainwindow.cpp
Start of tools:
[kdenlive] / src / mainwindow.cpp
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
22 #include <QTextStream>
23 #include <QTimer>
24 #include <QAction>
25 #include <QtTest>
26 #include <QtCore>
27
28 #include <KApplication>
29 #include <KAction>
30 #include <KLocale>
31 #include <KGlobal>
32 #include <KActionCollection>
33 #include <KStandardAction>
34 #include <KFileDialog>
35 #include <KMessageBox>
36 #include <KDebug>
37 #include <KIO/NetAccess>
38 #include <KSaveFile>
39 #include <KRuler>
40 #include <KConfigDialog>
41 #include <KXMLGUIFactory>
42 #include <KStatusBar>
43 #include <kstandarddirs.h>
44 #include <KUrlRequesterDialog>
45 #include <KTemporaryFile>
46 #include <KActionMenu>
47 #include <KMenu>
48 #include <locale.h>
49 #include <ktogglefullscreenaction.h>
50
51 #include <mlt++/Mlt.h>
52
53 #include "mainwindow.h"
54 #include "kdenlivesettings.h"
55 #include "kdenlivesettingsdialog.h"
56 #include "initeffects.h"
57 #include "profilesdialog.h"
58 #include "projectsettings.h"
59 #include "events.h"
60 #include "renderjob.h"
61 #include "clipmanager.h"
62 #include "projectlist.h"
63 #include "monitor.h"
64 #include "recmonitor.h"
65 #include "monitormanager.h"
66 #include "kdenlivedoc.h"
67 #include "trackview.h"
68 #include "customtrackview.h"
69 #include "effectslistview.h"
70 #include "effectstackview.h"
71 #include "transitionsettings.h"
72 #include "renderwidget.h"
73 #include "renderer.h"
74 #include "jogshuttle.h"
75 #include "clipproperties.h"
76
77 #define ID_STATUS_MSG 1
78 #define ID_EDITMODE_MSG 2
79 #define ID_TIMELINE_MSG 3
80 #define ID_TIMELINE_BUTTONS 5
81 #define ID_TIMELINE_POS 6
82 #define ID_TIMELINE_FORMAT 7
83
84 EffectsList MainWindow::videoEffects;
85 EffectsList MainWindow::audioEffects;
86 EffectsList MainWindow::customEffects;
87 EffectsList MainWindow::transitions;
88
89 MainWindow::MainWindow(QWidget *parent)
90         : KXmlGuiWindow(parent),
91         m_activeDocument(NULL), m_activeTimeline(NULL), m_renderWidget(NULL), m_jogProcess(NULL) {
92     setlocale(LC_NUMERIC, "POSIX");
93     parseProfiles();
94     setFont(KGlobalSettings::toolBarFont());
95     m_commandStack = new QUndoGroup;
96     m_timelineArea = new KTabWidget(this);
97     m_timelineArea->setTabReorderingEnabled(true);
98     m_timelineArea->setTabBarHidden(true);
99
100     QToolButton *closeTabButton = new QToolButton;
101     connect(closeTabButton, SIGNAL(clicked()), this, SLOT(slotRemoveTab()));
102     closeTabButton->setIcon(KIcon("tab-close"));
103     closeTabButton->adjustSize();
104     closeTabButton->setToolTip(i18n("Close the current tab"));
105     m_timelineArea->setCornerWidget(closeTabButton);
106     connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
107
108     initEffects::parseEffectFiles();
109     m_monitorManager = new MonitorManager();
110
111     projectListDock = new QDockWidget(i18n("Project Tree"), this);
112     projectListDock->setObjectName("project_tree");
113     m_projectList = new ProjectList(this);
114     projectListDock->setWidget(m_projectList);
115     addDockWidget(Qt::TopDockWidgetArea, projectListDock);
116
117     effectListDock = new QDockWidget(i18n("Effect List"), this);
118     effectListDock->setObjectName("effect_list");
119     m_effectList = new EffectsListView();
120
121     //m_effectList = new KListWidget(this);
122     effectListDock->setWidget(m_effectList);
123     addDockWidget(Qt::TopDockWidgetArea, effectListDock);
124
125     effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
126     effectStackDock->setObjectName("effect_stack");
127     effectStack = new EffectStackView(this);
128     effectStackDock->setWidget(effectStack);
129     addDockWidget(Qt::TopDockWidgetArea, effectStackDock);
130
131     transitionConfigDock = new QDockWidget(i18n("Transition"), this);
132     transitionConfigDock->setObjectName("transition");
133     transitionConfig = new TransitionSettings(this);
134     transitionConfigDock->setWidget(transitionConfig);
135     addDockWidget(Qt::TopDockWidgetArea, transitionConfigDock);
136
137
138     clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
139     clipMonitorDock->setObjectName("clip_monitor");
140     m_clipMonitor = new Monitor("clip", m_monitorManager, this);
141     clipMonitorDock->setWidget(m_clipMonitor);
142     addDockWidget(Qt::TopDockWidgetArea, clipMonitorDock);
143     //m_clipMonitor->stop();
144
145     projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
146     projectMonitorDock->setObjectName("project_monitor");
147     m_projectMonitor = new Monitor("project", m_monitorManager, this);
148     projectMonitorDock->setWidget(m_projectMonitor);
149     addDockWidget(Qt::TopDockWidgetArea, projectMonitorDock);
150
151     recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
152     recMonitorDock->setObjectName("record_monitor");
153     m_recMonitor = new RecMonitor("record", this);
154     recMonitorDock->setWidget(m_recMonitor);
155     addDockWidget(Qt::TopDockWidgetArea, recMonitorDock);
156
157     connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
158
159     undoViewDock = new QDockWidget(i18n("Undo History"), this);
160     undoViewDock->setObjectName("undo_history");
161     m_undoView = new QUndoView(this);
162     m_undoView->setCleanIcon(KIcon("edit-clear"));
163     m_undoView->setEmptyLabel(i18n("Clean"));
164     undoViewDock->setWidget(m_undoView);
165     m_undoView->setGroup(m_commandStack);
166     addDockWidget(Qt::TopDockWidgetArea, undoViewDock);
167
168     overviewDock = new QDockWidget(i18n("Project Overview"), this);
169     overviewDock->setObjectName("project_overview");
170     m_overView = new CustomTrackView(NULL, NULL, this);
171     overviewDock->setWidget(m_overView);
172     addDockWidget(Qt::TopDockWidgetArea, overviewDock);
173
174     setupActions();
175     tabifyDockWidget(projectListDock, effectListDock);
176     tabifyDockWidget(projectListDock, effectStackDock);
177     tabifyDockWidget(projectListDock, transitionConfigDock);
178     tabifyDockWidget(projectListDock, undoViewDock);
179     projectListDock->raise();
180
181     tabifyDockWidget(clipMonitorDock, projectMonitorDock);
182     setCentralWidget(m_timelineArea);
183
184     setupGUI(Default, NULL /*"kdenliveui.rc"*/);
185     kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
186
187     // build effects menus
188     QAction *action;
189     QMenu *videoEffectsMenu = (QMenu*)(factory()->container("video_effects_menu", this));
190     QStringList effects = videoEffects.effectNames();
191     foreach(QString name, effects) {
192         action = new QAction(name, this);
193         action->setData(name);
194         videoEffectsMenu->addAction(action);
195     }
196     QMenu *audioEffectsMenu = (QMenu*)(factory()->container("audio_effects_menu", this));
197     effects = audioEffects.effectNames();
198     foreach(QString name, effects) {
199         action = new QAction(name, this);
200         action->setData(name);
201         audioEffectsMenu->addAction(action);
202     }
203     QMenu *customEffectsMenu = (QMenu*)(factory()->container("custom_effects_menu", this));
204     effects = customEffects.effectNames();
205     foreach(QString name, effects) {
206         action = new QAction(name, this);
207         action->setData(name);
208         customEffectsMenu->addAction(action);
209     }
210
211     connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
212     connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
213     connect(customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
214
215     m_timelineContextMenu = new QMenu(this);
216     m_timelineContextClipMenu = new QMenu(this);
217     m_timelineContextTransitionMenu = new QMenu(this);
218
219     action = actionCollection()->action("delete_timeline_clip");
220     m_timelineContextClipMenu->addAction(action);
221     m_timelineContextClipMenu->addMenu(videoEffectsMenu);
222     m_timelineContextClipMenu->addMenu(audioEffectsMenu);
223     m_timelineContextClipMenu->addMenu(customEffectsMenu);
224
225     connect(projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
226     connect(clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
227     //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
228     connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
229     connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
230     m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
231     slotConnectMonitors();
232
233     setAutoSaveSettings();
234     newFile();
235
236     activateShuttleDevice();
237 }
238
239 void MainWindow::queryQuit() {
240     kDebug() << "----- SAVING CONFUIG";
241     if (queryClose()) kapp->quit();
242 }
243
244 //virtual
245 bool MainWindow::queryClose() {
246     saveOptions();
247     if (m_activeDocument && m_activeDocument->isModified()) {
248         switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
249         case KMessageBox::Yes :
250             // save document here. If saving fails, return false;
251             return true;
252         case KMessageBox::No :
253             return true;
254         default: // cancel
255             return false;
256         }
257     }
258     return true;
259 }
260
261 void MainWindow::activateShuttleDevice() {
262     if (m_jogProcess) delete m_jogProcess;
263     m_jogProcess = NULL;
264     if (KdenliveSettings::enableshuttle() == false) return;
265     m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
266     connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
267     connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
268     connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
269     connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
270     connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
271     connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
272 }
273
274 void MainWindow::slotShuttleButton(int code) {
275     switch (code) {
276     case 5:
277         slotShuttleAction(KdenliveSettings::shuttle1());
278         break;
279     case 6:
280         slotShuttleAction(KdenliveSettings::shuttle2());
281         break;
282     case 7:
283         slotShuttleAction(KdenliveSettings::shuttle3());
284         break;
285     case 8:
286         slotShuttleAction(KdenliveSettings::shuttle4());
287         break;
288     case 9:
289         slotShuttleAction(KdenliveSettings::shuttle5());
290         break;
291     }
292 }
293
294 void MainWindow::slotShuttleAction(int code) {
295     switch (code) {
296     case 0:
297         return;
298     case 1:
299         m_monitorManager->slotPlay();
300         break;
301     default:
302         m_monitorManager->slotPlay();
303         break;
304     }
305 }
306
307 void MainWindow::slotFullScreen() {
308     //KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
309 }
310
311 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track) {
312     if (!m_activeDocument) return;
313     if (effect.isNull()) {
314         kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
315         return;
316     }
317     TrackView *currentTimeLine = (TrackView *) m_timelineArea->currentWidget();
318     currentTimeLine->projectView()->slotAddEffect(effect, pos, track);
319 }
320
321 void MainWindow::slotRaiseMonitor(bool clipMonitor) {
322     if (clipMonitor) clipMonitorDock->raise();
323     else projectMonitorDock->raise();
324 }
325
326 void MainWindow::slotSetClipDuration(int id, int duration) {
327     if (!m_activeDocument) return;
328     m_activeDocument->setProducerDuration(id, duration);
329 }
330
331 void MainWindow::slotConnectMonitors() {
332
333     m_projectList->setRenderer(m_clipMonitor->render);
334     connect(m_projectList, SIGNAL(clipSelected(const QDomElement &)), m_clipMonitor, SLOT(slotSetXml(const QDomElement &)));
335     connect(m_projectList, SIGNAL(receivedClipDuration(int, int)), this, SLOT(slotSetClipDuration(int, int)));
336     connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
337     connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, int)), m_clipMonitor->render, SLOT(getFileProperties(const QDomElement &, int)));
338     connect(m_clipMonitor->render, SIGNAL(replyGetImage(int, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(int, int, const QPixmap &, int, int)));
339     connect(m_clipMonitor->render, SIGNAL(replyGetFileProperties(int, const QMap < QString, QString > &, const QMap < QString, QString > &)), m_projectList, SLOT(slotReplyGetFileProperties(int, const QMap < QString, QString > &, const QMap < QString, QString > &)));
340 }
341
342 void MainWindow::setupActions() {
343
344     m_timecodeFormat = new KComboBox(this);
345     m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
346     m_timecodeFormat->addItem(i18n("Frames"));
347
348     statusProgressBar = new QProgressBar(this);
349     statusProgressBar->setMinimum(0);
350     statusProgressBar->setMaximum(100);
351     statusProgressBar->setMaximumWidth(150);
352     statusProgressBar->setVisible(false);
353     statusLabel = new QLabel(this);
354
355     QWidget *w = new QWidget;
356
357     QHBoxLayout *layout = new QHBoxLayout;
358     w->setLayout(layout);
359     layout->setContentsMargins(5, 0, 5, 0);
360     QToolBar *toolbar = new QToolBar("statusToolBar", this);
361     w->setMinimumHeight(34);
362
363     m_toolGroup = new QActionGroup(this);
364
365     m_buttonSelectTool = toolbar->addAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"));
366     m_buttonSelectTool->setCheckable(true);
367     m_buttonSelectTool->setChecked(true);
368
369     m_buttonRazorTool = toolbar->addAction(KIcon("edit-cut"), i18n("Razor tool"));
370     m_buttonRazorTool->setCheckable(true);
371     m_buttonRazorTool->setChecked(false);
372
373     m_toolGroup->addAction(m_buttonSelectTool);
374     m_toolGroup->addAction(m_buttonRazorTool);
375     m_toolGroup->setExclusive(true);
376     connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
377
378     toolbar->addSeparator();
379     m_buttonFitZoom = toolbar->addAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"));
380     m_buttonFitZoom->setCheckable(false);
381     connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
382
383     m_zoomSlider = new QSlider(Qt::Horizontal, this);
384     m_zoomSlider->setMaximum(13);
385     m_zoomSlider->setMaximumHeight(34);
386     m_zoomSlider->setMaximumWidth(150);
387     m_zoomSlider->setMinimumWidth(100);
388     toolbar->addWidget(m_zoomSlider);
389
390     m_buttonVideoThumbs = toolbar->addAction(KIcon("video-mpeg"), i18n("Show videoo thumbnails"));
391     m_buttonVideoThumbs->setCheckable(true);
392     m_buttonVideoThumbs->setChecked(KdenliveSettings::audiothumbnails());
393     connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
394
395     m_buttonAudioThumbs = toolbar->addAction(KIcon("audio-mpeg"), i18n("Show audio thumbnails"));
396     m_buttonAudioThumbs->setCheckable(true);
397     m_buttonAudioThumbs->setChecked(KdenliveSettings::videothumbnails());
398     connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
399     layout->addWidget(toolbar);
400
401     statusBar()->insertPermanentWidget(0, statusProgressBar, 1);
402     statusBar()->insertPermanentWidget(1, statusLabel, 1);
403     statusBar()->insertPermanentWidget(ID_TIMELINE_BUTTONS, w);
404     statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
405     statusBar()->insertPermanentWidget(ID_TIMELINE_FORMAT, m_timecodeFormat);
406     statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
407
408     actionCollection()->addAction("select_tool", m_buttonSelectTool);
409     actionCollection()->addAction("razor_tool", m_buttonRazorTool);
410
411     KAction* clearAction = new KAction(this);
412     clearAction->setText(i18n("Clear"));
413     clearAction->setIcon(KIcon("document-new"));
414     clearAction->setShortcut(Qt::CTRL + Qt::Key_W);
415     actionCollection()->addAction("clear", clearAction);
416     /*connect(clearAction, SIGNAL(triggered(bool)),
417             textArea, SLOT(clear()));*/
418
419     KAction* profilesAction = new KAction(this);
420     profilesAction->setText(i18n("Manage Profiles"));
421     profilesAction->setIcon(KIcon("document-new"));
422     actionCollection()->addAction("manage_profiles", profilesAction);
423     connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
424
425     KAction* projectAction = new KAction(this);
426     projectAction->setText(i18n("Project Settings"));
427     projectAction->setIcon(KIcon("document-new"));
428     actionCollection()->addAction("project_settings", projectAction);
429     connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
430
431     KAction* projectRender = new KAction(this);
432     projectRender->setText(i18n("Render Project"));
433     projectRender->setIcon(KIcon("document-new"));
434     actionCollection()->addAction("project_render", projectRender);
435     connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
436
437     KAction* monitorPlay = new KAction(this);
438     monitorPlay->setText(i18n("Play"));
439     monitorPlay->setIcon(KIcon("media-playback-start"));
440     monitorPlay->setShortcut(Qt::Key_Space);
441     actionCollection()->addAction("monitor_play", monitorPlay);
442     connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
443
444     KAction* monitorSeekBackward = new KAction(this);
445     monitorSeekBackward->setText(i18n("Rewind"));
446     monitorSeekBackward->setIcon(KIcon("media-seek-backward"));
447     monitorSeekBackward->setShortcut(Qt::Key_J);
448     actionCollection()->addAction("monitor_seek_backward", monitorSeekBackward);
449     connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
450
451     KAction* monitorSeekBackwardOneFrame = new KAction(this);
452     monitorSeekBackwardOneFrame->setText(i18n("Rewind 1 Frame"));
453     monitorSeekBackwardOneFrame->setIcon(KIcon("media-skip-backward"));
454     monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
455     actionCollection()->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
456     connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
457
458     KAction* monitorSeekForward = new KAction(this);
459     monitorSeekForward->setText(i18n("Forward"));
460     monitorSeekForward->setIcon(KIcon("media-seek-forward"));
461     monitorSeekForward->setShortcut(Qt::Key_L);
462     actionCollection()->addAction("monitor_seek_forward", monitorSeekForward);
463     connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
464
465     KAction* monitorSeekForwardOneFrame = new KAction(this);
466     monitorSeekForwardOneFrame->setText(i18n("Forward 1 Frame"));
467     monitorSeekForwardOneFrame->setIcon(KIcon("media-skip-forward"));
468     monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
469     actionCollection()->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
470     connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
471
472     KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
473     deleteTimelineClip->setShortcut(Qt::Key_Delete);
474     actionCollection()->addAction("delete_timeline_clip", deleteTimelineClip);
475     connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
476
477     KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
478     cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
479     actionCollection()->addAction("cut_timeline_clip", cutTimelineClip);
480     connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
481
482     KStandardAction::quit(this, SLOT(queryQuit()),
483                           actionCollection());
484
485     KStandardAction::open(this, SLOT(openFile()),
486                           actionCollection());
487
488     m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
489                        actionCollection());
490
491     KStandardAction::save(this, SLOT(saveFile()),
492                           actionCollection());
493
494     KStandardAction::saveAs(this, SLOT(saveFileAs()),
495                             actionCollection());
496
497     KStandardAction::openNew(this, SLOT(newFile()),
498                              actionCollection());
499
500     KStandardAction::preferences(this, SLOT(slotPreferences()),
501                                  actionCollection());
502
503     KStandardAction::undo(this, SLOT(undo()),
504                           actionCollection());
505
506     KStandardAction::redo(this, SLOT(redo()),
507                           actionCollection());
508
509     KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, actionCollection());
510
511     connect(actionCollection(), SIGNAL(actionHovered(QAction*)),
512             this, SLOT(slotDisplayActionMessage(QAction*)));
513     //connect(actionCollection(), SIGNAL( clearStatusText() ),
514     //statusBar(), SLOT( clear() ) );
515
516     readOptions();
517 }
518
519 void MainWindow::undo() {
520     m_commandStack->undo();
521 }
522
523 void MainWindow::redo() {
524     m_commandStack->redo();
525 }
526
527 void MainWindow::slotDisplayActionMessage(QAction *a) {
528     statusBar()->showMessage(a->data().toString(), 3000);
529 }
530
531 void MainWindow::saveOptions() {
532     KdenliveSettings::self()->writeConfig();
533     KSharedConfigPtr config = KGlobal::config();
534     m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
535     config->sync();
536 }
537
538 void MainWindow::readOptions() {
539     KSharedConfigPtr config = KGlobal::config();
540     m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
541 }
542
543 void MainWindow::newFile() {
544     QString profileName;
545     KUrl projectFolder;
546     if (m_timelineArea->count() == 0) profileName = KdenliveSettings::default_profile();
547     else {
548         ProjectSettings *w = new ProjectSettings;
549         if (w->exec() != QDialog::Accepted) return;
550         profileName = w->selectedProfile();
551         projectFolder = w->selectedFolder();
552         delete w;
553     }
554     MltVideoProfile prof = ProfilesDialog::getVideoProfile(profileName);
555     if (prof.width == 0) prof = ProfilesDialog::getVideoProfile("dv_pal");
556     KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, prof, m_commandStack);
557     TrackView *trackView = new TrackView(doc, this);
558     m_timelineArea->addTab(trackView, KIcon("kdenlive"), i18n("Untitled") + " / " + prof.description);
559     if (m_timelineArea->count() == 1)
560         connectDocument(trackView, doc);
561     else m_timelineArea->setTabBarHidden(false);
562 }
563
564 void MainWindow::activateDocument() {
565     TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
566     KdenliveDoc *currentDoc = currentTab->document();
567     connectDocument(currentTab, currentDoc);
568 }
569
570 void MainWindow::slotRemoveTab() {
571     QWidget *w = m_timelineArea->currentWidget();
572     // closing current document
573     int ix = m_timelineArea->currentIndex() + 1;
574     if (ix == m_timelineArea->count()) ix = 0;
575     m_timelineArea->setCurrentIndex(ix);
576     TrackView *tabToClose = (TrackView *) w;
577     KdenliveDoc *docToClose = tabToClose->document();
578     m_timelineArea->removeTab(m_timelineArea->indexOf(w));
579     if (m_timelineArea->count() == 1) m_timelineArea->setTabBarHidden(true);
580     delete docToClose;
581     delete w;
582 }
583
584 void MainWindow::saveFileAs(const QString &outputFileName) {
585     m_projectMonitor->saveSceneList(outputFileName, m_activeDocument->documentInfoXml());
586     m_activeDocument->setUrl(KUrl(outputFileName));
587     setCaption(m_activeDocument->description());
588     m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
589     m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
590     m_activeDocument->setModified(false);
591 }
592
593 void MainWindow::saveFileAs() {
594     QString outputFile = KFileDialog::getSaveFileName();
595     if (QFile::exists(outputFile)) {
596         if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) == KMessageBox::No) return;
597     }
598     saveFileAs(outputFile);
599 }
600
601 void MainWindow::saveFile() {
602     if (!m_activeDocument) return;
603     if (m_activeDocument->url().isEmpty()) {
604         saveFileAs();
605     } else {
606         saveFileAs(m_activeDocument->url().path());
607     }
608 }
609
610 void MainWindow::openFile() { //changed
611     KUrl url = KFileDialog::getOpenUrl(KUrl(), "application/vnd.kde.kdenlive;*.kdenlive");
612     if (url.isEmpty()) return;
613     m_fileOpenRecent->addUrl(url);
614     openFile(url);
615 }
616
617 void MainWindow::openFile(const KUrl &url) { //new
618     //TODO: get video profile from url before opening it
619     MltVideoProfile prof = ProfilesDialog::getVideoProfile(KdenliveSettings::default_profile());
620     if (prof.width == 0) prof = ProfilesDialog::getVideoProfile("dv_pal");
621     KdenliveDoc *doc = new KdenliveDoc(url, KUrl(), prof, m_commandStack);
622     TrackView *trackView = new TrackView(doc, this);
623     m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
624     m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
625     if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
626     //connectDocument(trackView, doc);
627 }
628
629
630 void MainWindow::parseProfiles() {
631     //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
632
633     //KdenliveSettings::setDefaulttmpfolder();
634     if (KdenliveSettings::mltpath().isEmpty()) {
635         KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
636     }
637     if (KdenliveSettings::rendererpath().isEmpty()) {
638         KdenliveSettings::setRendererpath(KStandardDirs::findExe("inigo"));
639     }
640     QStringList profilesFilter;
641     profilesFilter << "*";
642     QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
643
644     if (profilesList.isEmpty()) {
645         // Cannot find MLT path, try finding inigo
646         QString profilePath = KdenliveSettings::rendererpath();
647         if (!profilePath.isEmpty()) {
648             profilePath = profilePath.section('/', 0, -3);
649             KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
650             QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
651         }
652
653         if (profilesList.isEmpty()) {
654             // Cannot find the MLT profiles, ask for location
655             KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
656             getUrl->fileDialog()->setMode(KFile::Directory);
657             getUrl->exec();
658             KUrl mltPath = getUrl->selectedUrl();
659             delete getUrl;
660             if (mltPath.isEmpty()) exit(1);
661             KdenliveSettings::setMltpath(mltPath.path());
662             QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
663         }
664     }
665
666     if (KdenliveSettings::rendererpath().isEmpty()) {
667         // Cannot find the MLT inigo renderer, ask for location
668         KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this);
669         getUrl->exec();
670         KUrl rendererPath = getUrl->selectedUrl();
671         delete getUrl;
672         if (rendererPath.isEmpty()) exit(1);
673         KdenliveSettings::setRendererpath(rendererPath.path());
674     }
675
676     kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
677
678     // Parse MLT profiles to build a list of available video formats
679     if (profilesList.isEmpty()) parseProfiles();
680 }
681
682
683 void MainWindow::slotEditProfiles() {
684     ProfilesDialog *w = new ProfilesDialog;
685     w->exec();
686     delete w;
687 }
688
689 void MainWindow::slotEditProjectSettings() {
690     ProjectSettings *w = new ProjectSettings;
691     if (w->exec() == QDialog::Accepted) {
692         QString profile = w->selectedProfile();
693         m_activeDocument->setProfilePath(profile);
694         m_monitorManager->resetProfiles(profile);
695         setCaption(m_activeDocument->description());
696         KdenliveSettings::setCurrent_profile(m_activeDocument->profilePath());
697         if (m_renderWidget) m_renderWidget->setDocumentStandard(m_activeDocument->getDocumentStandard());
698         m_monitorManager->setTimecode(m_activeDocument->timecode());
699         m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
700
701         // We need to desactivate & reactivate monitors to get a refresh
702         m_monitorManager->switchMonitors();
703     }
704     delete w;
705 }
706
707 void MainWindow::slotRenderProject() {
708     if (!m_renderWidget) {
709         m_renderWidget = new RenderWidget(this);
710         connect(m_renderWidget, SIGNAL(doRender(const QString&, const QString&, const QStringList &, bool, bool)), this, SLOT(slotDoRender(const QString&, const QString&, const QStringList &, bool, bool)));
711     }
712     /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
713     if (currentTab) m_renderWidget->setTimeline(currentTab);
714     m_renderWidget->setDocument(m_activeDocument);*/
715     m_renderWidget->show();
716 }
717
718 void MainWindow::slotDoRender(const QString &dest, const QString &render, const QStringList &avformat_args, bool zoneOnly, bool playAfter) {
719     if (dest.isEmpty()) return;
720     int in;
721     int out;
722     TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
723     if (currentTab && zoneOnly) {
724         in = currentTab->inPoint();
725         out = currentTab->outPoint();
726     }
727     KTemporaryFile temp;
728     temp.setAutoRemove(false);
729     temp.setSuffix(".westley");
730     if (temp.open()) {
731         m_projectMonitor->saveSceneList(temp.fileName());
732         QStringList args;
733         args << "-erase";
734         if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
735         QString videoPlayer = "-";
736         if (playAfter) videoPlayer = "kmplayer";
737         args << "inigo" << m_activeDocument->profilePath() << render << videoPlayer << temp.fileName() << dest << avformat_args;
738         QProcess::startDetached("kdenlive_render", args);
739     }
740 }
741
742 void MainWindow::slotUpdateMousePosition(int pos) {
743     if (m_activeDocument)
744         switch (m_timecodeFormat->currentIndex()) {
745         case 0:
746             statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
747             break;
748         default:
749             statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
750         }
751 }
752
753 void MainWindow::slotUpdateDocumentState(bool modified) {
754     setCaption(m_activeDocument->description(), modified);
755     if (modified) {
756         m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
757         m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
758     } else {
759         m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
760         m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
761     }
762 }
763
764 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //changed
765     //m_projectMonitor->stop();
766     kDebug() << "///////////////////   CONNECTING DOC TO PROJECT VIEW ////////////////";
767     if (m_activeDocument) {
768         if (m_activeDocument == doc) return;
769         m_activeDocument->backupMltPlaylist();
770         if (m_activeTimeline) {
771             disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
772             disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
773             disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
774             disconnect(m_activeDocument, SIGNAL(addProjectFolder(const QString, int, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, int, bool, bool)));
775             disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(int)), m_projectList, SLOT(slotDeleteClip(int)));
776             disconnect(m_activeDocument, SIGNAL(updateClipDisplay(int)), m_projectList, SLOT(slotUpdateClip(int)));
777             disconnect(m_activeDocument, SIGNAL(refreshClipThumbnail(int)), m_projectList, SLOT(slotRefreshClipThumbnail(int)));
778             disconnect(m_activeDocument, SIGNAL(deletTimelineClip(int)), m_activeTimeline, SLOT(slotDeleteClip(int)));
779             disconnect(m_activeDocument, SIGNAL(thumbsProgress(KUrl, int)), this, SLOT(slotGotProgressInfo(KUrl, int)));
780             disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
781             disconnect(trackView, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
782             disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
783             disconnect(trackView, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
784             disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
785             disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
786             disconnect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement)));
787             disconnect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
788             disconnect(effectStack, SIGNAL(changeEffectState(ClipItem*, QDomElement, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, QDomElement, bool)));
789             disconnect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
790             disconnect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
791             disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
792         }
793         m_activeDocument->setRenderer(NULL);
794         disconnect(m_projectList, SIGNAL(clipSelected(const QDomElement &)), m_clipMonitor, SLOT(slotSetXml(const QDomElement &)));
795         m_clipMonitor->stop();
796     }
797     m_monitorManager->resetProfiles(doc->profilePath());
798     m_projectList->setDocument(doc);
799     connect(m_projectList, SIGNAL(clipSelected(const QDomElement &)), m_clipMonitor, SLOT(slotSetXml(const QDomElement &)));
800     connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
801     connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
802     connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
803     connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
804     connect(doc, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
805     connect(doc, SIGNAL(addProjectFolder(const QString, int, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, int, bool, bool)));
806     connect(doc, SIGNAL(signalDeleteProjectClip(int)), m_projectList, SLOT(slotDeleteClip(int)));
807     connect(doc, SIGNAL(updateClipDisplay(int)), m_projectList, SLOT(slotUpdateClip(int)));
808     connect(doc, SIGNAL(refreshClipThumbnail(int)), m_projectList, SLOT(slotRefreshClipThumbnail(int)));
809
810     connect(doc, SIGNAL(deletTimelineClip(int)), trackView, SLOT(slotDeleteClip(int)));
811     connect(doc, SIGNAL(thumbsProgress(KUrl, int)), this, SLOT(slotGotProgressInfo(KUrl, int)));
812     connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
813
814
815
816     connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
817     connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
818     connect(trackView, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
819     connect(trackView, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
820     m_zoomSlider->setValue(trackView->currentZoom());
821     connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
822     connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
823     connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
824     connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement)));
825     connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
826     connect(effectStack, SIGNAL(changeEffectState(ClipItem*, QDomElement, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, QDomElement, bool)));
827     connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
828     connect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
829     connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
830     trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu);
831     m_activeTimeline = trackView;
832     KdenliveSettings::setCurrent_profile(doc->profilePath());
833     if (m_renderWidget) m_renderWidget->setDocumentStandard(doc->getDocumentStandard());
834     m_monitorManager->setTimecode(doc->timecode());
835     doc->setRenderer(m_projectMonitor->render);
836     m_commandStack->setActiveStack(doc->commandStack());
837     if (m_commandStack->isClean()) kDebug() << "////////////  UNDO STACK IS CLEAN";
838     else  kDebug() << "////////////  UNDO STACK IS NOT CLEAN*******************";
839
840     m_overView->setScene(trackView->projectScene());
841     //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
842     //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
843
844     setCaption(doc->description());
845     m_activeDocument = doc;
846 }
847
848 void MainWindow::slotPreferences() {
849     //An instance of your dialog could be already created and could be
850     // cached, in which case you want to display the cached dialog
851     // instead of creating another one
852     if (KConfigDialog::showDialog("settings"))
853         return;
854
855     // KConfigDialog didn't find an instance of this dialog, so lets
856     // create it :
857     KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
858     connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
859     dialog->show();
860 }
861
862 void MainWindow::updateConfiguration() {
863     //TODO: we should apply settings to all projects, not only the current one
864     TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
865     if (currentTab) {
866         currentTab->refresh();
867         currentTab->projectView()->checkAutoScroll();
868         currentTab->projectView()->checkTrackHeight();
869         if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
870     }
871     m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
872     m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
873     activateShuttleDevice();
874
875 }
876
877 void MainWindow::slotSwitchVideoThumbs() {
878     KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
879     TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
880     if (currentTab) {
881         currentTab->refresh();
882     }
883     m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
884 }
885
886 void MainWindow::slotSwitchAudioThumbs() {
887     KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
888     TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
889     if (currentTab) {
890         currentTab->refresh();
891         currentTab->projectView()->checkAutoScroll();
892         if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
893     }
894     m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
895 }
896
897 void MainWindow::slotDeleteTimelineClip() {
898     TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
899     if (currentTab) {
900         currentTab->projectView()->deleteSelectedClips();
901     }
902 }
903
904 void MainWindow::slotCutTimelineClip() {
905     TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
906     if (currentTab) {
907         currentTab->projectView()->cutSelectedClips();
908     }
909 }
910
911 void MainWindow::slotAddProjectClip(KUrl url) {
912     if (m_activeDocument)
913         m_activeDocument->slotAddClipFile(url, QString());
914 }
915
916 void MainWindow::slotAddVideoEffect(QAction *result) {
917     if (!result) return;
918     QDomElement effect = videoEffects.getEffectByName(result->data().toString());
919     slotAddEffect(effect);
920 }
921
922 void MainWindow::slotAddAudioEffect(QAction *result) {
923     if (!result) return;
924     QDomElement effect = audioEffects.getEffectByName(result->data().toString());
925     slotAddEffect(effect);
926 }
927
928 void MainWindow::slotAddCustomEffect(QAction *result) {
929     if (!result) return;
930     QDomElement effect = customEffects.getEffectByName(result->data().toString());
931     slotAddEffect(effect);
932 }
933
934 void MainWindow::slotZoomIn() {
935     m_zoomSlider->setValue(m_zoomSlider->value() - 1);
936 }
937
938 void MainWindow::slotZoomOut() {
939     m_zoomSlider->setValue(m_zoomSlider->value() + 1);
940 }
941
942 void MainWindow::slotFitZoom() {
943     TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
944     if (currentTab) {
945         m_zoomSlider->setValue(currentTab->fitZoom());
946     }
947 }
948
949 void MainWindow::slotGotProgressInfo(KUrl url, int progress) {
950     statusProgressBar->setValue(progress);
951     if (progress > 0) {
952         statusLabel->setText(tr("Creating Audio Thumbs"));
953         statusProgressBar->setVisible(true);
954     } else {
955         statusLabel->setText("");
956         statusProgressBar->setVisible(false);
957     }
958 }
959
960 void MainWindow::slotShowClipProperties(DocClipBase *clip) {
961     if (clip->clipType() == TEXT) {
962         m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
963         return;
964     }
965     ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
966     if (dia.exec() == QDialog::Accepted) {
967         m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
968     }
969 }
970
971 void MainWindow::customEvent(QEvent* e) {
972     if (e->type() == QEvent::User) {
973         // The timeline playing position changed...
974         kDebug() << "RECIEVED JOG EVEMNT!!!";
975     }
976 }
977 void MainWindow::slotActivateEffectStackView() {
978     effectStack->raiseWindow(effectStackDock);
979 }
980
981 void MainWindow::slotActivateTransitionView() {
982     transitionConfig->raiseWindow(transitionConfigDock);
983 }
984
985 void MainWindow::slotChangeTool(QAction * action) {
986     if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
987     else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
988 }
989
990 void MainWindow::slotSetTool(PROJECTTOOL tool) {
991     if (m_activeDocument) {
992         //m_activeDocument->setTool(tool);
993         TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
994         currentTab->projectView()->setTool(tool);
995     }
996 }
997
998 #include "mainwindow.moc"