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