]> git.sesse.net Git - kdenlive/blob - src/mainwindow.cpp
c3494a6749adee8cfeb0afc2b76fe219234dc2a1
[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 #include "audiosignal.h"
43 #ifndef NO_JOGSHUTTLE
44 #include "jogshuttle.h"
45 #include "jogaction.h"
46 #include "jogshuttleconfig.h"
47 #endif /* NO_JOGSHUTTLE */
48 #include "clipproperties.h"
49 #include "wizard.h"
50 #include "editclipcommand.h"
51 #include "titlewidget.h"
52 #include "markerdialog.h"
53 #include "clipitem.h"
54 #include "interfaces.h"
55 #include "kdenlive-config.h"
56 #include "cliptranscode.h"
57 #include "ui_templateclip_ui.h"
58 #include "colorscopes/vectorscope.h"
59 #include "colorscopes/waveform.h"
60 #include "colorscopes/rgbparade.h"
61 #include "colorscopes/histogram.h"
62 #include "audiospectrum.h"
63 #include "spectrogram.h"
64
65 #include <KApplication>
66 #include <KAction>
67 #include <KLocale>
68 #include <KGlobal>
69 #include <KActionCollection>
70 #include <KActionCategory>
71 #include <KStandardAction>
72 #include <KShortcutsDialog>
73 #include <KFileDialog>
74 #include <KMessageBox>
75 #include <KDebug>
76 #include <KIO/NetAccess>
77 #include <KSaveFile>
78 #include <KRuler>
79 #include <KConfigDialog>
80 #include <KXMLGUIFactory>
81 #include <KStatusBar>
82 #include <kstandarddirs.h>
83 #include <KUrlRequesterDialog>
84 #include <KTemporaryFile>
85 #include <KProcess>
86 #include <KActionMenu>
87 #include <KMenu>
88 #include <locale.h>
89 #include <ktogglefullscreenaction.h>
90 #include <KFileItem>
91 #include <KNotification>
92 #include <KNotifyConfigWidget>
93 #if KDE_IS_VERSION(4,3,80)
94 #include <knewstuff3/downloaddialog.h>
95 #include <knewstuff3/knewstuffaction.h>
96 #else
97 #include <knewstuff2/engine.h>
98 #include <knewstuff2/ui/knewstuffaction.h>
99 #define KNS3 KNS
100 #endif /* KDE_IS_VERSION(4,3,80) */
101 #include <KToolBar>
102 #include <KColorScheme>
103 #include <KProgressDialog>
104
105 #include <QTextStream>
106 #include <QTimer>
107 #include <QAction>
108 #include <QKeyEvent>
109 #include <QInputDialog>
110 #include <QDesktopWidget>
111 #include <QBitmap>
112
113 #include <stdlib.h>
114
115 // Uncomment for deeper debugging
116 //#define DEBUG_MAINW
117
118 #ifdef DEBUG_MAINW
119 #include <QDebug>
120 #endif
121
122 static const char version[] = VERSION;
123
124 static const int ID_TIMELINE_POS = 0;
125 namespace Mlt
126 {
127 class Producer;
128 };
129
130 Q_DECLARE_METATYPE(QVector<int16_t>)
131
132 EffectsList MainWindow::videoEffects;
133 EffectsList MainWindow::audioEffects;
134 EffectsList MainWindow::customEffects;
135 EffectsList MainWindow::transitions;
136
137 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString & clipsToLoad, QWidget *parent) :
138     KXmlGuiWindow(parent),
139     m_activeDocument(NULL),
140     m_activeTimeline(NULL),
141     m_renderWidget(NULL),
142 #ifndef NO_JOGSHUTTLE
143     m_jogProcess(NULL),
144     m_jogShuttle(NULL),
145 #endif /* NO_JOGSHUTTLE */
146     m_findActivated(false),
147     m_stopmotion(NULL)
148 {
149     qRegisterMetaType<QVector<int16_t> > ();
150     // Create DBus interface
151     new MainWindowAdaptor(this);
152     QDBusConnection dbus = QDBusConnection::sessionBus();
153     dbus.registerObject("/MainWindow", this);
154
155     setlocale(LC_NUMERIC, "POSIX");
156     if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
157     setFont(KGlobalSettings::toolBarFont());
158     parseProfiles(MltPath);
159     KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
160     m_commandStack = new QUndoGroup;
161     setDockNestingEnabled(true);
162     m_timelineArea = new KTabWidget(this);
163     m_timelineArea->setTabReorderingEnabled(true);
164     m_timelineArea->setTabBarHidden(true);
165     m_timelineArea->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
166     m_timelineArea->setMinimumHeight(200);
167
168     QToolButton *closeTabButton = new QToolButton;
169     connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
170     closeTabButton->setIcon(KIcon("tab-close"));
171     closeTabButton->adjustSize();
172     closeTabButton->setToolTip(i18n("Close the current tab"));
173     m_timelineArea->setCornerWidget(closeTabButton);
174     connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
175
176     connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
177     m_findTimer.setSingleShot(true);
178
179     // FIXME: the next call returns a newly allocated object, which leaks
180     initEffects::parseEffectFiles();
181     //initEffects::parseCustomEffectsFile();
182
183     m_monitorManager = new MonitorManager();
184
185     m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
186     connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
187
188
189     /// Add Widgets ///
190
191     m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
192     m_projectListDock->setObjectName("project_tree");
193     m_projectList = new ProjectList();
194     m_projectListDock->setWidget(m_projectList);
195     addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
196
197     m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
198     m_clipMonitorDock->setObjectName("clip_monitor");
199     m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), m_timelineArea);
200     m_clipMonitorDock->setWidget(m_clipMonitor);
201     addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
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());
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");
213     m_recMonitorDock->setWidget(m_recMonitor);
214     addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
215     connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
216     connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
217 #endif
218
219     m_notesDock = new QDockWidget(i18n("Project Notes"), this);
220     m_notesDock->setObjectName("notes_widget");
221     m_notesWidget = new KTextEdit();
222     m_notesWidget->setTabChangesFocus(true);
223 #if KDE_IS_VERSION(4,4,0)
224     m_notesWidget->setClickMessage(i18n("Enter your project notes here..."));
225 #endif
226     m_notesDock->setWidget(m_notesWidget);
227     addDockWidget(Qt::TopDockWidgetArea, m_notesDock);
228
229     m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
230     m_effectStackDock->setObjectName("effect_stack");
231     m_effectStack = new EffectStackView(m_projectMonitor);
232     m_effectStackDock->setWidget(m_effectStack);
233     addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
234
235     m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
236     m_transitionConfigDock->setObjectName("transition");
237     m_transitionConfig = new TransitionSettings(m_projectMonitor);
238     m_transitionConfigDock->setWidget(m_transitionConfig);
239     addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
240
241     m_effectListDock = new QDockWidget(i18n("Effect List"), this);
242     m_effectListDock->setObjectName("effect_list");
243     m_effectList = new EffectsListView();
244     m_effectListDock->setWidget(m_effectList);
245     addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
246
247     m_vectorscope = new Vectorscope(m_projectMonitor, m_clipMonitor);
248     m_vectorscopeDock = new QDockWidget(i18n("Vectorscope"), this);
249     m_vectorscopeDock->setObjectName(m_vectorscope->widgetName());
250     m_vectorscopeDock->setWidget(m_vectorscope);
251     addDockWidget(Qt::TopDockWidgetArea, m_vectorscopeDock);
252     connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), m_vectorscope, SLOT(forceUpdate(bool)));
253     connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
254     connect(m_vectorscope, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
255     m_gfxScopesList.append(m_vectorscopeDock);
256
257     m_waveform = new Waveform(m_projectMonitor, m_clipMonitor);
258     m_waveformDock = new QDockWidget(i18n("Waveform"), this);
259     m_waveformDock->setObjectName(m_waveform->widgetName());
260     m_waveformDock->setWidget(m_waveform);
261     addDockWidget(Qt::TopDockWidgetArea, m_waveformDock);
262     connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), m_waveform, SLOT(forceUpdate(bool)));
263     connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
264     connect(m_waveform, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
265     m_gfxScopesList.append(m_waveformDock);
266
267     m_RGBParade = new RGBParade(m_projectMonitor, m_clipMonitor);
268     m_RGBParadeDock = new QDockWidget(i18n("RGB Parade"), this);
269     m_RGBParadeDock->setObjectName(m_RGBParade->widgetName());
270     m_RGBParadeDock->setWidget(m_RGBParade);
271     addDockWidget(Qt::TopDockWidgetArea, m_RGBParadeDock);
272     connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), m_RGBParade, SLOT(forceUpdate(bool)));
273     connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
274     connect(m_RGBParade, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
275     m_gfxScopesList.append(m_RGBParadeDock);
276
277     m_histogram = new Histogram(m_projectMonitor, m_clipMonitor);
278     m_histogramDock = new QDockWidget(i18n("Histogram"), this);
279     m_histogramDock->setObjectName(m_histogram->widgetName());
280     m_histogramDock->setWidget(m_histogram);
281     addDockWidget(Qt::TopDockWidgetArea, m_histogramDock);
282     connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), m_histogram, SLOT(forceUpdate(bool)));
283     connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
284     connect(m_histogram, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
285     m_gfxScopesList.append(m_histogramDock);
286
287
288     m_audiosignal = new AudioSignal;
289     m_audiosignalDock = new QDockWidget(i18n("Audio Signal"), this);
290     m_audiosignalDock->setObjectName("audiosignal");
291     m_audiosignalDock->setWidget(m_audiosignal);
292     addDockWidget(Qt::TopDockWidgetArea, m_audiosignalDock);
293 //    connect(m_audiosignal, SIGNAL(updateAudioMonitoring()), m_monitorManager, SLOT(slotUpdateAudioMonitoring()));
294     connect(m_audiosignalDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
295     connect(m_audiosignal, SIGNAL(updateAudioMonitoring()), this, SLOT(slotUpdateAudioScopeFrameRequest()));
296
297     m_audioSpectrum = new AudioSpectrum();
298     m_audioSpectrumDock = new QDockWidget(i18n("AudioSpectrum"), this);
299     m_audioSpectrumDock->setObjectName(m_audioSpectrum->widgetName());
300     m_audioSpectrumDock->setWidget(m_audioSpectrum);
301     addDockWidget(Qt::TopDockWidgetArea, m_audioSpectrumDock);
302     m_audioScopesList.append(m_audioSpectrum);
303     connect(m_audioSpectrumDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
304     connect(m_audioSpectrum, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
305
306     m_spectrogram = new Spectrogram();
307     m_spectrogramDock = new QDockWidget(i18n("Spectrogram"), this);
308     m_spectrogramDock->setObjectName(m_spectrogram->widgetName());
309     m_spectrogramDock->setWidget(m_spectrogram);
310     addDockWidget(Qt::TopDockWidgetArea, m_spectrogramDock);
311     m_audioScopesList.append(m_spectrogram);
312     connect(m_audioSpectrumDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
313     connect(m_audioSpectrum, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
314
315     // Connect the audio signal to the audio scope slots
316     bool b = true;
317     if (m_projectMonitor) {
318         qDebug() << "project monitor connected";
319         b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
320                      m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
321         b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, const int&, const int&, const int&)),
322                      m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, const int&, const int&, const int&)));
323         b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
324                      m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
325     }
326     if (m_clipMonitor) {
327         qDebug() << "clip monitor connected";
328         b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
329                      m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
330         b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, int, int, int)),
331                      m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, int, int, int)));
332         b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
333                      m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
334     }
335     // Ensure connections were set up correctly
336     Q_ASSERT(b);
337
338     m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
339     m_undoViewDock->setObjectName("undo_history");
340     m_undoView = new QUndoView();
341     m_undoView->setCleanIcon(KIcon("edit-clear"));
342     m_undoView->setEmptyLabel(i18n("Clean"));
343     m_undoViewDock->setWidget(m_undoView);
344     m_undoView->setGroup(m_commandStack);
345     addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
346
347     //overviewDock = new QDockWidget(i18n("Project Overview"), this);
348     //overviewDock->setObjectName("project_overview");
349     //m_overView = new CustomTrackView(NULL, NULL, this);
350     //overviewDock->setWidget(m_overView);
351     //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
352
353
354     setupActions();
355
356     /// Tabify Widgets ///
357     tabifyDockWidget(m_projectListDock, m_effectStackDock);
358     tabifyDockWidget(m_projectListDock, m_transitionConfigDock);
359     tabifyDockWidget(m_projectListDock, m_notesDock);
360
361
362     tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
363 #ifndef Q_WS_MAC
364     tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
365 #endif
366
367     tabifyDockWidget(m_vectorscopeDock, m_waveformDock);
368     tabifyDockWidget(m_vectorscopeDock, m_RGBParadeDock);
369     tabifyDockWidget(m_vectorscopeDock, m_histogramDock);
370     tabifyDockWidget(m_vectorscopeDock, m_undoViewDock);
371     tabifyDockWidget(m_vectorscopeDock, m_effectListDock);
372
373
374     setCentralWidget(m_timelineArea);
375
376
377     m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
378     readOptions();
379     m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
380     m_fileRevert->setEnabled(false);
381
382     // Prepare layout actions
383     KActionCategory *layoutActions = new KActionCategory(i18n("Layouts"), actionCollection());
384     m_loadLayout = new KSelectAction(i18n("Load Layout"), actionCollection());
385     for (int i = 1; i < 5; i++) {
386         KAction *load = new KAction(KIcon(), i18n("Layout %1").arg(i), this);
387         load->setData("_" + QString::number(i));
388         layoutActions->addAction("load_layout" + QString::number(i), load);
389         m_loadLayout->addAction(load);
390         KAction *save = new KAction(KIcon(), i18n("Save As Layout %1").arg(i), this);
391         save->setData("_" + QString::number(i));
392         layoutActions->addAction("save_layout" + QString::number(i), save);
393     }
394     layoutActions->addAction("load_layouts", m_loadLayout);
395     connect(m_loadLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotLoadLayout(QAction*)));
396
397     KAction *action;
398     // Stop motion actions. Beware of the order, we MUST use the same order in stopmotion/stopmotion.cpp
399     m_stopmotion_actions = new KActionCategory(i18n("Stop Motion"), actionCollection());
400     action = new KAction(KIcon("media-record"), i18n("Capture frame"), this);
401     //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
402     m_stopmotion_actions->addAction("stopmotion_capture", action);
403     action = new KAction(i18n("Switch live / captured frame"), this);
404     //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
405     m_stopmotion_actions->addAction("stopmotion_switch", action);
406     action = new KAction(KIcon("edit-paste"), i18n("Show last frame over video"), this);
407     action->setCheckable(true);
408     action->setChecked(false);
409     m_stopmotion_actions->addAction("stopmotion_overlay", action);
410     setupGUI();
411
412
413     // Find QDockWidget tab bars and show / hide widget title bars on right click
414     QList <QTabBar *> tabs = findChildren<QTabBar *>();
415     for (int i = 0; i < tabs.count(); i++) {
416         tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
417         connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
418     }
419
420     /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
421     guiFactory()->addClient(sp);*/
422
423     QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
424     if (saveLayout)
425         connect(saveLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotSaveLayout(QAction*)));
426
427
428     // Load layout names from config file
429     loadLayouts();
430
431     loadPlugins();
432     loadTranscoders();
433     //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
434
435     m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, NULL, m_loopClip);
436     m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
437
438     QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
439     clipInTimeline->setIcon(KIcon("go-jump"));
440     m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)),
441                                       static_cast<QMenu*>(factory()->container("transcoders", this)),
442                                       clipInTimeline);
443
444     // build themes menus
445     QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
446     QActionGroup *themegroup = new QActionGroup(this);
447     themegroup->setExclusive(true);
448     action = new KAction(i18n("Default"), this);
449     action->setCheckable(true);
450     themegroup->addAction(action);
451     if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
452
453     const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
454
455     for (int i = 0; i < schemeFiles.size(); ++i) {
456         // get the file name
457         const QString filename = schemeFiles.at(i);
458         const QFileInfo info(filename);
459
460         // add the entry
461         KSharedConfigPtr config = KSharedConfig::openConfig(filename);
462         QIcon icon = createSchemePreviewIcon(config);
463         KConfigGroup group(config, "General");
464         const QString name = group.readEntry("Name", info.baseName());
465         action = new KAction(name, this);
466         action->setData(filename);
467         action->setIcon(icon);
468         action->setCheckable(true);
469         themegroup->addAction(action);
470         if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
471     }
472
473     /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
474     QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
475     for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
476     {
477     QFileInfo fi(*it);
478         action = new QAction(fi.fileName(), this);
479         action->setData(*it);
480     action->setCheckable(true);
481     themegroup->addAction(action);
482     if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
483     }*/
484     themesMenu->addActions(themegroup->actions());
485     connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
486
487     // Setup and fill effects and transitions menus.
488     m_videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
489     for (int i = 0; i < videoEffects.count(); ++i)
490         m_videoEffectsMenu->addAction(m_videoEffects[i]);
491     m_audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
492     for (int i = 0; i < audioEffects.count(); ++i)
493         m_audioEffectsMenu->addAction(m_audioEffects[i]);
494     m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
495     if (customEffects.isEmpty())
496         m_customEffectsMenu->setEnabled(false);
497     else
498         m_customEffectsMenu->setEnabled(true);
499     for (int i = 0; i < customEffects.count(); ++i)
500         m_customEffectsMenu->addAction(m_customEffects[i]);
501     m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
502     for (int i = 0; i < transitions.count(); ++i)
503         m_transitionsMenu->addAction(m_transitions[i]);
504
505     connect(m_videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
506     connect(m_audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
507     connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
508     connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
509
510     QMenu *newEffect = new QMenu(this);
511     newEffect->addMenu(m_videoEffectsMenu);
512     newEffect->addMenu(m_audioEffectsMenu);
513     newEffect->addMenu(m_customEffectsMenu);
514     m_effectStack->setMenu(newEffect);
515
516     QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
517     const QList<QAction *> viewActions = createPopupMenu()->actions();
518     viewMenu->insertActions(NULL, viewActions);
519
520     m_timelineContextMenu = new QMenu(this);
521     m_timelineContextClipMenu = new QMenu(this);
522     m_timelineContextTransitionMenu = new QMenu(this);
523
524     m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
525     m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
526     m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
527
528     m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
529     //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
530     m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
531     m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
532     m_timelineContextClipMenu->addSeparator();
533     m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
534     m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
535     m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
536     m_timelineContextClipMenu->addSeparator();
537     m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
538     m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
539     m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
540     m_timelineContextClipMenu->addSeparator();
541
542     QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
543     m_timelineContextClipMenu->addMenu(markersMenu);
544     m_timelineContextClipMenu->addSeparator();
545     m_timelineContextClipMenu->addMenu(m_transitionsMenu);
546     m_timelineContextClipMenu->addMenu(m_videoEffectsMenu);
547     m_timelineContextClipMenu->addMenu(m_audioEffectsMenu);
548     m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
549
550     m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
551     m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
552     m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
553
554     m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
555
556     connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
557     connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
558     //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
559     connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
560     connect(m_monitorManager, SIGNAL(checkColorScopes()), this, SLOT(slotUpdateColorScopes()));
561     connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
562     connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
563
564     m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
565     slotConnectMonitors();
566
567     // Open or create a file.  Command line argument passed in Url has
568     // precedence, then "openlastproject", then just a plain empty file.
569     // If opening Url fails, openlastproject will _not_ be used.
570     if (!Url.isEmpty()) {
571         // delay loading so that the window shows up
572         m_startUrl = Url;
573         QTimer::singleShot(500, this, SLOT(openFile()));
574     } else if (KdenliveSettings::openlastproject()) {
575         QTimer::singleShot(500, this, SLOT(openLastFile()));
576     } else { //if (m_timelineArea->count() == 0) {
577         newFile(false);
578     }
579
580     if (!clipsToLoad.isEmpty() && m_activeDocument) {
581         QStringList list = clipsToLoad.split(',');
582         QList <QUrl> urls;
583         foreach(QString path, list) {
584             kDebug() << QDir::current().absoluteFilePath(path);
585             urls << QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
586         }
587         m_projectList->slotAddClip(urls);
588     }
589
590 #ifndef NO_JOGSHUTTLE
591     activateShuttleDevice();
592 #endif /* NO_JOGSHUTTLE */
593     m_projectListDock->raise();
594
595     actionCollection()->addAssociatedWidget(m_clipMonitor->container());
596     actionCollection()->addAssociatedWidget(m_projectMonitor->container());
597 }
598
599 MainWindow::~MainWindow()
600 {
601     if (m_stopmotion) {
602         delete m_stopmotion;
603     }
604     m_effectStack->slotClipItemSelected(NULL, 0);
605     m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
606
607     if (m_projectMonitor) m_projectMonitor->stop();
608     if (m_clipMonitor) m_clipMonitor->stop();
609
610     delete m_activeTimeline;
611     delete m_effectStack;
612     delete m_transitionConfig;
613     delete m_activeDocument;
614     delete m_projectMonitor;
615     delete m_clipMonitor;
616     delete m_shortcutRemoveFocus;
617     Mlt::Factory::close();
618 }
619
620 //virtual
621 bool MainWindow::queryClose()
622 {
623     if (m_renderWidget) {
624         int waitingJobs = m_renderWidget->waitingJobsCount();
625         if (waitingJobs > 0) {
626             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")))) {
627             case KMessageBox::Yes :
628                 // create script with waiting jobs and start it
629                 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
630                 break;
631             case KMessageBox::No :
632                 // Don't do anything, jobs will be deleted
633                 break;
634             default:
635                 return false;
636             }
637         }
638     }
639     saveOptions();
640     if (m_monitorManager) m_monitorManager->stopActiveMonitor();
641     // warn the user to save if document is modified and we have clips in our project list
642     if (m_activeDocument && m_activeDocument->isModified() &&
643             ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
644              !m_projectList->documentClipList().isEmpty())) {
645         raise();
646         activateWindow();
647         QString message;
648         if (m_activeDocument->url().fileName().isEmpty())
649             message = i18n("Save changes to document?");
650         else
651             message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
652         switch (KMessageBox::warningYesNoCancel(this, message)) {
653         case KMessageBox::Yes :
654             // save document here. If saving fails, return false;
655             return saveFile();
656         case KMessageBox::No :
657             // User does not want to save the changes, clear recovery files
658             m_activeDocument->m_autosave->resize(0);
659             return true;
660         default: // cancel
661             return false;
662         }
663     }
664     return true;
665 }
666
667 void MainWindow::loadPlugins()
668 {
669     foreach(QObject * plugin, QPluginLoader::staticInstances()) {
670         populateMenus(plugin);
671     }
672
673     QStringList directories = KGlobal::dirs()->findDirs("module", QString());
674     QStringList filters;
675     filters << "libkdenlive*";
676     foreach(const QString & folder, directories) {
677         kDebug() << "Parsing plugin folder: " << folder;
678         QDir pluginsDir(folder);
679         foreach(const QString & fileName,
680                 pluginsDir.entryList(filters, QDir::Files)) {
681             /*
682              * Avoid loading the same plugin twice when there is more than one
683              * installation.
684              */
685             if (!m_pluginFileNames.contains(fileName)) {
686                 kDebug() << "Found plugin: " << fileName;
687                 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
688                 QObject *plugin = loader.instance();
689                 if (plugin) {
690                     populateMenus(plugin);
691                     m_pluginFileNames += fileName;
692                 } else
693                     kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
694             }
695         }
696     }
697 }
698
699 void MainWindow::populateMenus(QObject *plugin)
700 {
701     QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
702     ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
703     if (iGenerator)
704         addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
705                   NULL);
706 }
707
708 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
709                            QMenu *menu, const char *member,
710                            QActionGroup *actionGroup)
711 {
712     kDebug() << "// ADD to MENU" << texts;
713     foreach(const QString & text, texts) {
714         QAction *action = new QAction(text, plugin);
715         action->setData(text);
716         connect(action, SIGNAL(triggered()), this, member);
717         menu->addAction(action);
718
719         if (actionGroup) {
720             action->setCheckable(true);
721             actionGroup->addAction(action);
722         }
723     }
724 }
725
726 void MainWindow::aboutPlugins()
727 {
728     //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
729     //dialog.exec();
730 }
731
732
733 void MainWindow::generateClip()
734 {
735     QAction *action = qobject_cast<QAction *>(sender());
736     ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
737
738     KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
739                    QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
740     if (!clipUrl.isEmpty()) {
741         m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
742     }
743 }
744
745 void MainWindow::saveProperties(KConfigGroup &config)
746 {
747     // save properties here,used by session management
748     saveFile();
749     KMainWindow::saveProperties(config);
750 }
751
752
753 void MainWindow::readProperties(const KConfigGroup &config)
754 {
755     // read properties here,used by session management
756     KMainWindow::readProperties(config);
757     QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
758     openFile(KUrl(Lastproject));
759 }
760
761 void MainWindow::slotReloadEffects()
762 {
763     m_customEffectsMenu->clear();
764     initEffects::parseCustomEffectsFile();
765     QAction *action;
766     QStringList effectInfo;
767     QMap<QString, QStringList> effectsList;
768     for (int ix = 0; ix < customEffects.count(); ix++) {
769         effectInfo = customEffects.effectIdInfo(ix);
770         effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
771     }
772     if (effectsList.isEmpty())
773         m_customEffectsMenu->setEnabled(false);
774     else
775         m_customEffectsMenu->setEnabled(true);
776
777     foreach(const QStringList & value, effectsList) {
778         action = new QAction(value.at(0), this);
779         action->setData(value);
780         m_customEffectsMenu->addAction(action);
781     }
782     m_effectList->reloadEffectList();
783 }
784
785 #ifndef NO_JOGSHUTTLE
786 void MainWindow::activateShuttleDevice()
787 {
788     delete m_jogShuttle;
789     m_jogShuttle = NULL;
790     delete m_jogProcess;
791     m_jogProcess = NULL;
792     if (KdenliveSettings::enableshuttle() == false) return;
793     
794     m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
795     m_jogShuttle = new JogShuttleAction(m_jogProcess, JogShuttleConfig::actionMap(KdenliveSettings::shuttlebuttons()));
796     
797     connect(m_jogShuttle, SIGNAL(rewindOneFrame()), m_monitorManager, SLOT(slotRewindOneFrame()));
798     connect(m_jogShuttle, SIGNAL(forwardOneFrame()), m_monitorManager, SLOT(slotForwardOneFrame()));
799     connect(m_jogShuttle, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
800     connect(m_jogShuttle, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
801     connect(m_jogShuttle, SIGNAL(action(const QString&)), this, SLOT(slotDoAction(const QString&)));
802 }
803 #endif /* NO_JOGSHUTTLE */
804
805 void MainWindow::slotDoAction(const QString& action_name)
806 {
807     QAction* action = actionCollection()->action(action_name);
808     if (!action) {
809         fprintf(stderr, "%s", QString("shuttle action '%1' unknown\n").arg(action_name).toAscii().constData());
810         return;
811     }
812     action->trigger();
813 }
814
815 void MainWindow::configureNotifications()
816 {
817     KNotifyConfigWidget::configure(this);
818 }
819
820 void MainWindow::slotFullScreen()
821 {
822     KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
823 }
824
825 void MainWindow::slotAddEffect(const QDomElement effect)
826 {
827     if (!m_activeDocument) return;
828     if (effect.isNull()) {
829         kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
830         return;
831     }
832     QDomElement effectToAdd = effect.cloneNode().toElement();
833     bool ok;
834     int ix = m_effectStack->isTrackMode(&ok);
835     if (ok) m_activeTimeline->projectView()->slotAddTrackEffect(effectToAdd, m_activeDocument->tracksCount() - ix);
836     else m_activeTimeline->projectView()->slotAddEffect(effectToAdd, GenTime(), -1);
837 }
838
839 void MainWindow::slotRaiseMonitor(bool clipMonitor)
840 {
841     if (clipMonitor) m_clipMonitorDock->raise();
842     else m_projectMonitorDock->raise();
843 }
844
845 void MainWindow::slotUpdateClip(const QString &id)
846 {
847     if (!m_activeDocument) return;
848     m_activeTimeline->projectView()->slotUpdateClip(id);
849 }
850
851 void MainWindow::slotConnectMonitors()
852 {
853     m_projectList->setRenderer(m_projectMonitor->render);
854     //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
855     connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
856     connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
857     connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
858     connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, int, bool, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, int, bool, bool)));
859     connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
860     connect(m_projectMonitor->render, SIGNAL(replyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool, bool)), m_projectList, SLOT(slotReplyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool, bool)));
861
862     connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
863     connect(m_projectMonitor->render, SIGNAL(removeInvalidProxy(const QString &)), m_projectList, SLOT(slotRemoveInvalidProxy(const QString &)));
864
865     connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &, bool)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &, bool)));
866
867     connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
868     connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
869
870     connect(m_projectMonitor, SIGNAL(requestFrameForAnalysis(bool)), this, SLOT(slotMonitorRequestRenderFrame(bool)));
871
872     connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
873     connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
874 }
875
876 void MainWindow::slotAdjustClipMonitor()
877 {
878     m_clipMonitorDock->updateGeometry();
879     m_clipMonitorDock->adjustSize();
880     m_clipMonitor->resetSize();
881 }
882
883 void MainWindow::slotAdjustProjectMonitor()
884 {
885     m_projectMonitorDock->updateGeometry();
886     m_projectMonitorDock->adjustSize();
887     m_projectMonitor->resetSize();
888 }
889
890
891 class NameGrabbingKActionCollection {
892 public:
893   NameGrabbingKActionCollection(KActionCollection* collection, QStringList& action_names)
894     : m_collection(collection), m_action_names(action_names) {
895       m_action_names.clear();
896     }
897   KAction* addAction(const QString& action_name) {
898     m_action_names << action_name;
899     return m_collection->addAction(action_name);
900   }
901   void addAction(const QString& action_name, QAction* action) {
902     m_action_names << action_name;
903     m_collection->addAction(action_name, action);
904   }
905   operator KActionCollection*() { return m_collection; }
906   const QStringList& actionNames() const { return m_action_names; }
907 private:
908   KActionCollection* m_collection;
909   QStringList& m_action_names;
910 };
911
912 void MainWindow::setupActions()
913 {
914
915     NameGrabbingKActionCollection collection(actionCollection(), m_action_names);
916     m_timecodeFormat = new KComboBox(this);
917     m_timecodeFormat->addItem(i18n("hh:mm:ss:ff"));
918     m_timecodeFormat->addItem(i18n("Frames"));
919     if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
920     connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
921
922     m_statusProgressBar = new QProgressBar(this);
923     m_statusProgressBar->setMinimum(0);
924     m_statusProgressBar->setMaximum(100);
925     m_statusProgressBar->setMaximumWidth(150);
926     m_statusProgressBar->setVisible(false);
927
928     KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
929     toolbar->setMovable(false);
930     KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
931     QColor buttonBg = scheme.background(KColorScheme::LinkBackground).color();
932     QColor buttonBord = scheme.foreground(KColorScheme::LinkText).color();
933     QColor buttonBord2 = scheme.shade(KColorScheme::LightShade);
934     statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
935     QString style1 = QString("QToolBar { border: 0px } QToolButton { border-style: inset; border:1px solid transparent;border-radius: 3px;margin: 0px 3px;padding: 0px;} QToolButton:hover { background: rgb(%7, %8, %9);border-style: inset; border:1px solid rgb(%7, %8, %9);border-radius: 3px;} QToolButton:checked { background-color: rgb(%1, %2, %3); border-style: inset; border:1px solid rgb(%4, %5, %6);border-radius: 3px;}").arg(buttonBg.red()).arg(buttonBg.green()).arg(buttonBg.blue()).arg(buttonBord.red()).arg(buttonBord.green()).arg(buttonBord.blue()).arg(buttonBord2.red()).arg(buttonBord2.green()).arg(buttonBord2.blue());
936     QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
937
938     //create edit mode buttons
939     m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
940     m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
941     toolbar->addAction(m_normalEditTool);
942     m_normalEditTool->setCheckable(true);
943     m_normalEditTool->setChecked(true);
944
945     m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
946     //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
947     toolbar->addAction(m_overwriteEditTool);
948     m_overwriteEditTool->setCheckable(true);
949     m_overwriteEditTool->setChecked(false);
950
951     m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
952     //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
953     toolbar->addAction(m_insertEditTool);
954     m_insertEditTool->setCheckable(true);
955     m_insertEditTool->setChecked(false);
956     // not implemented yet
957     m_insertEditTool->setEnabled(false);
958
959     QActionGroup *editGroup = new QActionGroup(this);
960     editGroup->addAction(m_normalEditTool);
961     editGroup->addAction(m_overwriteEditTool);
962     editGroup->addAction(m_insertEditTool);
963     editGroup->setExclusive(true);
964     connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
965     //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
966
967     toolbar->addSeparator();
968
969     // create tools buttons
970     m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
971     m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
972     toolbar->addAction(m_buttonSelectTool);
973     m_buttonSelectTool->setCheckable(true);
974     m_buttonSelectTool->setChecked(true);
975
976     m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
977     m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
978     toolbar->addAction(m_buttonRazorTool);
979     m_buttonRazorTool->setCheckable(true);
980     m_buttonRazorTool->setChecked(false);
981
982     m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
983     m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
984     toolbar->addAction(m_buttonSpacerTool);
985     m_buttonSpacerTool->setCheckable(true);
986     m_buttonSpacerTool->setChecked(false);
987
988     QActionGroup *toolGroup = new QActionGroup(this);
989     toolGroup->addAction(m_buttonSelectTool);
990     toolGroup->addAction(m_buttonRazorTool);
991     toolGroup->addAction(m_buttonSpacerTool);
992     toolGroup->setExclusive(true);
993     toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
994
995     QWidget * actionWidget;
996     int max = toolbar->iconSizeDefault() + 2;
997     actionWidget = toolbar->widgetForAction(m_normalEditTool);
998     actionWidget->setMaximumWidth(max);
999     actionWidget->setMaximumHeight(max - 4);
1000
1001     actionWidget = toolbar->widgetForAction(m_insertEditTool);
1002     actionWidget->setMaximumWidth(max);
1003     actionWidget->setMaximumHeight(max - 4);
1004
1005     actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
1006     actionWidget->setMaximumWidth(max);
1007     actionWidget->setMaximumHeight(max - 4);
1008
1009     actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
1010     actionWidget->setMaximumWidth(max);
1011     actionWidget->setMaximumHeight(max - 4);
1012
1013     actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
1014     actionWidget->setMaximumWidth(max);
1015     actionWidget->setMaximumHeight(max - 4);
1016
1017     actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
1018     actionWidget->setMaximumWidth(max);
1019     actionWidget->setMaximumHeight(max - 4);
1020
1021     toolbar->setStyleSheet(style1);
1022     connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
1023
1024     toolbar->addSeparator();
1025     m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
1026     toolbar->addAction(m_buttonFitZoom);
1027     m_buttonFitZoom->setCheckable(false);
1028
1029     m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
1030     toolbar->addAction(m_zoomOut);
1031     m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
1032
1033     m_zoomSlider = new QSlider(Qt::Horizontal, this);
1034     m_zoomSlider->setMaximum(13);
1035     m_zoomSlider->setPageStep(1);
1036     m_zoomSlider->setInvertedAppearance(true);
1037
1038     m_zoomSlider->setMaximumWidth(150);
1039     m_zoomSlider->setMinimumWidth(100);
1040     toolbar->addWidget(m_zoomSlider);
1041
1042     m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
1043     toolbar->addAction(m_zoomIn);
1044     m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
1045
1046     actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
1047     actionWidget->setMaximumWidth(max);
1048     actionWidget->setMaximumHeight(max - 4);
1049     actionWidget->setStyleSheet(styleBorderless);
1050
1051     actionWidget = toolbar->widgetForAction(m_zoomIn);
1052     actionWidget->setMaximumWidth(max);
1053     actionWidget->setMaximumHeight(max - 4);
1054     actionWidget->setStyleSheet(styleBorderless);
1055
1056     actionWidget = toolbar->widgetForAction(m_zoomOut);
1057     actionWidget->setMaximumWidth(max);
1058     actionWidget->setMaximumHeight(max - 4);
1059     actionWidget->setStyleSheet(styleBorderless);
1060
1061     connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
1062     connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
1063     connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
1064     connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
1065     connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
1066
1067     toolbar->addSeparator();
1068
1069     //create automatic audio split button
1070     m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
1071     toolbar->addAction(m_buttonAutomaticSplitAudio);
1072     m_buttonAutomaticSplitAudio->setCheckable(true);
1073     m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
1074     connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
1075
1076     m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
1077     toolbar->addAction(m_buttonVideoThumbs);
1078     m_buttonVideoThumbs->setCheckable(true);
1079     m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1080     connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
1081
1082     m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
1083     toolbar->addAction(m_buttonAudioThumbs);
1084     m_buttonAudioThumbs->setCheckable(true);
1085     m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1086     connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
1087
1088     m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
1089     toolbar->addAction(m_buttonShowMarkers);
1090     m_buttonShowMarkers->setCheckable(true);
1091     m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1092     connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
1093
1094     m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
1095     toolbar->addAction(m_buttonSnap);
1096     m_buttonSnap->setCheckable(true);
1097     m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1098     connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
1099
1100     actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
1101     actionWidget->setMaximumWidth(max);
1102     actionWidget->setMaximumHeight(max - 4);
1103
1104     actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
1105     actionWidget->setMaximumWidth(max);
1106     actionWidget->setMaximumHeight(max - 4);
1107
1108     actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
1109     actionWidget->setMaximumWidth(max);
1110     actionWidget->setMaximumHeight(max - 4);
1111
1112     actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
1113     actionWidget->setMaximumWidth(max);
1114     actionWidget->setMaximumHeight(max - 4);
1115
1116     actionWidget = toolbar->widgetForAction(m_buttonSnap);
1117     actionWidget->setMaximumWidth(max);
1118     actionWidget->setMaximumHeight(max - 4);
1119
1120     m_messageLabel = new StatusBarMessageLabel(this);
1121     m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
1122
1123     statusBar()->addWidget(m_messageLabel, 10);
1124     statusBar()->addWidget(m_statusProgressBar, 0);
1125     statusBar()->addPermanentWidget(toolbar);
1126     statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
1127     statusBar()->addPermanentWidget(m_timecodeFormat);
1128     //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
1129
1130     collection.addAction("normal_mode", m_normalEditTool);
1131     collection.addAction("overwrite_mode", m_overwriteEditTool);
1132     collection.addAction("insert_mode", m_insertEditTool);
1133     collection.addAction("select_tool", m_buttonSelectTool);
1134     collection.addAction("razor_tool", m_buttonRazorTool);
1135     collection.addAction("spacer_tool", m_buttonSpacerTool);
1136
1137     collection.addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
1138     collection.addAction("show_video_thumbs", m_buttonVideoThumbs);
1139     collection.addAction("show_audio_thumbs", m_buttonAudioThumbs);
1140     collection.addAction("show_markers", m_buttonShowMarkers);
1141     collection.addAction("snap", m_buttonSnap);
1142     collection.addAction("zoom_fit", m_buttonFitZoom);
1143     collection.addAction("zoom_in", m_zoomIn);
1144     collection.addAction("zoom_out", m_zoomOut);
1145
1146     m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
1147     collection.addAction("project_find", m_projectSearch);
1148     connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
1149     m_projectSearch->setShortcut(Qt::Key_Slash);
1150
1151     m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
1152     collection.addAction("project_find_next", m_projectSearchNext);
1153     connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
1154     m_projectSearchNext->setShortcut(Qt::Key_F3);
1155     m_projectSearchNext->setEnabled(false);
1156
1157     KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
1158     collection.addAction("manage_profiles", profilesAction);
1159     connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
1160
1161     KNS3::standardAction(i18n("Download New Wipes..."),            this, SLOT(slotGetNewLumaStuff()),       actionCollection(), "get_new_lumas");
1162     KNS3::standardAction(i18n("Download New Render Profiles..."),  this, SLOT(slotGetNewRenderStuff()),     actionCollection(), "get_new_profiles");
1163     KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
1164     KNS3::standardAction(i18n("Download New Title Templates..."),  this, SLOT(slotGetNewTitleStuff()),      actionCollection(), "get_new_titles");
1165
1166     KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
1167     collection.addAction("run_wizard", wizAction);
1168     connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
1169
1170     KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
1171     collection.addAction("project_settings", projectAction);
1172     connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
1173
1174     KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
1175     collection.addAction("project_render", projectRender);
1176     projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
1177     connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
1178
1179     KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1180     collection.addAction("project_clean", projectClean);
1181     connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1182
1183     KAction* projectAdjust = new KAction(KIcon(), i18n("Adjust Profile to Current Clip"), this);
1184     collection.addAction("project_adjust_profile", projectAdjust);
1185     connect(projectAdjust, SIGNAL(triggered(bool)), m_projectList, SLOT(adjustProjectProfileToItem()));
1186
1187     KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1188     KShortcut playShortcut;
1189     playShortcut.setPrimary(Qt::Key_Space);
1190     playShortcut.setAlternate(Qt::Key_K);
1191     monitorPlay->setShortcut(playShortcut);
1192     collection.addAction("monitor_play", monitorPlay);
1193     connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1194
1195     KAction* monitorPause = new KAction(KIcon("media-playback-stop"), i18n("Pause"), this);
1196     collection.addAction("monitor_pause", monitorPause);
1197     connect(monitorPause, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPause()));
1198
1199     m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1200     m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1201     collection.addAction("monitor_play_zone", m_playZone);
1202     connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1203
1204     m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1205     m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1206     collection.addAction("monitor_loop_zone", m_loopZone);
1207     connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1208
1209     m_loopClip = new KAction(KIcon("media-playback-start"), i18n("Loop selected clip"), this);
1210     m_loopClip->setEnabled(false);
1211     collection.addAction("monitor_loop_clip", m_loopClip);
1212     connect(m_loopClip, SIGNAL(triggered(bool)), m_projectMonitor, SLOT(slotLoopClip()));
1213
1214     KAction *dvdWizard =  new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1215     collection.addAction("dvd_wizard", dvdWizard);
1216     connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1217
1218     KAction *transcodeClip =  new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1219     collection.addAction("transcode_clip", transcodeClip);
1220     connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1221
1222     KAction *markIn = collection.addAction("mark_in");
1223     markIn->setText(i18n("Set Zone In"));
1224     markIn->setShortcut(Qt::Key_I);
1225     connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1226
1227     KAction *markOut = collection.addAction("mark_out");
1228     markOut->setText(i18n("Set Zone Out"));
1229     markOut->setShortcut(Qt::Key_O);
1230     connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1231
1232     KAction *switchMon = collection.addAction("switch_monitor");
1233     switchMon->setText(i18n("Switch monitor"));
1234     switchMon->setShortcut(Qt::Key_T);
1235     connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1236
1237     KAction *fullMon = collection.addAction("monitor_fullscreen");
1238     fullMon->setText(i18n("Switch monitor fullscreen"));
1239     fullMon->setIcon(KIcon("view-fullscreen"));
1240     connect(fullMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchFullscreen()));
1241
1242     KAction *insertTree = collection.addAction("insert_project_tree");
1243     insertTree->setText(i18n("Insert zone in project tree"));
1244     insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1245     connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1246
1247     KAction *insertTimeline = collection.addAction("insert_timeline");
1248     insertTimeline->setText(i18n("Insert zone in timeline"));
1249     insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1250     connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1251
1252     KAction *resizeStart =  new KAction(KIcon(), i18n("Resize Item Start"), this);
1253     collection.addAction("resize_timeline_clip_start", resizeStart);
1254     resizeStart->setShortcut(Qt::Key_1);
1255     connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1256
1257     KAction *resizeEnd =  new KAction(KIcon(), i18n("Resize Item End"), this);
1258     collection.addAction("resize_timeline_clip_end", resizeEnd);
1259     resizeEnd->setShortcut(Qt::Key_2);
1260     connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1261
1262     KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1263     monitorSeekBackward->setShortcut(Qt::Key_J);
1264     collection.addAction("monitor_seek_backward", monitorSeekBackward);
1265     connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1266
1267     KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1268     monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1269     collection.addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1270     connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1271
1272     KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1273     monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1274     collection.addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1275     connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1276
1277     KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1278     monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1279     collection.addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1280     connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1281
1282     KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1283     monitorSeekForward->setShortcut(Qt::Key_L);
1284     collection.addAction("monitor_seek_forward", monitorSeekForward);
1285     connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1286
1287     KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1288     clipStart->setShortcut(Qt::Key_Home);
1289     collection.addAction("seek_clip_start", clipStart);
1290     connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1291
1292     KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1293     clipEnd->setShortcut(Qt::Key_End);
1294     collection.addAction("seek_clip_end", clipEnd);
1295     connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1296
1297     KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1298     zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1299     collection.addAction("seek_zone_start", zoneStart);
1300     connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1301
1302     KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1303     zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1304     collection.addAction("seek_zone_end", zoneEnd);
1305     connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1306
1307     KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1308     projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1309     collection.addAction("seek_start", projectStart);
1310     connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1311
1312     KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1313     projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1314     collection.addAction("seek_end", projectEnd);
1315     connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1316
1317     KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1318     monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1319     collection.addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1320     connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1321
1322     KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1323     monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1324     collection.addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1325     connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1326
1327     KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1328     monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1329     collection.addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1330     connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1331
1332     KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1333     deleteItem->setShortcut(Qt::Key_Delete);
1334     collection.addAction("delete_timeline_clip", deleteItem);
1335     connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1336
1337     /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1338     collection.addAction("change_clip_speed", editTimelineClipSpeed);
1339     editTimelineClipSpeed->setData("change_speed");
1340     connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1341
1342     KAction *stickTransition = collection.addAction("auto_transition");
1343     stickTransition->setData(QString("auto"));
1344     stickTransition->setCheckable(true);
1345     stickTransition->setEnabled(false);
1346     stickTransition->setText(i18n("Automatic Transition"));
1347     connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1348
1349     KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1350     groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1351     collection.addAction("group_clip", groupClip);
1352     connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1353
1354     KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1355     collection.addAction("ungroup_clip", ungroupClip);
1356     ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1357     ungroupClip->setData("ungroup_clip");
1358     connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1359
1360     KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1361     collection.addAction("edit_item_duration", editItemDuration);
1362     connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1363
1364     KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1365     collection.addAction("clip_in_project_tree", clipInProjectTree);
1366     connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1367
1368     /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1369     collection.addAction("clip_to_project_tree", clipToProjectTree);
1370     connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1371
1372     KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1373     insertOvertwrite->setShortcut(Qt::Key_V);
1374     collection.addAction("overwrite_to_in_point", insertOvertwrite);
1375     connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1376
1377     KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1378     selectTimelineClip->setShortcut(Qt::Key_Plus);
1379     collection.addAction("select_timeline_clip", selectTimelineClip);
1380     connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1381
1382     KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1383     deselectTimelineClip->setShortcut(Qt::Key_Minus);
1384     collection.addAction("deselect_timeline_clip", deselectTimelineClip);
1385     connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1386
1387     KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1388     selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1389     collection.addAction("select_add_timeline_clip", selectAddTimelineClip);
1390     connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1391
1392     KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1393     selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1394     collection.addAction("select_timeline_transition", selectTimelineTransition);
1395     connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1396
1397     KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1398     deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1399     collection.addAction("deselect_timeline_transition", deselectTimelineTransition);
1400     connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1401
1402     KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1403     selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1404     collection.addAction("select_add_timeline_transition", selectAddTimelineTransition);
1405     connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1406
1407     KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1408     cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1409     collection.addAction("cut_timeline_clip", cutTimelineClip);
1410     connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1411
1412     KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1413     collection.addAction("add_clip_marker", addClipMarker);
1414     connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1415
1416     KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1417     collection.addAction("delete_clip_marker", deleteClipMarker);
1418     connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1419
1420     KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1421     collection.addAction("delete_all_clip_markers", deleteAllClipMarkers);
1422     connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1423
1424     KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1425     collection.addAction("edit_clip_marker", editClipMarker);
1426     connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1427
1428     KAction *addMarkerGuideQuickly = new KAction(KIcon("bookmark-new"), i18n("Add Marker/Guide quickly"), this);
1429     addMarkerGuideQuickly->setShortcut(Qt::Key_Asterisk);
1430     collection.addAction("add_marker_guide_quickly", addMarkerGuideQuickly);
1431     connect(addMarkerGuideQuickly, SIGNAL(triggered(bool)), this, SLOT(slotAddMarkerGuideQuickly()));
1432
1433     KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1434     collection.addAction("split_audio", splitAudio);
1435     connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1436
1437     KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1438     collection.addAction("clip_audio_only", audioOnly);
1439     audioOnly->setData("clip_audio_only");
1440     audioOnly->setCheckable(true);
1441
1442     KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1443     collection.addAction("clip_video_only", videoOnly);
1444     videoOnly->setData("clip_video_only");
1445     videoOnly->setCheckable(true);
1446
1447     KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1448     collection.addAction("clip_audio_and_video", audioAndVideo);
1449     audioAndVideo->setData("clip_audio_and_video");
1450     audioAndVideo->setCheckable(true);
1451
1452     m_clipTypeGroup = new QActionGroup(this);
1453     m_clipTypeGroup->addAction(audioOnly);
1454     m_clipTypeGroup->addAction(videoOnly);
1455     m_clipTypeGroup->addAction(audioAndVideo);
1456     connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1457     m_clipTypeGroup->setEnabled(false);
1458
1459     KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1460     collection.addAction("insert_space", insertSpace);
1461     connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1462
1463     KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1464     collection.addAction("delete_space", removeSpace);
1465     connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1466
1467     KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1468     collection.addAction("insert_track", insertTrack);
1469     connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1470
1471     KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1472     collection.addAction("delete_track", deleteTrack);
1473     connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1474
1475     KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
1476     collection.addAction("config_tracks", configTracks);
1477     connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1478
1479     KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1480     collection.addAction("add_guide", addGuide);
1481     connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1482
1483     QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1484     collection.addAction("delete_guide", delGuide);
1485     connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1486
1487     QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1488     collection.addAction("edit_guide", editGuide);
1489     connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1490
1491     QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1492     collection.addAction("delete_all_guides", delAllGuides);
1493     connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1494
1495     QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1496     collection.addAction("paste_effects", pasteEffects);
1497     pasteEffects->setData("paste_effects");
1498     connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1499
1500     QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1501     collection.addAction("show_timeline", showTimeline);
1502     showTimeline->setCheckable(true);
1503     showTimeline->setChecked(true);
1504     connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1505
1506     QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1507     collection.addAction("show_titlebars", showTitleBar);
1508     showTitleBar->setCheckable(true);
1509     connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1510     showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1511     slotShowTitleBars(KdenliveSettings::showtitlebars());
1512
1513
1514     //const QByteArray state = layoutGroup.readEntry("layout1", QByteArray());
1515
1516     /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1517     collection.addAction("maximize_current", maxCurrent);
1518     maxCurrent->setCheckable(true);
1519     maxCurrent->setChecked(false);
1520     connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1521
1522     m_closeAction = KStandardAction::close(this,  SLOT(closeCurrentDocument()),   collection);
1523     KStandardAction::quit(this,                   SLOT(close()),              collection);
1524     KStandardAction::open(this,                   SLOT(openFile()),               collection);
1525     m_saveAction = KStandardAction::save(this,    SLOT(saveFile()),               collection);
1526     KStandardAction::saveAs(this,                 SLOT(saveFileAs()),             collection);
1527     KStandardAction::openNew(this,                SLOT(newFile()),                collection);
1528     // TODO: make the following connection to slotEditKeys work
1529     KStandardAction::keyBindings(this,            SLOT(slotEditKeys()),           collection);
1530     KStandardAction::preferences(this,            SLOT(slotPreferences()),        collection);
1531     KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1532     KStandardAction::copy(this,                   SLOT(slotCopy()),               collection);
1533     KStandardAction::paste(this,                  SLOT(slotPaste()),              collection);
1534     KStandardAction::fullScreen(this,             SLOT(slotFullScreen()), this,   collection);
1535
1536     KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1537     undo->setEnabled(false);
1538     connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1539
1540     KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1541     redo->setEnabled(false);
1542     connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1543
1544     /*
1545     //TODO: Add status tooltip to actions ?
1546     connect(collection, SIGNAL(actionHovered(QAction*)),
1547             this, SLOT(slotDisplayActionMessage(QAction*)));*/
1548
1549
1550     QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1551     collection.addAction("add_clip", addClip);
1552     connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1553
1554     QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1555     collection.addAction("add_color_clip", addColorClip);
1556     connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1557
1558     QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1559     collection.addAction("add_slide_clip", addSlideClip);
1560     connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1561
1562     QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1563     collection.addAction("add_text_clip", addTitleClip);
1564     connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1565
1566     QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1567     collection.addAction("add_text_template_clip", addTitleTemplateClip);
1568     connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1569
1570     QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1571     collection.addAction("add_folder", addFolderButton);
1572     connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1573
1574     QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1575     collection.addAction("clip_properties", clipProperties);
1576     clipProperties->setData("clip_properties");
1577     connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1578     clipProperties->setEnabled(false);
1579
1580     QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1581     collection.addAction("edit_clip", openClip);
1582     openClip->setData("edit_clip");
1583     connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1584     openClip->setEnabled(false);
1585
1586     QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1587     collection.addAction("delete_clip", deleteClip);
1588     deleteClip->setData("delete_clip");
1589     connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1590     deleteClip->setEnabled(false);
1591
1592     QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1593     collection.addAction("reload_clip", reloadClip);
1594     reloadClip->setData("reload_clip");
1595     connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1596     reloadClip->setEnabled(false);
1597
1598     QAction *stopMotion = new KAction(KIcon("image-x-generic"), i18n("Stop Motion Capture"), this);
1599     collection.addAction("stopmotion", stopMotion);
1600     connect(stopMotion , SIGNAL(triggered()), this, SLOT(slotOpenStopmotion()));
1601
1602     QMenu *addClips = new QMenu();
1603     addClips->addAction(addClip);
1604     addClips->addAction(addColorClip);
1605     addClips->addAction(addSlideClip);
1606     addClips->addAction(addTitleClip);
1607     addClips->addAction(addTitleTemplateClip);
1608     addClips->addAction(addFolderButton);
1609
1610     addClips->addAction(reloadClip);
1611     addClips->addAction(clipProperties);
1612     addClips->addAction(openClip);
1613     addClips->addAction(deleteClip);
1614     m_projectList->setupMenu(addClips, addClip);
1615
1616     // Setup effects and transitions actions.
1617     m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1618     //KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), m_effectsActionCollection);
1619     KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), collection);
1620     m_videoEffects = new KAction*[videoEffects.count()];
1621     for (int i = 0; i < videoEffects.count(); ++i) {
1622         QStringList effectInfo = videoEffects.effectIdInfo(i);
1623         m_videoEffects[i] = new KAction(KIcon("kdenlive-show-video"), effectInfo.at(0), this);
1624         m_videoEffects[i]->setData(effectInfo);
1625         m_videoEffects[i]->setIconVisibleInMenu(false);
1626         videoEffectActions->addAction("video_effect_" + effectInfo.at(0), m_videoEffects[i]);
1627     }
1628     //KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), m_effectsActionCollection);
1629     KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), collection);
1630     m_audioEffects = new KAction*[audioEffects.count()];
1631     for (int i = 0; i < audioEffects.count(); ++i) {
1632         QStringList effectInfo = audioEffects.effectIdInfo(i);
1633         m_audioEffects[i] = new KAction(KIcon("kdenlive-show-audio"), effectInfo.at(0), this);
1634         m_audioEffects[i]->setData(effectInfo);
1635         m_audioEffects[i]->setIconVisibleInMenu(false);
1636         audioEffectActions->addAction("audio_effect_" + effectInfo.at(0), m_audioEffects[i]);
1637     }
1638     //KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), m_effectsActionCollection);
1639     KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), collection);
1640     m_customEffects = new KAction*[customEffects.count()];
1641     for (int i = 0; i < customEffects.count(); ++i) {
1642         QStringList effectInfo = customEffects.effectIdInfo(i);
1643         m_customEffects[i] = new KAction(KIcon("kdenlive-custom-effect"), effectInfo.at(0), this);
1644         m_customEffects[i]->setData(effectInfo);
1645         m_customEffects[i]->setIconVisibleInMenu(false);
1646         customEffectActions->addAction("custom_effect_" + effectInfo.at(0), m_customEffects[i]);
1647     }
1648     //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1649     KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1650     m_transitions = new KAction*[transitions.count()];
1651     for (int i = 0; i < transitions.count(); i++) {
1652         QStringList effectInfo = transitions.effectIdInfo(i);
1653         m_transitions[i] = new KAction(effectInfo.at(0), this);
1654         m_transitions[i]->setData(effectInfo);
1655         m_transitions[i]->setIconVisibleInMenu(false);
1656         transitionActions->addAction("transition_" + effectInfo.at(0), m_transitions[i]);
1657     }
1658     m_effectsActionCollection->readSettings();
1659
1660     //connect(collection, SIGNAL( clearStatusText() ),
1661     //statusBar(), SLOT( clear() ) );
1662 }
1663
1664 void MainWindow::slotDisplayActionMessage(QAction *a)
1665 {
1666     statusBar()->showMessage(a->data().toString(), 3000);
1667 }
1668
1669 void MainWindow::loadLayouts()
1670 {
1671     QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
1672     if (m_loadLayout == NULL || saveLayout == NULL) return;
1673     KSharedConfigPtr config = KGlobal::config();
1674     KConfigGroup layoutGroup(config, "Layouts");
1675     QStringList entries = layoutGroup.keyList();
1676     QList<QAction *> loadActions = m_loadLayout->actions();
1677     QList<QAction *> saveActions = saveLayout->actions();
1678     for (int i = 1; i < 5; i++) {
1679         // Rename the layouts actions
1680         foreach(const QString & key, entries) {
1681             if (key.endsWith(QString("_%1").arg(i))) {
1682                 // Found previously saved layout
1683                 QString layoutName = key.section("_", 0, -2);
1684                 for (int j = 0; j < loadActions.count(); j++) {
1685                     if (loadActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1686                         loadActions[j]->setText(layoutName);
1687                         loadActions[j]->setData(key);
1688                         break;
1689                     }
1690                 }
1691                 for (int j = 0; j < saveActions.count(); j++) {
1692                     if (saveActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1693                         saveActions[j]->setText(i18n("Save as %1").arg(layoutName));
1694                         saveActions[j]->setData(key);
1695                         break;
1696                     }
1697                 }
1698             }
1699         }
1700     }
1701 }
1702
1703 void MainWindow::slotLoadLayout(QAction *action)
1704 {
1705     if (!action) return;
1706     QString layoutId = action->data().toString();
1707     if (layoutId.isEmpty()) return;
1708     KSharedConfigPtr config = KGlobal::config();
1709     KConfigGroup layouts(config, "Layouts");
1710     //QByteArray geom = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1711     QByteArray state = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1712     //restoreGeometry(geom);
1713     restoreState(state);
1714 }
1715
1716 void MainWindow::slotSaveLayout(QAction *action)
1717 {
1718     QString originallayoutName = action->data().toString();
1719     int layoutId = originallayoutName.section('_', -1).toInt();
1720
1721     QString layoutName = QInputDialog::getText(this, i18n("Save Layout"), i18n("Layout name:"), QLineEdit::Normal, originallayoutName.section('_', 0, -2));
1722     if (layoutName.isEmpty()) return;
1723     KSharedConfigPtr config = KGlobal::config();
1724     KConfigGroup layouts(config, "Layouts");
1725     layouts.deleteEntry(originallayoutName);
1726
1727     QByteArray st = saveState();
1728     layoutName.append("_" + QString::number(layoutId));
1729     layouts.writeEntry(layoutName, st.toBase64());
1730     loadLayouts();
1731 }
1732
1733 void MainWindow::saveOptions()
1734 {
1735     KdenliveSettings::self()->writeConfig();
1736     KSharedConfigPtr config = KGlobal::config();
1737     m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1738     KConfigGroup treecolumns(config, "Project Tree");
1739     treecolumns.writeEntry("columns", m_projectList->headerInfo());
1740     config->sync();
1741 }
1742
1743 void MainWindow::readOptions()
1744 {
1745     KSharedConfigPtr config = KGlobal::config();
1746     m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1747     KConfigGroup initialGroup(config, "version");
1748     bool upgrade = false;
1749     if (initialGroup.exists()) {
1750         if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1751             upgrade = true;
1752         }
1753
1754         if (initialGroup.readEntry("version") == "0.7") {
1755             //Add new settings from 0.7.1
1756             if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1757                 QString path = QDir::homePath() + "/kdenlive";
1758                 if (KStandardDirs::makeDir(path)  == false) {
1759                     kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1760                 } else KdenliveSettings::setDefaultprojectfolder(path);
1761             }
1762         }
1763
1764     }
1765
1766     if (!initialGroup.exists() || upgrade) {
1767         // this is our first run, show Wizard
1768         Wizard *w = new Wizard(upgrade, this);
1769         if (w->exec() == QDialog::Accepted && w->isOk()) {
1770             w->adjustSettings();
1771             initialGroup.writeEntry("version", version);
1772             delete w;
1773         } else {
1774             ::exit(1);
1775         }
1776     }
1777     KConfigGroup treecolumns(config, "Project Tree");
1778     const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1779     if (!state.isEmpty())
1780         m_projectList->setHeaderInfo(state);
1781 }
1782
1783 void MainWindow::slotRunWizard()
1784 {
1785     Wizard *w = new Wizard(false, this);
1786     if (w->exec() == QDialog::Accepted && w->isOk()) {
1787         w->adjustSettings();
1788     }
1789     delete w;
1790 }
1791
1792 void MainWindow::newFile(bool showProjectSettings, bool force)
1793 {
1794     if (!m_timelineArea->isEnabled() && !force)
1795         return;
1796     m_fileRevert->setEnabled(false);
1797     QString profileName = KdenliveSettings::default_profile();
1798     KUrl projectFolder = KdenliveSettings::defaultprojectfolder();
1799     QMap <QString, QString> documentProperties;
1800     QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1801     if (!showProjectSettings) {
1802         // set up default properties
1803         documentProperties.insert("enableproxy", QString::number((int) KdenliveSettings::enableproxy()));
1804         documentProperties.insert("generateproxy", QString::number((int) KdenliveSettings::generateproxy()));
1805         documentProperties.insert("proxyminsize", QString::number(KdenliveSettings::proxyminsize()));
1806         documentProperties.insert("proxyparams", KdenliveSettings::proxyparams());
1807         documentProperties.insert("proxyextension", KdenliveSettings::proxyextension());
1808         documentProperties.insert("generateimageproxy", QString::number((int) KdenliveSettings::generateimageproxy()));
1809         documentProperties.insert("proxyimageminsize", QString::number(KdenliveSettings::proxyimageminsize()));
1810         if (!KdenliveSettings::activatetabs())
1811             if (!closeCurrentDocument())
1812                 return;
1813     } else {
1814         ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1815         if (w->exec() != QDialog::Accepted)
1816             return;
1817         if (!KdenliveSettings::activatetabs())
1818             if (!closeCurrentDocument())
1819                 return;
1820         if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs())
1821             slotSwitchVideoThumbs();
1822         if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs())
1823             slotSwitchAudioThumbs();
1824         profileName = w->selectedProfile();
1825         projectFolder = w->selectedFolder();
1826         projectTracks = w->tracks();
1827         documentProperties.insert("enableproxy", QString::number((int) w->useProxy()));
1828         documentProperties.insert("generateproxy", QString::number((int) w->generateProxy()));
1829         documentProperties.insert("proxyminsize", QString::number(w->proxyMinSize()));
1830         documentProperties.insert("proxyparams", w->proxyParams());
1831         documentProperties.insert("proxyextension", w->proxyExtension());
1832         documentProperties.insert("generateimageproxy", QString::number((int) w->generateImageProxy()));
1833         documentProperties.insert("proxyimageminsize", QString::number(w->proxyImageMinSize()));
1834         delete w;
1835     }
1836     m_timelineArea->setEnabled(true);
1837     m_projectList->setEnabled(true);
1838     
1839     KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, documentProperties, projectTracks, m_projectMonitor->render, m_notesWidget, this);
1840     doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1841     bool ok;
1842     TrackView *trackView = new TrackView(doc, &ok, this);
1843     m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1844     if (!ok) {
1845         // MLT is broken
1846         //m_timelineArea->setEnabled(false);
1847         //m_projectList->setEnabled(false);
1848         slotPreferences(6);
1849         return;
1850     }
1851     if (m_timelineArea->count() == 1) {
1852         connectDocumentInfo(doc);
1853         connectDocument(trackView, doc);
1854     } else
1855         m_timelineArea->setTabBarHidden(false);
1856     m_monitorManager->activateMonitor("clip");
1857     m_closeAction->setEnabled(m_timelineArea->count() > 1);
1858 }
1859
1860 void MainWindow::activateDocument()
1861 {
1862     if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1863     TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1864     KdenliveDoc *currentDoc = currentTab->document();
1865     connectDocumentInfo(currentDoc);
1866     connectDocument(currentTab, currentDoc);
1867 }
1868
1869 bool MainWindow::closeCurrentDocument(bool saveChanges)
1870 {
1871     QWidget *w = m_timelineArea->currentWidget();
1872     if (!w) return true;
1873     // closing current document
1874     int ix = m_timelineArea->currentIndex() + 1;
1875     if (ix == m_timelineArea->count()) ix = 0;
1876     m_timelineArea->setCurrentIndex(ix);
1877     TrackView *tabToClose = (TrackView *) w;
1878     KdenliveDoc *docToClose = tabToClose->document();
1879     if (docToClose && docToClose->isModified() && saveChanges) {
1880         QString message;
1881         if (m_activeDocument->url().fileName().isEmpty())
1882             message = i18n("Save changes to document?");
1883         else
1884             message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1885         switch (KMessageBox::warningYesNoCancel(this, message)) {
1886         case KMessageBox::Yes :
1887             // save document here. If saving fails, return false;
1888             if (saveFile() == false) return false;
1889             break;
1890         case KMessageBox::Cancel :
1891             return false;
1892             break;
1893         default:
1894             break;
1895         }
1896     }
1897     m_clipMonitor->slotSetXml(NULL);
1898     m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1899     if (m_timelineArea->count() == 1) {
1900         m_timelineArea->setTabBarHidden(true);
1901         m_closeAction->setEnabled(false);
1902     }
1903     if (docToClose == m_activeDocument) {
1904         delete m_activeDocument;
1905         m_activeDocument = NULL;
1906         m_effectStack->clear();
1907         m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1908     } else {
1909         delete docToClose;
1910     }
1911     if (w == m_activeTimeline) {
1912         delete m_activeTimeline;
1913         m_activeTimeline = NULL;
1914     } else {
1915         delete w;
1916     }
1917     return true;
1918 }
1919
1920 bool MainWindow::saveFileAs(const QString &outputFileName)
1921 {
1922     QString currentSceneList;
1923     m_monitorManager->stopActiveMonitor();
1924
1925     if (m_activeDocument->saveSceneList(outputFileName, m_projectMonitor->sceneList()) == false)
1926         return false;
1927
1928     // Save timeline thumbnails
1929     m_activeTimeline->projectView()->saveThumbnails();
1930     m_activeDocument->setUrl(KUrl(outputFileName));
1931     if (m_activeDocument->m_autosave == NULL) {
1932         m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1933     } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1934     setCaption(m_activeDocument->description());
1935     m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1936     m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1937     m_activeDocument->setModified(false);
1938     m_fileOpenRecent->addUrl(KUrl(outputFileName));
1939     m_fileRevert->setEnabled(true);
1940     return true;
1941 }
1942
1943 bool MainWindow::saveFileAs()
1944 {
1945     QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType());
1946     if (outputFile.isEmpty()) {
1947         return false;
1948     }
1949     if (QFile::exists(outputFile)) {
1950         // Show the file dialog again if the user does not want to overwrite the file
1951         if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", outputFile)) == KMessageBox::No)
1952             return saveFileAs();
1953     }
1954     return saveFileAs(outputFile);
1955 }
1956
1957 bool MainWindow::saveFile()
1958 {
1959     if (!m_activeDocument) return true;
1960     if (m_activeDocument->url().isEmpty()) {
1961         return saveFileAs();
1962     } else {
1963         bool result = saveFileAs(m_activeDocument->url().path());
1964         m_activeDocument->m_autosave->resize(0);
1965         return result;
1966     }
1967 }
1968
1969 void MainWindow::openFile()
1970 {
1971     if (!m_startUrl.isEmpty()) {
1972         openFile(m_startUrl);
1973         m_startUrl = KUrl();
1974         return;
1975     }
1976     KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
1977     if (url.isEmpty()) return;
1978     m_fileOpenRecent->addUrl(url);
1979     openFile(url);
1980 }
1981
1982 void MainWindow::openLastFile()
1983 {
1984     KSharedConfigPtr config = KGlobal::config();
1985     KUrl::List urls = m_fileOpenRecent->urls();
1986     //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1987     if (urls.isEmpty()) newFile(false);
1988     else openFile(urls.last());
1989 }
1990
1991 void MainWindow::openFile(const KUrl &url)
1992 {
1993     // Check if the document is already opened
1994     const int ct = m_timelineArea->count();
1995     bool isOpened = false;
1996     int i;
1997     for (i = 0; i < ct; i++) {
1998         TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1999         KdenliveDoc *doc = tab->document();
2000         if (doc->url() == url) {
2001             isOpened = true;
2002             break;
2003         }
2004     }
2005     if (isOpened) {
2006         m_timelineArea->setCurrentIndex(i);
2007         return;
2008     }
2009
2010     if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
2011
2012     // Check for backup file
2013     QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
2014     if (!staleFiles.isEmpty()) {
2015         if (KMessageBox::questionYesNo(this,
2016                                        i18n("Auto-saved files exist. Do you want to recover them now?"),
2017                                        i18n("File Recovery"),
2018                                        KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
2019             recoverFiles(staleFiles);
2020             return;
2021         } else {
2022             // remove the stale files
2023             foreach(KAutoSaveFile * stale, staleFiles) {
2024                 stale->open(QIODevice::ReadWrite);
2025                 delete stale;
2026             }
2027         }
2028     }
2029     m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
2030     m_messageLabel->repaint();
2031     doOpenFile(url, NULL);
2032 }
2033
2034 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
2035 {
2036     if (!m_timelineArea->isEnabled()) return;
2037     m_fileRevert->setEnabled(true);
2038
2039     // Recreate stopmotion widget on document change
2040     if (m_stopmotion) {
2041         delete m_stopmotion;
2042         m_stopmotion = NULL;
2043     }
2044
2045     KProgressDialog progressDialog(this, i18n("Loading project"), i18n("Loading project"));
2046     progressDialog.setAllowCancel(false);
2047     progressDialog.progressBar()->setMaximum(4);
2048     progressDialog.show();
2049     progressDialog.progressBar()->setValue(0);
2050     qApp->processEvents();
2051
2052     KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QMap <QString, QString> (), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, m_notesWidget, this, &progressDialog);
2053
2054     progressDialog.progressBar()->setValue(1);
2055     progressDialog.progressBar()->setMaximum(4);
2056     progressDialog.setLabelText(i18n("Loading project"));
2057     qApp->processEvents();
2058
2059     if (stale == NULL) {
2060         stale = new KAutoSaveFile(url, doc);
2061         doc->m_autosave = stale;
2062     } else {
2063         doc->m_autosave = stale;
2064         doc->setUrl(stale->managedFile());
2065         doc->setModified(true);
2066         stale->setParent(doc);
2067     }
2068     connectDocumentInfo(doc);
2069
2070     progressDialog.progressBar()->setValue(2);
2071     qApp->processEvents();
2072
2073     bool ok;
2074     TrackView *trackView = new TrackView(doc, &ok, this);
2075
2076     progressDialog.progressBar()->setValue(3);
2077     qApp->processEvents();
2078
2079     m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
2080     if (!ok) {
2081         m_timelineArea->setEnabled(false);
2082         m_projectList->setEnabled(false);
2083         KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
2084         slotGotProgressInfo(QString(), -1);
2085         newFile(false, true);
2086         return;
2087     }
2088     m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
2089     trackView->setDuration(trackView->duration());
2090     trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
2091
2092     if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
2093     slotGotProgressInfo(QString(), -1);
2094     m_projectMonitor->adjustRulerSize(trackView->duration());
2095     m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
2096     m_clipMonitor->refreshMonitor(true);
2097
2098     progressDialog.progressBar()->setValue(4);
2099 }
2100
2101 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
2102 {
2103     foreach(KAutoSaveFile * stale, staleFiles) {
2104         /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
2105                   // show an error message; we could not steal the lockfile
2106                   // maybe another application got to the file before us?
2107                   delete stale;
2108                   continue;
2109         }*/
2110         kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
2111         // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
2112         if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
2113         else KIO::NetAccess::del(KUrl(stale->fileName()), this);
2114     }
2115 }
2116
2117 void MainWindow::parseProfiles(const QString &mltPath)
2118 {
2119     //KdenliveSettings::setDefaulttmpfolder();
2120     if (!mltPath.isEmpty()) {
2121         KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
2122         KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
2123     }
2124
2125     if (KdenliveSettings::mltpath().isEmpty())
2126         KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
2127
2128     if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
2129         QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
2130         if (!QFile::exists(meltPath))
2131             meltPath = KStandardDirs::findExe("melt");
2132         KdenliveSettings::setRendererpath(meltPath);
2133     }
2134
2135     if (KdenliveSettings::rendererpath().isEmpty()) {
2136         // Cannot find the MLT melt renderer, ask for location
2137         KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
2138         if (getUrl->exec() == QDialog::Rejected) {
2139             ::exit(0);
2140         }
2141         KUrl rendererPath = getUrl->selectedUrl();
2142         delete getUrl;
2143         if (rendererPath.isEmpty()) ::exit(0);
2144         KdenliveSettings::setRendererpath(rendererPath.path());
2145     }
2146
2147     QStringList profilesFilter;
2148     profilesFilter << "*";
2149     QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2150     if (profilesList.isEmpty()) {
2151         // Cannot find MLT path, try finding melt
2152         QString profilePath = KdenliveSettings::rendererpath();
2153         if (!profilePath.isEmpty()) {
2154             profilePath = profilePath.section('/', 0, -3);
2155             KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
2156             profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2157         }
2158         if (profilesList.isEmpty()) {
2159             // Cannot find the MLT profiles, ask for location
2160             KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
2161             getUrl->fileDialog()->setMode(KFile::Directory);
2162             if (getUrl->exec() == QDialog::Rejected) {
2163                 ::exit(0);
2164             }
2165             KUrl mltPath = getUrl->selectedUrl();
2166             delete getUrl;
2167             if (mltPath.isEmpty()) ::exit(0);
2168             KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
2169             profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2170         }
2171     }
2172
2173     kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
2174
2175     // Parse again MLT profiles to build a list of available video formats
2176     if (profilesList.isEmpty()) parseProfiles();
2177 }
2178
2179
2180 void MainWindow::slotEditProfiles()
2181 {
2182     ProfilesDialog *w = new ProfilesDialog;
2183     if (w->exec() == QDialog::Accepted) {
2184         KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2185         if (d) d->checkProfile();
2186     }
2187     delete w;
2188 }
2189
2190 void MainWindow::slotDetectAudioDriver()
2191 {
2192     /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
2193     leading to no audio output, see bug #934 */
2194
2195     //decide which audio driver is really best, in some cases SDL is wrong
2196     if (KdenliveSettings::audiodrivername().isEmpty()) {
2197         QString driver;
2198         KProcess readProcess;
2199         //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
2200         if (!KStandardDirs::findExe("pactl").isEmpty()) {
2201             readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
2202             readProcess.setProgram("pactl", QStringList() << "stat");
2203             readProcess.execute(2000); // Kill it after 2 seconds
2204
2205             QString result = QString(readProcess.readAllStandardOutput());
2206             kDebug() << "// / / / / / READING PACTL: ";
2207             kDebug() << result;
2208             if (!result.isEmpty()) {
2209                 driver = "pulse";
2210                 kDebug() << "// / / / / PULSEAUDIO DETECTED";
2211             }
2212         }
2213         //put others here
2214         KdenliveSettings::setAutoaudiodrivername(driver);
2215     }
2216 }
2217
2218 void MainWindow::slotEditProjectSettings()
2219 {
2220     QPoint p = m_activeDocument->getTracksCount();
2221     ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
2222
2223     if (w->exec() == QDialog::Accepted) {
2224         QString profile = w->selectedProfile();
2225         m_activeDocument->setProjectFolder(w->selectedFolder());
2226 #ifndef   Q_WS_MAC
2227         m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2228 #endif
2229         if (m_renderWidget) m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2230         if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
2231         if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
2232         if (m_activeDocument->profilePath() != profile) slotUpdateProjectProfile(profile);
2233         if (m_activeDocument->getDocumentProperty("proxyparams") != w->proxyParams()) {
2234             m_activeDocument->setModified();
2235             m_activeDocument->setDocumentProperty("proxyparams", w->proxyParams());
2236             if (m_activeDocument->clipManager()->clipsCount() > 0 && KMessageBox::questionYesNo(this, i18n("You have changed the proxy parameters. Do you want to recreate all proxy clips for this project?")) == KMessageBox::Yes) {
2237                 //TODO: rebuild all proxies
2238                 //m_activeDocument->rebuildAllProxies();
2239             }
2240         }
2241         if (m_activeDocument->getDocumentProperty("proxyextension") != w->proxyExtension()) {
2242             m_activeDocument->setModified();
2243             m_activeDocument->setDocumentProperty("proxyextension", w->proxyExtension());
2244         }
2245         if (m_activeDocument->getDocumentProperty("generateproxy") != QString::number((int) w->generateProxy())) {
2246             m_activeDocument->setModified();
2247             m_activeDocument->setDocumentProperty("generateproxy", QString::number((int) w->generateProxy()));
2248         }
2249         if (m_activeDocument->getDocumentProperty("proxyminsize") != QString::number(w->proxyMinSize())) {
2250             m_activeDocument->setModified();
2251             m_activeDocument->setDocumentProperty("proxyminsize", QString::number(w->proxyMinSize()));
2252         }
2253         if (m_activeDocument->getDocumentProperty("generateimageproxy") != QString::number((int) w->generateImageProxy())) {
2254             m_activeDocument->setModified();
2255             m_activeDocument->setDocumentProperty("generateimageproxy", QString::number((int) w->generateImageProxy()));
2256         }
2257         if (m_activeDocument->getDocumentProperty("proxyimageminsize") != QString::number(w->proxyImageMinSize())) {
2258             m_activeDocument->setModified();
2259             m_activeDocument->setDocumentProperty("proxyimageminsize", QString::number(w->proxyImageMinSize()));
2260         }
2261         if (QString::number((int) w->useProxy()) != m_activeDocument->getDocumentProperty("enableproxy")) {
2262             m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) w->useProxy()));
2263             m_activeDocument->setModified();
2264             slotUpdateProxySettings();
2265         }
2266     }
2267     delete w;
2268 }
2269
2270 void MainWindow::slotUpdateProjectProfile(const QString &profile)
2271 {
2272     double dar = m_activeDocument->dar();
2273
2274     // Recreate the stopmotion widget if profile changes
2275     if (m_stopmotion) {
2276         delete m_stopmotion;
2277         m_stopmotion = NULL;
2278     }
2279
2280     // Deselect current effect / transition
2281     m_effectStack->slotClipItemSelected(NULL, 0);
2282     m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
2283     m_clipMonitor->slotSetXml(NULL);
2284     bool updateFps = m_activeDocument->setProfilePath(profile);
2285     KdenliveSettings::setCurrent_profile(profile);
2286     KdenliveSettings::setProject_fps(m_activeDocument->fps());
2287     setCaption(m_activeDocument->description(), m_activeDocument->isModified());
2288
2289     m_activeDocument->clipManager()->clearUnusedProducers();
2290     m_monitorManager->resetProfiles(m_activeDocument->timecode());
2291     m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2292     m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
2293     m_projectList->updateProjectFormat(m_activeDocument->timecode());
2294     if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
2295     m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
2296     //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
2297     if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
2298     if (updateFps) m_activeTimeline->updateProjectFps();
2299     m_activeDocument->setModified(true);
2300     m_commandStack->activeStack()->clear();
2301     //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2302     slotUpdateMousePosition(0);
2303     // We need to desactivate & reactivate monitors to get a refresh
2304     //m_monitorManager->switchMonitors();
2305 }
2306
2307
2308 void MainWindow::slotRenderProject()
2309 {
2310     if (!m_renderWidget) {
2311         QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
2312         m_renderWidget = new RenderWidget(projectfolder, m_projectList->useProxy(), this);
2313         connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
2314         connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
2315         connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
2316         connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
2317         connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
2318         if (m_activeDocument) {
2319             m_renderWidget->setProfile(m_activeDocument->mltProfile());
2320             m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2321             m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2322             m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
2323         }
2324     }
2325     slotCheckRenderStatus();
2326     m_renderWidget->show();
2327     m_renderWidget->showNormal();
2328
2329     // What are the following lines supposed to do?
2330     //m_activeTimeline->tracksNumber();
2331     //m_renderWidget->enableAudio(false);
2332     //m_renderWidget->export_audio;
2333 }
2334
2335 void MainWindow::slotCheckRenderStatus()
2336 {
2337     // Make sure there are no missing clips
2338     if (m_renderWidget)
2339         m_renderWidget->missingClips(m_projectList->hasMissingClips());
2340 }
2341
2342 void MainWindow::setRenderingProgress(const QString &url, int progress)
2343 {
2344     if (m_renderWidget)
2345         m_renderWidget->setRenderJob(url, progress);
2346 }
2347
2348 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2349 {
2350     if (m_renderWidget)
2351         m_renderWidget->setRenderStatus(url, status, error);
2352 }
2353
2354 void MainWindow::slotCleanProject()
2355 {
2356     if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2357     m_projectList->cleanup();
2358 }
2359
2360 void MainWindow::slotUpdateMousePosition(int pos)
2361 {
2362     if (m_activeDocument)
2363         switch (m_timecodeFormat->currentIndex()) {
2364         case 0:
2365             statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2366             break;
2367         default:
2368             statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2369         }
2370 }
2371
2372 void MainWindow::slotUpdateDocumentState(bool modified)
2373 {
2374     if (!m_activeDocument) return;
2375     setCaption(m_activeDocument->description(), modified);
2376     m_saveAction->setEnabled(modified);
2377     if (modified) {
2378         m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2379         m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2380     } else {
2381         m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2382         m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2383     }
2384 }
2385
2386 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2387 {
2388     if (m_activeDocument) {
2389         if (m_activeDocument == doc) return;
2390         disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2391     }
2392     connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2393 }
2394
2395 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //changed
2396 {
2397     //m_projectMonitor->stop();
2398     m_closeAction->setEnabled(m_timelineArea->count() > 1);
2399     kDebug() << "///////////////////   CONNECTING DOC TO PROJECT VIEW ////////////////";
2400     if (m_activeDocument) {
2401         if (m_activeDocument == doc) return;
2402         if (m_activeTimeline) {
2403             disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2404             disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2405             disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2406             disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2407             disconnect(m_notesWidget, SIGNAL(textChanged()), m_activeDocument, SLOT(setModified()));
2408             disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2409             disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2410             disconnect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2411
2412             disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
2413
2414             disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2415             disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2416             disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2417             disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2418             disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2419             disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2420             disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
2421             disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2422             disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2423             disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2424             disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2425             disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2426             disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2427             disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2428             disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2429             disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2430             disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2431             disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2432             disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2433             disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2434             disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2435             disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2436             disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2437             disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2438             disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2439             disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2440             disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2441             disconnect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2442             disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2443             disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2444             disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2445             disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2446             disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2447             disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2448             disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2449             disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2450             disconnect(m_projectList, SIGNAL(refreshClip(const QString &)), m_activeTimeline->projectView(), SLOT(slotRefreshThumbs(const QString &)));
2451             m_effectStack->clear();
2452         }
2453         //m_activeDocument->setRenderer(NULL);
2454         disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
2455         disconnect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
2456         m_clipMonitor->stop();
2457     }
2458     KdenliveSettings::setCurrent_profile(doc->profilePath());
2459     KdenliveSettings::setProject_fps(doc->fps());
2460     m_monitorManager->resetProfiles(doc->timecode());
2461     m_projectList->setDocument(doc);
2462     m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2463     m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2464     connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint)));
2465     connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
2466     connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), trackView->projectView(), SLOT(slotRefreshThumbs(const QString &, bool)));
2467     connect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), trackView->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2468
2469     connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2470     connect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2471     connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2472
2473     connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
2474
2475
2476     connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2477     connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2478     connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2479     connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2480     connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2481     connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2482     connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
2483     connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2484     connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2485     connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
2486     connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2487     connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2488     connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2489     connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
2490
2491     connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2492     connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2493     connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2494     connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2495     connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2496
2497     connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
2498     connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2499     connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2500     connect(m_notesWidget, SIGNAL(textChanged()), doc, SLOT(setModified()));
2501
2502     connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2503     connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2504     connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), m_effectStack, SLOT(slotTrackItemSelected(int, TrackInfo)));
2505     connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotActivateEffectStackView()));
2506
2507     connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2508     connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2509     connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2510     m_zoomSlider->setValue(doc->zoom().x());
2511     connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2512     connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2513     connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2514     connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2515
2516     connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2517     connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2518
2519     connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2520     connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2521
2522     connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2523     connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2524     connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2525     connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2526     connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2527     connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2528     connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2529     connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2530     connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2531     connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2532     connect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2533
2534     connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2535     connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2536     connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2537     connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2538     connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2539
2540
2541     trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2542     m_activeTimeline = trackView;
2543     if (m_renderWidget) {
2544         slotCheckRenderStatus();
2545         m_renderWidget->setProfile(doc->mltProfile());
2546         m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2547         m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2548         m_renderWidget->setRenderProfile(doc->getRenderProperties());
2549     }
2550     //doc->setRenderer(m_projectMonitor->render);
2551     m_commandStack->setActiveStack(doc->commandStack());
2552     KdenliveSettings::setProject_display_ratio(doc->dar());
2553     //doc->clipManager()->checkAudioThumbs();
2554
2555     //m_overView->setScene(trackView->projectScene());
2556     //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2557     //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2558
2559     setCaption(doc->description(), doc->isModified());
2560     m_saveAction->setEnabled(doc->isModified());
2561     m_normalEditTool->setChecked(true);
2562     m_activeDocument = doc;
2563     m_activeTimeline->updateProjectFps();
2564     m_activeDocument->checkProjectClips();
2565 #ifndef   Q_WS_MAC
2566     m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2567 #endif
2568     //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2569     slotUpdateMousePosition(0);
2570     // set tool to select tool
2571     m_buttonSelectTool->setChecked(true);
2572 }
2573
2574 void MainWindow::slotZoneMoved(int start, int end)
2575 {
2576     m_activeDocument->setZone(start, end);
2577     m_projectMonitor->slotZoneMoved(start, end);
2578 }
2579
2580 void MainWindow::slotGuidesUpdated()
2581 {
2582     if (m_renderWidget)
2583         m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2584 }
2585
2586 void MainWindow::slotEditKeys()
2587 {
2588     KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2589     dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2590     dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2591     dialog.configure();
2592 }
2593
2594 void MainWindow::slotPreferences(int page, int option)
2595 {
2596     /*
2597      * An instance of your dialog could be already created and could be
2598      * cached, in which case you want to display the cached dialog
2599      * instead of creating another one
2600      */
2601     if (m_stopmotion) m_stopmotion->slotLive(false);
2602     if (KConfigDialog::showDialog("settings")) {
2603         KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2604         if (page != -1) d->showPage(page, option);
2605         return;
2606     }
2607
2608     // KConfigDialog didn't find an instance of this dialog, so lets
2609     // create it :
2610     
2611     // Get the mappable actions in localized form
2612     QMap<QString, QString> actions;
2613     KActionCollection* collection = actionCollection();
2614     foreach (const QString& action_name, m_action_names) {
2615         actions[collection->action(action_name)->text()] = action_name;
2616     }
2617     
2618     KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(actions, this);
2619     connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2620     connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2621 #ifndef Q_WS_MAC
2622     connect(dialog, SIGNAL(updateCaptureFolder()), this, SLOT(slotUpdateCaptureFolder()));
2623 #endif
2624     dialog->show();
2625     if (page != -1) dialog->showPage(page, option);
2626 }
2627
2628 void MainWindow::slotUpdateCaptureFolder()
2629 {
2630
2631 #ifndef   Q_WS_MAC
2632     if (m_activeDocument) m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2633     else m_recMonitor->slotUpdateCaptureFolder(KdenliveSettings::defaultprojectfolder());
2634 #endif
2635 }
2636
2637 void MainWindow::updateConfiguration()
2638 {
2639     //TODO: we should apply settings to all projects, not only the current one
2640     if (m_activeTimeline) {
2641         m_activeTimeline->refresh();
2642         m_activeTimeline->projectView()->checkAutoScroll();
2643         m_activeTimeline->projectView()->checkTrackHeight();
2644         if (m_activeDocument)
2645             m_activeDocument->clipManager()->checkAudioThumbs();
2646     }
2647     m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2648     m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2649     m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2650     m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2651
2652     // Update list of transcoding profiles
2653     loadTranscoders();
2654 #ifndef NO_JOGSHUTTLE
2655     activateShuttleDevice();
2656 #endif /* NO_JOGSHUTTLE */
2657
2658 }
2659
2660 void MainWindow::slotSwitchSplitAudio()
2661 {
2662     KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2663     m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2664 }
2665
2666 void MainWindow::slotSwitchVideoThumbs()
2667 {
2668     KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2669     if (m_activeTimeline)
2670         m_activeTimeline->projectView()->slotUpdateAllThumbs();
2671     m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2672 }
2673
2674 void MainWindow::slotSwitchAudioThumbs()
2675 {
2676     KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2677     if (m_activeTimeline) {
2678         m_activeTimeline->refresh();
2679         m_activeTimeline->projectView()->checkAutoScroll();
2680         if (m_activeDocument)
2681             m_activeDocument->clipManager()->checkAudioThumbs();
2682     }
2683     m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2684 }
2685
2686 void MainWindow::slotSwitchMarkersComments()
2687 {
2688     KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2689     if (m_activeTimeline)
2690         m_activeTimeline->refresh();
2691     m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2692 }
2693
2694 void MainWindow::slotSwitchSnap()
2695 {
2696     KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2697     m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2698 }
2699
2700
2701 void MainWindow::slotDeleteItem()
2702 {
2703     if (QApplication::focusWidget() &&
2704             QApplication::focusWidget()->parentWidget() &&
2705             QApplication::focusWidget()->parentWidget()->parentWidget() &&
2706             QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2707         m_projectList->slotRemoveClip();
2708
2709     } else {
2710         QWidget *widget = QApplication::focusWidget();
2711         while (widget) {
2712             if (widget == m_effectStackDock) {
2713                 m_effectStack->slotItemDel();
2714                 return;
2715             }
2716             widget = widget->parentWidget();
2717         }
2718
2719         // effect stack has no focus
2720         if (m_activeTimeline)
2721             m_activeTimeline->projectView()->deleteSelectedClips();
2722     }
2723 }
2724
2725 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2726 {
2727     if (m_clipMonitor->isActive())
2728         m_clipMonitor->checkOverlay();
2729     m_clipMonitor->updateMarkers(clip);
2730 }
2731
2732 void MainWindow::slotAddClipMarker()
2733 {
2734     DocClipBase *clip = NULL;
2735     GenTime pos;
2736     if (m_projectMonitor->isActive()) {
2737         if (m_activeTimeline) {
2738             ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2739             if (item) {
2740                 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2741                 clip = item->baseClip();
2742             }
2743         }
2744     } else {
2745         clip = m_clipMonitor->activeClip();
2746         pos = m_clipMonitor->position();
2747     }
2748     if (!clip) {
2749         m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2750         return;
2751     }
2752     QString id = clip->getId();
2753     CommentedTime marker(pos, i18n("Marker"));
2754     MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2755     if (d.exec() == QDialog::Accepted)
2756         m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2757 }
2758
2759 void MainWindow::slotDeleteClipMarker()
2760 {
2761     DocClipBase *clip = NULL;
2762     GenTime pos;
2763     if (m_projectMonitor->isActive()) {
2764         if (m_activeTimeline) {
2765             ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2766             if (item) {
2767                 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2768                 clip = item->baseClip();
2769             }
2770         }
2771     } else {
2772         clip = m_clipMonitor->activeClip();
2773         pos = m_clipMonitor->position();
2774     }
2775     if (!clip) {
2776         m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2777         return;
2778     }
2779
2780     QString id = clip->getId();
2781     QString comment = clip->markerComment(pos);
2782     if (comment.isEmpty()) {
2783         m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2784         return;
2785     }
2786     m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2787 }
2788
2789 void MainWindow::slotDeleteAllClipMarkers()
2790 {
2791     DocClipBase *clip = NULL;
2792     if (m_projectMonitor->isActive()) {
2793         if (m_activeTimeline) {
2794             ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2795             if (item) {
2796                 clip = item->baseClip();
2797             }
2798         }
2799     } else {
2800         clip = m_clipMonitor->activeClip();
2801     }
2802     if (!clip) {
2803         m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2804         return;
2805     }
2806     m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2807 }
2808
2809 void MainWindow::slotEditClipMarker()
2810 {
2811     DocClipBase *clip = NULL;
2812     GenTime pos;
2813     if (m_projectMonitor->isActive()) {
2814         if (m_activeTimeline) {
2815             ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2816             if (item) {
2817                 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2818                 clip = item->baseClip();
2819             }
2820         }
2821     } else {
2822         clip = m_clipMonitor->activeClip();
2823         pos = m_clipMonitor->position();
2824     }
2825     if (!clip) {
2826         m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2827         return;
2828     }
2829
2830     QString id = clip->getId();
2831     QString oldcomment = clip->markerComment(pos);
2832     if (oldcomment.isEmpty()) {
2833         m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2834         return;
2835     }
2836
2837     CommentedTime marker(pos, oldcomment);
2838     MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2839     if (d.exec() == QDialog::Accepted) {
2840         m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2841         if (d.newMarker().time() != pos) {
2842             // remove old marker
2843             m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2844         }
2845     }
2846 }
2847
2848 void MainWindow::slotAddMarkerGuideQuickly()
2849 {
2850     if (!m_activeTimeline || !m_activeDocument)
2851         return;
2852
2853     if (m_clipMonitor->isActive()) {
2854         DocClipBase *clip = m_clipMonitor->activeClip();
2855         GenTime pos = m_clipMonitor->position();
2856
2857         if (!clip) {
2858             m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2859             return;
2860         }
2861
2862         m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), pos, m_activeDocument->timecode().getDisplayTimecode(pos, false));
2863     } else {
2864         m_activeTimeline->projectView()->slotAddGuide(false);
2865     }
2866 }
2867
2868 void MainWindow::slotAddGuide()
2869 {
2870     if (m_activeTimeline)
2871         m_activeTimeline->projectView()->slotAddGuide();
2872 }
2873
2874 void MainWindow::slotInsertSpace()
2875 {
2876     if (m_activeTimeline)
2877         m_activeTimeline->projectView()->slotInsertSpace();
2878 }
2879
2880 void MainWindow::slotRemoveSpace()
2881 {
2882     if (m_activeTimeline)
2883         m_activeTimeline->projectView()->slotRemoveSpace();
2884 }
2885
2886 void MainWindow::slotInsertTrack(int ix)
2887 {
2888     m_projectMonitor->activateMonitor();
2889     if (m_activeTimeline)
2890         m_activeTimeline->projectView()->slotInsertTrack(ix);
2891     if (m_activeDocument)
2892         m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2893 }
2894
2895 void MainWindow::slotDeleteTrack(int ix)
2896 {
2897     m_projectMonitor->activateMonitor();
2898     if (m_activeTimeline)
2899         m_activeTimeline->projectView()->slotDeleteTrack(ix);
2900     if (m_activeDocument)
2901         m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2902 }
2903
2904 void MainWindow::slotConfigTrack(int ix)
2905 {
2906     m_projectMonitor->activateMonitor();
2907     if (m_activeTimeline)
2908         m_activeTimeline->projectView()->slotConfigTracks(ix);
2909     if (m_activeDocument)
2910         m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2911 }
2912
2913 void MainWindow::slotEditGuide()
2914 {
2915     if (m_activeTimeline)
2916         m_activeTimeline->projectView()->slotEditGuide();
2917 }
2918
2919 void MainWindow::slotDeleteGuide()
2920 {
2921     if (m_activeTimeline)
2922         m_activeTimeline->projectView()->slotDeleteGuide();
2923 }
2924
2925 void MainWindow::slotDeleteAllGuides()
2926 {
2927     if (m_activeTimeline)
2928         m_activeTimeline->projectView()->slotDeleteAllGuides();
2929 }
2930
2931 void MainWindow::slotCutTimelineClip()
2932 {
2933     if (m_activeTimeline)
2934         m_activeTimeline->projectView()->cutSelectedClips();
2935 }
2936
2937 void MainWindow::slotInsertClipOverwrite()
2938 {
2939     if (m_activeTimeline) {
2940         QStringList data = m_clipMonitor->getZoneInfo();
2941         m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2942     }
2943 }
2944
2945 void MainWindow::slotSelectTimelineClip()
2946 {
2947     if (m_activeTimeline)
2948         m_activeTimeline->projectView()->selectClip(true);
2949 }
2950
2951 void MainWindow::slotSelectTimelineTransition()
2952 {
2953     if (m_activeTimeline)
2954         m_activeTimeline->projectView()->selectTransition(true);
2955 }
2956
2957 void MainWindow::slotDeselectTimelineClip()
2958 {
2959     if (m_activeTimeline)
2960         m_activeTimeline->projectView()->selectClip(false, true);
2961 }
2962
2963 void MainWindow::slotDeselectTimelineTransition()
2964 {
2965     if (m_activeTimeline)
2966         m_activeTimeline->projectView()->selectTransition(false, true);
2967 }
2968
2969 void MainWindow::slotSelectAddTimelineClip()
2970 {
2971     if (m_activeTimeline)
2972         m_activeTimeline->projectView()->selectClip(true, true);
2973 }
2974
2975 void MainWindow::slotSelectAddTimelineTransition()
2976 {
2977     if (m_activeTimeline)
2978         m_activeTimeline->projectView()->selectTransition(true, true);
2979 }
2980
2981 void MainWindow::slotGroupClips()
2982 {
2983     if (m_activeTimeline)
2984         m_activeTimeline->projectView()->groupClips();
2985 }
2986
2987 void MainWindow::slotUnGroupClips()
2988 {
2989     if (m_activeTimeline)
2990         m_activeTimeline->projectView()->groupClips(false);
2991 }
2992
2993 void MainWindow::slotEditItemDuration()
2994 {
2995     if (m_activeTimeline)
2996         m_activeTimeline->projectView()->editItemDuration();
2997 }
2998
2999 void MainWindow::slotAddProjectClip(KUrl url)
3000 {
3001     if (m_activeDocument)
3002         m_activeDocument->slotAddClipFile(url, QString());
3003 }
3004
3005 void MainWindow::slotAddTransition(QAction *result)
3006 {
3007     if (!result) return;
3008     QStringList info = result->data().toStringList();
3009     if (info.isEmpty()) return;
3010     QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
3011     if (m_activeTimeline && !transition.isNull()) {
3012         m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
3013     }
3014 }
3015
3016 void MainWindow::slotAddVideoEffect(QAction *result)
3017 {
3018     if (!result) return;
3019     QStringList info = result->data().toStringList();
3020     if (info.isEmpty()) return;
3021     QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
3022     slotAddEffect(effect);
3023 }
3024
3025 void MainWindow::slotAddAudioEffect(QAction *result)
3026 {
3027     if (!result) return;
3028     QStringList info = result->data().toStringList();
3029     if (info.isEmpty()) return;
3030     QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
3031     slotAddEffect(effect);
3032 }
3033
3034 void MainWindow::slotAddCustomEffect(QAction *result)
3035 {
3036     if (!result) return;
3037     QStringList info = result->data().toStringList();
3038     if (info.isEmpty()) return;
3039     QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
3040     slotAddEffect(effect);
3041 }
3042
3043 void MainWindow::slotZoomIn()
3044 {
3045     m_zoomSlider->setValue(m_zoomSlider->value() - 1);
3046     slotShowZoomSliderToolTip();
3047 }
3048
3049 void MainWindow::slotZoomOut()
3050 {
3051     m_zoomSlider->setValue(m_zoomSlider->value() + 1);
3052     slotShowZoomSliderToolTip();
3053 }
3054
3055 void MainWindow::slotFitZoom()
3056 {
3057     if (m_activeTimeline)
3058         m_zoomSlider->setValue(m_activeTimeline->fitZoom());
3059 }
3060
3061 void MainWindow::slotSetZoom(int value)
3062 {
3063     value = qMax(m_zoomSlider->minimum(), value);
3064     value = qMin(m_zoomSlider->maximum(), value);
3065
3066     if (m_activeTimeline)
3067         m_activeTimeline->slotChangeZoom(value);
3068
3069     m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
3070     m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
3071     slotUpdateZoomSliderToolTip(value);
3072
3073     m_zoomSlider->blockSignals(true);
3074     m_zoomSlider->setValue(value);
3075     m_zoomSlider->blockSignals(false);
3076 }
3077
3078 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
3079 {
3080     if (zoomlevel != -1)
3081         slotUpdateZoomSliderToolTip(zoomlevel);
3082
3083     QPoint global = m_zoomSlider->rect().topLeft();
3084     global.ry() += m_zoomSlider->height() / 2;
3085     QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
3086     QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
3087 }
3088
3089 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
3090 {
3091     m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
3092 }
3093
3094 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
3095 {
3096     m_statusProgressBar->setValue(progress);
3097     if (progress >= 0) {
3098         if (!message.isEmpty())
3099             m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
3100         m_statusProgressBar->setVisible(true);
3101     } else if (progress == -2) {
3102         if (!message.isEmpty())
3103             m_messageLabel->setMessage(message, ErrorMessage);
3104         m_statusProgressBar->setVisible(false);
3105     } else {
3106         m_messageLabel->setMessage(QString(), DefaultMessage);
3107         m_statusProgressBar->setVisible(false);
3108     }
3109 }
3110
3111 void MainWindow::slotShowClipProperties(DocClipBase *clip)
3112 {
3113     if (clip->clipType() == TEXT) {
3114         QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
3115         if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
3116             // template text clip
3117
3118             // Get the list of existing templates
3119             QStringList filter;
3120             filter << "*.kdenlivetitle";
3121             QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
3122
3123             QDialog *dia = new QDialog(this);
3124             Ui::TemplateClip_UI dia_ui;
3125             dia_ui.setupUi(dia);
3126             int ix = -1;
3127             const QString templatePath = clip->getProperty("resource");
3128             for (int i = 0; i < templateFiles.size(); ++i) {
3129                 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
3130                 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
3131             }
3132             if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
3133             else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
3134             dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
3135             //warning: setting base directory doesn't work??
3136             KUrl startDir(titlepath);
3137             dia_ui.template_list->fileDialog()->setUrl(startDir);
3138             dia_ui.description->setText(clip->getProperty("description"));
3139             if (dia->exec() == QDialog::Accepted) {
3140                 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
3141                 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
3142
3143                 QMap <QString, QString> newprops;
3144
3145                 if (KUrl(textTemplate).path() != templatePath) {
3146                     // The template was changed
3147                     newprops.insert("resource", textTemplate);
3148                 }
3149
3150                 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
3151                     newprops.insert("description", dia_ui.description->toPlainText());
3152                 }
3153
3154                 QString newtemplate = newprops.value("xmltemplate");
3155                 if (newtemplate.isEmpty()) newtemplate = templatePath;
3156
3157                 // template modified we need to update xmldata
3158                 QString description = newprops.value("description");
3159                 if (description.isEmpty()) description = clip->getProperty("description");
3160                 else newprops.insert("templatetext", description);
3161                 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
3162                 if (!newprops.isEmpty()) {
3163                     EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3164                     m_activeDocument->commandStack()->push(command);
3165                 }
3166             }
3167             delete dia;
3168             return;
3169         }
3170         QString path = clip->getProperty("resource");
3171         TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
3172         QDomDocument doc;
3173         doc.setContent(clip->getProperty("xmldata"));
3174         dia_ui->setXml(doc);
3175         if (dia_ui->exec() == QDialog::Accepted) {
3176             QMap <QString, QString> newprops;
3177             newprops.insert("xmldata", dia_ui->xml().toString());
3178             if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
3179                 // duration changed, we need to update duration
3180                 newprops.insert("out", QString::number(dia_ui->outPoint()));
3181                 int currentLength = QString(clip->producerProperty("length")).toInt();
3182                 if (currentLength <= dia_ui->outPoint())
3183                         newprops.insert("length", QString::number(dia_ui->outPoint() + 1));
3184                 else newprops.insert("length", clip->producerProperty("length"));
3185             }
3186             if (!path.isEmpty()) {
3187                 // we are editing an external file, asked if we want to detach from that file or save the result to that title file.
3188                 if (KMessageBox::questionYesNo(this, i18n("You are editing an external title clip (%1). Do you want to save your changes to the title file or save the changes for this project only?", path), i18n("Save Title"), KGuiItem(i18n("Save to title file")), KGuiItem(i18n("Save in project only"))) == KMessageBox::Yes) {
3189                     // save to external file
3190                     dia_ui->saveTitle(path);
3191                 } else newprops.insert("resource", QString());
3192             }
3193             EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3194             m_activeDocument->commandStack()->push(command);
3195             //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
3196             m_activeDocument->setModified(true);
3197         }
3198         delete dia_ui;
3199
3200         //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
3201         return;
3202     }
3203
3204     // any type of clip but a title
3205     ClipProperties *dia = new ClipProperties(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
3206     connect(dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
3207     connect(dia, SIGNAL(applyNewClipProperties(const QString, QMap <QString, QString> , QMap <QString, QString> , bool, bool)), this, SLOT(slotApplyNewClipProperties(const QString, QMap <QString, QString> , QMap <QString, QString> , bool, bool)));
3208     dia->show();
3209 }
3210
3211
3212 void MainWindow::slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload)
3213 {
3214     if (newprops.isEmpty()) return;
3215     EditClipCommand *command = new EditClipCommand(m_projectList, id, props, newprops, true);
3216     m_activeDocument->commandStack()->push(command);
3217     m_activeDocument->setModified();
3218
3219     if (refresh) {
3220         // update clip occurences in timeline
3221         m_activeTimeline->projectView()->slotUpdateClip(id, reload);
3222     }
3223 }
3224
3225
3226 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
3227 {
3228     ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
3229     if (dia.exec() == QDialog::Accepted) {
3230         QUndoCommand *command = new QUndoCommand();
3231         command->setText(i18n("Edit clips"));
3232         QMap <QString, QString> newImageProps = dia.properties();
3233         // Transparency setting applies only for images
3234         QMap <QString, QString> newProps = newImageProps;
3235         newProps.remove("transparency");
3236
3237         for (int i = 0; i < cliplist.count(); i++) {
3238             DocClipBase *clip = cliplist.at(i);
3239             if (clip->clipType() == IMAGE)
3240                 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newImageProps, true, command);
3241             else 
3242                 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newProps, true, command);
3243         }
3244         m_activeDocument->commandStack()->push(command);
3245         for (int i = 0; i < cliplist.count(); i++)
3246             m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
3247     }
3248 }
3249
3250 void MainWindow::customEvent(QEvent* e)
3251 {
3252     if (e->type() == QEvent::User)
3253         m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
3254 }
3255 void MainWindow::slotActivateEffectStackView()
3256 {
3257     m_effectStack->raiseWindow(m_effectStackDock);
3258 }
3259
3260 void MainWindow::slotActivateTransitionView(Transition *t)
3261 {
3262     if (t)
3263         m_transitionConfig->raiseWindow(m_transitionConfigDock);
3264 }
3265
3266 void MainWindow::slotSnapRewind()
3267 {
3268     if (m_projectMonitor->isActive()) {
3269         if (m_activeTimeline)
3270             m_activeTimeline->projectView()->slotSeekToPreviousSnap();
3271     } else  {
3272         m_clipMonitor->slotSeekToPreviousSnap();
3273     }
3274 }
3275
3276 void MainWindow::slotSnapForward()
3277 {
3278     if (m_projectMonitor->isActive()) {
3279         if (m_activeTimeline)
3280             m_activeTimeline->projectView()->slotSeekToNextSnap();
3281     } else {
3282         m_clipMonitor->slotSeekToNextSnap();
3283     }
3284 }
3285
3286 void MainWindow::slotClipStart()
3287 {
3288     if (m_projectMonitor->isActive()) {
3289         if (m_activeTimeline)
3290             m_activeTimeline->projectView()->clipStart();
3291     }
3292 }
3293
3294 void MainWindow::slotClipEnd()
3295 {
3296     if (m_projectMonitor->isActive()) {
3297         if (m_activeTimeline)
3298             m_activeTimeline->projectView()->clipEnd();
3299     }
3300 }
3301
3302 void MainWindow::slotZoneStart()
3303 {
3304     if (m_projectMonitor->isActive())
3305         m_projectMonitor->slotZoneStart();
3306     else
3307         m_clipMonitor->slotZoneStart();
3308 }
3309
3310 void MainWindow::slotZoneEnd()
3311 {
3312     if (m_projectMonitor->isActive())
3313         m_projectMonitor->slotZoneEnd();
3314     else
3315         m_clipMonitor->slotZoneEnd();
3316 }
3317
3318 void MainWindow::slotChangeTool(QAction * action)
3319 {
3320     if (action == m_buttonSelectTool)
3321         slotSetTool(SELECTTOOL);
3322     else if (action == m_buttonRazorTool)
3323         slotSetTool(RAZORTOOL);
3324     else if (action == m_buttonSpacerTool)
3325         slotSetTool(SPACERTOOL);
3326 }
3327
3328 void MainWindow::slotChangeEdit(QAction * action)
3329 {
3330     if (!m_activeTimeline)
3331         return;
3332
3333     if (action == m_overwriteEditTool)
3334         m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
3335     else if (action == m_insertEditTool)
3336         m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
3337     else
3338         m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
3339 }
3340
3341 void MainWindow::slotSetTool(PROJECTTOOL tool)
3342 {
3343     if (m_activeDocument && m_activeTimeline) {
3344         //m_activeDocument->setTool(tool);
3345         QString message;
3346         switch (tool)  {
3347         case SPACERTOOL:
3348             message = i18n("Ctrl + click to use spacer on current track only");
3349             break;
3350         case RAZORTOOL:
3351             message = i18n("Click on a clip to cut it");
3352             break;
3353         default:
3354             message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
3355             break;
3356         }
3357         m_messageLabel->setMessage(message, InformationMessage);
3358         m_activeTimeline->projectView()->setTool(tool);
3359     }
3360 }
3361
3362 void MainWindow::slotCopy()
3363 {
3364     if (m_activeDocument && m_activeTimeline)
3365         m_activeTimeline->projectView()->copyClip();
3366 }
3367
3368 void MainWindow::slotPaste()
3369 {
3370     if (m_activeDocument && m_activeTimeline)
3371         m_activeTimeline->projectView()->pasteClip();
3372 }
3373
3374 void MainWindow::slotPasteEffects()
3375 {
3376     if (m_activeDocument && m_activeTimeline)
3377         m_activeTimeline->projectView()->pasteClipEffects();
3378 }
3379
3380 void MainWindow::slotFind()
3381 {
3382     if (!m_activeDocument || !m_activeTimeline) return;
3383     m_projectSearch->setEnabled(false);
3384     m_findActivated = true;
3385     m_findString.clear();
3386     m_activeTimeline->projectView()->initSearchStrings();
3387     statusBar()->showMessage(i18n("Starting -- find text as you type"));
3388     m_findTimer.start(5000);
3389     qApp->installEventFilter(this);
3390 }
3391
3392 void MainWindow::slotFindNext()
3393 {
3394     if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
3395         statusBar()->showMessage(i18n("Found: %1", m_findString));
3396     else
3397         statusBar()->showMessage(i18n("Reached end of project"));
3398     m_findTimer.start(4000);
3399 }
3400
3401 void MainWindow::findAhead()
3402 {
3403     if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3404         m_projectSearchNext->setEnabled(true);
3405         statusBar()->showMessage(i18n("Found: %1", m_findString));
3406     } else {
3407         m_projectSearchNext->setEnabled(false);
3408         statusBar()->showMessage(i18n("Not found: %1", m_findString));
3409     }
3410 }
3411
3412 void MainWindow::findTimeout()
3413 {
3414     m_projectSearchNext->setEnabled(false);
3415     m_findActivated = false;
3416     m_findString.clear();
3417     statusBar()->showMessage(i18n("Find stopped"), 3000);
3418     if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3419     m_projectSearch->setEnabled(true);
3420     removeEventFilter(this);
3421 }
3422
3423 void MainWindow::slotClipInTimeline(const QString &clipId)
3424 {
3425     if (m_activeTimeline && m_activeDocument) {
3426         QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3427
3428         QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3429         inTimelineMenu->clear();
3430
3431         QList <QAction *> actionList;
3432
3433         for (int i = 0; i < matching.count(); ++i) {
3434             QString track = QString::number(matching.at(i).track);
3435             QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3436             int j = 0;
3437             QAction *a = new QAction(track + ": " + start, this);
3438             a->setData(QStringList() << track << start);
3439             connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3440             while (j < actionList.count()) {
3441                 if (actionList.at(j)->text() > a->text()) break;
3442                 j++;
3443             }
3444             actionList.insert(j, a);
3445         }
3446         inTimelineMenu->addActions(actionList);
3447
3448         if (matching.empty())
3449             inTimelineMenu->setEnabled(false);
3450         else
3451             inTimelineMenu->setEnabled(true);
3452     }
3453 }
3454
3455 void MainWindow::slotClipInProjectTree()
3456 {
3457     if (m_activeTimeline) {
3458         const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3459         if (clipIds.isEmpty())
3460             return;
3461         m_projectListDock->raise();
3462         for (int i = 0; i < clipIds.count(); i++)
3463             m_projectList->selectItemById(clipIds.at(i));
3464         if (m_projectMonitor->isActive())
3465             slotSwitchMonitors();
3466     }
3467 }
3468
3469 /*void MainWindow::slotClipToProjectTree()
3470 {
3471     if (m_activeTimeline) {
3472     const QList<ClipItem *> clips =  m_activeTimeline->projectView()->selectedClipItems();
3473         if (clips.isEmpty()) return;
3474         for (int i = 0; i < clips.count(); i++) {
3475         m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3476         }
3477         //m_projectList->selectItemById(clipIds.at(i));
3478     }
3479 }*/
3480
3481 void MainWindow::slotSelectClipInTimeline()
3482 {
3483     if (m_activeTimeline) {
3484         QAction *action = qobject_cast<QAction *>(sender());
3485         QStringList data = action->data().toStringList();
3486         m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3487     }
3488 }
3489
3490 void MainWindow::keyPressEvent(QKeyEvent *ke)
3491 {
3492     if (m_findActivated) {
3493         if (ke->key() == Qt::Key_Backspace) {
3494             m_findString = m_findString.left(m_findString.length() - 1);
3495
3496             if (!m_findString.isEmpty())
3497                 findAhead();
3498             else
3499                 findTimeout();
3500
3501             m_findTimer.start(4000);
3502             ke->accept();
3503             return;
3504         } else if (ke->key() == Qt::Key_Escape) {
3505             findTimeout();
3506             ke->accept();
3507             return;
3508         } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3509             m_findString += ke->text();
3510
3511             findAhead();
3512
3513             m_findTimer.start(4000);
3514             ke->accept();
3515             return;
3516         }
3517     } else {
3518         KXmlGuiWindow::keyPressEvent(ke);
3519     }
3520 }
3521
3522
3523 /** Gets called when the window gets hidden */
3524 void MainWindow::hideEvent(QHideEvent */*event*/)
3525 {
3526     if (isMinimized() && m_monitorManager)
3527         m_monitorManager->stopActiveMonitor();
3528 }
3529
3530 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3531 {
3532     if (m_findActivated) {
3533         if (event->type() == QEvent::ShortcutOverride) {
3534             QKeyEvent* ke = (QKeyEvent*) event;
3535             if (ke->text().trimmed().isEmpty()) return false;
3536             ke->accept();
3537             return true;
3538         } else {
3539             return false;
3540         }
3541     } else {
3542         // pass the event on to the parent class
3543         return QMainWindow::eventFilter(obj, event);
3544     }
3545 }
3546
3547
3548 void MainWindow::slotSaveZone(Render *render, QPoint zone)
3549 {
3550     KDialog *dialog = new KDialog(this);
3551     dialog->setCaption("Save clip zone");
3552     dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3553
3554     QWidget *widget = new QWidget(dialog);
3555     dialog->setMainWidget(widget);
3556
3557     QVBoxLayout *vbox = new QVBoxLayout(widget);
3558     QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3559     QString path = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash);
3560     path.append("untitled.mlt");
3561     KUrlRequester *url = new KUrlRequester(KUrl(path), this);
3562     url->setFilter("video/mlt-playlist");
3563     QLabel *label2 = new QLabel(i18n("Description:"), this);
3564     KLineEdit *edit = new KLineEdit(this);
3565     vbox->addWidget(label1);
3566     vbox->addWidget(url);
3567     vbox->addWidget(label2);
3568     vbox->addWidget(edit);
3569     if (dialog->exec() == QDialog::Accepted)
3570         render->saveZone(url->url(), edit->text(), zone);
3571
3572 }
3573
3574 void MainWindow::slotSetInPoint()
3575 {
3576     if (m_clipMonitor->isActive())
3577         m_clipMonitor->slotSetZoneStart();
3578     else
3579         m_projectMonitor->slotSetZoneStart();
3580     //else m_activeTimeline->projectView()->setInPoint();
3581 }
3582
3583 void MainWindow::slotSetOutPoint()
3584 {
3585     if (m_clipMonitor->isActive())
3586         m_clipMonitor->slotSetZoneEnd();
3587     else
3588         m_projectMonitor->slotSetZoneEnd();
3589     // else m_activeTimeline->projectView()->setOutPoint();
3590 }
3591
3592 void MainWindow::slotResizeItemStart()
3593 {
3594     if (m_activeTimeline)
3595         m_activeTimeline->projectView()->setInPoint();
3596 }
3597
3598 void MainWindow::slotResizeItemEnd()
3599 {
3600     if (m_activeTimeline)
3601         m_activeTimeline->projectView()->setOutPoint();
3602 }
3603
3604 int MainWindow::getNewStuff(const QString &configFile)
3605 {
3606     KNS3::Entry::List entries;
3607 #if KDE_IS_VERSION(4,3,80)
3608     KNS3::DownloadDialog dialog(configFile);
3609     dialog.exec();
3610     entries = dialog.changedEntries();
3611     foreach(const KNS3::Entry & entry, entries) {
3612         if (entry.status() == KNS3::Entry::Installed)
3613             kDebug() << "// Installed files: " << entry.installedFiles();
3614     }
3615 #else
3616     KNS::Engine engine(0);
3617     if (engine.init(configFile))
3618         entries = engine.downloadDialogModal(this);
3619     foreach(KNS::Entry * entry, entries) {
3620         if (entry->status() == KNS::Entry::Installed)
3621             kDebug() << "// Installed files: " << entry->installedFiles();
3622     }
3623 #endif /* KDE_IS_VERSION(4,3,80) */
3624     return entries.size();
3625 }
3626
3627 void MainWindow::slotGetNewTitleStuff()
3628 {
3629     if (getNewStuff("kdenlive_titles.knsrc") > 0)
3630         TitleWidget::refreshTitleTemplates();
3631 }
3632
3633 void MainWindow::slotGetNewLumaStuff()
3634 {
3635     if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3636         initEffects::refreshLumas();
3637         m_activeTimeline->projectView()->reloadTransitionLumas();
3638     }
3639 }
3640
3641 void MainWindow::slotGetNewRenderStuff()
3642 {
3643     if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3644         if (m_renderWidget)
3645             m_renderWidget->reloadProfiles();
3646 }
3647
3648 void MainWindow::slotGetNewMltProfileStuff()
3649 {
3650     if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3651         // update the list of profiles in settings dialog
3652         KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3653         if (d)
3654             d->checkProfile();
3655     }
3656 }
3657
3658 void MainWindow::slotAutoTransition()
3659 {
3660     if (m_activeTimeline)
3661         m_activeTimeline->projectView()->autoTransition();
3662 }
3663
3664 void MainWindow::slotSplitAudio()
3665 {
3666     if (m_activeTimeline)
3667         m_activeTimeline->projectView()->splitAudio();
3668 }
3669
3670 void MainWindow::slotUpdateClipType(QAction *action)
3671 {
3672     if (m_activeTimeline) {
3673         if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3674         else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3675         else m_activeTimeline->projectView()->setAudioAndVideo();
3676     }
3677 }
3678
3679 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3680 {
3681     // We must stop the monitors since we create a new on in the dvd wizard
3682     m_clipMonitor->stop();
3683     m_projectMonitor->stop();
3684     DvdWizard w(url, profile, this);
3685     w.exec();
3686     m_projectMonitor->start();
3687 }
3688
3689 void MainWindow::slotShowTimeline(bool show)
3690 {
3691     if (show == false) {
3692         m_timelineState = saveState();
3693         centralWidget()->setHidden(true);
3694     } else {
3695         centralWidget()->setHidden(false);
3696         restoreState(m_timelineState);
3697     }
3698 }
3699
3700 void MainWindow::slotMaximizeCurrent(bool /*show*/)
3701 {
3702     //TODO: is there a way to maximize current widget?
3703     //if (show == true)
3704     {
3705         m_timelineState = saveState();
3706         QWidget *par = focusWidget()->parentWidget();
3707         while (par->parentWidget() && par->parentWidget() != this)
3708             par = par->parentWidget();
3709         kDebug() << "CURRENT WIDGET: " << par->objectName();
3710     }
3711     /*else {
3712     //centralWidget()->setHidden(false);
3713     //restoreState(m_timelineState);
3714     }*/
3715 }
3716
3717 void MainWindow::loadTranscoders()
3718 {
3719     QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3720     transMenu->clear();
3721
3722     KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3723     KConfigGroup transConfig(config, "Transcoding");
3724     // read the entries
3725     QMap< QString, QString > profiles = transConfig.entryMap();
3726     QMapIterator<QString, QString> i(profiles);
3727     while (i.hasNext()) {
3728         i.next();
3729         QStringList data = i.value().split(";", QString::SkipEmptyParts);
3730         QAction *a = transMenu->addAction(i.key());
3731         a->setData(data);
3732         if (data.count() > 1)
3733             a->setToolTip(data.at(1));
3734         connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3735     }
3736 }
3737
3738 void MainWindow::slotTranscode(KUrl::List urls)
3739 {
3740     QString params;
3741     QString desc;
3742     QString condition;
3743     if (urls.isEmpty()) {
3744         QAction *action = qobject_cast<QAction *>(sender());
3745         QStringList data = action->data().toStringList();
3746         params = data.at(0);
3747         if (data.count() > 1) desc = data.at(1);
3748         if (data.count() > 2) condition = data.at(2);
3749         urls << m_projectList->getConditionalUrls(condition);
3750         urls.removeAll(KUrl());
3751     }
3752     if (urls.isEmpty()) {
3753         m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3754         return;
3755     }
3756     ClipTranscode *d = new ClipTranscode(urls, params, desc);
3757     connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3758     d->show();
3759     //QProcess::startDetached("ffmpeg", parameters);
3760 }
3761
3762 void MainWindow::slotTranscodeClip()
3763 {
3764     KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3765     if (urls.isEmpty()) return;
3766     slotTranscode(urls);
3767 }
3768
3769 void MainWindow::slotSetDocumentRenderProfile(QMap <QString, QString> props)
3770 {
3771     if (m_activeDocument == NULL) return;
3772     QMapIterator<QString, QString> i(props);
3773     while (i.hasNext()) {
3774         i.next();
3775         m_activeDocument->setDocumentProperty(i.key(), i.value());
3776     }
3777     m_activeDocument->setModified(true);
3778 }
3779
3780
3781 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3782 {
3783     if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3784     QString scriptPath;
3785     QString playlistPath;
3786     if (scriptExport) {
3787         bool ok;
3788         QString scriptsFolder = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "scripts/";
3789         QString path = m_renderWidget->getFreeScriptName();
3790         scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3791         if (!ok || scriptPath.isEmpty()) return;
3792         scriptPath.prepend(scriptsFolder);
3793         QFile f(scriptPath);
3794         if (f.exists()) {
3795             if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3796                 return;
3797         }
3798         playlistPath = scriptPath + ".mlt";
3799     } else {
3800         KTemporaryFile temp;
3801         temp.setAutoRemove(false);
3802         temp.setSuffix(".mlt");
3803         temp.open();
3804         playlistPath = temp.fileName();
3805     }
3806     QString playlistContent = m_projectMonitor->sceneList();
3807     if (!chapterFile.isEmpty()) {
3808         int in = 0;
3809         int out;
3810         if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3811         else {
3812             in = m_activeTimeline->inPoint();
3813             out = m_activeTimeline->outPoint();
3814         }
3815         QDomDocument doc;
3816         QDomElement chapters = doc.createElement("chapters");
3817         chapters.setAttribute("fps", m_activeDocument->fps());
3818         doc.appendChild(chapters);
3819
3820         QDomElement guidesxml = m_activeDocument->guidesXml();
3821         QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3822         for (int i = 0; i < nodes.count(); i++) {
3823             QDomElement e = nodes.item(i).toElement();
3824             if (!e.isNull()) {
3825                 QString comment = e.attribute("comment");
3826                 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3827                 if (time >= in && time < out) {
3828                     if (zoneOnly) time = time - in;
3829                     QDomElement chapter = doc.createElement("chapter");
3830                     chapters.appendChild(chapter);
3831                     chapter.setAttribute("title", comment);
3832                     chapter.setAttribute("time", time);
3833                 }
3834             }
3835         }
3836         if (chapters.childNodes().count() > 0) {
3837             if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3838                 // Always insert a guide in pos 0
3839                 QDomElement chapter = doc.createElement("chapter");
3840                 chapters.insertBefore(chapter, QDomNode());
3841                 chapter.setAttribute("title", i18n("Start"));
3842                 chapter.setAttribute("time", "0");
3843             }
3844             // save chapters file
3845             QFile file(chapterFile);
3846             if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3847                 kWarning() << "//////  ERROR writing DVD CHAPTER file: " << chapterFile;
3848             } else {
3849                 file.write(doc.toString().toUtf8());
3850                 if (file.error() != QFile::NoError) {
3851                     kWarning() << "//////  ERROR writing DVD CHAPTER file: " << chapterFile;
3852                 }
3853                 file.close();
3854             }
3855         }
3856     }
3857     bool exportAudio;
3858     if (m_renderWidget->automaticAudioExport()) {
3859         exportAudio = m_activeTimeline->checkProjectAudio();
3860     } else exportAudio = m_renderWidget->selectedAudioExport();
3861     
3862     // Do we want proxy rendering
3863     if (m_projectList->useProxy() && !m_renderWidget->proxyRendering()) {
3864         // replace proxy clips with originals
3865         QMap <QString, QString> proxies = m_projectList->getProxies();
3866         QMapIterator<QString, QString> i(proxies);
3867         while (i.hasNext()) {
3868             i.next();
3869             // Replace all keys with their values (proxy path with original path)
3870             playlistContent.replace(i.key(), i.value());
3871         }
3872     }
3873     
3874     // Do save scenelist
3875     QFile file(playlistPath);
3876     if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3877         m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
3878         return;
3879     }
3880     file.write(playlistContent.toUtf8());
3881     if (file.error() != QFile::NoError) {
3882         m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
3883         file.close();
3884         return;
3885     }
3886     file.close();
3887     m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath, exportAudio);
3888 }
3889
3890 void MainWindow::slotUpdateTimecodeFormat(int ix)
3891 {
3892     KdenliveSettings::setFrametimecode(ix == 1);
3893     m_clipMonitor->updateTimecodeFormat();
3894     m_projectMonitor->updateTimecodeFormat();
3895     m_transitionConfig->updateTimecodeFormat();
3896     m_effectStack->updateTimecodeFormat();
3897     //m_activeTimeline->projectView()->clearSelection();
3898     m_activeTimeline->updateRuler();
3899 }
3900
3901 void MainWindow::slotRemoveFocus()
3902 {
3903     statusBar()->setFocus();
3904     statusBar()->clearFocus();
3905 }
3906
3907 void MainWindow::slotRevert()
3908 {
3909     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;
3910     KUrl url = m_activeDocument->url();
3911     if (closeCurrentDocument(false))
3912         doOpenFile(url, NULL);
3913 }
3914
3915
3916 void MainWindow::slotShutdown()
3917 {
3918     if (m_activeDocument) m_activeDocument->setModified(false);
3919     // Call shutdown
3920     QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
3921     if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
3922         QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
3923         smserver.call("logout", 1, 2, 2);
3924     } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
3925         QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
3926         smserver.call("Shutdown");
3927     }
3928 }
3929
3930 void MainWindow::slotUpdateTrackInfo()
3931 {
3932     if (m_activeDocument)
3933         m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
3934 }
3935
3936 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
3937 {
3938     // Load the theme file
3939     QString theme;
3940     if (action == NULL) theme = themename;
3941     else theme = action->data().toString();
3942     KdenliveSettings::setColortheme(theme);
3943     // Make palette for all widgets.
3944     QPalette plt;
3945     if (theme.isEmpty())
3946         plt = QApplication::desktop()->palette();
3947     else {
3948         KSharedConfigPtr config = KSharedConfig::openConfig(theme);
3949         plt = KGlobalSettings::createApplicationPalette(config);
3950     }
3951
3952     kapp->setPalette(plt);
3953     const QObjectList children = statusBar()->children();
3954
3955     foreach(QObject * child, children) {
3956         if (child->isWidgetType())
3957             ((QWidget*)child)->setPalette(plt);
3958         const QObjectList subchildren = child->children();
3959         foreach(QObject * subchild, subchildren) {
3960             if (subchild->isWidgetType())
3961                 ((QWidget*)subchild)->setPalette(plt);
3962         }
3963     }
3964     if (m_activeTimeline) {
3965         m_activeTimeline->projectView()->updatePalette();
3966     }
3967 }
3968
3969
3970 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
3971 {
3972     // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
3973     const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
3974     const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
3975     const QSize bitsSize(24, 2);
3976     const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
3977     const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
3978
3979     QPixmap pixmap(23, 16);
3980     pixmap.fill(Qt::black); // ### use some color other than black for borders?
3981
3982     KConfigGroup group(config, "WM");
3983     QPainter p(&pixmap);
3984     KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
3985     p.fillRect(1,  1, 7, 7, windowScheme.background());
3986     p.fillRect(2,  2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
3987
3988     KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
3989     p.fillRect(8,  1, 7, 7, buttonScheme.background());
3990     p.fillRect(9,  2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
3991
3992     p.fillRect(15,  1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
3993     p.fillRect(16,  2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
3994
3995     KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
3996     p.fillRect(1,  8, 7, 7, viewScheme.background());
3997     p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
3998
3999     KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
4000     p.fillRect(8,  8, 7, 7, selectionScheme.background());
4001     p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
4002
4003     p.fillRect(15,  8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
4004     p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
4005
4006     p.end();
4007     return pixmap;
4008 }
4009
4010 void MainWindow::slotSwitchMonitors()
4011 {
4012     m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
4013     if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
4014     else m_projectList->focusTree();
4015 }
4016
4017 void MainWindow::slotSwitchFullscreen()
4018 {
4019     if (m_projectMonitor->isActive()) m_projectMonitor->slotSwitchFullScreen();
4020     else m_clipMonitor->slotSwitchFullScreen();
4021 }
4022
4023 void MainWindow::slotInsertZoneToTree()
4024 {
4025     if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
4026     QStringList info = m_clipMonitor->getZoneInfo();
4027     m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
4028 }
4029
4030 void MainWindow::slotInsertZoneToTimeline()
4031 {
4032     if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
4033     QStringList info = m_clipMonitor->getZoneInfo();
4034     m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
4035 }
4036
4037
4038 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
4039 {
4040     if (m_activeDocument && m_activeTimeline) {
4041         if (!ids.isEmpty()) {
4042             for (int i = 0; i < ids.size(); ++i) {
4043                 m_activeTimeline->slotDeleteClip(ids.at(i));
4044             }
4045             m_activeDocument->clipManager()->slotDeleteClips(ids);
4046         }
4047         if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
4048         m_activeDocument->setModified(true);
4049     }
4050 }
4051
4052 void MainWindow::slotShowTitleBars(bool show)
4053 {
4054     QList <QDockWidget *> docks = findChildren<QDockWidget *>();
4055     for (int i = 0; i < docks.count(); i++) {
4056         QDockWidget* dock = docks.at(i);
4057         if (show) {
4058             dock->setTitleBarWidget(0);
4059         } else {
4060             if (!dock->isFloating()) {
4061                 dock->setTitleBarWidget(new QWidget);
4062             }
4063         }
4064     }
4065     KdenliveSettings::setShowtitlebars(show);
4066 }
4067
4068 void MainWindow::slotSwitchTitles()
4069 {
4070     slotShowTitleBars(!KdenliveSettings::showtitlebars());
4071 }
4072
4073 QString MainWindow::getMimeType()
4074 {
4075     QString mimetype = "application/x-kdenlive";
4076     KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
4077     if (!mime) mimetype = "*.kdenlive";
4078     return mimetype;
4079 }
4080
4081 void MainWindow::slotMonitorRequestRenderFrame(bool request)
4082 {
4083     if (request) {
4084         m_projectMonitor->render->sendFrameForAnalysis = true;
4085         return;
4086     } else {
4087         for (int i = 0; i < m_gfxScopesList.count(); i++) {
4088             if (m_gfxScopesList.at(i)->isVisible() && tabifiedDockWidgets(m_gfxScopesList.at(i)).isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4089                 request = true;
4090                 break;
4091             }
4092         }
4093     }
4094 #ifdef DEBUG_MAINW
4095     qDebug() << "Any scope accepting new frames? " << request;
4096 #endif
4097     if (!request) {
4098         m_projectMonitor->render->sendFrameForAnalysis = false;
4099     }
4100 }
4101
4102 void MainWindow::slotUpdateGfxScopeFrameRequest()
4103 {
4104     // We need a delay to make sure widgets are hidden after a close event for example
4105     QTimer::singleShot(500, this, SLOT(slotDoUpdateGfxScopeFrameRequest()));
4106 }
4107
4108 void MainWindow::slotDoUpdateGfxScopeFrameRequest()
4109 {
4110     // Check scopes
4111     bool request = false;
4112     for (int i = 0; i < m_gfxScopesList.count(); i++) {
4113         if (!m_gfxScopesList.at(i)->widget()->visibleRegion().isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4114             kDebug() << "SCOPE VISIBLE: " << static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->widgetName();
4115             request = true;
4116             break;
4117         }
4118     }
4119     if (!request) {
4120         if (!m_projectMonitor->effectSceneDisplayed()) {
4121             m_projectMonitor->render->sendFrameForAnalysis = false;
4122         }
4123         m_clipMonitor->render->sendFrameForAnalysis = false;
4124     } else {
4125         m_projectMonitor->render->sendFrameForAnalysis = true;
4126         m_clipMonitor->render->sendFrameForAnalysis = true;
4127     }
4128 }
4129
4130 void MainWindow::slotUpdateAudioScopeFrameRequest()
4131 {
4132     QTimer::singleShot(500, this, SLOT(slotDoUpdateAudioScopeFrameRequest()));
4133 }
4134
4135 void MainWindow::slotDoUpdateAudioScopeFrameRequest()
4136 {
4137     bool request = false;
4138     for (int i = 0; i < m_audioScopesList.count(); i++) {
4139         if (!m_audioScopesList.at(i)->visibleRegion().isEmpty() && m_audioScopesList.at(i)->autoRefreshEnabled()) {
4140             kDebug() << "AUDIO SCOPE VISIBLE: " << m_audioScopesList.at(i)->widgetName();
4141             request = true;
4142             break;
4143         }
4144     }
4145     // Handle audio signal separately (no common interface)
4146     if (!m_audiosignal->visibleRegion().isEmpty() && m_audiosignal->monitoringEnabled()) {
4147         kDebug() << "AUDIO SCOPE VISIBLE: " << "audiosignal";
4148         request = true;
4149     }
4150 #ifdef DEBUG_MAINW
4151     qDebug() << "Scopes Requesting Audio data: " << request;
4152 #endif
4153     KdenliveSettings::setMonitor_audio(request);
4154     m_monitorManager->slotUpdateAudioMonitoring();
4155 }
4156
4157 void MainWindow::slotUpdateColorScopes()
4158 {
4159     bool request = false;
4160     for (int i = 0; i < m_gfxScopesList.count(); i++) {
4161         // Check if we need the renderer to send a new frame for update
4162         if (!m_gfxScopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled())) request = true;
4163         static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->slotActiveMonitorChanged(m_clipMonitor->isActive());
4164     }
4165     if (request) {
4166         if (m_clipMonitor->isActive()) m_clipMonitor->render->sendFrameUpdate();
4167         else m_projectMonitor->render->sendFrameUpdate();
4168     }
4169 }
4170
4171 void MainWindow::slotOpenStopmotion()
4172 {
4173     if (m_stopmotion == NULL) {
4174         m_stopmotion = new StopmotionWidget(m_activeDocument->projectFolder(), m_stopmotion_actions->actions(), this);
4175         connect(m_stopmotion, SIGNAL(addOrUpdateSequence(const QString)), m_projectList, SLOT(slotAddOrUpdateSequence(const QString)));
4176         for (int i = 0; i < m_gfxScopesList.count(); i++) {
4177             // Check if we need the renderer to send a new frame for update
4178             /*if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;*/
4179             connect(m_stopmotion, SIGNAL(gotFrame(QImage)), static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget()), SLOT(slotRenderZoneUpdated(QImage)));
4180             //static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotMonitorCapture();
4181         }
4182     }
4183     m_stopmotion->show();
4184 }
4185
4186 void MainWindow::slotDeleteClip(const QString &id)
4187 {
4188     QList <ClipProperties *> list = findChildren<ClipProperties *>();
4189     for (int i = 0; i < list.size(); ++i) {
4190         list.at(i)->disableClipId(id);
4191     }
4192     m_projectList->slotDeleteClip(id);
4193 }
4194
4195 void MainWindow::slotUpdateProxySettings()
4196 {
4197     if (m_renderWidget) m_renderWidget->updateProxyConfig(m_projectList->useProxy());
4198     if (KdenliveSettings::enableproxy())
4199         KStandardDirs::makeDir(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "proxy/");
4200     m_projectList->updateProxyConfig();
4201 }
4202
4203 #include "mainwindow.moc"
4204
4205 #ifdef DEBUG_MAINW
4206 #undef DEBUG_MAINW
4207 #endif