]> git.sesse.net Git - kdenlive/blob - src/mainwindow.cpp
Make "Edit duration" in the transition context menu work
[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 #include "mainwindow.h"
22 #include "mainwindowadaptor.h"
23 #include "kdenlivesettings.h"
24 #include "kdenlivesettingsdialog.h"
25 #include "initeffects.h"
26 #include "profilesdialog.h"
27 #include "projectsettings.h"
28 #include "events.h"
29 #include "clipmanager.h"
30 #include "projectlist.h"
31 #include "monitor.h"
32 #include "recmonitor.h"
33 #include "monitormanager.h"
34 #include "kdenlivedoc.h"
35 #include "trackview.h"
36 #include "customtrackview.h"
37 #include "effectslistview.h"
38 #include "effectstackview.h"
39 #include "transitionsettings.h"
40 #include "renderwidget.h"
41 #include "renderer.h"
42 #ifndef NO_JOGSHUTTLE
43 #include "jogshuttle.h"
44 #endif /* NO_JOGSHUTTLE */
45 #include "clipproperties.h"
46 #include "wizard.h"
47 #include "editclipcommand.h"
48 #include "titlewidget.h"
49 #include "markerdialog.h"
50 #include "clipitem.h"
51 #include "interfaces.h"
52 #include "kdenlive-config.h"
53 #include "cliptranscode.h"
54 #include "ui_templateclip_ui.h"
55
56 #include <KApplication>
57 #include <KAction>
58 #include <KLocale>
59 #include <KGlobal>
60 #include <KActionCollection>
61 #include <KStandardAction>
62 #include <KFileDialog>
63 #include <KMessageBox>
64 #include <KDebug>
65 #include <KIO/NetAccess>
66 #include <KSaveFile>
67 #include <KRuler>
68 #include <KConfigDialog>
69 #include <KXMLGUIFactory>
70 #include <KStatusBar>
71 #include <kstandarddirs.h>
72 #include <KUrlRequesterDialog>
73 #include <KTemporaryFile>
74 #include <KProcess>
75 #include <KActionMenu>
76 #include <KMenu>
77 #include <locale.h>
78 #include <ktogglefullscreenaction.h>
79 #include <KFileItem>
80 #include <KNotification>
81 #include <KNotifyConfigWidget>
82 #if KDE_IS_VERSION(4,3,80)
83 #include <knewstuff3/downloaddialog.h>
84 #include <knewstuff3/knewstuffaction.h>
85 #else
86 #include <knewstuff2/engine.h>
87 #include <knewstuff2/ui/knewstuffaction.h>
88 #define KNS3 KNS
89 #endif /* KDE_IS_VERSION(4,3,80) */
90 #include <KToolBar>
91 #include <KColorScheme>
92
93 #include <QTextStream>
94 #include <QTimer>
95 #include <QAction>
96 #include <QKeyEvent>
97 #include <QInputDialog>
98 #include <QDesktopWidget>
99 #include <QBitmap>
100
101 #include <stdlib.h>
102
103 static const char version[] = VERSION;
104
105 static const int ID_TIMELINE_POS = 0;
106
107 namespace Mlt
108 {
109 class Producer;
110 };
111
112 EffectsList MainWindow::videoEffects;
113 EffectsList MainWindow::audioEffects;
114 EffectsList MainWindow::customEffects;
115 EffectsList MainWindow::transitions;
116
117 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent) :
118         KXmlGuiWindow(parent),
119         m_activeDocument(NULL),
120         m_activeTimeline(NULL),
121         m_renderWidget(NULL),
122 #ifndef NO_JOGSHUTTLE
123         m_jogProcess(NULL),
124 #endif /* NO_JOGSHUTTLE */
125         m_findActivated(false)
126 {
127
128     // Create DBus interface
129     new MainWindowAdaptor(this);
130     QDBusConnection dbus = QDBusConnection::sessionBus();
131     dbus.registerObject("/MainWindow", this);
132
133     setlocale(LC_NUMERIC, "POSIX");
134     if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
135     setFont(KGlobalSettings::toolBarFont());
136     parseProfiles(MltPath);
137     m_commandStack = new QUndoGroup;
138     m_timelineArea = new KTabWidget(this);
139     m_timelineArea->setTabReorderingEnabled(true);
140     m_timelineArea->setTabBarHidden(true);
141
142     QToolButton *closeTabButton = new QToolButton;
143     connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
144     closeTabButton->setIcon(KIcon("tab-close"));
145     closeTabButton->adjustSize();
146     closeTabButton->setToolTip(i18n("Close the current tab"));
147     m_timelineArea->setCornerWidget(closeTabButton);
148     connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
149
150     connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
151     m_findTimer.setSingleShot(true);
152
153     // FIXME: the next call returns a newly allocated object, which leaks
154     initEffects::parseEffectFiles();
155     //initEffects::parseCustomEffectsFile();
156
157     m_monitorManager = new MonitorManager();
158
159     m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
160     m_projectListDock->setObjectName("project_tree");
161     m_projectList = new ProjectList(this);
162     m_projectListDock->setWidget(m_projectList);
163     addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
164
165     m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
166     connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
167
168     m_effectListDock = new QDockWidget(i18n("Effect List"), this);
169     m_effectListDock->setObjectName("effect_list");
170     m_effectList = new EffectsListView();
171
172     //m_effectList = new KListWidget(this);
173     m_effectListDock->setWidget(m_effectList);
174     addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
175
176     m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
177     m_effectStackDock->setObjectName("effect_stack");
178     m_effectStack = new EffectStackView(this);
179     m_effectStackDock->setWidget(m_effectStack);
180     addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
181
182     m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
183     m_transitionConfigDock->setObjectName("transition");
184     m_transitionConfig = new TransitionSettings(this);
185     m_transitionConfigDock->setWidget(m_transitionConfig);
186     addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
187
188     KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
189     m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
190     readOptions();
191     m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
192     m_fileRevert->setEnabled(false);
193
194     //slotDetectAudioDriver();
195
196     m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
197     m_clipMonitorDock->setObjectName("clip_monitor");
198     m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), this);
199     m_clipMonitorDock->setWidget(m_clipMonitor);
200     addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
201     //m_clipMonitor->stop();
202
203     m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
204     m_projectMonitorDock->setObjectName("project_monitor");
205     m_projectMonitor = new Monitor("project", m_monitorManager, QString(), this);
206     m_projectMonitorDock->setWidget(m_projectMonitor);
207     addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
208
209 #ifndef Q_WS_MAC
210     m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
211     m_recMonitorDock->setObjectName("record_monitor");
212     m_recMonitor = new RecMonitor("record", this);
213     m_recMonitorDock->setWidget(m_recMonitor);
214     addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
215
216     connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
217     connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
218 #endif
219
220     m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
221     m_undoViewDock->setObjectName("undo_history");
222     m_undoView = new QUndoView(this);
223     m_undoView->setCleanIcon(KIcon("edit-clear"));
224     m_undoView->setEmptyLabel(i18n("Clean"));
225     m_undoViewDock->setWidget(m_undoView);
226     m_undoView->setGroup(m_commandStack);
227     addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
228
229     //overviewDock = new QDockWidget(i18n("Project Overview"), this);
230     //overviewDock->setObjectName("project_overview");
231     //m_overView = new CustomTrackView(NULL, NULL, this);
232     //overviewDock->setWidget(m_overView);
233     //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
234
235     setupActions();
236     //tabifyDockWidget(projectListDock, effectListDock);
237     tabifyDockWidget(m_projectListDock, m_effectStackDock);
238     tabifyDockWidget(m_projectListDock, m_transitionConfigDock);
239     //tabifyDockWidget(projectListDock, undoViewDock);
240
241
242     tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
243 #ifndef Q_WS_MAC
244     tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
245 #endif
246     setCentralWidget(m_timelineArea);
247     setupGUI();
248
249     // Find QDockWidget tab bars and show / hide widget title bars on right click
250     QList <QTabBar *> tabs = findChildren<QTabBar *>();
251     for (int i = 0; i < tabs.count(); i++) {
252         tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
253         connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
254     }
255
256     /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
257     guiFactory()->addClient(sp);*/
258
259     loadPlugins();
260     loadTranscoders();
261     //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
262
263     m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone);
264     m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
265     m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)), static_cast<QMenu*>(factory()->container("transcoders", this)));
266
267     QAction *action;
268     // build themes menus
269     QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
270     QActionGroup *themegroup = new QActionGroup(this);
271     themegroup->setExclusive(true);
272     action = new QAction(i18n("Default"), this);
273     action->setCheckable(true);
274     themegroup->addAction(action);
275     if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
276
277
278     const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
279
280     for (int i = 0; i < schemeFiles.size(); ++i) {
281         // get the file name
282         const QString filename = schemeFiles.at(i);
283         const QFileInfo info(filename);
284
285         // add the entry
286         KSharedConfigPtr config = KSharedConfig::openConfig(filename);
287         QIcon icon = createSchemePreviewIcon(config);
288         KConfigGroup group(config, "General");
289         const QString name = group.readEntry("Name", info.baseName());
290         action = new QAction(name, this);
291         action->setData(filename);
292         action->setIcon(icon);
293         action->setCheckable(true);
294         themegroup->addAction(action);
295         if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
296     }
297
298
299
300
301
302
303     /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
304     QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
305     for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
306     {
307     QFileInfo fi(*it);
308         action = new QAction(fi.fileName(), this);
309         action->setData(*it);
310     action->setCheckable(true);
311     themegroup->addAction(action);
312     if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
313     }*/
314     themesMenu->addActions(themegroup->actions());
315     connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
316
317     // build effects menus
318     QMenu *videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
319
320     QStringList effectInfo;
321     QMap<QString, QStringList> effectsList;
322     for (int ix = 0; ix < videoEffects.count(); ix++) {
323         effectInfo = videoEffects.effectIdInfo(ix);
324         effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
325     }
326
327     foreach(const QStringList &value, effectsList) {
328         action = new QAction(value.at(0), this);
329         action->setData(value);
330         videoEffectsMenu->addAction(action);
331     }
332
333     QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
334
335
336     effectsList.clear();
337     for (int ix = 0; ix < audioEffects.count(); ix++) {
338         effectInfo = audioEffects.effectIdInfo(ix);
339         effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
340     }
341
342     foreach(const QStringList &value, effectsList) {
343         action = new QAction(value.at(0), this);
344         action->setData(value);
345         audioEffectsMenu->addAction(action);
346     }
347
348     m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
349
350     if (customEffects.isEmpty()) m_customEffectsMenu->setEnabled(false);
351     else m_customEffectsMenu->setEnabled(true);
352
353     effectsList.clear();
354     for (int ix = 0; ix < customEffects.count(); ix++) {
355         effectInfo = customEffects.effectIdInfo(ix);
356         effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
357     }
358
359     foreach(const QStringList &value, effectsList) {
360         action = new QAction(value.at(0), this);
361         action->setData(value);
362         m_customEffectsMenu->addAction(action);
363     }
364
365     QMenu *newEffect = new QMenu(this);
366     newEffect->addMenu(videoEffectsMenu);
367     newEffect->addMenu(audioEffectsMenu);
368     newEffect->addMenu(m_customEffectsMenu);
369     m_effectStack->setMenu(newEffect);
370
371
372     QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
373     const QList<QAction *> viewActions = createPopupMenu()->actions();
374     viewMenu->insertActions(NULL, viewActions);
375
376     connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
377     connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
378     connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
379
380     m_timelineContextMenu = new QMenu(this);
381     m_timelineContextClipMenu = new QMenu(this);
382     m_timelineContextTransitionMenu = new QMenu(this);
383
384
385     QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
386     QStringList effects = transitions.effectNames();
387
388     effectsList.clear();
389     for (int ix = 0; ix < transitions.count(); ix++) {
390         effectInfo = transitions.effectIdInfo(ix);
391         effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
392     }
393     foreach(const QStringList &value, effectsList) {
394         action = new QAction(value.at(0), this);
395         action->setData(value);
396         transitionsMenu->addAction(action);
397     }
398     connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
399
400     m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
401     m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
402     m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
403
404     m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
405     m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
406     m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
407     m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
408     m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
409     m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
410     m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
411     m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
412
413     QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
414     m_timelineContextClipMenu->addMenu(markersMenu);
415     m_timelineContextClipMenu->addMenu(transitionsMenu);
416     m_timelineContextClipMenu->addMenu(videoEffectsMenu);
417     m_timelineContextClipMenu->addMenu(audioEffectsMenu);
418     //TODO: re-enable custom effects menu when it is implemented
419     m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
420
421     m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
422     m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
423     m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
424
425     m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
426
427     connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
428     connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
429     //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
430     connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
431     connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
432     connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
433
434     m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
435     slotConnectMonitors();
436
437     // Disable drop B frames, see Kdenlive issue #1330, see also kdenlivesettingsdialog.cpp
438     KdenliveSettings::setDropbframes(false);
439
440     // Open or create a file.  Command line argument passed in Url has
441     // precedence, then "openlastproject", then just a plain empty file.
442     // If opening Url fails, openlastproject will _not_ be used.
443     if (!Url.isEmpty()) {
444         // delay loading so that the window shows up
445         m_startUrl = Url;
446         QTimer::singleShot(500, this, SLOT(openFile()));
447     } else if (KdenliveSettings::openlastproject()) {
448         QTimer::singleShot(500, this, SLOT(openLastFile()));
449     } else { //if (m_timelineArea->count() == 0) {
450         newFile(false);
451     }
452
453 #ifndef NO_JOGSHUTTLE
454     activateShuttleDevice();
455 #endif /* NO_JOGSHUTTLE */
456     m_projectListDock->raise();
457 }
458
459 void MainWindow::queryQuit()
460 {
461     if (queryClose()) {
462         if (m_projectMonitor) m_projectMonitor->stop();
463         if (m_clipMonitor) m_clipMonitor->stop();
464         delete m_effectStack;
465         delete m_activeTimeline;
466 #ifndef Q_WS_MAC
467         // This sometimes causes crash on exit on OS X for some reason.
468         delete m_projectMonitor;
469         delete m_clipMonitor;
470 #endif
471         delete m_activeDocument;
472         delete m_shortcutRemoveFocus;
473         Mlt::Factory::close();
474         kapp->quit();
475     }
476 }
477
478 //virtual
479 bool MainWindow::queryClose()
480 {
481     if (m_renderWidget) {
482         int waitingJobs = m_renderWidget->waitingJobsCount();
483         if (waitingJobs > 0) {
484             switch (KMessageBox::warningYesNoCancel(this, i18np("You have 1 rendering job waiting in the queue.\nWhat do you want to do with this job?", "You have %1 rendering jobs waiting in the queue.\nWhat do you want to do with these jobs?", waitingJobs), QString(), KGuiItem(i18n("Start them now")), KGuiItem(i18n("Delete them")))) {
485             case KMessageBox::Yes :
486                 // create script with waiting jobs and start it
487                 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
488                 break;
489             case KMessageBox::No :
490                 // Don't do anything, jobs will be deleted
491                 break;
492             default:
493                 return false;
494             }
495         }
496     }
497     saveOptions();
498     if (m_monitorManager) m_monitorManager->stopActiveMonitor();
499     if (m_activeDocument && m_activeDocument->isModified()) {
500         switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
501         case KMessageBox::Yes :
502             // save document here. If saving fails, return false;
503             return saveFile();
504         case KMessageBox::No :
505             // User does not want to save the changes, clear recovery files
506             m_activeDocument->m_autosave->resize(0);
507             return true;
508         default: // cancel
509             return false;
510         }
511     }
512     return true;
513 }
514
515
516 void MainWindow::loadPlugins()
517 {
518     foreach(QObject *plugin, QPluginLoader::staticInstances())
519     populateMenus(plugin);
520
521     QStringList directories = KGlobal::dirs()->findDirs("module", QString());
522     QStringList filters;
523     filters << "libkdenlive*";
524     foreach(const QString &folder, directories) {
525         kDebug() << "// PARSING FIOLER: " << folder;
526         QDir pluginsDir(folder);
527         foreach(const QString &fileName, pluginsDir.entryList(filters, QDir::Files)) {
528             kDebug() << "// FOUND PLUGIN: " << fileName << "= " << pluginsDir.absoluteFilePath(fileName);
529             QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
530             QObject *plugin = loader.instance();
531             if (plugin) {
532                 populateMenus(plugin);
533                 m_pluginFileNames += fileName;
534             } else kDebug() << "// ERROR LOADING PLUGIN: " << fileName << ", " << loader.errorString();
535         }
536     }
537     //exit(1);
538 }
539
540 void MainWindow::populateMenus(QObject *plugin)
541 {
542     QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
543     ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
544     if (iGenerator)
545         addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
546                   NULL);
547 }
548
549 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
550                            QMenu *menu, const char *member,
551                            QActionGroup *actionGroup)
552 {
553     kDebug() << "// ADD to MENU" << texts;
554     foreach(const QString &text, texts) {
555         QAction *action = new QAction(text, plugin);
556         action->setData(text);
557         connect(action, SIGNAL(triggered()), this, member);
558         menu->addAction(action);
559
560         if (actionGroup) {
561             action->setCheckable(true);
562             actionGroup->addAction(action);
563         }
564     }
565 }
566
567 void MainWindow::aboutPlugins()
568 {
569     //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
570     //dialog.exec();
571 }
572
573
574 void MainWindow::generateClip()
575 {
576     QAction *action = qobject_cast<QAction *>(sender());
577     ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
578
579     KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(), QStringList(), QStringList(), 25, 720, 576);
580     if (!clipUrl.isEmpty()) {
581         m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
582     }
583 }
584
585 void MainWindow::saveProperties(KConfigGroup &config)
586 {
587     // save properties here,used by session management
588     saveFile();
589     KMainWindow::saveProperties(config);
590 }
591
592
593 void MainWindow::readProperties(const KConfigGroup &config)
594 {
595     // read properties here,used by session management
596     KMainWindow::readProperties(config);
597     QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
598     openFile(KUrl(Lastproject));
599 }
600
601 void MainWindow::slotReloadEffects()
602 {
603     m_customEffectsMenu->clear();
604     initEffects::parseCustomEffectsFile();
605     QAction *action;
606     QStringList effectInfo;
607     QMap<QString, QStringList> effectsList;
608
609     for (int ix = 0; ix < customEffects.count(); ix++) {
610         effectInfo = customEffects.effectIdInfo(ix);
611         effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
612     }
613     if (effectsList.isEmpty()) {
614         m_customEffectsMenu->setEnabled(false);
615         return;
616     } else m_customEffectsMenu->setEnabled(true);
617
618     foreach(const QStringList &value, effectsList) {
619         action = new QAction(value.at(0), this);
620         action->setData(value);
621         m_customEffectsMenu->addAction(action);
622     }
623     m_effectList->reloadEffectList();
624 }
625
626 #ifndef NO_JOGSHUTTLE
627 void MainWindow::activateShuttleDevice()
628 {
629     delete m_jogProcess;
630     m_jogProcess = NULL;
631     if (KdenliveSettings::enableshuttle() == false) return;
632     m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
633     connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
634     connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
635     connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
636     connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
637     connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
638     connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
639 }
640
641 void MainWindow::slotShuttleButton(int code)
642 {
643     switch (code) {
644     case 5:
645         slotShuttleAction(KdenliveSettings::shuttle1());
646         break;
647     case 6:
648         slotShuttleAction(KdenliveSettings::shuttle2());
649         break;
650     case 7:
651         slotShuttleAction(KdenliveSettings::shuttle3());
652         break;
653     case 8:
654         slotShuttleAction(KdenliveSettings::shuttle4());
655         break;
656     case 9:
657         slotShuttleAction(KdenliveSettings::shuttle5());
658         break;
659     }
660 }
661
662 void MainWindow::slotShuttleAction(int code)
663 {
664     switch (code) {
665     case 0:
666         return;
667     case 1:
668         m_monitorManager->slotPlay();
669         break;
670     default:
671         m_monitorManager->slotPlay();
672         break;
673     }
674 }
675 #endif /* NO_JOGSHUTTLE */
676
677 void MainWindow::configureNotifications()
678 {
679     KNotifyConfigWidget::configure(this);
680 }
681
682 void MainWindow::slotFullScreen()
683 {
684     KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
685 }
686
687 void MainWindow::slotAddEffect(const QDomElement effect, GenTime pos, int track)
688 {
689     if (!m_activeDocument) return;
690     if (effect.isNull()) {
691         kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
692         return;
693     }
694     QDomElement effectToAdd = effect.cloneNode().toElement();
695     m_activeTimeline->projectView()->slotAddEffect(effectToAdd, pos, track);
696 }
697
698 void MainWindow::slotRaiseMonitor(bool clipMonitor)
699 {
700     if (clipMonitor) m_clipMonitorDock->raise();
701     else m_projectMonitorDock->raise();
702 }
703
704 void MainWindow::slotUpdateClip(const QString &id)
705 {
706     if (!m_activeDocument) return;
707     m_activeTimeline->projectView()->slotUpdateClip(id);
708 }
709
710 void MainWindow::slotConnectMonitors()
711 {
712
713     m_projectList->setRenderer(m_projectMonitor->render);
714     //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
715     connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
716     connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
717     connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
718     connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, int, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, int, bool)));
719     connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
720     connect(m_projectMonitor->render, SIGNAL(replyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool)), m_projectList, SLOT(slotReplyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool)));
721
722     connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
723
724     connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
725
726     connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
727     connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
728
729     connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
730     connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
731 }
732
733 void MainWindow::slotAdjustClipMonitor()
734 {
735     m_clipMonitorDock->updateGeometry();
736     m_clipMonitorDock->adjustSize();
737     m_clipMonitor->resetSize();
738 }
739
740 void MainWindow::slotAdjustProjectMonitor()
741 {
742     m_projectMonitorDock->updateGeometry();
743     m_projectMonitorDock->adjustSize();
744     m_projectMonitor->resetSize();
745 }
746
747 void MainWindow::setupActions()
748 {
749
750     KActionCollection* collection = actionCollection();
751     m_timecodeFormat = new KComboBox(this);
752     m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
753     m_timecodeFormat->addItem(i18n("Frames"));
754     if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
755     connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
756
757     m_statusProgressBar = new QProgressBar(this);
758     m_statusProgressBar->setMinimum(0);
759     m_statusProgressBar->setMaximum(100);
760     m_statusProgressBar->setMaximumWidth(150);
761     m_statusProgressBar->setVisible(false);
762
763     KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
764     toolbar->setMovable(false);
765     statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
766     QString style1 = "QToolBar { border: 0px } QToolButton { border-style: inset; border:1px solid #999999;border-radius: 3px;margin: 0px 3px;padding: 0px;} QToolButton:checked { background-color: rgba(224, 224, 0, 100); border-style: inset; border:1px solid #cc6666;border-radius: 3px;}";
767
768     //create edit mode buttons
769     m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
770     m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
771     toolbar->addAction(m_normalEditTool);
772     m_normalEditTool->setCheckable(true);
773     m_normalEditTool->setChecked(true);
774
775     m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
776     //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
777     toolbar->addAction(m_overwriteEditTool);
778     m_overwriteEditTool->setCheckable(true);
779     m_overwriteEditTool->setChecked(false);
780
781     m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
782     //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
783     toolbar->addAction(m_insertEditTool);
784     m_insertEditTool->setCheckable(true);
785     m_insertEditTool->setChecked(false);
786     // not implemented yet
787     m_insertEditTool->setEnabled(false);
788
789     QActionGroup *editGroup = new QActionGroup(this);
790     editGroup->addAction(m_normalEditTool);
791     editGroup->addAction(m_overwriteEditTool);
792     editGroup->addAction(m_insertEditTool);
793     editGroup->setExclusive(true);
794     connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
795     //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
796
797     toolbar->addSeparator();
798
799     // create tools buttons
800     m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
801     m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
802     toolbar->addAction(m_buttonSelectTool);
803     m_buttonSelectTool->setCheckable(true);
804     m_buttonSelectTool->setChecked(true);
805
806     m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
807     m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
808     toolbar->addAction(m_buttonRazorTool);
809     m_buttonRazorTool->setCheckable(true);
810     m_buttonRazorTool->setChecked(false);
811
812     m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
813     m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
814     toolbar->addAction(m_buttonSpacerTool);
815     m_buttonSpacerTool->setCheckable(true);
816     m_buttonSpacerTool->setChecked(false);
817
818     QActionGroup *toolGroup = new QActionGroup(this);
819     toolGroup->addAction(m_buttonSelectTool);
820     toolGroup->addAction(m_buttonRazorTool);
821     toolGroup->addAction(m_buttonSpacerTool);
822     toolGroup->setExclusive(true);
823     toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
824
825     QWidget * actionWidget;
826     int max = toolbar->iconSizeDefault() + 2;
827     actionWidget = toolbar->widgetForAction(m_normalEditTool);
828     actionWidget->setMaximumWidth(max);
829     actionWidget->setMaximumHeight(max - 4);
830
831     actionWidget = toolbar->widgetForAction(m_insertEditTool);
832     actionWidget->setMaximumWidth(max);
833     actionWidget->setMaximumHeight(max - 4);
834
835     actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
836     actionWidget->setMaximumWidth(max);
837     actionWidget->setMaximumHeight(max - 4);
838
839     actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
840     actionWidget->setMaximumWidth(max);
841     actionWidget->setMaximumHeight(max - 4);
842
843     actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
844     actionWidget->setMaximumWidth(max);
845     actionWidget->setMaximumHeight(max - 4);
846
847     actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
848     actionWidget->setMaximumWidth(max);
849     actionWidget->setMaximumHeight(max - 4);
850
851     toolbar->setStyleSheet(style1);
852     connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
853
854     toolbar->addSeparator();
855     m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
856     toolbar->addAction(m_buttonFitZoom);
857     m_buttonFitZoom->setCheckable(false);
858     connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
859
860     actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
861     actionWidget->setMaximumWidth(max);
862     actionWidget->setMaximumHeight(max - 4);
863
864     m_zoomSlider = new QSlider(Qt::Horizontal, this);
865     m_zoomSlider->setMaximum(13);
866     m_zoomSlider->setPageStep(1);
867
868     m_zoomSlider->setMaximumWidth(150);
869     m_zoomSlider->setMinimumWidth(100);
870     toolbar->addWidget(m_zoomSlider);
871
872     m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
873     toolbar->addAction(m_buttonVideoThumbs);
874     m_buttonVideoThumbs->setCheckable(true);
875     m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
876     connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
877
878     m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
879     toolbar->addAction(m_buttonAudioThumbs);
880     m_buttonAudioThumbs->setCheckable(true);
881     m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
882     connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
883
884     m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
885     toolbar->addAction(m_buttonShowMarkers);
886     m_buttonShowMarkers->setCheckable(true);
887     m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
888     connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
889
890     m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
891     toolbar->addAction(m_buttonSnap);
892     m_buttonSnap->setCheckable(true);
893     m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
894     connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
895
896     actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
897     actionWidget->setMaximumWidth(max);
898     actionWidget->setMaximumHeight(max - 4);
899
900     actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
901     actionWidget->setMaximumWidth(max);
902     actionWidget->setMaximumHeight(max - 4);
903
904     actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
905     actionWidget->setMaximumWidth(max);
906     actionWidget->setMaximumHeight(max - 4);
907
908     actionWidget = toolbar->widgetForAction(m_buttonSnap);
909     actionWidget->setMaximumWidth(max);
910     actionWidget->setMaximumHeight(max - 4);
911
912     m_messageLabel = new StatusBarMessageLabel(this);
913     m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
914
915     statusBar()->addWidget(m_messageLabel, 10);
916     statusBar()->addWidget(m_statusProgressBar, 0);
917     statusBar()->addPermanentWidget(toolbar);
918     statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
919     statusBar()->addPermanentWidget(m_timecodeFormat);
920     //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
921
922     collection->addAction("normal_mode", m_normalEditTool);
923     collection->addAction("overwrite_mode", m_overwriteEditTool);
924     collection->addAction("insert_mode", m_insertEditTool);
925     collection->addAction("select_tool", m_buttonSelectTool);
926     collection->addAction("razor_tool", m_buttonRazorTool);
927     collection->addAction("spacer_tool", m_buttonSpacerTool);
928
929     collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
930     collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
931     collection->addAction("show_markers", m_buttonShowMarkers);
932     collection->addAction("snap", m_buttonSnap);
933     collection->addAction("zoom_fit", m_buttonFitZoom);
934
935     KAction* zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
936     collection->addAction("zoom_in", zoomIn);
937     connect(zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
938     zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
939
940     KAction* zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
941     collection->addAction("zoom_out", zoomOut);
942     connect(zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
943     zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
944
945     m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
946     collection->addAction("project_find", m_projectSearch);
947     connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
948     m_projectSearch->setShortcut(Qt::Key_Slash);
949
950     m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
951     collection->addAction("project_find_next", m_projectSearchNext);
952     connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
953     m_projectSearchNext->setShortcut(Qt::Key_F3);
954     m_projectSearchNext->setEnabled(false);
955
956     KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
957     collection->addAction("manage_profiles", profilesAction);
958     connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
959
960     KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
961
962     KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
963
964     KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
965
966     KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
967
968     KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
969     collection->addAction("run_wizard", wizAction);
970     connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
971
972     KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
973     collection->addAction("project_settings", projectAction);
974     connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
975
976     KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
977     collection->addAction("project_render", projectRender);
978     projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
979     connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
980
981     KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
982     collection->addAction("project_clean", projectClean);
983     connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
984
985     KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
986     KShortcut playShortcut;
987     playShortcut.setPrimary(Qt::Key_Space);
988     playShortcut.setAlternate(Qt::Key_K);
989     monitorPlay->setShortcut(playShortcut);
990     collection->addAction("monitor_play", monitorPlay);
991     connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
992
993     m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
994     m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
995     collection->addAction("monitor_play_zone", m_playZone);
996     connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
997
998     m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
999     m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1000     collection->addAction("monitor_loop_zone", m_loopZone);
1001     connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1002
1003     KAction *dvdWizard =  new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1004     collection->addAction("dvd_wizard", dvdWizard);
1005     connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1006
1007     KAction *transcodeClip =  new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1008     collection->addAction("transcode_clip", transcodeClip);
1009     connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1010
1011     KAction *markIn = collection->addAction("mark_in");
1012     markIn->setText(i18n("Set Zone In"));
1013     markIn->setShortcut(Qt::Key_I);
1014     connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1015
1016     KAction *markOut = collection->addAction("mark_out");
1017     markOut->setText(i18n("Set Zone Out"));
1018     markOut->setShortcut(Qt::Key_O);
1019     connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1020
1021     KAction *switchMon = collection->addAction("switch_monitor");
1022     switchMon->setText(i18n("Switch monitor"));
1023     switchMon->setShortcut(Qt::Key_T);
1024     connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1025
1026     KAction *insertTree = collection->addAction("insert_project_tree");
1027     insertTree->setText(i18n("Insert zone in project tree"));
1028     insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1029     connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1030
1031     KAction *insertTimeline = collection->addAction("insert_timeline");
1032     insertTimeline->setText(i18n("Insert zone in timeline"));
1033     insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1034     connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1035
1036     KAction *resizeStart =  new KAction(KIcon(), i18n("Resize Item Start"), this);
1037     collection->addAction("resize_timeline_clip_start", resizeStart);
1038     resizeStart->setShortcut(Qt::Key_1);
1039     connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1040
1041     KAction *resizeEnd =  new KAction(KIcon(), i18n("Resize Item End"), this);
1042     collection->addAction("resize_timeline_clip_end", resizeEnd);
1043     resizeEnd->setShortcut(Qt::Key_2);
1044     connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1045
1046     KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1047     monitorSeekBackward->setShortcut(Qt::Key_J);
1048     collection->addAction("monitor_seek_backward", monitorSeekBackward);
1049     connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1050
1051     KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1052     monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1053     collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1054     connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1055
1056     KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1057     monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1058     collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1059     connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1060
1061     KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1062     monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1063     collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1064     connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1065
1066     KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1067     monitorSeekForward->setShortcut(Qt::Key_L);
1068     collection->addAction("monitor_seek_forward", monitorSeekForward);
1069     connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1070
1071     KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1072     clipStart->setShortcut(Qt::Key_Home);
1073     collection->addAction("seek_clip_start", clipStart);
1074     connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1075
1076     KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1077     clipEnd->setShortcut(Qt::Key_End);
1078     collection->addAction("seek_clip_end", clipEnd);
1079     connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1080
1081     KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1082     zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1083     collection->addAction("seek_zone_start", zoneStart);
1084     connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1085
1086     KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1087     zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1088     collection->addAction("seek_zone_end", zoneEnd);
1089     connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1090
1091     KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1092     projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1093     collection->addAction("seek_start", projectStart);
1094     connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1095
1096     KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1097     projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1098     collection->addAction("seek_end", projectEnd);
1099     connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1100
1101     KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1102     monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1103     collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1104     connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1105
1106     KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1107     monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1108     collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1109     connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1110
1111     KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1112     monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1113     collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1114     connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1115
1116     KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1117     deleteTimelineClip->setShortcut(Qt::Key_Delete);
1118     collection->addAction("delete_timeline_clip", deleteTimelineClip);
1119     connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
1120
1121     /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1122     collection->addAction("change_clip_speed", editTimelineClipSpeed);
1123     editTimelineClipSpeed->setData("change_speed");
1124     connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1125
1126     KAction *stickTransition = collection->addAction("auto_transition");
1127     stickTransition->setData(QString("auto"));
1128     stickTransition->setCheckable(true);
1129     stickTransition->setEnabled(false);
1130     stickTransition->setText(i18n("Automatic Transition"));
1131     connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1132
1133     KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1134     groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1135     collection->addAction("group_clip", groupClip);
1136     connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1137
1138     KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1139     collection->addAction("ungroup_clip", ungroupClip);
1140     ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1141     ungroupClip->setData("ungroup_clip");
1142     connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1143
1144     KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1145     collection->addAction("edit_item_duration", editItemDuration);
1146     connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1147
1148     KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1149     insertOvertwrite->setShortcut(Qt::Key_V);
1150     collection->addAction("overwrite_to_in_point", insertOvertwrite);
1151     connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1152
1153     KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1154     selectTimelineClip->setShortcut(Qt::Key_Plus);
1155     collection->addAction("select_timeline_clip", selectTimelineClip);
1156     connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1157
1158     KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1159     deselectTimelineClip->setShortcut(Qt::Key_Minus);
1160     collection->addAction("deselect_timeline_clip", deselectTimelineClip);
1161     connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1162
1163     KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1164     selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1165     collection->addAction("select_add_timeline_clip", selectAddTimelineClip);
1166     connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1167
1168     KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1169     selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1170     collection->addAction("select_timeline_transition", selectTimelineTransition);
1171     connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1172
1173     KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1174     deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1175     collection->addAction("deselect_timeline_transition", deselectTimelineTransition);
1176     connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1177
1178     KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1179     selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1180     collection->addAction("select_add_timeline_transition", selectAddTimelineTransition);
1181     connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1182
1183     KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1184     cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1185     collection->addAction("cut_timeline_clip", cutTimelineClip);
1186     connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1187
1188     KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1189     collection->addAction("add_clip_marker", addClipMarker);
1190     connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1191
1192     KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1193     collection->addAction("delete_clip_marker", deleteClipMarker);
1194     connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1195
1196     KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1197     collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
1198     connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1199
1200     KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1201     collection->addAction("edit_clip_marker", editClipMarker);
1202     connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1203
1204     KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1205     collection->addAction("split_audio", splitAudio);
1206     connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1207
1208     KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1209     collection->addAction("clip_audio_only", audioOnly);
1210     audioOnly->setData("clip_audio_only");
1211     audioOnly->setCheckable(true);
1212
1213     KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1214     collection->addAction("clip_video_only", videoOnly);
1215     videoOnly->setData("clip_video_only");
1216     videoOnly->setCheckable(true);
1217
1218     KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1219     collection->addAction("clip_audio_and_video", audioAndVideo);
1220     audioAndVideo->setData("clip_audio_and_video");
1221     audioAndVideo->setCheckable(true);
1222
1223     m_clipTypeGroup = new QActionGroup(this);
1224     m_clipTypeGroup->addAction(audioOnly);
1225     m_clipTypeGroup->addAction(videoOnly);
1226     m_clipTypeGroup->addAction(audioAndVideo);
1227     connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1228     m_clipTypeGroup->setEnabled(false);
1229
1230     KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1231     collection->addAction("insert_space", insertSpace);
1232     connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1233
1234     KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1235     collection->addAction("delete_space", removeSpace);
1236     connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1237
1238     KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1239     collection->addAction("insert_track", insertTrack);
1240     connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1241
1242     KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1243     collection->addAction("delete_track", deleteTrack);
1244     connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1245
1246     KAction *changeTrack = new KAction(KIcon(), i18n("Change Track"), this);
1247     collection->addAction("change_track", changeTrack);
1248     connect(changeTrack, SIGNAL(triggered()), this, SLOT(slotChangeTrack()));
1249
1250     KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1251     collection->addAction("add_guide", addGuide);
1252     connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1253
1254     QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1255     collection->addAction("delete_guide", delGuide);
1256     connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1257
1258     QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1259     collection->addAction("edit_guide", editGuide);
1260     connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1261
1262     QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1263     collection->addAction("delete_all_guides", delAllGuides);
1264     connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1265
1266     QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1267     collection->addAction("paste_effects", pasteEffects);
1268     pasteEffects->setData("paste_effects");
1269     connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1270
1271     QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1272     collection->addAction("show_timeline", showTimeline);
1273     showTimeline->setCheckable(true);
1274     showTimeline->setChecked(true);
1275     connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1276
1277     QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1278     collection->addAction("show_titlebars", showTitleBar);
1279     showTitleBar->setCheckable(true);
1280     connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1281     showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1282     slotShowTitleBars(KdenliveSettings::showtitlebars());
1283
1284     /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1285     collection->addAction("maximize_current", maxCurrent);
1286     maxCurrent->setCheckable(true);
1287     maxCurrent->setChecked(false);
1288     connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1289
1290
1291     m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1292
1293     KStandardAction::quit(this, SLOT(queryQuit()), collection);
1294
1295     KStandardAction::open(this, SLOT(openFile()), collection);
1296
1297     m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1298
1299     KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1300
1301     KStandardAction::openNew(this, SLOT(newFile()), collection);
1302
1303     KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1304
1305     KStandardAction::configureNotifications(this , SLOT(configureNotifications()), collection);
1306
1307     KStandardAction::copy(this, SLOT(slotCopy()), collection);
1308
1309     KStandardAction::paste(this, SLOT(slotPaste()), collection);
1310
1311     KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1312     undo->setEnabled(false);
1313     connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1314
1315     KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1316     redo->setEnabled(false);
1317     connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1318
1319     KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1320
1321     /*
1322     //TODO: Add status tooltip to actions ?
1323     connect(collection, SIGNAL(actionHovered(QAction*)),
1324             this, SLOT(slotDisplayActionMessage(QAction*)));*/
1325
1326
1327     QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1328     collection->addAction("add_clip", addClip);
1329     connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1330
1331     QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1332     collection->addAction("add_color_clip", addColorClip);
1333     connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1334
1335     QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1336     collection->addAction("add_slide_clip", addSlideClip);
1337     connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1338
1339     QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1340     collection->addAction("add_text_clip", addTitleClip);
1341     connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1342
1343     QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1344     collection->addAction("add_text_template_clip", addTitleTemplateClip);
1345     connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1346
1347     QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1348     collection->addAction("add_folder", addFolderButton);
1349     connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1350
1351     QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1352     collection->addAction("clip_properties", clipProperties);
1353     clipProperties->setData("clip_properties");
1354     connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1355     clipProperties->setEnabled(false);
1356
1357     QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1358     collection->addAction("edit_clip", openClip);
1359     openClip->setData("edit_clip");
1360     connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1361     openClip->setEnabled(false);
1362
1363     QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1364     collection->addAction("delete_clip", deleteClip);
1365     deleteClip->setData("delete_clip");
1366     connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1367     deleteClip->setEnabled(false);
1368
1369     QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1370     collection->addAction("reload_clip", reloadClip);
1371     reloadClip->setData("reload_clip");
1372     connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1373     reloadClip->setEnabled(false);
1374
1375     QMenu *addClips = new QMenu();
1376     addClips->addAction(addClip);
1377     addClips->addAction(addColorClip);
1378     addClips->addAction(addSlideClip);
1379     addClips->addAction(addTitleClip);
1380     addClips->addAction(addTitleTemplateClip);
1381     addClips->addAction(addFolderButton);
1382
1383     addClips->addAction(reloadClip);
1384     addClips->addAction(clipProperties);
1385     addClips->addAction(openClip);
1386     addClips->addAction(deleteClip);
1387     m_projectList->setupMenu(addClips, addClip);
1388
1389     //connect(collection, SIGNAL( clearStatusText() ),
1390     //statusBar(), SLOT( clear() ) );
1391 }
1392
1393 void MainWindow::slotDisplayActionMessage(QAction *a)
1394 {
1395     statusBar()->showMessage(a->data().toString(), 3000);
1396 }
1397
1398 void MainWindow::saveOptions()
1399 {
1400     KdenliveSettings::self()->writeConfig();
1401     KSharedConfigPtr config = KGlobal::config();
1402     m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1403     KConfigGroup treecolumns(config, "Project Tree");
1404     treecolumns.writeEntry("columns", m_projectList->headerInfo());
1405     config->sync();
1406 }
1407
1408 void MainWindow::readOptions()
1409 {
1410     KSharedConfigPtr config = KGlobal::config();
1411     m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1412     KConfigGroup initialGroup(config, "version");
1413     bool upgrade = false;
1414     if (initialGroup.exists()) {
1415         if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1416             upgrade = true;
1417         }
1418
1419         if (initialGroup.readEntry("version") == "0.7") {
1420             //Add new settings from 0.7.1
1421             if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1422                 QString path = QDir::homePath() + "/kdenlive";
1423                 if (KStandardDirs::makeDir(path)  == false) {
1424                     kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1425                 } else KdenliveSettings::setDefaultprojectfolder(path);
1426             }
1427         }
1428
1429     }
1430
1431     if (!initialGroup.exists() || upgrade) {
1432         // this is our first run, show Wizard
1433         Wizard *w = new Wizard(upgrade, this);
1434         if (w->exec() == QDialog::Accepted && w->isOk()) {
1435             w->adjustSettings();
1436             initialGroup.writeEntry("version", version);
1437             delete w;
1438         } else {
1439             ::exit(1);
1440         }
1441     }
1442     KConfigGroup treecolumns(config, "Project Tree");
1443     const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1444     if (!state.isEmpty())
1445         m_projectList->setHeaderInfo(state);
1446 }
1447
1448 void MainWindow::slotRunWizard()
1449 {
1450     Wizard *w = new Wizard(false, this);
1451     if (w->exec() == QDialog::Accepted && w->isOk()) {
1452         w->adjustSettings();
1453     }
1454     delete w;
1455 }
1456
1457 void MainWindow::newFile(bool showProjectSettings, bool force)
1458 {
1459     if (!m_timelineArea->isEnabled() && !force) return;
1460     m_fileRevert->setEnabled(false);
1461     QString profileName;
1462     KUrl projectFolder;
1463     QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1464     if (!showProjectSettings) {
1465         if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1466         profileName = KdenliveSettings::default_profile();
1467         projectFolder = KdenliveSettings::defaultprojectfolder();
1468     } else {
1469         ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1470         if (w->exec() != QDialog::Accepted) return;
1471         if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1472         if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
1473         if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
1474         profileName = w->selectedProfile();
1475         projectFolder = w->selectedFolder();
1476         projectTracks = w->tracks();
1477         delete w;
1478     }
1479     m_timelineArea->setEnabled(true);
1480     m_projectList->setEnabled(true);
1481     KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1482     doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1483     bool ok;
1484     TrackView *trackView = new TrackView(doc, &ok, this);
1485     m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1486     if (!ok) {
1487         // MLT is broken
1488         //m_timelineArea->setEnabled(false);
1489         //m_projectList->setEnabled(false);
1490         slotPreferences(6);
1491         return;
1492     }
1493     if (m_timelineArea->count() == 1) {
1494         connectDocumentInfo(doc);
1495         connectDocument(trackView, doc);
1496     } else m_timelineArea->setTabBarHidden(false);
1497     m_monitorManager->activateMonitor("clip");
1498     m_closeAction->setEnabled(m_timelineArea->count() > 1);
1499 }
1500
1501 void MainWindow::activateDocument()
1502 {
1503     if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1504     TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1505     KdenliveDoc *currentDoc = currentTab->document();
1506     connectDocumentInfo(currentDoc);
1507     connectDocument(currentTab, currentDoc);
1508 }
1509
1510 void MainWindow::closeCurrentDocument(bool saveChanges)
1511 {
1512     QWidget *w = m_timelineArea->currentWidget();
1513     if (!w) return;
1514     // closing current document
1515     int ix = m_timelineArea->currentIndex() + 1;
1516     if (ix == m_timelineArea->count()) ix = 0;
1517     m_timelineArea->setCurrentIndex(ix);
1518     TrackView *tabToClose = (TrackView *) w;
1519     KdenliveDoc *docToClose = tabToClose->document();
1520     if (docToClose && docToClose->isModified() && saveChanges) {
1521         switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
1522         case KMessageBox::Yes :
1523             // save document here. If saving fails, return false;
1524             if (saveFile() == false) return;
1525             break;
1526         case KMessageBox::Cancel :
1527             return;
1528             break;
1529         default:
1530             break;
1531         }
1532     }
1533     m_clipMonitor->slotSetXml(NULL);
1534     m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1535     if (m_timelineArea->count() == 1) {
1536         m_timelineArea->setTabBarHidden(true);
1537         m_closeAction->setEnabled(false);
1538     }
1539     if (docToClose == m_activeDocument) {
1540         delete m_activeDocument;
1541         m_activeDocument = NULL;
1542         m_effectStack->clear();
1543         m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1544     } else delete docToClose;
1545     if (w == m_activeTimeline) {
1546         delete m_activeTimeline;
1547         m_activeTimeline = NULL;
1548     } else delete w;
1549 }
1550
1551 bool MainWindow::saveFileAs(const QString &outputFileName)
1552 {
1553     QString currentSceneList;
1554     m_monitorManager->stopActiveMonitor();
1555     if (KdenliveSettings::dropbframes()) {
1556         KdenliveSettings::setDropbframes(false);
1557         m_activeDocument->clipManager()->updatePreviewSettings();
1558         currentSceneList = m_projectMonitor->sceneList();
1559         KdenliveSettings::setDropbframes(true);
1560         m_activeDocument->clipManager()->updatePreviewSettings();
1561     } else currentSceneList = m_projectMonitor->sceneList();
1562
1563     if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1564         return false;
1565
1566     // Save timeline thumbnails
1567     m_activeTimeline->projectView()->saveThumbnails();
1568     m_activeDocument->setUrl(KUrl(outputFileName));
1569     if (m_activeDocument->m_autosave == NULL) {
1570         m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1571     } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1572     setCaption(m_activeDocument->description());
1573     m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1574     m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1575     m_activeDocument->setModified(false);
1576     m_fileOpenRecent->addUrl(KUrl(outputFileName));
1577     m_fileRevert->setEnabled(true);
1578     return true;
1579 }
1580
1581 bool MainWindow::saveFileAs()
1582 {
1583     // Check that the Kdenlive mime type is correctly installed
1584     QString mimetype = "application/x-kdenlive";
1585     KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1586     if (!mime) mimetype = "*.kdenlive";
1587
1588     QString outputFile = KFileDialog::getSaveFileName(KUrl(), mimetype);
1589     if (outputFile.isEmpty()) return false;
1590     if (QFile::exists(outputFile)) {
1591         if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it?")) == KMessageBox::No) return false;
1592     }
1593     return saveFileAs(outputFile);
1594 }
1595
1596 bool MainWindow::saveFile()
1597 {
1598     if (!m_activeDocument) return true;
1599     if (m_activeDocument->url().isEmpty()) {
1600         return saveFileAs();
1601     } else {
1602         bool result = saveFileAs(m_activeDocument->url().path());
1603         m_activeDocument->m_autosave->resize(0);
1604         return result;
1605     }
1606 }
1607
1608 void MainWindow::openFile()
1609 {
1610     if (!m_startUrl.isEmpty()) {
1611         openFile(m_startUrl);
1612         m_startUrl = KUrl();
1613         return;
1614     }
1615     // Check that the Kdenlive mime type is correctly installed
1616     QString mimetype = "application/x-kdenlive";
1617     KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1618     if (!mime) mimetype = "*.kdenlive";
1619
1620     KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), mimetype);
1621     if (url.isEmpty()) return;
1622     m_fileOpenRecent->addUrl(url);
1623     openFile(url);
1624 }
1625
1626 void MainWindow::openLastFile()
1627 {
1628     KSharedConfigPtr config = KGlobal::config();
1629     KUrl::List urls = m_fileOpenRecent->urls();
1630     //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1631     if (urls.isEmpty()) newFile(false);
1632     else openFile(urls.last());
1633 }
1634
1635 void MainWindow::openFile(const KUrl &url)
1636 {
1637     // Check if the document is already opened
1638     const int ct = m_timelineArea->count();
1639     bool isOpened = false;
1640     int i;
1641     for (i = 0; i < ct; i++) {
1642         TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1643         KdenliveDoc *doc = tab->document();
1644         if (doc->url() == url) {
1645             isOpened = true;
1646             break;
1647         }
1648     }
1649     if (isOpened) {
1650         m_timelineArea->setCurrentIndex(i);
1651         return;
1652     }
1653
1654     // Check for backup file
1655     QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1656     if (!staleFiles.isEmpty()) {
1657         if (KMessageBox::questionYesNo(this,
1658                                        i18n("Auto-saved files exist. Do you want to recover them now?"),
1659                                        i18n("File Recovery"),
1660                                        KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1661             recoverFiles(staleFiles);
1662             return;
1663         } else {
1664             // remove the stale files
1665             foreach(KAutoSaveFile *stale, staleFiles) {
1666                 stale->open(QIODevice::ReadWrite);
1667                 delete stale;
1668             }
1669         }
1670     }
1671     if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1672     m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
1673     m_messageLabel->repaint();
1674     doOpenFile(url, NULL);
1675 }
1676
1677 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1678 {
1679     if (!m_timelineArea->isEnabled()) return;
1680     m_fileRevert->setEnabled(true);
1681     KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, this);
1682     if (stale == NULL) {
1683         stale = new KAutoSaveFile(url, doc);
1684         doc->m_autosave = stale;
1685     } else {
1686         doc->m_autosave = stale;
1687         doc->setUrl(stale->managedFile());
1688         doc->setModified(true);
1689         stale->setParent(doc);
1690     }
1691     connectDocumentInfo(doc);
1692     bool ok;
1693     TrackView *trackView = new TrackView(doc, &ok, this);
1694     m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1695     if (!ok) {
1696         m_timelineArea->setEnabled(false);
1697         m_projectList->setEnabled(false);
1698         KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
1699         slotGotProgressInfo(QString(), -1);
1700         newFile(false, true);
1701         return;
1702     }
1703     m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1704     trackView->setDuration(trackView->duration());
1705     trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1706
1707     if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1708     slotGotProgressInfo(QString(), -1);
1709     m_projectMonitor->adjustRulerSize(trackView->duration());
1710     m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1711     m_clipMonitor->refreshMonitor(true);
1712 }
1713
1714 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1715 {
1716     if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1717     foreach(KAutoSaveFile *stale, staleFiles) {
1718         /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1719                   // show an error message; we could not steal the lockfile
1720                   // maybe another application got to the file before us?
1721                   delete stale;
1722                   continue;
1723         }*/
1724         kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1725         // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
1726         if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1727         else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1728     }
1729 }
1730
1731
1732 void MainWindow::parseProfiles(const QString &mltPath)
1733 {
1734     // kDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
1735
1736     //KdenliveSettings::setDefaulttmpfolder();
1737     if (!mltPath.isEmpty()) {
1738         KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1739         KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
1740     }
1741
1742     if (KdenliveSettings::mltpath().isEmpty()) {
1743         KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1744     }
1745     if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
1746         QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
1747         if (!QFile::exists(meltPath))
1748             meltPath = KStandardDirs::findExe("melt");
1749         KdenliveSettings::setRendererpath(meltPath);
1750     }
1751     QStringList profilesFilter;
1752     profilesFilter << "*";
1753     QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1754
1755     if (profilesList.isEmpty()) {
1756         // Cannot find MLT path, try finding melt
1757         QString profilePath = KdenliveSettings::rendererpath();
1758         if (!profilePath.isEmpty()) {
1759             profilePath = profilePath.section('/', 0, -3);
1760             KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1761             QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1762         }
1763
1764         if (profilesList.isEmpty()) {
1765             // Cannot find the MLT profiles, ask for location
1766             KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1767             getUrl->fileDialog()->setMode(KFile::Directory);
1768             if (getUrl->exec() == QDialog::Rejected) {
1769                 ::exit(0);
1770             }
1771             KUrl mltPath = getUrl->selectedUrl();
1772             delete getUrl;
1773             if (mltPath.isEmpty()) ::exit(0);
1774             KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
1775             QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1776         }
1777     }
1778
1779     if (KdenliveSettings::rendererpath().isEmpty()) {
1780         // Cannot find the MLT melt renderer, ask for location
1781         KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of Mlt)"), this);
1782         if (getUrl->exec() == QDialog::Rejected) {
1783             ::exit(0);
1784         }
1785         KUrl rendererPath = getUrl->selectedUrl();
1786         delete getUrl;
1787         if (rendererPath.isEmpty()) ::exit(0);
1788         KdenliveSettings::setRendererpath(rendererPath.path());
1789     }
1790
1791     kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1792
1793     // Parse MLT profiles to build a list of available video formats
1794     if (profilesList.isEmpty()) parseProfiles();
1795 }
1796
1797
1798 void MainWindow::slotEditProfiles()
1799 {
1800     ProfilesDialog *w = new ProfilesDialog;
1801     if (w->exec() == QDialog::Accepted) {
1802         KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1803         if (d) d->checkProfile();
1804     }
1805     delete w;
1806 }
1807
1808 void MainWindow::slotDetectAudioDriver()
1809 {
1810     /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
1811     leading to no audio output, see bug #934 */
1812
1813     //decide which audio driver is really best, in some cases SDL is wrong
1814     if (KdenliveSettings::audiodrivername().isEmpty()) {
1815         QString driver;
1816         KProcess readProcess;
1817         //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
1818         if (!KStandardDirs::findExe("pactl").isEmpty()) {
1819             readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
1820             readProcess.setProgram("pactl", QStringList() << "stat");
1821             readProcess.execute(2000); // Kill it after 2 seconds
1822
1823             QString result = QString(readProcess.readAllStandardOutput());
1824             kDebug() << "// / / / / / READING PACTL: ";
1825             kDebug() << result;
1826             if (!result.isEmpty()) {
1827                 driver = "pulse";
1828                 kDebug() << "// / / / / PULSEAUDIO DETECTED";
1829             }
1830         }
1831         //put others here
1832         KdenliveSettings::setAutoaudiodrivername(driver);
1833     }
1834 }
1835
1836 void MainWindow::slotEditProjectSettings()
1837 {
1838     QPoint p = m_activeDocument->getTracksCount();
1839     ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
1840
1841     if (w->exec() == QDialog::Accepted) {
1842         QString profile = w->selectedProfile();
1843         m_activeDocument->setProjectFolder(w->selectedFolder());
1844         if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path(KUrl::AddTrailingSlash));
1845         if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
1846         if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
1847         if (m_activeDocument->profilePath() != profile) {
1848             // Profile was changed
1849             double dar = m_activeDocument->dar();
1850
1851             // Deselect current effect / transition
1852             m_effectStack->slotClipItemSelected(NULL, 0);
1853             m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1854             m_clipMonitor->slotSetXml(NULL);
1855             bool updateFps = m_activeDocument->setProfilePath(profile);
1856             KdenliveSettings::setCurrent_profile(profile);
1857             KdenliveSettings::setProject_fps(m_activeDocument->fps());
1858             setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1859
1860             m_activeDocument->clipManager()->clearUnusedProducers();
1861             m_monitorManager->resetProfiles(m_activeDocument->timecode());
1862
1863             m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
1864             m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
1865             m_projectList->updateProjectFormat(m_activeDocument->timecode());
1866             if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1867             m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1868             //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1869             if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
1870             if (updateFps) m_activeTimeline->updateProjectFps();
1871             m_activeDocument->setModified(true);
1872             m_commandStack->activeStack()->clear();
1873             //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
1874             slotUpdateMousePosition(0);
1875             // We need to desactivate & reactivate monitors to get a refresh
1876             //m_monitorManager->switchMonitors();
1877         }
1878     }
1879     delete w;
1880 }
1881
1882
1883 void MainWindow::slotRenderProject()
1884 {
1885     if (!m_renderWidget) {
1886         QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
1887         m_renderWidget = new RenderWidget(projectfolder, this);
1888         connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
1889         connect(m_renderWidget, SIGNAL(selectedRenderProfile(const QString &, const QString &, const QString &, const QString&)), this, SLOT(slotSetDocumentRenderProfile(const QString &, const QString &, const QString &, const QString&)));
1890         connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
1891         connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1892         connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1893         if (m_activeDocument) {
1894             m_renderWidget->setProfile(m_activeDocument->mltProfile());
1895             m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1896             m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
1897             m_renderWidget->setRenderProfile(m_activeDocument->getDocumentProperty("renderdestination"), m_activeDocument->getDocumentProperty("rendercategory"), m_activeDocument->getDocumentProperty("renderprofile"), m_activeDocument->getDocumentProperty("renderurl"));
1898         }
1899     }
1900     slotCheckRenderStatus();
1901     /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1902     if (currentTab) m_renderWidget->setTimeline(currentTab);
1903     m_renderWidget->setDocument(m_activeDocument);*/
1904     m_renderWidget->show();
1905     m_renderWidget->showNormal();
1906 }
1907
1908 void MainWindow::slotCheckRenderStatus()
1909 {
1910     // Make sure there are no missing clips
1911     if (m_renderWidget) m_renderWidget->missingClips(m_projectList->hasMissingClips());
1912 }
1913
1914 void MainWindow::setRenderingProgress(const QString &url, int progress)
1915 {
1916     if (m_renderWidget) m_renderWidget->setRenderJob(url, progress);
1917 }
1918
1919 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
1920 {
1921     if (m_renderWidget) m_renderWidget->setRenderStatus(url, status, error);
1922 }
1923
1924 void MainWindow::slotCleanProject()
1925 {
1926     if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
1927     m_projectList->cleanup();
1928 }
1929
1930 void MainWindow::slotUpdateMousePosition(int pos)
1931 {
1932     if (m_activeDocument)
1933         switch (m_timecodeFormat->currentIndex()) {
1934         case 0:
1935             statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1936             break;
1937         default:
1938             statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1939         }
1940 }
1941
1942 void MainWindow::slotUpdateDocumentState(bool modified)
1943 {
1944     if (!m_activeDocument) return;
1945     setCaption(m_activeDocument->description(), modified);
1946     m_saveAction->setEnabled(modified);
1947     if (modified) {
1948         m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1949         m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1950     } else {
1951         m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1952         m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1953     }
1954 }
1955
1956 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
1957 {
1958     if (m_activeDocument) {
1959         if (m_activeDocument == doc) return;
1960         disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1961     }
1962     connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1963 }
1964
1965 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //changed
1966 {
1967     //m_projectMonitor->stop();
1968     m_closeAction->setEnabled(m_timelineArea->count() > 1);
1969     kDebug() << "///////////////////   CONNECTING DOC TO PROJECT VIEW ////////////////";
1970     if (m_activeDocument) {
1971         if (m_activeDocument == doc) return;
1972         if (m_activeTimeline) {
1973             disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1974             disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1975             disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1976             disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1977             disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
1978
1979             disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1980             disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1981             disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1982             disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1983             disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1984             disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1985             disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1986             disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1987             disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1988             disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
1989             disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1990             disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
1991             disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1992             disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1993             disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
1994             disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1995             disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1996             disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1997             disconnect(m_activeTimeline, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1998             disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1999             disconnect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
2000             disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
2001             disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
2002             disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
2003             disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2004             disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2005             disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2006             disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2007             disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2008             disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2009             disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2010             disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2011             disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2012             disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2013             m_effectStack->clear();
2014         }
2015         //m_activeDocument->setRenderer(NULL);
2016         disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
2017         disconnect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2018         m_clipMonitor->stop();
2019     }
2020     KdenliveSettings::setCurrent_profile(doc->profilePath());
2021     KdenliveSettings::setProject_fps(doc->fps());
2022     m_monitorManager->resetProfiles(doc->timecode());
2023     m_projectList->setDocument(doc);
2024     m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2025     m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2026     connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint)));
2027     connect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2028     connect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), trackView->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2029
2030     connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2031     connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2032
2033
2034     connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2035     connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2036     connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2037     connect(trackView, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
2038     connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2039     connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2040     connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2041     connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2042     connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
2043     connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2044     connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
2045
2046     connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2047     connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2048     connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
2049     connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2050     connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2051
2052     connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
2053     connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2054     connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2055
2056
2057     connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2058     connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2059
2060     connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2061     connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2062     connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2063     m_zoomSlider->setValue(doc->zoom().x());
2064     connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
2065     connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2066     connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2067     connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2068     connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2069
2070     connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2071     connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2072
2073
2074     connect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
2075     connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
2076     connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
2077     connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
2078     connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2079     connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2080     connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2081     connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2082     connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2083
2084     connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2085     connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2086     connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2087     connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2088     connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2089
2090
2091     trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2092     m_activeTimeline = trackView;
2093     if (m_renderWidget) {
2094         slotCheckRenderStatus();
2095         m_renderWidget->setProfile(doc->mltProfile());
2096         m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2097         m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2098         m_renderWidget->setRenderProfile(doc->getDocumentProperty("renderdestination"), doc->getDocumentProperty("rendercategory"), doc->getDocumentProperty("renderprofile"), doc->getDocumentProperty("renderurl"));
2099     }
2100     //doc->setRenderer(m_projectMonitor->render);
2101     m_commandStack->setActiveStack(doc->commandStack());
2102     KdenliveSettings::setProject_display_ratio(doc->dar());
2103     //doc->clipManager()->checkAudioThumbs();
2104
2105     //m_overView->setScene(trackView->projectScene());
2106     //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2107     //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2108
2109     setCaption(doc->description(), doc->isModified());
2110     m_saveAction->setEnabled(doc->isModified());
2111     m_normalEditTool->setChecked(true);
2112     m_activeDocument = doc;
2113     m_activeTimeline->updateProjectFps();
2114     m_activeDocument->checkProjectClips();
2115     if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
2116     //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2117     slotUpdateMousePosition(0);
2118     // set tool to select tool
2119     m_buttonSelectTool->setChecked(true);
2120 }
2121
2122 void MainWindow::slotZoneMoved(int start, int end)
2123 {
2124     m_activeDocument->setZone(start, end);
2125     m_projectMonitor->slotZoneMoved(start, end);
2126 }
2127
2128 void MainWindow::slotGuidesUpdated()
2129 {
2130     if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2131 }
2132
2133 void MainWindow::slotPreferences(int page, int option)
2134 {
2135     //An instance of your dialog could be already created and could be
2136     // cached, in which case you want to display the cached dialog
2137     // instead of creating another one
2138     if (KConfigDialog::showDialog("settings")) {
2139         KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2140         if (page != -1) d->showPage(page, option);
2141         return;
2142     }
2143
2144     // KConfigDialog didn't find an instance of this dialog, so lets
2145     // create it :
2146     KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
2147     connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2148     //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
2149     connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2150     connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2151 #ifndef Q_WS_MAC
2152     connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
2153 #endif
2154     //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2155     dialog->show();
2156     if (page != -1) dialog->showPage(page, option);
2157 }
2158
2159 void MainWindow::slotUpdatePreviewSettings()
2160 {
2161     if (m_activeDocument) {
2162         m_clipMonitor->slotSetXml(NULL);
2163         m_activeDocument->updatePreviewSettings();
2164     }
2165 }
2166
2167 void MainWindow::updateConfiguration()
2168 {
2169     //TODO: we should apply settings to all projects, not only the current one
2170     if (m_activeTimeline) {
2171         m_activeTimeline->refresh();
2172         m_activeTimeline->projectView()->checkAutoScroll();
2173         m_activeTimeline->projectView()->checkTrackHeight();
2174         if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
2175     }
2176     m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2177     m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2178
2179     // Update list of transcoding profiles
2180     loadTranscoders();
2181 #ifndef NO_JOGSHUTTLE
2182     activateShuttleDevice();
2183 #endif /* NO_JOGSHUTTLE */
2184
2185 }
2186
2187
2188 void MainWindow::slotSwitchVideoThumbs()
2189 {
2190     KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2191     if (m_activeTimeline) {
2192         m_activeTimeline->projectView()->slotUpdateAllThumbs();
2193     }
2194     m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2195 }
2196
2197 void MainWindow::slotSwitchAudioThumbs()
2198 {
2199     KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2200     if (m_activeTimeline) {
2201         m_activeTimeline->refresh();
2202         m_activeTimeline->projectView()->checkAutoScroll();
2203         if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
2204     }
2205     m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2206 }
2207
2208 void MainWindow::slotSwitchMarkersComments()
2209 {
2210     KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2211     if (m_activeTimeline) {
2212         m_activeTimeline->refresh();
2213     }
2214     m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2215 }
2216
2217 void MainWindow::slotSwitchSnap()
2218 {
2219     KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2220     m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2221 }
2222
2223
2224 void MainWindow::slotDeleteTimelineClip()
2225 {
2226     if (QApplication::focusWidget() && QApplication::focusWidget()->parentWidget() && QApplication::focusWidget()->parentWidget()->parentWidget() && QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) m_projectList->slotRemoveClip();
2227     else if (m_activeTimeline) {
2228         m_activeTimeline->projectView()->deleteSelectedClips();
2229     }
2230 }
2231
2232 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2233 {
2234     if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2235     m_clipMonitor->updateMarkers(clip);
2236 }
2237
2238 void MainWindow::slotAddClipMarker()
2239 {
2240     DocClipBase *clip = NULL;
2241     GenTime pos;
2242     if (m_projectMonitor->isActive()) {
2243         if (m_activeTimeline) {
2244             ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2245             if (item) {
2246                 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2247                 clip = item->baseClip();
2248             }
2249         }
2250     } else {
2251         clip = m_clipMonitor->activeClip();
2252         pos = m_clipMonitor->position();
2253     }
2254     if (!clip) {
2255         m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2256         return;
2257     }
2258     QString id = clip->getId();
2259     CommentedTime marker(pos, i18n("Marker"));
2260     MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2261     if (d.exec() == QDialog::Accepted) {
2262         m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2263     }
2264 }
2265
2266 void MainWindow::slotDeleteClipMarker()
2267 {
2268     DocClipBase *clip = NULL;
2269     GenTime pos;
2270     if (m_projectMonitor->isActive()) {
2271         if (m_activeTimeline) {
2272             ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2273             if (item) {
2274                 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2275                 clip = item->baseClip();
2276             }
2277         }
2278     } else {
2279         clip = m_clipMonitor->activeClip();
2280         pos = m_clipMonitor->position();
2281     }
2282     if (!clip) {
2283         m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2284         return;
2285     }
2286
2287     QString id = clip->getId();
2288     QString comment = clip->markerComment(pos);
2289     if (comment.isEmpty()) {
2290         m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2291         return;
2292     }
2293     m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2294 }
2295
2296 void MainWindow::slotDeleteAllClipMarkers()
2297 {
2298     DocClipBase *clip = NULL;
2299     if (m_projectMonitor->isActive()) {
2300         if (m_activeTimeline) {
2301             ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2302             if (item) {
2303                 clip = item->baseClip();
2304             }
2305         }
2306     } else {
2307         clip = m_clipMonitor->activeClip();
2308     }
2309     if (!clip) {
2310         m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2311         return;
2312     }
2313     m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2314 }
2315
2316 void MainWindow::slotEditClipMarker()
2317 {
2318     DocClipBase *clip = NULL;
2319     GenTime pos;
2320     if (m_projectMonitor->isActive()) {
2321         if (m_activeTimeline) {
2322             ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2323             if (item) {
2324                 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2325                 clip = item->baseClip();
2326             }
2327         }
2328     } else {
2329         clip = m_clipMonitor->activeClip();
2330         pos = m_clipMonitor->position();
2331     }
2332     if (!clip) {
2333         m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2334         return;
2335     }
2336
2337     QString id = clip->getId();
2338     QString oldcomment = clip->markerComment(pos);
2339     if (oldcomment.isEmpty()) {
2340         m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2341         return;
2342     }
2343
2344     CommentedTime marker(pos, oldcomment);
2345     MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2346     if (d.exec() == QDialog::Accepted) {
2347         m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2348         if (d.newMarker().time() != pos) {
2349             // remove old marker
2350             m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2351         }
2352     }
2353 }
2354
2355 void MainWindow::slotAddGuide()
2356 {
2357     if (m_activeTimeline)
2358         m_activeTimeline->projectView()->slotAddGuide();
2359 }
2360
2361 void MainWindow::slotInsertSpace()
2362 {
2363     if (m_activeTimeline)
2364         m_activeTimeline->projectView()->slotInsertSpace();
2365 }
2366
2367 void MainWindow::slotRemoveSpace()
2368 {
2369     if (m_activeTimeline)
2370         m_activeTimeline->projectView()->slotRemoveSpace();
2371 }
2372
2373 void MainWindow::slotInsertTrack(int ix)
2374 {
2375     m_projectMonitor->activateMonitor();
2376     if (m_activeTimeline)
2377         m_activeTimeline->projectView()->slotInsertTrack(ix);
2378 }
2379
2380 void MainWindow::slotDeleteTrack(int ix)
2381 {
2382     m_projectMonitor->activateMonitor();
2383     if (m_activeTimeline)
2384         m_activeTimeline->projectView()->slotDeleteTrack(ix);
2385 }
2386
2387 void MainWindow::slotChangeTrack(int ix)
2388 {
2389     m_projectMonitor->activateMonitor();
2390     if (m_activeTimeline)
2391         m_activeTimeline->projectView()->slotChangeTrack(ix);
2392 }
2393
2394 void MainWindow::slotEditGuide()
2395 {
2396     if (m_activeTimeline)
2397         m_activeTimeline->projectView()->slotEditGuide();
2398 }
2399
2400 void MainWindow::slotDeleteGuide()
2401 {
2402     if (m_activeTimeline)
2403         m_activeTimeline->projectView()->slotDeleteGuide();
2404 }
2405
2406 void MainWindow::slotDeleteAllGuides()
2407 {
2408     if (m_activeTimeline)
2409         m_activeTimeline->projectView()->slotDeleteAllGuides();
2410 }
2411
2412 void MainWindow::slotCutTimelineClip()
2413 {
2414     if (m_activeTimeline) {
2415         m_activeTimeline->projectView()->cutSelectedClips();
2416     }
2417 }
2418
2419 void MainWindow::slotInsertClipOverwrite()
2420 {
2421     if (m_activeTimeline) {
2422         QStringList data = m_clipMonitor->getZoneInfo();
2423         m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2424     }
2425 }
2426
2427 void MainWindow::slotSelectTimelineClip()
2428 {
2429     if (m_activeTimeline) {
2430         m_activeTimeline->projectView()->selectClip(true);
2431     }
2432 }
2433
2434 void MainWindow::slotSelectTimelineTransition()
2435 {
2436     if (m_activeTimeline) {
2437         m_activeTimeline->projectView()->selectTransition(true);
2438     }
2439 }
2440
2441 void MainWindow::slotDeselectTimelineClip()
2442 {
2443     if (m_activeTimeline) {
2444         m_activeTimeline->projectView()->selectClip(false, true);
2445     }
2446 }
2447
2448 void MainWindow::slotDeselectTimelineTransition()
2449 {
2450     if (m_activeTimeline) {
2451         m_activeTimeline->projectView()->selectTransition(false, true);
2452     }
2453 }
2454
2455 void MainWindow::slotSelectAddTimelineClip()
2456 {
2457     if (m_activeTimeline) {
2458         m_activeTimeline->projectView()->selectClip(true, true);
2459     }
2460 }
2461
2462 void MainWindow::slotSelectAddTimelineTransition()
2463 {
2464     if (m_activeTimeline) {
2465         m_activeTimeline->projectView()->selectTransition(true, true);
2466     }
2467 }
2468
2469 void MainWindow::slotGroupClips()
2470 {
2471     if (m_activeTimeline) {
2472         m_activeTimeline->projectView()->groupClips();
2473     }
2474 }
2475
2476 void MainWindow::slotUnGroupClips()
2477 {
2478     if (m_activeTimeline) {
2479         m_activeTimeline->projectView()->groupClips(false);
2480     }
2481 }
2482
2483 void MainWindow::slotEditItemDuration()
2484 {
2485     if (m_activeTimeline) {
2486         m_activeTimeline->projectView()->editItemDuration();
2487     }
2488 }
2489
2490 void MainWindow::slotAddProjectClip(KUrl url)
2491 {
2492     if (m_activeDocument)
2493         m_activeDocument->slotAddClipFile(url, QString());
2494 }
2495
2496 void MainWindow::slotAddTransition(QAction *result)
2497 {
2498     if (!result) return;
2499     QStringList info = result->data().toStringList();
2500     if (info.isEmpty()) return;
2501     QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2502     if (m_activeTimeline && !transition.isNull()) {
2503         m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2504     }
2505 }
2506
2507 void MainWindow::slotAddVideoEffect(QAction *result)
2508 {
2509     if (!result) return;
2510     QStringList info = result->data().toStringList();
2511     if (info.isEmpty()) return;
2512     QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2513     slotAddEffect(effect);
2514 }
2515
2516 void MainWindow::slotAddAudioEffect(QAction *result)
2517 {
2518     if (!result) return;
2519     QStringList info = result->data().toStringList();
2520     if (info.isEmpty()) return;
2521     QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2522     slotAddEffect(effect);
2523 }
2524
2525 void MainWindow::slotAddCustomEffect(QAction *result)
2526 {
2527     if (!result) return;
2528     QStringList info = result->data().toStringList();
2529     if (info.isEmpty()) return;
2530     QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2531     slotAddEffect(effect);
2532 }
2533
2534 void MainWindow::slotZoomIn()
2535 {
2536     m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2537 }
2538
2539 void MainWindow::slotZoomOut()
2540 {
2541     m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2542 }
2543
2544 void MainWindow::slotFitZoom()
2545 {
2546     if (m_activeTimeline) {
2547         m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2548     }
2549 }
2550
2551 void MainWindow::slotSetZoom(int value)
2552 {
2553     m_zoomSlider->setValue(value);
2554 }
2555
2556 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2557 {
2558     m_statusProgressBar->setValue(progress);
2559     if (progress >= 0) {
2560         if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2561         m_statusProgressBar->setVisible(true);
2562     } else if (progress == -2) {
2563         if (!message.isEmpty()) m_messageLabel->setMessage(message, ErrorMessage);
2564         m_statusProgressBar->setVisible(false);
2565     } else {
2566         m_messageLabel->setMessage(QString(), DefaultMessage);
2567         m_statusProgressBar->setVisible(false);
2568     }
2569 }
2570
2571 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2572 {
2573     if (clip->clipType() == TEXT) {
2574         QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
2575         if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
2576             // template text clip
2577
2578             // Get the list of existing templates
2579             QStringList filter;
2580             filter << "*.kdenlivetitle";
2581             QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
2582
2583             QDialog *dia = new QDialog(this);
2584             Ui::TemplateClip_UI dia_ui;
2585             dia_ui.setupUi(dia);
2586             int ix = -1;
2587             const QString templatePath = clip->getProperty("resource");
2588             for (int i = 0; i < templateFiles.size(); ++i) {
2589                 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
2590                 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
2591             }
2592             if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
2593             else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
2594             dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
2595             //warning: setting base directory doesn't work??
2596             KUrl startDir(titlepath);
2597             dia_ui.template_list->fileDialog()->setUrl(startDir);
2598             dia_ui.description->setText(clip->getProperty("description"));
2599             if (dia->exec() == QDialog::Accepted) {
2600                 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
2601                 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
2602
2603                 QMap <QString, QString> newprops;
2604
2605                 if (KUrl(textTemplate).path() != templatePath) {
2606                     // The template was changed
2607                     newprops.insert("resource", textTemplate);
2608                 }
2609
2610                 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
2611                     newprops.insert("description", dia_ui.description->toPlainText());
2612                 }
2613
2614                 QString newtemplate = newprops.value("xmltemplate");
2615                 if (newtemplate.isEmpty()) newtemplate = templatePath;
2616
2617                 // template modified we need to update xmldata
2618                 QString description = newprops.value("description");
2619                 if (description.isEmpty()) description = clip->getProperty("description");
2620                 else newprops.insert("templatetext", description);
2621                 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
2622                 if (!newprops.isEmpty()) {
2623                     EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2624                     m_activeDocument->commandStack()->push(command);
2625                 }
2626             }
2627             delete dia;
2628             return;
2629         }
2630         QString path = clip->getProperty("resource");
2631         TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
2632         QDomDocument doc;
2633         doc.setContent(clip->getProperty("xmldata"));
2634         dia_ui->setXml(doc);
2635         if (dia_ui->exec() == QDialog::Accepted) {
2636             QMap <QString, QString> newprops;
2637             newprops.insert("xmldata", dia_ui->xml().toString());
2638             if (dia_ui->duration() != clip->duration().frames(m_activeDocument->fps()) - 1) {
2639                 // duration changed, we need to update duration
2640                 newprops.insert("out", QString::number(dia_ui->duration()));
2641             }
2642             EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2643             m_activeDocument->commandStack()->push(command);
2644             //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
2645             m_activeDocument->setModified(true);
2646         }
2647         delete dia_ui;
2648
2649         //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2650         return;
2651     }
2652     ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2653     connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2654     if (dia.exec() == QDialog::Accepted) {
2655         QMap <QString, QString> newprops = dia.properties();
2656         if (newprops.isEmpty()) return;
2657         EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2658         m_activeDocument->commandStack()->push(command);
2659
2660         if (dia.needsTimelineRefresh()) {
2661             // update clip occurences in timeline
2662             m_activeTimeline->projectView()->slotUpdateClip(clip->getId(), dia.needsTimelineReload());
2663         }
2664     }
2665 }
2666
2667
2668 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
2669 {
2670     ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
2671     if (dia.exec() == QDialog::Accepted) {
2672         QUndoCommand *command = new QUndoCommand();
2673         command->setText(i18n("Edit clips"));
2674         for (int i = 0; i < cliplist.count(); i++) {
2675             DocClipBase *clip = cliplist.at(i);
2676             new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true, command);
2677         }
2678         m_activeDocument->commandStack()->push(command);
2679         for (int i = 0; i < cliplist.count(); i++) {
2680             m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
2681         }
2682     }
2683 }
2684
2685 void MainWindow::customEvent(QEvent* e)
2686 {
2687     if (e->type() == QEvent::User) {
2688         m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
2689     }
2690 }
2691 void MainWindow::slotActivateEffectStackView()
2692 {
2693     m_effectStack->raiseWindow(m_effectStackDock);
2694 }
2695
2696 void MainWindow::slotActivateTransitionView(Transition *t)
2697 {
2698     if (t) m_transitionConfig->raiseWindow(m_transitionConfigDock);
2699 }
2700
2701 void MainWindow::slotSnapRewind()
2702 {
2703     if (m_projectMonitor->isActive()) {
2704         if (m_activeTimeline)
2705             m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2706     } else m_clipMonitor->slotSeekToPreviousSnap();
2707 }
2708
2709 void MainWindow::slotSnapForward()
2710 {
2711     if (m_projectMonitor->isActive()) {
2712         if (m_activeTimeline)
2713             m_activeTimeline->projectView()->slotSeekToNextSnap();
2714     } else m_clipMonitor->slotSeekToNextSnap();
2715 }
2716
2717 void MainWindow::slotClipStart()
2718 {
2719     if (m_projectMonitor->isActive()) {
2720         if (m_activeTimeline)
2721             m_activeTimeline->projectView()->clipStart();
2722     }
2723 }
2724
2725 void MainWindow::slotClipEnd()
2726 {
2727     if (m_projectMonitor->isActive()) {
2728         if (m_activeTimeline)
2729             m_activeTimeline->projectView()->clipEnd();
2730     }
2731 }
2732
2733 void MainWindow::slotZoneStart()
2734 {
2735     if (m_projectMonitor->isActive()) m_projectMonitor->slotZoneStart();
2736     else m_clipMonitor->slotZoneStart();
2737 }
2738
2739 void MainWindow::slotZoneEnd()
2740 {
2741     if (m_projectMonitor->isActive()) m_projectMonitor->slotZoneEnd();
2742     else m_clipMonitor->slotZoneEnd();
2743 }
2744
2745 void MainWindow::slotChangeTool(QAction * action)
2746 {
2747     if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
2748     else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
2749     else if (action == m_buttonSpacerTool) slotSetTool(SPACERTOOL);
2750 }
2751
2752 void MainWindow::slotChangeEdit(QAction * action)
2753 {
2754     if (!m_activeTimeline) return;
2755     if (action == m_overwriteEditTool) m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
2756     else if (action == m_insertEditTool) m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
2757     else m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
2758 }
2759
2760 void MainWindow::slotSetTool(PROJECTTOOL tool)
2761 {
2762     if (m_activeDocument && m_activeTimeline) {
2763         //m_activeDocument->setTool(tool);
2764         QString message;
2765         switch (tool)  {
2766         case SPACERTOOL:
2767             message = i18n("Ctrl + click to use spacer on current track only");
2768             break;
2769         case RAZORTOOL:
2770             message = i18n("Click on a clip to cut it");
2771             break;
2772         default:
2773             message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
2774             break;
2775         }
2776         m_messageLabel->setMessage(message, InformationMessage);
2777         m_activeTimeline->projectView()->setTool(tool);
2778     }
2779 }
2780
2781 void MainWindow::slotCopy()
2782 {
2783     if (!m_activeDocument || !m_activeTimeline) return;
2784     m_activeTimeline->projectView()->copyClip();
2785 }
2786
2787 void MainWindow::slotPaste()
2788 {
2789     if (!m_activeDocument || !m_activeTimeline) return;
2790     m_activeTimeline->projectView()->pasteClip();
2791 }
2792
2793 void MainWindow::slotPasteEffects()
2794 {
2795     if (!m_activeDocument || !m_activeTimeline) return;
2796     m_activeTimeline->projectView()->pasteClipEffects();
2797 }
2798
2799 void MainWindow::slotFind()
2800 {
2801     if (!m_activeDocument || !m_activeTimeline) return;
2802     m_projectSearch->setEnabled(false);
2803     m_findActivated = true;
2804     m_findString.clear();
2805     m_activeTimeline->projectView()->initSearchStrings();
2806     statusBar()->showMessage(i18n("Starting -- find text as you type"));
2807     m_findTimer.start(5000);
2808     qApp->installEventFilter(this);
2809 }
2810
2811 void MainWindow::slotFindNext()
2812 {
2813     if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
2814         statusBar()->showMessage(i18n("Found: %1", m_findString));
2815     } else {
2816         statusBar()->showMessage(i18n("Reached end of project"));
2817     }
2818     m_findTimer.start(4000);
2819 }
2820
2821 void MainWindow::findAhead()
2822 {
2823     if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
2824         m_projectSearchNext->setEnabled(true);
2825         statusBar()->showMessage(i18n("Found: %1", m_findString));
2826     } else {
2827         m_projectSearchNext->setEnabled(false);
2828         statusBar()->showMessage(i18n("Not found: %1", m_findString));
2829     }
2830 }
2831
2832 void MainWindow::findTimeout()
2833 {
2834     m_projectSearchNext->setEnabled(false);
2835     m_findActivated = false;
2836     m_findString.clear();
2837     statusBar()->showMessage(i18n("Find stopped"), 3000);
2838     if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
2839     m_projectSearch->setEnabled(true);
2840     removeEventFilter(this);
2841 }
2842
2843 void MainWindow::keyPressEvent(QKeyEvent *ke)
2844 {
2845     if (m_findActivated) {
2846         if (ke->key() == Qt::Key_Backspace) {
2847             m_findString = m_findString.left(m_findString.length() - 1);
2848
2849             if (!m_findString.isEmpty()) {
2850                 findAhead();
2851             } else {
2852                 findTimeout();
2853             }
2854
2855             m_findTimer.start(4000);
2856             ke->accept();
2857             return;
2858         } else if (ke->key() == Qt::Key_Escape) {
2859             findTimeout();
2860             ke->accept();
2861             return;
2862         } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
2863             m_findString += ke->text();
2864
2865             findAhead();
2866
2867             m_findTimer.start(4000);
2868             ke->accept();
2869             return;
2870         }
2871     } else KXmlGuiWindow::keyPressEvent(ke);
2872 }
2873
2874
2875 /** Gets called when the window gets hidden */
2876 void MainWindow::hideEvent(QHideEvent */*event*/)
2877 {
2878     // kDebug() << "I was hidden";
2879     // issue http://www.kdenlive.org/mantis/view.php?id=231
2880     if (isMinimized()) {
2881         // kDebug() << "I am minimized";
2882         if (m_monitorManager) m_monitorManager->stopActiveMonitor();
2883     }
2884 }
2885
2886 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
2887 {
2888     if (m_findActivated) {
2889         if (event->type() == QEvent::ShortcutOverride) {
2890             QKeyEvent* ke = (QKeyEvent*) event;
2891             if (ke->text().trimmed().isEmpty()) return false;
2892             ke->accept();
2893             return true;
2894         } else return false;
2895     } else {
2896         // pass the event on to the parent class
2897         return QMainWindow::eventFilter(obj, event);
2898     }
2899 }
2900
2901
2902 void MainWindow::slotSaveZone(Render *render, QPoint zone)
2903 {
2904     KDialog *dialog = new KDialog(this);
2905     dialog->setCaption("Save clip zone");
2906     dialog->setButtons(KDialog::Ok | KDialog::Cancel);
2907
2908     QWidget *widget = new QWidget(dialog);
2909     dialog->setMainWidget(widget);
2910
2911     QVBoxLayout *vbox = new QVBoxLayout(widget);
2912     QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
2913     QString path = m_activeDocument->projectFolder().path();
2914     path.append("/");
2915     path.append("untitled.mlt");
2916     KUrlRequester *url = new KUrlRequester(KUrl(path), this);
2917     url->setFilter("video/mlt-playlist");
2918     QLabel *label2 = new QLabel(i18n("Description:"), this);
2919     KLineEdit *edit = new KLineEdit(this);
2920     vbox->addWidget(label1);
2921     vbox->addWidget(url);
2922     vbox->addWidget(label2);
2923     vbox->addWidget(edit);
2924     if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
2925
2926 }
2927
2928 void MainWindow::slotSetInPoint()
2929 {
2930     if (m_clipMonitor->isActive()) {
2931         m_clipMonitor->slotSetZoneStart();
2932     } else m_projectMonitor->slotSetZoneStart();
2933     //else m_activeTimeline->projectView()->setInPoint();
2934 }
2935
2936 void MainWindow::slotSetOutPoint()
2937 {
2938     if (m_clipMonitor->isActive()) {
2939         m_clipMonitor->slotSetZoneEnd();
2940     } else m_projectMonitor->slotSetZoneEnd();
2941     // else m_activeTimeline->projectView()->setOutPoint();
2942 }
2943
2944 void MainWindow::slotResizeItemStart()
2945 {
2946     if (m_activeTimeline) m_activeTimeline->projectView()->setInPoint();
2947 }
2948
2949 void MainWindow::slotResizeItemEnd()
2950 {
2951     if (m_activeTimeline) m_activeTimeline->projectView()->setOutPoint();
2952 }
2953
2954 int MainWindow::getNewStuff(const QString &configFile)
2955 {
2956     KNS3::Entry::List entries;
2957 #if KDE_IS_VERSION(4,3,80)
2958     KNS3::DownloadDialog dialog(configFile);
2959     dialog.exec();
2960     entries = dialog.changedEntries();
2961     foreach(const KNS3::Entry &entry, entries) {
2962         if (entry.status() == KNS3::Entry::Installed)
2963             kDebug() << "// Installed files: " << entry.installedFiles();
2964     }
2965 #else
2966     KNS::Engine engine(0);
2967     if (engine.init(configFile))
2968         entries = engine.downloadDialogModal(this);
2969     foreach(KNS::Entry *entry, entries) {
2970         if (entry->status() == KNS::Entry::Installed)
2971             kDebug() << "// Installed files: " << entry->installedFiles();
2972     }
2973 #endif /* KDE_IS_VERSION(4,3,80) */
2974     return entries.size();
2975 }
2976
2977 void MainWindow::slotGetNewTitleStuff()
2978 {
2979     if (getNewStuff("kdenlive_titles.knsrc") > 0) {
2980         TitleWidget::refreshTitleTemplates();
2981     }
2982 }
2983
2984 void MainWindow::slotGetNewLumaStuff()
2985 {
2986     if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
2987         initEffects::refreshLumas();
2988         m_activeTimeline->projectView()->reloadTransitionLumas();
2989     }
2990 }
2991
2992 void MainWindow::slotGetNewRenderStuff()
2993 {
2994     if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0) {
2995         if (m_renderWidget)
2996             m_renderWidget->reloadProfiles();
2997     }
2998 }
2999
3000 void MainWindow::slotGetNewMltProfileStuff()
3001 {
3002     if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3003         // update the list of profiles in settings dialog
3004         KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3005         if (d)
3006             d->checkProfile();
3007     }
3008 }
3009
3010 void MainWindow::slotAutoTransition()
3011 {
3012     if (m_activeTimeline) m_activeTimeline->projectView()->autoTransition();
3013 }
3014
3015 void MainWindow::slotSplitAudio()
3016 {
3017     if (m_activeTimeline) m_activeTimeline->projectView()->splitAudio();
3018 }
3019
3020 void MainWindow::slotUpdateClipType(QAction *action)
3021 {
3022     if (m_activeTimeline) {
3023         if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3024         else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3025         else m_activeTimeline->projectView()->setAudioAndVideo();
3026     }
3027 }
3028
3029 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3030 {
3031     // We must stop the monitors since we create a new on in the dvd wizard
3032     m_clipMonitor->stop();
3033     m_projectMonitor->stop();
3034     DvdWizard w(url, profile, this);
3035     w.exec();
3036     m_projectMonitor->start();
3037 }
3038
3039 void MainWindow::slotShowTimeline(bool show)
3040 {
3041     if (show == false) {
3042         m_timelineState = saveState();
3043         centralWidget()->setHidden(true);
3044     } else {
3045         centralWidget()->setHidden(false);
3046         restoreState(m_timelineState);
3047     }
3048 }
3049
3050 void MainWindow::slotMaximizeCurrent(bool /*show*/)
3051 {
3052     //TODO: is there a way to maximize current widget?
3053     //if (show == true)
3054     {
3055         m_timelineState = saveState();
3056         QWidget *par = focusWidget()->parentWidget();
3057         while (par->parentWidget() && par->parentWidget() != this) {
3058             par = par->parentWidget();
3059         }
3060         kDebug() << "CURRENT WIDGET: " << par->objectName();
3061     }
3062     /*else {
3063     //centralWidget()->setHidden(false);
3064     //restoreState(m_timelineState);
3065     }*/
3066 }
3067
3068 void MainWindow::loadTranscoders()
3069 {
3070     QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3071     transMenu->clear();
3072
3073     KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3074     KConfigGroup transConfig(config, "Transcoding");
3075     // read the entries
3076     QMap< QString, QString > profiles = transConfig.entryMap();
3077     QMapIterator<QString, QString> i(profiles);
3078     while (i.hasNext()) {
3079         i.next();
3080         QStringList data = i.value().split(";", QString::SkipEmptyParts);
3081         QAction *a = transMenu->addAction(i.key());
3082         a->setData(data);
3083         if (data.count() > 1) {
3084             a->setToolTip(data.at(1));
3085         }
3086         connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3087     }
3088 }
3089
3090 void MainWindow::slotTranscode(KUrl::List urls)
3091 {
3092     QString params;
3093     QString desc;
3094     QString condition;
3095     if (urls.isEmpty()) {
3096         QAction *action = qobject_cast<QAction *>(sender());
3097         QStringList data = action->data().toStringList();
3098         params = data.at(0);
3099         if (data.count() > 1) desc = data.at(1);
3100         if (data.count() > 2) condition = data.at(2);
3101         urls << m_projectList->getConditionalUrls(condition);
3102         urls.removeAll(KUrl());
3103     }
3104     if (urls.isEmpty()) {
3105         m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3106         return;
3107     }
3108     ClipTranscode *d = new ClipTranscode(urls, params, desc);
3109     connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3110     d->show();
3111     //QProcess::startDetached("ffmpeg", parameters);
3112 }
3113
3114 void MainWindow::slotTranscodeClip()
3115 {
3116     KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3117     if (urls.isEmpty()) return;
3118     slotTranscode(urls);
3119 }
3120
3121 void MainWindow::slotSetDocumentRenderProfile(const QString &dest, const QString &group, const QString &name, const QString &file)
3122 {
3123     if (m_activeDocument == NULL) return;
3124     m_activeDocument->setDocumentProperty("renderdestination", dest);
3125     m_activeDocument->setDocumentProperty("rendercategory", group);
3126     m_activeDocument->setDocumentProperty("renderprofile", name);
3127     m_activeDocument->setDocumentProperty("renderurl", file);
3128     m_activeDocument->setModified(true);
3129 }
3130
3131
3132 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3133 {
3134     if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3135     QString scriptPath;
3136     QString playlistPath;
3137     if (scriptExport) {
3138         bool ok;
3139         QString scriptsFolder = m_activeDocument->projectFolder().path() + "/scripts/";
3140         QString path = m_renderWidget->getFreeScriptName();
3141         scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3142         if (!ok || scriptPath.isEmpty()) return;
3143         scriptPath.prepend(scriptsFolder);
3144         QFile f(scriptPath);
3145         if (f.exists()) {
3146             if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3147                 return;
3148         }
3149         playlistPath = scriptPath + ".mlt";
3150         m_projectMonitor->saveSceneList(playlistPath);
3151     } else {
3152         KTemporaryFile temp;
3153         temp.setAutoRemove(false);
3154         temp.setSuffix(".mlt");
3155         temp.open();
3156         playlistPath = temp.fileName();
3157         m_projectMonitor->saveSceneList(playlistPath);
3158     }
3159
3160     if (!chapterFile.isEmpty()) {
3161         int in = 0;
3162         int out;
3163         if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3164         else {
3165             in = m_activeTimeline->inPoint();
3166             out = m_activeTimeline->outPoint();
3167         }
3168         QDomDocument doc;
3169         QDomElement chapters = doc.createElement("chapters");
3170         chapters.setAttribute("fps", m_activeDocument->fps());
3171         doc.appendChild(chapters);
3172
3173         QDomElement guidesxml = m_activeDocument->guidesXml();
3174         QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3175         for (int i = 0; i < nodes.count(); i++) {
3176             QDomElement e = nodes.item(i).toElement();
3177             if (!e.isNull()) {
3178                 QString comment = e.attribute("comment");
3179                 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3180                 if (time >= in && time < out) {
3181                     if (zoneOnly) time = time - in;
3182                     QDomElement chapter = doc.createElement("chapter");
3183                     chapters.appendChild(chapter);
3184                     chapter.setAttribute("title", comment);
3185                     chapter.setAttribute("time", time);
3186                 }
3187             }
3188         }
3189         if (chapters.childNodes().count() > 0) {
3190             if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3191                 // Always insert a guide in pos 0
3192                 QDomElement chapter = doc.createElement("chapter");
3193                 chapters.insertBefore(chapter, QDomNode());
3194                 chapter.setAttribute("title", i18n("Start"));
3195                 chapter.setAttribute("time", "0");
3196             }
3197             // save chapters file
3198             QFile file(chapterFile);
3199             if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3200                 kWarning() << "//////  ERROR writing DVD CHAPTER file: " << chapterFile;
3201             } else {
3202                 file.write(doc.toString().toUtf8());
3203                 if (file.error() != QFile::NoError) {
3204                     kWarning() << "//////  ERROR writing DVD CHAPTER file: " << chapterFile;
3205                 }
3206                 file.close();
3207             }
3208         }
3209     }
3210
3211     m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath);
3212 }
3213
3214 void MainWindow::slotUpdateTimecodeFormat(int ix)
3215 {
3216     KdenliveSettings::setFrametimecode(ix == 1);
3217     m_clipMonitor->updateTimecodeFormat();
3218     m_projectMonitor->updateTimecodeFormat();
3219     m_activeTimeline->projectView()->clearSelection();
3220 }
3221
3222 void MainWindow::slotRemoveFocus()
3223 {
3224     statusBar()->setFocus();
3225     statusBar()->clearFocus();
3226 }
3227
3228 void MainWindow::slotRevert()
3229 {
3230     if (KMessageBox::warningContinueCancel(this, i18n("This will delete all changes made since you last saved your project. Are you sure you want to continue?"), i18n("Revert to last saved version")) == KMessageBox::Cancel) return;
3231     KUrl url = m_activeDocument->url();
3232     closeCurrentDocument(false);
3233     doOpenFile(url, NULL);
3234 }
3235
3236
3237 void MainWindow::slotShutdown()
3238 {
3239     if (m_activeDocument) m_activeDocument->setModified(false);
3240     // Call shutdown
3241     QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
3242     if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
3243         QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
3244         smserver.call("logout", 1, 2, 2);
3245     } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
3246         QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
3247         smserver.call("Shutdown");
3248     }
3249 }
3250
3251 void MainWindow::slotUpdateTrackInfo()
3252 {
3253     if (m_activeDocument)
3254         m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
3255 }
3256
3257 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
3258 {
3259     // Load the theme file
3260     QString theme;
3261     if (action == NULL) theme = themename;
3262     else theme = action->data().toString();
3263     KdenliveSettings::setColortheme(theme);
3264     // Make palette for all widgets.
3265     QPalette plt;
3266     if (theme.isEmpty())
3267         plt = QApplication::desktop()->palette();
3268     else {
3269         KSharedConfigPtr config = KSharedConfig::openConfig(theme);
3270         plt = KGlobalSettings::createApplicationPalette(config);
3271     }
3272
3273     kapp->setPalette(plt);
3274     const QObjectList children = statusBar()->children();
3275
3276     foreach(QObject *child, children) {
3277         if (child->isWidgetType())
3278             ((QWidget*)child)->setPalette(plt);
3279         const QObjectList subchildren = child->children();
3280         foreach(QObject *subchild, subchildren) {
3281             if (subchild->isWidgetType())
3282                 ((QWidget*)subchild)->setPalette(plt);
3283         }
3284     }
3285 }
3286
3287
3288 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
3289 {
3290     // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
3291     const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
3292     const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
3293     const QSize bitsSize(24, 2);
3294     const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
3295     const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
3296
3297     QPixmap pixmap(23, 16);
3298     pixmap.fill(Qt::black); // ### use some color other than black for borders?
3299
3300     KConfigGroup group(config, "WM");
3301     QPainter p(&pixmap);
3302     KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
3303     p.fillRect(1,  1, 7, 7, windowScheme.background());
3304     p.fillRect(2,  2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
3305
3306     KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
3307     p.fillRect(8,  1, 7, 7, buttonScheme.background());
3308     p.fillRect(9,  2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
3309
3310     p.fillRect(15,  1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
3311     p.fillRect(16,  2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
3312
3313     KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
3314     p.fillRect(1,  8, 7, 7, viewScheme.background());
3315     p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
3316
3317     KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
3318     p.fillRect(8,  8, 7, 7, selectionScheme.background());
3319     p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
3320
3321     p.fillRect(15,  8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
3322     p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
3323
3324     p.end();
3325     return pixmap;
3326 }
3327
3328 void MainWindow::slotSwitchMonitors()
3329 {
3330     m_monitorManager->slotSwitchMonitors(m_clipMonitor->isActive());
3331     if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
3332     else m_projectList->focusTree();
3333 }
3334
3335 void MainWindow::slotInsertZoneToTree()
3336 {
3337     if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
3338     QStringList info = m_clipMonitor->getZoneInfo();
3339     m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
3340 }
3341
3342 void MainWindow::slotInsertZoneToTimeline()
3343 {
3344     if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
3345     QStringList info = m_clipMonitor->getZoneInfo();
3346     m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
3347 }
3348
3349
3350 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
3351 {
3352     for (int i = 0; i < ids.size(); ++i) {
3353         m_activeTimeline->slotDeleteClip(ids.at(i));
3354     }
3355     m_activeDocument->clipManager()->slotDeleteClips(ids);
3356     if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
3357
3358 }
3359
3360 void MainWindow::slotShowTitleBars(bool show)
3361 {
3362     if (show) {
3363         m_effectStackDock->setTitleBarWidget(0);
3364         m_clipMonitorDock->setTitleBarWidget(0);
3365         m_projectMonitorDock->setTitleBarWidget(0);
3366 #ifndef Q_WS_MAC
3367         m_recMonitorDock->setTitleBarWidget(0);
3368 #endif
3369         m_effectListDock->setTitleBarWidget(0);
3370         m_transitionConfigDock->setTitleBarWidget(0);
3371         m_projectListDock->setTitleBarWidget(0);
3372         m_undoViewDock->setTitleBarWidget(0);
3373     } else {
3374         if (!m_effectStackDock->isFloating()) m_effectStackDock->setTitleBarWidget(new QWidget(this));
3375         if (!m_clipMonitorDock->isFloating()) m_clipMonitorDock->setTitleBarWidget(new QWidget(this));
3376         if (!m_projectMonitorDock->isFloating()) m_projectMonitorDock->setTitleBarWidget(new QWidget(this));
3377 #ifndef Q_WS_MAC
3378         if (!m_recMonitorDock->isFloating()) m_recMonitorDock->setTitleBarWidget(new QWidget(this));
3379 #endif
3380         if (!m_effectListDock->isFloating()) m_effectListDock->setTitleBarWidget(new QWidget(this));
3381         if (!m_transitionConfigDock->isFloating()) m_transitionConfigDock->setTitleBarWidget(new QWidget(this));
3382         if (!m_projectListDock->isFloating()) m_projectListDock->setTitleBarWidget(new QWidget(this));
3383         if (!m_undoViewDock->isFloating()) m_undoViewDock->setTitleBarWidget(new QWidget(this));
3384     }
3385     KdenliveSettings::setShowtitlebars(show);
3386 }
3387
3388 void MainWindow::slotSwitchTitles()
3389 {
3390     slotShowTitleBars(!KdenliveSettings::showtitlebars());
3391 }
3392
3393 #include "mainwindow.moc"
3394