1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
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. *
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. *
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 ***************************************************************************/
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"
29 #include "clipmanager.h"
30 #include "projectlist.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"
42 #include "audiosignal.h"
44 #include "jogshuttle.h"
45 #endif /* NO_JOGSHUTTLE */
46 #include "clipproperties.h"
48 #include "editclipcommand.h"
49 #include "titlewidget.h"
50 #include "markerdialog.h"
52 #include "interfaces.h"
53 #include "kdenlive-config.h"
54 #include "cliptranscode.h"
55 #include "ui_templateclip_ui.h"
56 #include "colorscopes/vectorscope.h"
57 #include "colorscopes/waveform.h"
58 #include "colorscopes/rgbparade.h"
59 #include "colorscopes/histogram.h"
60 #include "audiospectrum.h"
62 #include <KApplication>
66 #include <KActionCollection>
67 #include <KActionCategory>
68 #include <KStandardAction>
69 #include <KShortcutsDialog>
70 #include <KFileDialog>
71 #include <KMessageBox>
73 #include <KIO/NetAccess>
76 #include <KConfigDialog>
77 #include <KXMLGUIFactory>
79 #include <kstandarddirs.h>
80 #include <KUrlRequesterDialog>
81 #include <KTemporaryFile>
83 #include <KActionMenu>
86 #include <ktogglefullscreenaction.h>
88 #include <KNotification>
89 #include <KNotifyConfigWidget>
90 #if KDE_IS_VERSION(4,3,80)
91 #include <knewstuff3/downloaddialog.h>
92 #include <knewstuff3/knewstuffaction.h>
94 #include <knewstuff2/engine.h>
95 #include <knewstuff2/ui/knewstuffaction.h>
97 #endif /* KDE_IS_VERSION(4,3,80) */
99 #include <KColorScheme>
100 #include <KProgressDialog>
102 #include <QTextStream>
106 #include <QInputDialog>
107 #include <QDesktopWidget>
112 static const char version[] = VERSION;
114 static const int ID_TIMELINE_POS = 0;
120 Q_DECLARE_METATYPE(QVector<int16_t>)
122 EffectsList MainWindow::videoEffects;
123 EffectsList MainWindow::audioEffects;
124 EffectsList MainWindow::customEffects;
125 EffectsList MainWindow::transitions;
127 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString & clipsToLoad, QWidget *parent) :
128 KXmlGuiWindow(parent),
129 m_activeDocument(NULL),
130 m_activeTimeline(NULL),
131 m_renderWidget(NULL),
132 #ifndef NO_JOGSHUTTLE
134 #endif /* NO_JOGSHUTTLE */
135 m_findActivated(false),
138 qRegisterMetaType<QVector<int16_t> > ();
139 // Create DBus interface
140 new MainWindowAdaptor(this);
141 QDBusConnection dbus = QDBusConnection::sessionBus();
142 dbus.registerObject("/MainWindow", this);
144 setlocale(LC_NUMERIC, "POSIX");
145 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
146 setFont(KGlobalSettings::toolBarFont());
147 parseProfiles(MltPath);
148 m_commandStack = new QUndoGroup;
149 setDockNestingEnabled(true);
150 m_timelineArea = new KTabWidget(this);
151 m_timelineArea->setTabReorderingEnabled(true);
152 m_timelineArea->setTabBarHidden(true);
153 m_timelineArea->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
154 m_timelineArea->setMinimumHeight(200);
156 QToolButton *closeTabButton = new QToolButton;
157 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
158 closeTabButton->setIcon(KIcon("tab-close"));
159 closeTabButton->adjustSize();
160 closeTabButton->setToolTip(i18n("Close the current tab"));
161 m_timelineArea->setCornerWidget(closeTabButton);
162 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
164 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
165 m_findTimer.setSingleShot(true);
167 // FIXME: the next call returns a newly allocated object, which leaks
168 initEffects::parseEffectFiles();
169 //initEffects::parseCustomEffectsFile();
171 m_monitorManager = new MonitorManager();
173 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
174 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
179 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
180 m_projectListDock->setObjectName("project_tree");
181 m_projectList = new ProjectList();
182 m_projectListDock->setWidget(m_projectList);
183 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
185 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
186 m_clipMonitorDock->setObjectName("clip_monitor");
187 m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), m_timelineArea);
188 m_clipMonitorDock->setWidget(m_clipMonitor);
189 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
191 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
192 m_projectMonitorDock->setObjectName("project_monitor");
193 m_projectMonitor = new Monitor("project", m_monitorManager, QString());
194 m_projectMonitorDock->setWidget(m_projectMonitor);
195 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
198 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
199 m_recMonitorDock->setObjectName("record_monitor");
200 m_recMonitor = new RecMonitor("record");
201 m_recMonitorDock->setWidget(m_recMonitor);
202 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
203 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
204 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
207 m_notesDock = new QDockWidget(i18n("Project Notes"), this);
208 m_notesDock->setObjectName("notes_widget");
209 m_notesWidget = new KTextEdit();
210 m_notesWidget->setTabChangesFocus(true);
211 #if KDE_IS_VERSION(4,4,0)
212 m_notesWidget->setClickMessage(i18n("Enter your project notes here..."));
214 m_notesDock->setWidget(m_notesWidget);
215 addDockWidget(Qt::TopDockWidgetArea, m_notesDock);
217 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
218 m_effectStackDock->setObjectName("effect_stack");
219 m_effectStack = new EffectStackView(m_projectMonitor);
220 m_effectStackDock->setWidget(m_effectStack);
221 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
223 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
224 m_transitionConfigDock->setObjectName("transition");
225 m_transitionConfig = new TransitionSettings(m_projectMonitor);
226 m_transitionConfigDock->setWidget(m_transitionConfig);
227 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
229 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
230 m_effectListDock->setObjectName("effect_list");
231 m_effectList = new EffectsListView();
232 m_effectListDock->setWidget(m_effectList);
233 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
235 m_vectorscope = new Vectorscope(m_projectMonitor, m_clipMonitor);
236 m_vectorscopeDock = new QDockWidget(i18n("Vectorscope"), this);
237 m_vectorscopeDock->setObjectName(m_vectorscope->widgetName());
238 m_vectorscopeDock->setWidget(m_vectorscope);
239 addDockWidget(Qt::TopDockWidgetArea, m_vectorscopeDock);
240 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), m_vectorscope, SLOT(forceUpdate(bool)));
241 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
242 connect(m_vectorscope, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
243 m_scopesList.append(m_vectorscopeDock);
245 m_waveform = new Waveform(m_projectMonitor, m_clipMonitor);
246 m_waveformDock = new QDockWidget(i18n("Waveform"), this);
247 m_waveformDock->setObjectName(m_waveform->widgetName());
248 m_waveformDock->setWidget(m_waveform);
249 addDockWidget(Qt::TopDockWidgetArea, m_waveformDock);
250 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), m_waveform, SLOT(forceUpdate(bool)));
251 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
252 connect(m_waveform, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
253 m_scopesList.append(m_waveformDock);
255 m_RGBParade = new RGBParade(m_projectMonitor, m_clipMonitor);
256 m_RGBParadeDock = new QDockWidget(i18n("RGB Parade"), this);
257 m_RGBParadeDock->setObjectName(m_RGBParade->widgetName());
258 m_RGBParadeDock->setWidget(m_RGBParade);
259 addDockWidget(Qt::TopDockWidgetArea, m_RGBParadeDock);
260 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), m_RGBParade, SLOT(forceUpdate(bool)));
261 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
262 connect(m_RGBParade, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
263 m_scopesList.append(m_RGBParadeDock);
265 m_histogram = new Histogram(m_projectMonitor, m_clipMonitor);
266 m_histogramDock = new QDockWidget(i18n("Histogram"), this);
267 m_histogramDock->setObjectName(m_histogram->widgetName());
268 m_histogramDock->setWidget(m_histogram);
269 addDockWidget(Qt::TopDockWidgetArea, m_histogramDock);
270 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), m_histogram, SLOT(forceUpdate(bool)));
271 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
272 connect(m_histogram, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
273 m_scopesList.append(m_histogramDock);
276 m_audiosignal = new AudioSignal;
277 m_audiosignalDock = new QDockWidget(i18n("Audio Signal"), this);
278 m_audiosignalDock->setObjectName("audiosignal");
279 m_audiosignalDock->setWidget(m_audiosignal);
280 addDockWidget(Qt::TopDockWidgetArea, m_audiosignalDock);
281 connect(m_audiosignal, SIGNAL(updateAudioMonitoring()), m_monitorManager, SLOT(slotUpdateAudioMonitoring()));
282 /*if (m_projectMonitor) {
283 connect(m_projectMonitor->render, SIGNAL(showAudioSignal(const QByteArray&)), m_audiosignal, SLOT(showAudio(const QByteArray&)));
286 connect(m_clipMonitor->render, SIGNAL(showAudioSignal(const QByteArray&)), m_audiosignal, SLOT(showAudio(const QByteArray&)));
289 m_audioSpectrum = new AudioSpectrum();
290 m_audioSpectrumDock = new QDockWidget(i18n("AudioSpectrum"), this);
291 m_audioSpectrumDock->setObjectName(m_audioSpectrum->widgetName());
292 m_audioSpectrumDock->setWidget(m_audioSpectrum);
293 addDockWidget(Qt::TopDockWidgetArea, m_audioSpectrumDock);
295 // Connect the audio signal to the audio scope slots
297 if (m_projectMonitor) {
298 qDebug() << "project monitor connected";
299 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
300 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
301 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, const int&, const int&, const int&)),
302 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, const int&, const int&, const int&)));
305 qDebug() << "clip monitor connected";
306 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
307 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
308 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, int, int, int)),
309 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, int, int, int)));
311 // Ensure connection was set up correctly
314 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
315 m_undoViewDock->setObjectName("undo_history");
316 m_undoView = new QUndoView();
317 m_undoView->setCleanIcon(KIcon("edit-clear"));
318 m_undoView->setEmptyLabel(i18n("Clean"));
319 m_undoViewDock->setWidget(m_undoView);
320 m_undoView->setGroup(m_commandStack);
321 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
323 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
324 //overviewDock->setObjectName("project_overview");
325 //m_overView = new CustomTrackView(NULL, NULL, this);
326 //overviewDock->setWidget(m_overView);
327 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
332 /// Tabify Widgets ///
333 tabifyDockWidget(m_projectListDock, m_effectStackDock);
334 tabifyDockWidget(m_projectListDock, m_transitionConfigDock);
335 tabifyDockWidget(m_projectListDock, m_notesDock);
338 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
340 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
343 tabifyDockWidget(m_vectorscopeDock, m_waveformDock);
344 tabifyDockWidget(m_vectorscopeDock, m_RGBParadeDock);
345 tabifyDockWidget(m_vectorscopeDock, m_histogramDock);
346 tabifyDockWidget(m_vectorscopeDock, m_undoViewDock);
347 tabifyDockWidget(m_vectorscopeDock, m_effectListDock);
350 setCentralWidget(m_timelineArea);
353 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
354 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
356 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
357 m_fileRevert->setEnabled(false);
359 // Prepare layout actions
360 KActionCategory *layoutActions = new KActionCategory(i18n("Layouts"), actionCollection());
361 for (int i = 1; i < 5; i++) {
362 KAction *load = new KAction(KIcon(), i18n("Load Layout %1").arg(i), this);
363 load->setData("_" + QString::number(i));
364 layoutActions->addAction("load_layout" + QString::number(i), load);
365 KAction *save = new KAction(KIcon(), i18n("Save As Layout %1").arg(i), this);
366 save->setData("_" + QString::number(i));
367 layoutActions->addAction("save_layout" + QString::number(i), save);
371 // Stop motion actions. Beware of the order, we MUST use the same order in stopmotion/stopmotion.cpp
372 m_stopmotion_actions = new KActionCategory(i18n("Stop Motion"), actionCollection());
373 action = new KAction(KIcon("media-record"), i18n("Capture frame"), this);
374 action->setShortcut(Qt::Key_Space);
375 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
376 m_stopmotion_actions->addAction("stopmotion_capture", action);
377 action = new KAction(i18n("Switch live / captured frame"), this);
378 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
379 m_stopmotion_actions->addAction("stopmotion_switch", action);
380 action = new KAction(KIcon("edit-paste"), i18n("Show last frame over video"), this);
381 action->setCheckable(true);
382 action->setChecked(false);
383 m_stopmotion_actions->addAction("stopmotion_overlay", action);
387 // Find QDockWidget tab bars and show / hide widget title bars on right click
388 QList <QTabBar *> tabs = findChildren<QTabBar *>();
389 for (int i = 0; i < tabs.count(); i++) {
390 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
391 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
394 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
395 guiFactory()->addClient(sp);*/
398 QMenu *loadLayout = (QMenu*)(factory()->container("layout_load", this));
400 connect(loadLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotLoadLayout(QAction*)));
401 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
403 connect(saveLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotSaveLayout(QAction*)));
406 // Load layout names from config file
411 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
413 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, NULL, m_loopClip);
414 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
416 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
417 clipInTimeline->setIcon(KIcon("go-jump"));
418 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)),
419 static_cast<QMenu*>(factory()->container("transcoders", this)),
422 // build themes menus
423 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
424 QActionGroup *themegroup = new QActionGroup(this);
425 themegroup->setExclusive(true);
426 action = new KAction(i18n("Default"), this);
427 action->setCheckable(true);
428 themegroup->addAction(action);
429 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
431 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
433 for (int i = 0; i < schemeFiles.size(); ++i) {
435 const QString filename = schemeFiles.at(i);
436 const QFileInfo info(filename);
439 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
440 QIcon icon = createSchemePreviewIcon(config);
441 KConfigGroup group(config, "General");
442 const QString name = group.readEntry("Name", info.baseName());
443 action = new KAction(name, this);
444 action->setData(filename);
445 action->setIcon(icon);
446 action->setCheckable(true);
447 themegroup->addAction(action);
448 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
451 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
452 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
453 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
456 action = new QAction(fi.fileName(), this);
457 action->setData(*it);
458 action->setCheckable(true);
459 themegroup->addAction(action);
460 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
462 themesMenu->addActions(themegroup->actions());
463 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
465 // Setup and fill effects and transitions menus.
466 m_videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
467 for (int i = 0; i < videoEffects.count(); ++i)
468 m_videoEffectsMenu->addAction(m_videoEffects[i]);
469 m_audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
470 for (int i = 0; i < audioEffects.count(); ++i)
471 m_audioEffectsMenu->addAction(m_audioEffects[i]);
472 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
473 if (customEffects.isEmpty())
474 m_customEffectsMenu->setEnabled(false);
476 m_customEffectsMenu->setEnabled(true);
477 for (int i = 0; i < customEffects.count(); ++i)
478 m_customEffectsMenu->addAction(m_customEffects[i]);
479 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
480 for (int i = 0; i < transitions.count(); ++i)
481 m_transitionsMenu->addAction(m_transitions[i]);
483 connect(m_videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
484 connect(m_audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
485 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
486 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
488 QMenu *newEffect = new QMenu(this);
489 newEffect->addMenu(m_videoEffectsMenu);
490 newEffect->addMenu(m_audioEffectsMenu);
491 newEffect->addMenu(m_customEffectsMenu);
492 m_effectStack->setMenu(newEffect);
494 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
495 const QList<QAction *> viewActions = createPopupMenu()->actions();
496 viewMenu->insertActions(NULL, viewActions);
498 m_timelineContextMenu = new QMenu(this);
499 m_timelineContextClipMenu = new QMenu(this);
500 m_timelineContextTransitionMenu = new QMenu(this);
502 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
503 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
504 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
506 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
507 //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
508 m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
509 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
510 m_timelineContextClipMenu->addSeparator();
511 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
512 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
513 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
514 m_timelineContextClipMenu->addSeparator();
515 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
516 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
517 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
518 m_timelineContextClipMenu->addSeparator();
520 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
521 m_timelineContextClipMenu->addMenu(markersMenu);
522 m_timelineContextClipMenu->addSeparator();
523 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
524 m_timelineContextClipMenu->addMenu(m_videoEffectsMenu);
525 m_timelineContextClipMenu->addMenu(m_audioEffectsMenu);
526 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
528 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
529 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
530 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
532 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
534 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
535 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
536 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
537 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
538 connect(m_monitorManager, SIGNAL(checkColorScopes()), this, SLOT(slotUpdateColorScopes()));
539 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
540 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
542 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
543 slotConnectMonitors();
545 // Open or create a file. Command line argument passed in Url has
546 // precedence, then "openlastproject", then just a plain empty file.
547 // If opening Url fails, openlastproject will _not_ be used.
548 if (!Url.isEmpty()) {
549 // delay loading so that the window shows up
551 QTimer::singleShot(500, this, SLOT(openFile()));
552 } else if (KdenliveSettings::openlastproject()) {
553 QTimer::singleShot(500, this, SLOT(openLastFile()));
554 } else { //if (m_timelineArea->count() == 0) {
558 if (!clipsToLoad.isEmpty() && m_activeDocument) {
559 QStringList list = clipsToLoad.split(',');
561 foreach(QString path, list) {
562 kDebug() << QDir::current().absoluteFilePath(path);
563 urls << QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
565 m_projectList->slotAddClip(urls);
568 #ifndef NO_JOGSHUTTLE
569 activateShuttleDevice();
570 #endif /* NO_JOGSHUTTLE */
571 m_projectListDock->raise();
573 actionCollection()->addAssociatedWidget(m_clipMonitor->container());
574 actionCollection()->addAssociatedWidget(m_projectMonitor->container());
577 MainWindow::~MainWindow()
582 m_effectStack->slotClipItemSelected(NULL, 0);
583 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
585 if (m_projectMonitor) m_projectMonitor->stop();
586 if (m_clipMonitor) m_clipMonitor->stop();
588 delete m_activeTimeline;
589 delete m_effectStack;
590 delete m_transitionConfig;
591 delete m_activeDocument;
592 delete m_projectMonitor;
593 delete m_clipMonitor;
594 delete m_shortcutRemoveFocus;
595 Mlt::Factory::close();
598 void MainWindow::queryQuit()
606 bool MainWindow::queryClose()
608 if (m_renderWidget) {
609 int waitingJobs = m_renderWidget->waitingJobsCount();
610 if (waitingJobs > 0) {
611 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")))) {
612 case KMessageBox::Yes :
613 // create script with waiting jobs and start it
614 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
616 case KMessageBox::No :
617 // Don't do anything, jobs will be deleted
625 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
626 // warn the user to save if document is modified and we have clips in our project list
627 if (m_activeDocument && m_activeDocument->isModified() &&
628 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
629 !m_projectList->documentClipList().isEmpty())) {
633 if (m_activeDocument->url().fileName().isEmpty())
634 message = i18n("Save changes to document?");
636 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
637 switch (KMessageBox::warningYesNoCancel(this, message)) {
638 case KMessageBox::Yes :
639 // save document here. If saving fails, return false;
641 case KMessageBox::No :
642 // User does not want to save the changes, clear recovery files
643 m_activeDocument->m_autosave->resize(0);
652 void MainWindow::loadPlugins()
654 foreach(QObject * plugin, QPluginLoader::staticInstances()) {
655 populateMenus(plugin);
658 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
660 filters << "libkdenlive*";
661 foreach(const QString & folder, directories) {
662 kDebug() << "Parsing plugin folder: " << folder;
663 QDir pluginsDir(folder);
664 foreach(const QString & fileName,
665 pluginsDir.entryList(filters, QDir::Files)) {
667 * Avoid loading the same plugin twice when there is more than one
670 if (!m_pluginFileNames.contains(fileName)) {
671 kDebug() << "Found plugin: " << fileName;
672 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
673 QObject *plugin = loader.instance();
675 populateMenus(plugin);
676 m_pluginFileNames += fileName;
678 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
684 void MainWindow::populateMenus(QObject *plugin)
686 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
687 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
689 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
693 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
694 QMenu *menu, const char *member,
695 QActionGroup *actionGroup)
697 kDebug() << "// ADD to MENU" << texts;
698 foreach(const QString & text, texts) {
699 QAction *action = new QAction(text, plugin);
700 action->setData(text);
701 connect(action, SIGNAL(triggered()), this, member);
702 menu->addAction(action);
705 action->setCheckable(true);
706 actionGroup->addAction(action);
711 void MainWindow::aboutPlugins()
713 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
718 void MainWindow::generateClip()
720 QAction *action = qobject_cast<QAction *>(sender());
721 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
723 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
724 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
725 if (!clipUrl.isEmpty()) {
726 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
730 void MainWindow::saveProperties(KConfigGroup &config)
732 // save properties here,used by session management
734 KMainWindow::saveProperties(config);
738 void MainWindow::readProperties(const KConfigGroup &config)
740 // read properties here,used by session management
741 KMainWindow::readProperties(config);
742 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
743 openFile(KUrl(Lastproject));
746 void MainWindow::slotReloadEffects()
748 m_customEffectsMenu->clear();
749 initEffects::parseCustomEffectsFile();
751 QStringList effectInfo;
752 QMap<QString, QStringList> effectsList;
753 for (int ix = 0; ix < customEffects.count(); ix++) {
754 effectInfo = customEffects.effectIdInfo(ix);
755 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
757 if (effectsList.isEmpty())
758 m_customEffectsMenu->setEnabled(false);
760 m_customEffectsMenu->setEnabled(true);
762 foreach(const QStringList & value, effectsList) {
763 action = new QAction(value.at(0), this);
764 action->setData(value);
765 m_customEffectsMenu->addAction(action);
767 m_effectList->reloadEffectList();
770 #ifndef NO_JOGSHUTTLE
771 void MainWindow::activateShuttleDevice()
775 if (KdenliveSettings::enableshuttle() == false) return;
776 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
777 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
778 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
779 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
780 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
781 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
784 void MainWindow::slotShuttleButton(int code)
788 slotShuttleAction(KdenliveSettings::shuttle1());
791 slotShuttleAction(KdenliveSettings::shuttle2());
794 slotShuttleAction(KdenliveSettings::shuttle3());
797 slotShuttleAction(KdenliveSettings::shuttle4());
800 slotShuttleAction(KdenliveSettings::shuttle5());
805 void MainWindow::slotShuttleAction(int code)
811 m_monitorManager->slotPlay();
814 m_monitorManager->slotPlay();
818 #endif /* NO_JOGSHUTTLE */
820 void MainWindow::configureNotifications()
822 KNotifyConfigWidget::configure(this);
825 void MainWindow::slotFullScreen()
827 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
830 void MainWindow::slotAddEffect(const QDomElement effect)
832 if (!m_activeDocument) return;
833 if (effect.isNull()) {
834 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
837 QDomElement effectToAdd = effect.cloneNode().toElement();
839 int ix = m_effectStack->isTrackMode(&ok);
840 if (ok) m_activeTimeline->projectView()->slotAddTrackEffect(effectToAdd, m_activeDocument->tracksCount() - ix);
841 else m_activeTimeline->projectView()->slotAddEffect(effectToAdd, GenTime(), -1);
844 void MainWindow::slotRaiseMonitor(bool clipMonitor)
846 if (clipMonitor) m_clipMonitorDock->raise();
847 else m_projectMonitorDock->raise();
850 void MainWindow::slotUpdateClip(const QString &id)
852 if (!m_activeDocument) return;
853 m_activeTimeline->projectView()->slotUpdateClip(id);
856 void MainWindow::slotConnectMonitors()
858 m_projectList->setRenderer(m_projectMonitor->render);
859 //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
860 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
861 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
862 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
863 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, int, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, int, bool)));
864 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
865 connect(m_projectMonitor->render, SIGNAL(replyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool)), m_projectList, SLOT(slotReplyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool)));
867 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
869 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
871 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
872 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
874 connect(m_projectMonitor, SIGNAL(requestFrameForAnalysis(bool)), this, SLOT(slotMonitorRequestRenderFrame(bool)));
876 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
877 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
880 void MainWindow::slotAdjustClipMonitor()
882 m_clipMonitorDock->updateGeometry();
883 m_clipMonitorDock->adjustSize();
884 m_clipMonitor->resetSize();
887 void MainWindow::slotAdjustProjectMonitor()
889 m_projectMonitorDock->updateGeometry();
890 m_projectMonitorDock->adjustSize();
891 m_projectMonitor->resetSize();
894 void MainWindow::setupActions()
897 KActionCollection* collection = actionCollection();
898 m_timecodeFormat = new KComboBox(this);
899 m_timecodeFormat->addItem(i18n("hh:mm:ss:ff"));
900 m_timecodeFormat->addItem(i18n("Frames"));
901 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
902 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
904 m_statusProgressBar = new QProgressBar(this);
905 m_statusProgressBar->setMinimum(0);
906 m_statusProgressBar->setMaximum(100);
907 m_statusProgressBar->setMaximumWidth(150);
908 m_statusProgressBar->setVisible(false);
910 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
911 toolbar->setMovable(false);
912 KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
913 QColor buttonBg = scheme.background(KColorScheme::LinkBackground).color();
914 QColor buttonBord = scheme.foreground(KColorScheme::LinkText).color();
915 QColor buttonBord2 = scheme.shade(KColorScheme::LightShade);
916 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
917 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());
918 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
920 //create edit mode buttons
921 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
922 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
923 toolbar->addAction(m_normalEditTool);
924 m_normalEditTool->setCheckable(true);
925 m_normalEditTool->setChecked(true);
927 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
928 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
929 toolbar->addAction(m_overwriteEditTool);
930 m_overwriteEditTool->setCheckable(true);
931 m_overwriteEditTool->setChecked(false);
933 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
934 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
935 toolbar->addAction(m_insertEditTool);
936 m_insertEditTool->setCheckable(true);
937 m_insertEditTool->setChecked(false);
938 // not implemented yet
939 m_insertEditTool->setEnabled(false);
941 QActionGroup *editGroup = new QActionGroup(this);
942 editGroup->addAction(m_normalEditTool);
943 editGroup->addAction(m_overwriteEditTool);
944 editGroup->addAction(m_insertEditTool);
945 editGroup->setExclusive(true);
946 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
947 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
949 toolbar->addSeparator();
951 // create tools buttons
952 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
953 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
954 toolbar->addAction(m_buttonSelectTool);
955 m_buttonSelectTool->setCheckable(true);
956 m_buttonSelectTool->setChecked(true);
958 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
959 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
960 toolbar->addAction(m_buttonRazorTool);
961 m_buttonRazorTool->setCheckable(true);
962 m_buttonRazorTool->setChecked(false);
964 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
965 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
966 toolbar->addAction(m_buttonSpacerTool);
967 m_buttonSpacerTool->setCheckable(true);
968 m_buttonSpacerTool->setChecked(false);
970 QActionGroup *toolGroup = new QActionGroup(this);
971 toolGroup->addAction(m_buttonSelectTool);
972 toolGroup->addAction(m_buttonRazorTool);
973 toolGroup->addAction(m_buttonSpacerTool);
974 toolGroup->setExclusive(true);
975 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
977 QWidget * actionWidget;
978 int max = toolbar->iconSizeDefault() + 2;
979 actionWidget = toolbar->widgetForAction(m_normalEditTool);
980 actionWidget->setMaximumWidth(max);
981 actionWidget->setMaximumHeight(max - 4);
983 actionWidget = toolbar->widgetForAction(m_insertEditTool);
984 actionWidget->setMaximumWidth(max);
985 actionWidget->setMaximumHeight(max - 4);
987 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
988 actionWidget->setMaximumWidth(max);
989 actionWidget->setMaximumHeight(max - 4);
991 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
992 actionWidget->setMaximumWidth(max);
993 actionWidget->setMaximumHeight(max - 4);
995 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
996 actionWidget->setMaximumWidth(max);
997 actionWidget->setMaximumHeight(max - 4);
999 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
1000 actionWidget->setMaximumWidth(max);
1001 actionWidget->setMaximumHeight(max - 4);
1003 toolbar->setStyleSheet(style1);
1004 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
1006 toolbar->addSeparator();
1007 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
1008 toolbar->addAction(m_buttonFitZoom);
1009 m_buttonFitZoom->setCheckable(false);
1011 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
1012 toolbar->addAction(m_zoomOut);
1013 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
1015 m_zoomSlider = new QSlider(Qt::Horizontal, this);
1016 m_zoomSlider->setMaximum(13);
1017 m_zoomSlider->setPageStep(1);
1018 m_zoomSlider->setInvertedAppearance(true);
1020 m_zoomSlider->setMaximumWidth(150);
1021 m_zoomSlider->setMinimumWidth(100);
1022 toolbar->addWidget(m_zoomSlider);
1024 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
1025 toolbar->addAction(m_zoomIn);
1026 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
1028 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
1029 actionWidget->setMaximumWidth(max);
1030 actionWidget->setMaximumHeight(max - 4);
1031 actionWidget->setStyleSheet(styleBorderless);
1033 actionWidget = toolbar->widgetForAction(m_zoomIn);
1034 actionWidget->setMaximumWidth(max);
1035 actionWidget->setMaximumHeight(max - 4);
1036 actionWidget->setStyleSheet(styleBorderless);
1038 actionWidget = toolbar->widgetForAction(m_zoomOut);
1039 actionWidget->setMaximumWidth(max);
1040 actionWidget->setMaximumHeight(max - 4);
1041 actionWidget->setStyleSheet(styleBorderless);
1043 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
1044 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
1045 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
1046 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
1047 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
1049 toolbar->addSeparator();
1051 //create automatic audio split button
1052 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
1053 toolbar->addAction(m_buttonAutomaticSplitAudio);
1054 m_buttonAutomaticSplitAudio->setCheckable(true);
1055 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
1056 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
1058 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
1059 toolbar->addAction(m_buttonVideoThumbs);
1060 m_buttonVideoThumbs->setCheckable(true);
1061 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1062 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
1064 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
1065 toolbar->addAction(m_buttonAudioThumbs);
1066 m_buttonAudioThumbs->setCheckable(true);
1067 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1068 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
1070 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
1071 toolbar->addAction(m_buttonShowMarkers);
1072 m_buttonShowMarkers->setCheckable(true);
1073 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1074 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
1076 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
1077 toolbar->addAction(m_buttonSnap);
1078 m_buttonSnap->setCheckable(true);
1079 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1080 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
1082 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
1083 actionWidget->setMaximumWidth(max);
1084 actionWidget->setMaximumHeight(max - 4);
1086 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
1087 actionWidget->setMaximumWidth(max);
1088 actionWidget->setMaximumHeight(max - 4);
1090 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
1091 actionWidget->setMaximumWidth(max);
1092 actionWidget->setMaximumHeight(max - 4);
1094 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
1095 actionWidget->setMaximumWidth(max);
1096 actionWidget->setMaximumHeight(max - 4);
1098 actionWidget = toolbar->widgetForAction(m_buttonSnap);
1099 actionWidget->setMaximumWidth(max);
1100 actionWidget->setMaximumHeight(max - 4);
1102 m_messageLabel = new StatusBarMessageLabel(this);
1103 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
1105 statusBar()->addWidget(m_messageLabel, 10);
1106 statusBar()->addWidget(m_statusProgressBar, 0);
1107 statusBar()->addPermanentWidget(toolbar);
1108 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
1109 statusBar()->addPermanentWidget(m_timecodeFormat);
1110 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
1112 collection->addAction("normal_mode", m_normalEditTool);
1113 collection->addAction("overwrite_mode", m_overwriteEditTool);
1114 collection->addAction("insert_mode", m_insertEditTool);
1115 collection->addAction("select_tool", m_buttonSelectTool);
1116 collection->addAction("razor_tool", m_buttonRazorTool);
1117 collection->addAction("spacer_tool", m_buttonSpacerTool);
1119 collection->addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
1120 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
1121 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
1122 collection->addAction("show_markers", m_buttonShowMarkers);
1123 collection->addAction("snap", m_buttonSnap);
1124 collection->addAction("zoom_fit", m_buttonFitZoom);
1125 collection->addAction("zoom_in", m_zoomIn);
1126 collection->addAction("zoom_out", m_zoomOut);
1128 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
1129 collection->addAction("project_find", m_projectSearch);
1130 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
1131 m_projectSearch->setShortcut(Qt::Key_Slash);
1133 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
1134 collection->addAction("project_find_next", m_projectSearchNext);
1135 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
1136 m_projectSearchNext->setShortcut(Qt::Key_F3);
1137 m_projectSearchNext->setEnabled(false);
1139 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
1140 collection->addAction("manage_profiles", profilesAction);
1141 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
1143 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
1144 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
1145 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
1146 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
1148 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
1149 collection->addAction("run_wizard", wizAction);
1150 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
1152 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
1153 collection->addAction("project_settings", projectAction);
1154 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
1156 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
1157 collection->addAction("project_render", projectRender);
1158 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
1159 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
1161 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1162 collection->addAction("project_clean", projectClean);
1163 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1165 KAction* projectAdjust = new KAction(KIcon(), i18n("Adjust Profile to Current Clip"), this);
1166 collection->addAction("project_adjust_profile", projectAdjust);
1167 connect(projectAdjust, SIGNAL(triggered(bool)), m_projectList, SLOT(adjustProjectProfileToItem()));
1169 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1170 KShortcut playShortcut;
1171 playShortcut.setPrimary(Qt::Key_Space);
1172 playShortcut.setAlternate(Qt::Key_K);
1173 monitorPlay->setShortcut(playShortcut);
1174 collection->addAction("monitor_play", monitorPlay);
1175 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1177 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1178 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1179 collection->addAction("monitor_play_zone", m_playZone);
1180 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1182 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1183 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1184 collection->addAction("monitor_loop_zone", m_loopZone);
1185 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1187 m_loopClip = new KAction(KIcon("media-playback-start"), i18n("Loop selected clip"), this);
1188 m_loopClip->setEnabled(false);
1189 collection->addAction("monitor_loop_clip", m_loopClip);
1190 connect(m_loopClip, SIGNAL(triggered(bool)), m_projectMonitor, SLOT(slotLoopClip()));
1192 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1193 collection->addAction("dvd_wizard", dvdWizard);
1194 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1196 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1197 collection->addAction("transcode_clip", transcodeClip);
1198 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1200 KAction *markIn = collection->addAction("mark_in");
1201 markIn->setText(i18n("Set Zone In"));
1202 markIn->setShortcut(Qt::Key_I);
1203 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1205 KAction *markOut = collection->addAction("mark_out");
1206 markOut->setText(i18n("Set Zone Out"));
1207 markOut->setShortcut(Qt::Key_O);
1208 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1210 KAction *switchMon = collection->addAction("switch_monitor");
1211 switchMon->setText(i18n("Switch monitor"));
1212 switchMon->setShortcut(Qt::Key_T);
1213 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1215 KAction *fullMon = collection->addAction("monitor_fullscreen");
1216 fullMon->setText(i18n("Switch monitor fullscreen"));
1217 fullMon->setIcon(KIcon("view-fullscreen"));
1218 connect(fullMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchFullscreen()));
1220 KAction *insertTree = collection->addAction("insert_project_tree");
1221 insertTree->setText(i18n("Insert zone in project tree"));
1222 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1223 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1225 KAction *insertTimeline = collection->addAction("insert_timeline");
1226 insertTimeline->setText(i18n("Insert zone in timeline"));
1227 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1228 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1230 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1231 collection->addAction("resize_timeline_clip_start", resizeStart);
1232 resizeStart->setShortcut(Qt::Key_1);
1233 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1235 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1236 collection->addAction("resize_timeline_clip_end", resizeEnd);
1237 resizeEnd->setShortcut(Qt::Key_2);
1238 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1240 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1241 monitorSeekBackward->setShortcut(Qt::Key_J);
1242 collection->addAction("monitor_seek_backward", monitorSeekBackward);
1243 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1245 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1246 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1247 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1248 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1250 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1251 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1252 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1253 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1255 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1256 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1257 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1258 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1260 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1261 monitorSeekForward->setShortcut(Qt::Key_L);
1262 collection->addAction("monitor_seek_forward", monitorSeekForward);
1263 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1265 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1266 clipStart->setShortcut(Qt::Key_Home);
1267 collection->addAction("seek_clip_start", clipStart);
1268 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1270 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1271 clipEnd->setShortcut(Qt::Key_End);
1272 collection->addAction("seek_clip_end", clipEnd);
1273 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1275 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1276 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1277 collection->addAction("seek_zone_start", zoneStart);
1278 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1280 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1281 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1282 collection->addAction("seek_zone_end", zoneEnd);
1283 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1285 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1286 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1287 collection->addAction("seek_start", projectStart);
1288 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1290 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1291 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1292 collection->addAction("seek_end", projectEnd);
1293 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1295 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1296 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1297 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1298 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1300 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1301 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1302 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1303 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1305 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1306 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1307 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1308 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1310 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1311 deleteItem->setShortcut(Qt::Key_Delete);
1312 collection->addAction("delete_timeline_clip", deleteItem);
1313 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1315 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1316 collection->addAction("change_clip_speed", editTimelineClipSpeed);
1317 editTimelineClipSpeed->setData("change_speed");
1318 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1320 KAction *stickTransition = collection->addAction("auto_transition");
1321 stickTransition->setData(QString("auto"));
1322 stickTransition->setCheckable(true);
1323 stickTransition->setEnabled(false);
1324 stickTransition->setText(i18n("Automatic Transition"));
1325 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1327 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1328 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1329 collection->addAction("group_clip", groupClip);
1330 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1332 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1333 collection->addAction("ungroup_clip", ungroupClip);
1334 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1335 ungroupClip->setData("ungroup_clip");
1336 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1338 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1339 collection->addAction("edit_item_duration", editItemDuration);
1340 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1342 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1343 collection->addAction("clip_in_project_tree", clipInProjectTree);
1344 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1346 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1347 collection->addAction("clip_to_project_tree", clipToProjectTree);
1348 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1350 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1351 insertOvertwrite->setShortcut(Qt::Key_V);
1352 collection->addAction("overwrite_to_in_point", insertOvertwrite);
1353 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1355 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1356 selectTimelineClip->setShortcut(Qt::Key_Plus);
1357 collection->addAction("select_timeline_clip", selectTimelineClip);
1358 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1360 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1361 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1362 collection->addAction("deselect_timeline_clip", deselectTimelineClip);
1363 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1365 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1366 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1367 collection->addAction("select_add_timeline_clip", selectAddTimelineClip);
1368 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1370 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1371 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1372 collection->addAction("select_timeline_transition", selectTimelineTransition);
1373 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1375 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1376 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1377 collection->addAction("deselect_timeline_transition", deselectTimelineTransition);
1378 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1380 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1381 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1382 collection->addAction("select_add_timeline_transition", selectAddTimelineTransition);
1383 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1385 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1386 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1387 collection->addAction("cut_timeline_clip", cutTimelineClip);
1388 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1390 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1391 collection->addAction("add_clip_marker", addClipMarker);
1392 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1394 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1395 collection->addAction("delete_clip_marker", deleteClipMarker);
1396 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1398 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1399 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
1400 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1402 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1403 collection->addAction("edit_clip_marker", editClipMarker);
1404 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1406 KAction *addMarkerGuideQuickly = new KAction(KIcon("bookmark-new"), i18n("Add Marker/Guide quickly"), this);
1407 addMarkerGuideQuickly->setShortcut(Qt::Key_Asterisk);
1408 collection->addAction("add_marker_guide_quickly", addMarkerGuideQuickly);
1409 connect(addMarkerGuideQuickly, SIGNAL(triggered(bool)), this, SLOT(slotAddMarkerGuideQuickly()));
1411 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1412 collection->addAction("split_audio", splitAudio);
1413 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1415 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1416 collection->addAction("clip_audio_only", audioOnly);
1417 audioOnly->setData("clip_audio_only");
1418 audioOnly->setCheckable(true);
1420 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1421 collection->addAction("clip_video_only", videoOnly);
1422 videoOnly->setData("clip_video_only");
1423 videoOnly->setCheckable(true);
1425 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1426 collection->addAction("clip_audio_and_video", audioAndVideo);
1427 audioAndVideo->setData("clip_audio_and_video");
1428 audioAndVideo->setCheckable(true);
1430 m_clipTypeGroup = new QActionGroup(this);
1431 m_clipTypeGroup->addAction(audioOnly);
1432 m_clipTypeGroup->addAction(videoOnly);
1433 m_clipTypeGroup->addAction(audioAndVideo);
1434 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1435 m_clipTypeGroup->setEnabled(false);
1437 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1438 collection->addAction("insert_space", insertSpace);
1439 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1441 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1442 collection->addAction("delete_space", removeSpace);
1443 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1445 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1446 collection->addAction("insert_track", insertTrack);
1447 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1449 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1450 collection->addAction("delete_track", deleteTrack);
1451 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1453 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
1454 collection->addAction("config_tracks", configTracks);
1455 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1457 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1458 collection->addAction("add_guide", addGuide);
1459 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1461 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1462 collection->addAction("delete_guide", delGuide);
1463 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1465 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1466 collection->addAction("edit_guide", editGuide);
1467 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1469 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1470 collection->addAction("delete_all_guides", delAllGuides);
1471 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1473 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1474 collection->addAction("paste_effects", pasteEffects);
1475 pasteEffects->setData("paste_effects");
1476 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1478 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1479 collection->addAction("show_timeline", showTimeline);
1480 showTimeline->setCheckable(true);
1481 showTimeline->setChecked(true);
1482 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1484 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1485 collection->addAction("show_titlebars", showTitleBar);
1486 showTitleBar->setCheckable(true);
1487 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1488 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1489 slotShowTitleBars(KdenliveSettings::showtitlebars());
1492 //const QByteArray state = layoutGroup.readEntry("layout1", QByteArray());
1494 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1495 collection->addAction("maximize_current", maxCurrent);
1496 maxCurrent->setCheckable(true);
1497 maxCurrent->setChecked(false);
1498 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1500 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1501 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1502 KStandardAction::open(this, SLOT(openFile()), collection);
1503 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1504 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1505 KStandardAction::openNew(this, SLOT(newFile()), collection);
1506 // TODO: make the following connection to slotEditKeys work
1507 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1508 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1509 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1510 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1511 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1512 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1514 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1515 undo->setEnabled(false);
1516 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1518 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1519 redo->setEnabled(false);
1520 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1523 //TODO: Add status tooltip to actions ?
1524 connect(collection, SIGNAL(actionHovered(QAction*)),
1525 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1528 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1529 collection->addAction("add_clip", addClip);
1530 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1532 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1533 collection->addAction("add_color_clip", addColorClip);
1534 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1536 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1537 collection->addAction("add_slide_clip", addSlideClip);
1538 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1540 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1541 collection->addAction("add_text_clip", addTitleClip);
1542 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1544 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1545 collection->addAction("add_text_template_clip", addTitleTemplateClip);
1546 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1548 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1549 collection->addAction("add_folder", addFolderButton);
1550 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1552 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1553 collection->addAction("clip_properties", clipProperties);
1554 clipProperties->setData("clip_properties");
1555 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1556 clipProperties->setEnabled(false);
1558 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1559 collection->addAction("edit_clip", openClip);
1560 openClip->setData("edit_clip");
1561 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1562 openClip->setEnabled(false);
1564 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1565 collection->addAction("delete_clip", deleteClip);
1566 deleteClip->setData("delete_clip");
1567 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1568 deleteClip->setEnabled(false);
1570 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1571 collection->addAction("reload_clip", reloadClip);
1572 reloadClip->setData("reload_clip");
1573 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1574 reloadClip->setEnabled(false);
1576 QAction *stopMotion = new KAction(KIcon("image-x-generic"), i18n("Stop Motion Capture"), this);
1577 collection->addAction("stopmotion", stopMotion);
1578 connect(stopMotion , SIGNAL(triggered()), this, SLOT(slotOpenStopmotion()));
1580 QMenu *addClips = new QMenu();
1581 addClips->addAction(addClip);
1582 addClips->addAction(addColorClip);
1583 addClips->addAction(addSlideClip);
1584 addClips->addAction(addTitleClip);
1585 addClips->addAction(addTitleTemplateClip);
1586 addClips->addAction(addFolderButton);
1588 addClips->addAction(reloadClip);
1589 addClips->addAction(clipProperties);
1590 addClips->addAction(openClip);
1591 addClips->addAction(deleteClip);
1592 m_projectList->setupMenu(addClips, addClip);
1594 // Setup effects and transitions actions.
1595 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1596 //KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), m_effectsActionCollection);
1597 KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), collection);
1598 m_videoEffects = new KAction*[videoEffects.count()];
1599 for (int i = 0; i < videoEffects.count(); ++i) {
1600 QStringList effectInfo = videoEffects.effectIdInfo(i);
1601 m_videoEffects[i] = new KAction(KIcon("kdenlive-show-video"), effectInfo.at(0), this);
1602 m_videoEffects[i]->setData(effectInfo);
1603 m_videoEffects[i]->setIconVisibleInMenu(false);
1604 videoEffectActions->addAction("video_effect_" + effectInfo.at(0), m_videoEffects[i]);
1606 //KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), m_effectsActionCollection);
1607 KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), collection);
1608 m_audioEffects = new KAction*[audioEffects.count()];
1609 for (int i = 0; i < audioEffects.count(); ++i) {
1610 QStringList effectInfo = audioEffects.effectIdInfo(i);
1611 m_audioEffects[i] = new KAction(KIcon("kdenlive-show-audio"), effectInfo.at(0), this);
1612 m_audioEffects[i]->setData(effectInfo);
1613 m_audioEffects[i]->setIconVisibleInMenu(false);
1614 audioEffectActions->addAction("audio_effect_" + effectInfo.at(0), m_audioEffects[i]);
1616 //KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), m_effectsActionCollection);
1617 KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), collection);
1618 m_customEffects = new KAction*[customEffects.count()];
1619 for (int i = 0; i < customEffects.count(); ++i) {
1620 QStringList effectInfo = customEffects.effectIdInfo(i);
1621 m_customEffects[i] = new KAction(KIcon("kdenlive-custom-effect"), effectInfo.at(0), this);
1622 m_customEffects[i]->setData(effectInfo);
1623 m_customEffects[i]->setIconVisibleInMenu(false);
1624 customEffectActions->addAction("custom_effect_" + effectInfo.at(0), m_customEffects[i]);
1626 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1627 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1628 m_transitions = new KAction*[transitions.count()];
1629 for (int i = 0; i < transitions.count(); i++) {
1630 QStringList effectInfo = transitions.effectIdInfo(i);
1631 m_transitions[i] = new KAction(effectInfo.at(0), this);
1632 m_transitions[i]->setData(effectInfo);
1633 m_transitions[i]->setIconVisibleInMenu(false);
1634 transitionActions->addAction("transition_" + effectInfo.at(0), m_transitions[i]);
1636 m_effectsActionCollection->readSettings();
1638 //connect(collection, SIGNAL( clearStatusText() ),
1639 //statusBar(), SLOT( clear() ) );
1642 void MainWindow::slotDisplayActionMessage(QAction *a)
1644 statusBar()->showMessage(a->data().toString(), 3000);
1647 void MainWindow::loadLayouts()
1649 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
1650 QMenu *loadLayout = (QMenu*)(factory()->container("layout_load", this));
1651 if (loadLayout == NULL || saveLayout == NULL) return;
1652 KSharedConfigPtr config = KGlobal::config();
1653 KConfigGroup layoutGroup(config, "Layouts");
1654 QStringList entries = layoutGroup.keyList();
1655 QList<QAction *> loadActions = loadLayout->actions();
1656 QList<QAction *> saveActions = saveLayout->actions();
1657 for (int i = 1; i < 5; i++) {
1658 // Rename the layouts actions
1659 foreach(const QString & key, entries) {
1660 if (key.endsWith(QString("_%1").arg(i))) {
1661 // Found previously saved layout
1662 QString layoutName = key.section("_", 0, -2);
1663 for (int j = 0; j < loadActions.count(); j++) {
1664 if (loadActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1665 loadActions[j]->setText(layoutName);
1666 loadActions[j]->setData(key);
1670 for (int j = 0; j < saveActions.count(); j++) {
1671 if (saveActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1672 saveActions[j]->setText(layoutName);
1673 saveActions[j]->setData(key);
1682 void MainWindow::slotLoadLayout(QAction *action)
1684 if (!action) return;
1685 QString layoutId = action->data().toString();
1686 if (layoutId.isEmpty()) return;
1687 KSharedConfigPtr config = KGlobal::config();
1688 KConfigGroup layouts(config, "Layouts");
1689 //QByteArray geom = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1690 QByteArray state = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1691 //restoreGeometry(geom);
1692 restoreState(state);
1695 void MainWindow::slotSaveLayout(QAction *action)
1697 QString originallayoutName = action->data().toString();
1698 int layoutId = originallayoutName.section('_', -1).toInt();
1700 QString layoutName = QInputDialog::getText(this, i18n("Save Layout"), i18n("Layout name:"), QLineEdit::Normal, originallayoutName.section('_', 0, -2));
1701 if (layoutName.isEmpty()) return;
1702 KSharedConfigPtr config = KGlobal::config();
1703 KConfigGroup layouts(config, "Layouts");
1704 layouts.deleteEntry(originallayoutName);
1706 QByteArray st = saveState();
1707 layoutName.append("_" + QString::number(layoutId));
1708 layouts.writeEntry(layoutName, st.toBase64());
1712 void MainWindow::saveOptions()
1714 KdenliveSettings::self()->writeConfig();
1715 KSharedConfigPtr config = KGlobal::config();
1716 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1717 KConfigGroup treecolumns(config, "Project Tree");
1718 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1722 void MainWindow::readOptions()
1724 KSharedConfigPtr config = KGlobal::config();
1725 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1726 KConfigGroup initialGroup(config, "version");
1727 bool upgrade = false;
1728 if (initialGroup.exists()) {
1729 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1733 if (initialGroup.readEntry("version") == "0.7") {
1734 //Add new settings from 0.7.1
1735 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1736 QString path = QDir::homePath() + "/kdenlive";
1737 if (KStandardDirs::makeDir(path) == false) {
1738 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1739 } else KdenliveSettings::setDefaultprojectfolder(path);
1745 if (!initialGroup.exists() || upgrade) {
1746 // this is our first run, show Wizard
1747 Wizard *w = new Wizard(upgrade, this);
1748 if (w->exec() == QDialog::Accepted && w->isOk()) {
1749 w->adjustSettings();
1750 initialGroup.writeEntry("version", version);
1756 KConfigGroup treecolumns(config, "Project Tree");
1757 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1758 if (!state.isEmpty())
1759 m_projectList->setHeaderInfo(state);
1762 void MainWindow::slotRunWizard()
1764 Wizard *w = new Wizard(false, this);
1765 if (w->exec() == QDialog::Accepted && w->isOk()) {
1766 w->adjustSettings();
1771 void MainWindow::newFile(bool showProjectSettings, bool force)
1773 if (!m_timelineArea->isEnabled() && !force)
1775 m_fileRevert->setEnabled(false);
1776 QString profileName = KdenliveSettings::default_profile();
1777 KUrl projectFolder = KdenliveSettings::defaultprojectfolder();
1778 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1779 if (!showProjectSettings) {
1780 if (!KdenliveSettings::activatetabs())
1781 if (!closeCurrentDocument())
1784 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1785 if (w->exec() != QDialog::Accepted)
1787 if (!KdenliveSettings::activatetabs())
1788 if (!closeCurrentDocument())
1790 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs())
1791 slotSwitchVideoThumbs();
1792 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs())
1793 slotSwitchAudioThumbs();
1794 profileName = w->selectedProfile();
1795 projectFolder = w->selectedFolder();
1796 projectTracks = w->tracks();
1799 m_timelineArea->setEnabled(true);
1800 m_projectList->setEnabled(true);
1801 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, m_notesWidget, this);
1802 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1804 TrackView *trackView = new TrackView(doc, &ok, this);
1805 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1808 //m_timelineArea->setEnabled(false);
1809 //m_projectList->setEnabled(false);
1813 if (m_timelineArea->count() == 1) {
1814 connectDocumentInfo(doc);
1815 connectDocument(trackView, doc);
1817 m_timelineArea->setTabBarHidden(false);
1818 m_monitorManager->activateMonitor("clip");
1819 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1822 void MainWindow::activateDocument()
1824 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1825 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1826 KdenliveDoc *currentDoc = currentTab->document();
1827 connectDocumentInfo(currentDoc);
1828 connectDocument(currentTab, currentDoc);
1831 bool MainWindow::closeCurrentDocument(bool saveChanges)
1833 QWidget *w = m_timelineArea->currentWidget();
1834 if (!w) return true;
1835 // closing current document
1836 int ix = m_timelineArea->currentIndex() + 1;
1837 if (ix == m_timelineArea->count()) ix = 0;
1838 m_timelineArea->setCurrentIndex(ix);
1839 TrackView *tabToClose = (TrackView *) w;
1840 KdenliveDoc *docToClose = tabToClose->document();
1841 if (docToClose && docToClose->isModified() && saveChanges) {
1843 if (m_activeDocument->url().fileName().isEmpty())
1844 message = i18n("Save changes to document?");
1846 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1847 switch (KMessageBox::warningYesNoCancel(this, message)) {
1848 case KMessageBox::Yes :
1849 // save document here. If saving fails, return false;
1850 if (saveFile() == false) return false;
1852 case KMessageBox::Cancel :
1859 m_clipMonitor->slotSetXml(NULL);
1860 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1861 if (m_timelineArea->count() == 1) {
1862 m_timelineArea->setTabBarHidden(true);
1863 m_closeAction->setEnabled(false);
1865 if (docToClose == m_activeDocument) {
1866 delete m_activeDocument;
1867 m_activeDocument = NULL;
1868 m_effectStack->clear();
1869 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1873 if (w == m_activeTimeline) {
1874 delete m_activeTimeline;
1875 m_activeTimeline = NULL;
1882 bool MainWindow::saveFileAs(const QString &outputFileName)
1884 QString currentSceneList;
1885 m_monitorManager->stopActiveMonitor();
1887 if (m_activeDocument->saveSceneList(outputFileName, m_projectMonitor->sceneList()) == false)
1890 // Save timeline thumbnails
1891 m_activeTimeline->projectView()->saveThumbnails();
1892 m_activeDocument->setUrl(KUrl(outputFileName));
1893 if (m_activeDocument->m_autosave == NULL) {
1894 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1895 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1896 setCaption(m_activeDocument->description());
1897 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1898 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1899 m_activeDocument->setModified(false);
1900 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1901 m_fileRevert->setEnabled(true);
1905 bool MainWindow::saveFileAs()
1907 QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType());
1908 if (outputFile.isEmpty()) {
1911 if (QFile::exists(outputFile)) {
1912 // Show the file dialog again if the user does not want to overwrite the file
1913 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", outputFile)) == KMessageBox::No)
1914 return saveFileAs();
1916 return saveFileAs(outputFile);
1919 bool MainWindow::saveFile()
1921 if (!m_activeDocument) return true;
1922 if (m_activeDocument->url().isEmpty()) {
1923 return saveFileAs();
1925 bool result = saveFileAs(m_activeDocument->url().path());
1926 m_activeDocument->m_autosave->resize(0);
1931 void MainWindow::openFile()
1933 if (!m_startUrl.isEmpty()) {
1934 openFile(m_startUrl);
1935 m_startUrl = KUrl();
1938 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
1939 if (url.isEmpty()) return;
1940 m_fileOpenRecent->addUrl(url);
1944 void MainWindow::openLastFile()
1946 KSharedConfigPtr config = KGlobal::config();
1947 KUrl::List urls = m_fileOpenRecent->urls();
1948 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1949 if (urls.isEmpty()) newFile(false);
1950 else openFile(urls.last());
1953 void MainWindow::openFile(const KUrl &url)
1955 // Check if the document is already opened
1956 const int ct = m_timelineArea->count();
1957 bool isOpened = false;
1959 for (i = 0; i < ct; i++) {
1960 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1961 KdenliveDoc *doc = tab->document();
1962 if (doc->url() == url) {
1968 m_timelineArea->setCurrentIndex(i);
1972 if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
1974 // Check for backup file
1975 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1976 if (!staleFiles.isEmpty()) {
1977 if (KMessageBox::questionYesNo(this,
1978 i18n("Auto-saved files exist. Do you want to recover them now?"),
1979 i18n("File Recovery"),
1980 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1981 recoverFiles(staleFiles);
1984 // remove the stale files
1985 foreach(KAutoSaveFile * stale, staleFiles) {
1986 stale->open(QIODevice::ReadWrite);
1991 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
1992 m_messageLabel->repaint();
1993 doOpenFile(url, NULL);
1996 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1998 if (!m_timelineArea->isEnabled()) return;
1999 m_fileRevert->setEnabled(true);
2001 // Recreate stopmotion widget on document change
2003 delete m_stopmotion;
2004 m_stopmotion = NULL;
2007 KProgressDialog progressDialog(this, i18n("Loading project"), i18n("Loading project"));
2008 progressDialog.setAllowCancel(false);
2009 progressDialog.progressBar()->setMaximum(4);
2010 progressDialog.show();
2011 progressDialog.progressBar()->setValue(0);
2012 qApp->processEvents();
2014 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, m_notesWidget, this, &progressDialog);
2016 progressDialog.progressBar()->setValue(1);
2017 progressDialog.progressBar()->setMaximum(4);
2018 progressDialog.setLabelText(i18n("Loading project"));
2019 qApp->processEvents();
2021 if (stale == NULL) {
2022 stale = new KAutoSaveFile(url, doc);
2023 doc->m_autosave = stale;
2025 doc->m_autosave = stale;
2026 doc->setUrl(stale->managedFile());
2027 doc->setModified(true);
2028 stale->setParent(doc);
2030 connectDocumentInfo(doc);
2032 progressDialog.progressBar()->setValue(2);
2033 qApp->processEvents();
2036 TrackView *trackView = new TrackView(doc, &ok, this);
2038 progressDialog.progressBar()->setValue(3);
2039 qApp->processEvents();
2041 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
2043 m_timelineArea->setEnabled(false);
2044 m_projectList->setEnabled(false);
2045 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
2046 slotGotProgressInfo(QString(), -1);
2047 newFile(false, true);
2050 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
2051 trackView->setDuration(trackView->duration());
2052 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
2054 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
2055 slotGotProgressInfo(QString(), -1);
2056 m_projectMonitor->adjustRulerSize(trackView->duration());
2057 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
2058 m_clipMonitor->refreshMonitor(true);
2060 progressDialog.progressBar()->setValue(4);
2063 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
2065 foreach(KAutoSaveFile * stale, staleFiles) {
2066 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
2067 // show an error message; we could not steal the lockfile
2068 // maybe another application got to the file before us?
2072 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
2073 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
2074 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
2075 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
2079 void MainWindow::parseProfiles(const QString &mltPath)
2081 //KdenliveSettings::setDefaulttmpfolder();
2082 if (!mltPath.isEmpty()) {
2083 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
2084 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
2087 if (KdenliveSettings::mltpath().isEmpty())
2088 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
2090 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
2091 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
2092 if (!QFile::exists(meltPath))
2093 meltPath = KStandardDirs::findExe("melt");
2094 KdenliveSettings::setRendererpath(meltPath);
2097 if (KdenliveSettings::rendererpath().isEmpty()) {
2098 // Cannot find the MLT melt renderer, ask for location
2099 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
2100 if (getUrl->exec() == QDialog::Rejected) {
2103 KUrl rendererPath = getUrl->selectedUrl();
2105 if (rendererPath.isEmpty()) ::exit(0);
2106 KdenliveSettings::setRendererpath(rendererPath.path());
2109 QStringList profilesFilter;
2110 profilesFilter << "*";
2111 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2112 if (profilesList.isEmpty()) {
2113 // Cannot find MLT path, try finding melt
2114 QString profilePath = KdenliveSettings::rendererpath();
2115 if (!profilePath.isEmpty()) {
2116 profilePath = profilePath.section('/', 0, -3);
2117 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
2118 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2120 if (profilesList.isEmpty()) {
2121 // Cannot find the MLT profiles, ask for location
2122 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
2123 getUrl->fileDialog()->setMode(KFile::Directory);
2124 if (getUrl->exec() == QDialog::Rejected) {
2127 KUrl mltPath = getUrl->selectedUrl();
2129 if (mltPath.isEmpty()) ::exit(0);
2130 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
2131 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2135 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
2137 // Parse again MLT profiles to build a list of available video formats
2138 if (profilesList.isEmpty()) parseProfiles();
2142 void MainWindow::slotEditProfiles()
2144 ProfilesDialog *w = new ProfilesDialog;
2145 if (w->exec() == QDialog::Accepted) {
2146 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2147 if (d) d->checkProfile();
2152 void MainWindow::slotDetectAudioDriver()
2154 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
2155 leading to no audio output, see bug #934 */
2157 //decide which audio driver is really best, in some cases SDL is wrong
2158 if (KdenliveSettings::audiodrivername().isEmpty()) {
2160 KProcess readProcess;
2161 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
2162 if (!KStandardDirs::findExe("pactl").isEmpty()) {
2163 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
2164 readProcess.setProgram("pactl", QStringList() << "stat");
2165 readProcess.execute(2000); // Kill it after 2 seconds
2167 QString result = QString(readProcess.readAllStandardOutput());
2168 kDebug() << "// / / / / / READING PACTL: ";
2170 if (!result.isEmpty()) {
2172 kDebug() << "// / / / / PULSEAUDIO DETECTED";
2176 KdenliveSettings::setAutoaudiodrivername(driver);
2180 void MainWindow::slotEditProjectSettings()
2182 QPoint p = m_activeDocument->getTracksCount();
2183 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
2185 if (w->exec() == QDialog::Accepted) {
2186 QString profile = w->selectedProfile();
2187 m_activeDocument->setProjectFolder(w->selectedFolder());
2189 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2191 if (m_renderWidget) m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2192 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
2193 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
2194 if (m_activeDocument->profilePath() != profile) slotUpdateProjectProfile(profile);
2199 void MainWindow::slotUpdateProjectProfile(const QString &profile)
2201 double dar = m_activeDocument->dar();
2203 // Recreate the stopmotion widget if profile changes
2205 delete m_stopmotion;
2206 m_stopmotion = NULL;
2209 // Deselect current effect / transition
2210 m_effectStack->slotClipItemSelected(NULL, 0);
2211 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
2212 m_clipMonitor->slotSetXml(NULL);
2213 bool updateFps = m_activeDocument->setProfilePath(profile);
2214 KdenliveSettings::setCurrent_profile(profile);
2215 KdenliveSettings::setProject_fps(m_activeDocument->fps());
2216 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
2218 m_activeDocument->clipManager()->clearUnusedProducers();
2219 m_monitorManager->resetProfiles(m_activeDocument->timecode());
2220 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2221 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
2222 m_projectList->updateProjectFormat(m_activeDocument->timecode());
2223 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
2224 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
2225 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
2226 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
2227 if (updateFps) m_activeTimeline->updateProjectFps();
2228 m_activeDocument->setModified(true);
2229 m_commandStack->activeStack()->clear();
2230 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2231 slotUpdateMousePosition(0);
2232 // We need to desactivate & reactivate monitors to get a refresh
2233 //m_monitorManager->switchMonitors();
2237 void MainWindow::slotRenderProject()
2239 if (!m_renderWidget) {
2240 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
2241 m_renderWidget = new RenderWidget(projectfolder, this);
2242 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
2243 connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
2244 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
2245 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
2246 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
2247 if (m_activeDocument) {
2248 m_renderWidget->setProfile(m_activeDocument->mltProfile());
2249 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2250 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2251 m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
2254 slotCheckRenderStatus();
2255 m_renderWidget->show();
2256 m_renderWidget->showNormal();
2258 // What are the following lines supposed to do?
2259 //m_activeTimeline->tracksNumber();
2260 //m_renderWidget->enableAudio(false);
2261 //m_renderWidget->export_audio;
2264 void MainWindow::slotCheckRenderStatus()
2266 // Make sure there are no missing clips
2268 m_renderWidget->missingClips(m_projectList->hasMissingClips());
2271 void MainWindow::setRenderingProgress(const QString &url, int progress)
2274 m_renderWidget->setRenderJob(url, progress);
2277 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2280 m_renderWidget->setRenderStatus(url, status, error);
2283 void MainWindow::slotCleanProject()
2285 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2286 m_projectList->cleanup();
2289 void MainWindow::slotUpdateMousePosition(int pos)
2291 if (m_activeDocument)
2292 switch (m_timecodeFormat->currentIndex()) {
2294 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2297 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2301 void MainWindow::slotUpdateDocumentState(bool modified)
2303 if (!m_activeDocument) return;
2304 setCaption(m_activeDocument->description(), modified);
2305 m_saveAction->setEnabled(modified);
2307 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2308 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2310 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2311 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2315 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2317 if (m_activeDocument) {
2318 if (m_activeDocument == doc) return;
2319 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2321 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2324 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2326 //m_projectMonitor->stop();
2327 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2328 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2329 if (m_activeDocument) {
2330 if (m_activeDocument == doc) return;
2331 if (m_activeTimeline) {
2332 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2333 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2334 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2335 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2336 disconnect(m_notesWidget, SIGNAL(textChanged()), m_activeDocument, SLOT(setModified()));
2337 disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2338 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2339 disconnect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2341 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
2343 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2344 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2345 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2346 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2347 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2348 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2349 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
2350 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2351 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2352 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2353 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2354 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2355 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2356 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2357 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2358 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2359 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2360 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2361 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2362 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2363 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2364 disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2365 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2366 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2367 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2368 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2369 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2370 disconnect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2371 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2372 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2373 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2374 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2375 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2376 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2377 disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2378 disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2379 m_effectStack->clear();
2381 //m_activeDocument->setRenderer(NULL);
2382 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
2383 disconnect(m_projectList, SIGNAL(refreshClip()), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
2384 m_clipMonitor->stop();
2386 KdenliveSettings::setCurrent_profile(doc->profilePath());
2387 KdenliveSettings::setProject_fps(doc->fps());
2388 m_monitorManager->resetProfiles(doc->timecode());
2389 m_projectList->setDocument(doc);
2390 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2391 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2392 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint)));
2393 connect(m_projectList, SIGNAL(refreshClip()), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
2394 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), trackView->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2396 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2397 connect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2398 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2400 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
2403 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2404 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2405 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2406 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2407 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2408 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2409 connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
2410 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2411 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2412 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
2413 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2414 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2415 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2416 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
2418 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2419 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2420 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2421 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2422 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2424 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
2425 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2426 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2427 connect(m_notesWidget, SIGNAL(textChanged()), doc, SLOT(setModified()));
2429 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2430 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2431 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), m_effectStack, SLOT(slotTrackItemSelected(int, TrackInfo)));
2432 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotActivateEffectStackView()));
2434 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2435 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2436 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2437 m_zoomSlider->setValue(doc->zoom().x());
2438 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2439 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2440 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2441 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2443 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2444 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2446 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2447 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2449 connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2450 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2451 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2452 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2453 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2454 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2455 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2456 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2457 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2458 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2459 connect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2461 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2462 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2463 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2464 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2465 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2468 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2469 m_activeTimeline = trackView;
2470 if (m_renderWidget) {
2471 slotCheckRenderStatus();
2472 m_renderWidget->setProfile(doc->mltProfile());
2473 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2474 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2475 m_renderWidget->setRenderProfile(doc->getRenderProperties());
2477 //doc->setRenderer(m_projectMonitor->render);
2478 m_commandStack->setActiveStack(doc->commandStack());
2479 KdenliveSettings::setProject_display_ratio(doc->dar());
2480 //doc->clipManager()->checkAudioThumbs();
2482 //m_overView->setScene(trackView->projectScene());
2483 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2484 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2486 setCaption(doc->description(), doc->isModified());
2487 m_saveAction->setEnabled(doc->isModified());
2488 m_normalEditTool->setChecked(true);
2489 m_activeDocument = doc;
2490 m_activeTimeline->updateProjectFps();
2491 m_activeDocument->checkProjectClips();
2493 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2495 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2496 slotUpdateMousePosition(0);
2497 // set tool to select tool
2498 m_buttonSelectTool->setChecked(true);
2501 void MainWindow::slotZoneMoved(int start, int end)
2503 m_activeDocument->setZone(start, end);
2504 m_projectMonitor->slotZoneMoved(start, end);
2507 void MainWindow::slotGuidesUpdated()
2510 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2513 void MainWindow::slotEditKeys()
2515 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2516 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2517 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2521 void MainWindow::slotPreferences(int page, int option)
2524 * An instance of your dialog could be already created and could be
2525 * cached, in which case you want to display the cached dialog
2526 * instead of creating another one
2528 if (m_stopmotion) m_stopmotion->slotLive(false);
2529 if (KConfigDialog::showDialog("settings")) {
2530 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2531 if (page != -1) d->showPage(page, option);
2535 // KConfigDialog didn't find an instance of this dialog, so lets
2537 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
2538 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2539 //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
2540 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2542 connect(dialog, SIGNAL(updateCaptureFolder()), this, SLOT(slotUpdateCaptureFolder()));
2545 if (page != -1) dialog->showPage(page, option);
2548 void MainWindow::slotUpdateCaptureFolder()
2552 if (m_activeDocument) m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2553 else m_recMonitor->slotUpdateCaptureFolder(KdenliveSettings::defaultprojectfolder());
2557 void MainWindow::updateConfiguration()
2559 //TODO: we should apply settings to all projects, not only the current one
2560 if (m_activeTimeline) {
2561 m_activeTimeline->refresh();
2562 m_activeTimeline->projectView()->checkAutoScroll();
2563 m_activeTimeline->projectView()->checkTrackHeight();
2564 if (m_activeDocument)
2565 m_activeDocument->clipManager()->checkAudioThumbs();
2567 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2568 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2569 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2570 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2572 // Update list of transcoding profiles
2574 #ifndef NO_JOGSHUTTLE
2575 activateShuttleDevice();
2576 #endif /* NO_JOGSHUTTLE */
2580 void MainWindow::slotSwitchSplitAudio()
2582 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2583 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2586 void MainWindow::slotSwitchVideoThumbs()
2588 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2589 if (m_activeTimeline)
2590 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2591 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2594 void MainWindow::slotSwitchAudioThumbs()
2596 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2597 if (m_activeTimeline) {
2598 m_activeTimeline->refresh();
2599 m_activeTimeline->projectView()->checkAutoScroll();
2600 if (m_activeDocument)
2601 m_activeDocument->clipManager()->checkAudioThumbs();
2603 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2606 void MainWindow::slotSwitchMarkersComments()
2608 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2609 if (m_activeTimeline)
2610 m_activeTimeline->refresh();
2611 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2614 void MainWindow::slotSwitchSnap()
2616 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2617 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2621 void MainWindow::slotDeleteItem()
2623 if (QApplication::focusWidget() &&
2624 QApplication::focusWidget()->parentWidget() &&
2625 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2626 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2627 m_projectList->slotRemoveClip();
2630 QWidget *widget = QApplication::focusWidget();
2632 if (widget == m_effectStackDock) {
2633 m_effectStack->slotItemDel();
2636 widget = widget->parentWidget();
2639 // effect stack has no focus
2640 if (m_activeTimeline)
2641 m_activeTimeline->projectView()->deleteSelectedClips();
2645 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2647 if (m_clipMonitor->isActive())
2648 m_clipMonitor->checkOverlay();
2649 m_clipMonitor->updateMarkers(clip);
2652 void MainWindow::slotAddClipMarker()
2654 DocClipBase *clip = NULL;
2656 if (m_projectMonitor->isActive()) {
2657 if (m_activeTimeline) {
2658 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2660 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2661 clip = item->baseClip();
2665 clip = m_clipMonitor->activeClip();
2666 pos = m_clipMonitor->position();
2669 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2672 QString id = clip->getId();
2673 CommentedTime marker(pos, i18n("Marker"));
2674 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2675 if (d.exec() == QDialog::Accepted)
2676 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2679 void MainWindow::slotDeleteClipMarker()
2681 DocClipBase *clip = NULL;
2683 if (m_projectMonitor->isActive()) {
2684 if (m_activeTimeline) {
2685 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2687 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2688 clip = item->baseClip();
2692 clip = m_clipMonitor->activeClip();
2693 pos = m_clipMonitor->position();
2696 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2700 QString id = clip->getId();
2701 QString comment = clip->markerComment(pos);
2702 if (comment.isEmpty()) {
2703 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2706 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2709 void MainWindow::slotDeleteAllClipMarkers()
2711 DocClipBase *clip = NULL;
2712 if (m_projectMonitor->isActive()) {
2713 if (m_activeTimeline) {
2714 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2716 clip = item->baseClip();
2720 clip = m_clipMonitor->activeClip();
2723 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2726 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2729 void MainWindow::slotEditClipMarker()
2731 DocClipBase *clip = NULL;
2733 if (m_projectMonitor->isActive()) {
2734 if (m_activeTimeline) {
2735 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2737 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2738 clip = item->baseClip();
2742 clip = m_clipMonitor->activeClip();
2743 pos = m_clipMonitor->position();
2746 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2750 QString id = clip->getId();
2751 QString oldcomment = clip->markerComment(pos);
2752 if (oldcomment.isEmpty()) {
2753 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2757 CommentedTime marker(pos, oldcomment);
2758 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2759 if (d.exec() == QDialog::Accepted) {
2760 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2761 if (d.newMarker().time() != pos) {
2762 // remove old marker
2763 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2768 void MainWindow::slotAddMarkerGuideQuickly()
2770 if (!m_activeTimeline || !m_activeDocument)
2773 if (m_clipMonitor->isActive()) {
2774 DocClipBase *clip = m_clipMonitor->activeClip();
2775 GenTime pos = m_clipMonitor->position();
2778 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2782 m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), pos, m_activeDocument->timecode().getDisplayTimecode(pos, false));
2784 m_activeTimeline->projectView()->slotAddGuide(false);
2788 void MainWindow::slotAddGuide()
2790 if (m_activeTimeline)
2791 m_activeTimeline->projectView()->slotAddGuide();
2794 void MainWindow::slotInsertSpace()
2796 if (m_activeTimeline)
2797 m_activeTimeline->projectView()->slotInsertSpace();
2800 void MainWindow::slotRemoveSpace()
2802 if (m_activeTimeline)
2803 m_activeTimeline->projectView()->slotRemoveSpace();
2806 void MainWindow::slotInsertTrack(int ix)
2808 m_projectMonitor->activateMonitor();
2809 if (m_activeTimeline)
2810 m_activeTimeline->projectView()->slotInsertTrack(ix);
2811 if (m_activeDocument)
2812 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2815 void MainWindow::slotDeleteTrack(int ix)
2817 m_projectMonitor->activateMonitor();
2818 if (m_activeTimeline)
2819 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2820 if (m_activeDocument)
2821 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2824 void MainWindow::slotConfigTrack(int ix)
2826 m_projectMonitor->activateMonitor();
2827 if (m_activeTimeline)
2828 m_activeTimeline->projectView()->slotConfigTracks(ix);
2829 if (m_activeDocument)
2830 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2833 void MainWindow::slotEditGuide()
2835 if (m_activeTimeline)
2836 m_activeTimeline->projectView()->slotEditGuide();
2839 void MainWindow::slotDeleteGuide()
2841 if (m_activeTimeline)
2842 m_activeTimeline->projectView()->slotDeleteGuide();
2845 void MainWindow::slotDeleteAllGuides()
2847 if (m_activeTimeline)
2848 m_activeTimeline->projectView()->slotDeleteAllGuides();
2851 void MainWindow::slotCutTimelineClip()
2853 if (m_activeTimeline)
2854 m_activeTimeline->projectView()->cutSelectedClips();
2857 void MainWindow::slotInsertClipOverwrite()
2859 if (m_activeTimeline) {
2860 QStringList data = m_clipMonitor->getZoneInfo();
2861 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2865 void MainWindow::slotSelectTimelineClip()
2867 if (m_activeTimeline)
2868 m_activeTimeline->projectView()->selectClip(true);
2871 void MainWindow::slotSelectTimelineTransition()
2873 if (m_activeTimeline)
2874 m_activeTimeline->projectView()->selectTransition(true);
2877 void MainWindow::slotDeselectTimelineClip()
2879 if (m_activeTimeline)
2880 m_activeTimeline->projectView()->selectClip(false, true);
2883 void MainWindow::slotDeselectTimelineTransition()
2885 if (m_activeTimeline)
2886 m_activeTimeline->projectView()->selectTransition(false, true);
2889 void MainWindow::slotSelectAddTimelineClip()
2891 if (m_activeTimeline)
2892 m_activeTimeline->projectView()->selectClip(true, true);
2895 void MainWindow::slotSelectAddTimelineTransition()
2897 if (m_activeTimeline)
2898 m_activeTimeline->projectView()->selectTransition(true, true);
2901 void MainWindow::slotGroupClips()
2903 if (m_activeTimeline)
2904 m_activeTimeline->projectView()->groupClips();
2907 void MainWindow::slotUnGroupClips()
2909 if (m_activeTimeline)
2910 m_activeTimeline->projectView()->groupClips(false);
2913 void MainWindow::slotEditItemDuration()
2915 if (m_activeTimeline)
2916 m_activeTimeline->projectView()->editItemDuration();
2919 void MainWindow::slotAddProjectClip(KUrl url)
2921 if (m_activeDocument)
2922 m_activeDocument->slotAddClipFile(url, QString());
2925 void MainWindow::slotAddTransition(QAction *result)
2927 if (!result) return;
2928 QStringList info = result->data().toStringList();
2929 if (info.isEmpty()) return;
2930 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2931 if (m_activeTimeline && !transition.isNull()) {
2932 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2936 void MainWindow::slotAddVideoEffect(QAction *result)
2938 if (!result) return;
2939 QStringList info = result->data().toStringList();
2940 if (info.isEmpty()) return;
2941 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2942 slotAddEffect(effect);
2945 void MainWindow::slotAddAudioEffect(QAction *result)
2947 if (!result) return;
2948 QStringList info = result->data().toStringList();
2949 if (info.isEmpty()) return;
2950 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2951 slotAddEffect(effect);
2954 void MainWindow::slotAddCustomEffect(QAction *result)
2956 if (!result) return;
2957 QStringList info = result->data().toStringList();
2958 if (info.isEmpty()) return;
2959 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2960 slotAddEffect(effect);
2963 void MainWindow::slotZoomIn()
2965 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2966 slotShowZoomSliderToolTip();
2969 void MainWindow::slotZoomOut()
2971 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2972 slotShowZoomSliderToolTip();
2975 void MainWindow::slotFitZoom()
2977 if (m_activeTimeline)
2978 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2981 void MainWindow::slotSetZoom(int value)
2983 value = qMax(m_zoomSlider->minimum(), value);
2984 value = qMin(m_zoomSlider->maximum(), value);
2986 if (m_activeTimeline)
2987 m_activeTimeline->slotChangeZoom(value);
2989 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
2990 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
2991 slotUpdateZoomSliderToolTip(value);
2993 m_zoomSlider->blockSignals(true);
2994 m_zoomSlider->setValue(value);
2995 m_zoomSlider->blockSignals(false);
2998 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
3000 if (zoomlevel != -1)
3001 slotUpdateZoomSliderToolTip(zoomlevel);
3003 QPoint global = m_zoomSlider->rect().topLeft();
3004 global.ry() += m_zoomSlider->height() / 2;
3005 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
3006 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
3009 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
3011 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
3014 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
3016 m_statusProgressBar->setValue(progress);
3017 if (progress >= 0) {
3018 if (!message.isEmpty())
3019 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
3020 m_statusProgressBar->setVisible(true);
3021 } else if (progress == -2) {
3022 if (!message.isEmpty())
3023 m_messageLabel->setMessage(message, ErrorMessage);
3024 m_statusProgressBar->setVisible(false);
3026 m_messageLabel->setMessage(QString(), DefaultMessage);
3027 m_statusProgressBar->setVisible(false);
3031 void MainWindow::slotShowClipProperties(DocClipBase *clip)
3033 if (clip->clipType() == TEXT) {
3034 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
3035 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
3036 // template text clip
3038 // Get the list of existing templates
3040 filter << "*.kdenlivetitle";
3041 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
3043 QDialog *dia = new QDialog(this);
3044 Ui::TemplateClip_UI dia_ui;
3045 dia_ui.setupUi(dia);
3047 const QString templatePath = clip->getProperty("resource");
3048 for (int i = 0; i < templateFiles.size(); ++i) {
3049 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
3050 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
3052 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
3053 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
3054 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
3055 //warning: setting base directory doesn't work??
3056 KUrl startDir(titlepath);
3057 dia_ui.template_list->fileDialog()->setUrl(startDir);
3058 dia_ui.description->setText(clip->getProperty("description"));
3059 if (dia->exec() == QDialog::Accepted) {
3060 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
3061 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
3063 QMap <QString, QString> newprops;
3065 if (KUrl(textTemplate).path() != templatePath) {
3066 // The template was changed
3067 newprops.insert("resource", textTemplate);
3070 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
3071 newprops.insert("description", dia_ui.description->toPlainText());
3074 QString newtemplate = newprops.value("xmltemplate");
3075 if (newtemplate.isEmpty()) newtemplate = templatePath;
3077 // template modified we need to update xmldata
3078 QString description = newprops.value("description");
3079 if (description.isEmpty()) description = clip->getProperty("description");
3080 else newprops.insert("templatetext", description);
3081 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
3082 if (!newprops.isEmpty()) {
3083 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3084 m_activeDocument->commandStack()->push(command);
3090 QString path = clip->getProperty("resource");
3091 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
3093 doc.setContent(clip->getProperty("xmldata"));
3094 dia_ui->setXml(doc);
3095 if (dia_ui->exec() == QDialog::Accepted) {
3096 QMap <QString, QString> newprops;
3097 newprops.insert("xmldata", dia_ui->xml().toString());
3098 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
3099 // duration changed, we need to update duration
3100 newprops.insert("out", QString::number(dia_ui->outPoint()));
3102 if (!path.isEmpty()) {
3103 // we are editing an external file, asked if we want to detach from that file or save the result to that title file.
3104 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) {
3105 // save to external file
3106 dia_ui->saveTitle(path);
3107 } else newprops.insert("resource", QString());
3109 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3110 m_activeDocument->commandStack()->push(command);
3111 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
3112 m_activeDocument->setModified(true);
3116 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
3120 // any type of clip but a title
3121 ClipProperties *dia = new ClipProperties(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
3122 connect(dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
3123 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)));
3128 void MainWindow::slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload)
3130 if (newprops.isEmpty()) return;
3131 EditClipCommand *command = new EditClipCommand(m_projectList, id, props, newprops, true);
3132 m_activeDocument->commandStack()->push(command);
3133 m_activeDocument->setModified();
3136 // update clip occurences in timeline
3137 m_activeTimeline->projectView()->slotUpdateClip(id, reload);
3142 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
3144 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
3145 if (dia.exec() == QDialog::Accepted) {
3146 QUndoCommand *command = new QUndoCommand();
3147 command->setText(i18n("Edit clips"));
3148 for (int i = 0; i < cliplist.count(); i++) {
3149 DocClipBase *clip = cliplist.at(i);
3150 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true, command);
3152 m_activeDocument->commandStack()->push(command);
3153 for (int i = 0; i < cliplist.count(); i++)
3154 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
3158 void MainWindow::customEvent(QEvent* e)
3160 if (e->type() == QEvent::User)
3161 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
3163 void MainWindow::slotActivateEffectStackView()
3165 m_effectStack->raiseWindow(m_effectStackDock);
3168 void MainWindow::slotActivateTransitionView(Transition *t)
3171 m_transitionConfig->raiseWindow(m_transitionConfigDock);
3174 void MainWindow::slotSnapRewind()
3176 if (m_projectMonitor->isActive()) {
3177 if (m_activeTimeline)
3178 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
3180 m_clipMonitor->slotSeekToPreviousSnap();
3184 void MainWindow::slotSnapForward()
3186 if (m_projectMonitor->isActive()) {
3187 if (m_activeTimeline)
3188 m_activeTimeline->projectView()->slotSeekToNextSnap();
3190 m_clipMonitor->slotSeekToNextSnap();
3194 void MainWindow::slotClipStart()
3196 if (m_projectMonitor->isActive()) {
3197 if (m_activeTimeline)
3198 m_activeTimeline->projectView()->clipStart();
3202 void MainWindow::slotClipEnd()
3204 if (m_projectMonitor->isActive()) {
3205 if (m_activeTimeline)
3206 m_activeTimeline->projectView()->clipEnd();
3210 void MainWindow::slotZoneStart()
3212 if (m_projectMonitor->isActive())
3213 m_projectMonitor->slotZoneStart();
3215 m_clipMonitor->slotZoneStart();
3218 void MainWindow::slotZoneEnd()
3220 if (m_projectMonitor->isActive())
3221 m_projectMonitor->slotZoneEnd();
3223 m_clipMonitor->slotZoneEnd();
3226 void MainWindow::slotChangeTool(QAction * action)
3228 if (action == m_buttonSelectTool)
3229 slotSetTool(SELECTTOOL);
3230 else if (action == m_buttonRazorTool)
3231 slotSetTool(RAZORTOOL);
3232 else if (action == m_buttonSpacerTool)
3233 slotSetTool(SPACERTOOL);
3236 void MainWindow::slotChangeEdit(QAction * action)
3238 if (!m_activeTimeline)
3241 if (action == m_overwriteEditTool)
3242 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
3243 else if (action == m_insertEditTool)
3244 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
3246 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
3249 void MainWindow::slotSetTool(PROJECTTOOL tool)
3251 if (m_activeDocument && m_activeTimeline) {
3252 //m_activeDocument->setTool(tool);
3256 message = i18n("Ctrl + click to use spacer on current track only");
3259 message = i18n("Click on a clip to cut it");
3262 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
3265 m_messageLabel->setMessage(message, InformationMessage);
3266 m_activeTimeline->projectView()->setTool(tool);
3270 void MainWindow::slotCopy()
3272 if (m_activeDocument && m_activeTimeline)
3273 m_activeTimeline->projectView()->copyClip();
3276 void MainWindow::slotPaste()
3278 if (m_activeDocument && m_activeTimeline)
3279 m_activeTimeline->projectView()->pasteClip();
3282 void MainWindow::slotPasteEffects()
3284 if (m_activeDocument && m_activeTimeline)
3285 m_activeTimeline->projectView()->pasteClipEffects();
3288 void MainWindow::slotFind()
3290 if (!m_activeDocument || !m_activeTimeline) return;
3291 m_projectSearch->setEnabled(false);
3292 m_findActivated = true;
3293 m_findString.clear();
3294 m_activeTimeline->projectView()->initSearchStrings();
3295 statusBar()->showMessage(i18n("Starting -- find text as you type"));
3296 m_findTimer.start(5000);
3297 qApp->installEventFilter(this);
3300 void MainWindow::slotFindNext()
3302 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
3303 statusBar()->showMessage(i18n("Found: %1", m_findString));
3305 statusBar()->showMessage(i18n("Reached end of project"));
3306 m_findTimer.start(4000);
3309 void MainWindow::findAhead()
3311 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3312 m_projectSearchNext->setEnabled(true);
3313 statusBar()->showMessage(i18n("Found: %1", m_findString));
3315 m_projectSearchNext->setEnabled(false);
3316 statusBar()->showMessage(i18n("Not found: %1", m_findString));
3320 void MainWindow::findTimeout()
3322 m_projectSearchNext->setEnabled(false);
3323 m_findActivated = false;
3324 m_findString.clear();
3325 statusBar()->showMessage(i18n("Find stopped"), 3000);
3326 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3327 m_projectSearch->setEnabled(true);
3328 removeEventFilter(this);
3331 void MainWindow::slotClipInTimeline(const QString &clipId)
3333 if (m_activeTimeline && m_activeDocument) {
3334 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3336 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3337 inTimelineMenu->clear();
3339 QList <QAction *> actionList;
3341 for (int i = 0; i < matching.count(); ++i) {
3342 QString track = QString::number(matching.at(i).track);
3343 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3345 QAction *a = new QAction(track + ": " + start, this);
3346 a->setData(QStringList() << track << start);
3347 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3348 while (j < actionList.count()) {
3349 if (actionList.at(j)->text() > a->text()) break;
3352 actionList.insert(j, a);
3354 inTimelineMenu->addActions(actionList);
3356 if (matching.empty())
3357 inTimelineMenu->setEnabled(false);
3359 inTimelineMenu->setEnabled(true);
3363 void MainWindow::slotClipInProjectTree()
3365 if (m_activeTimeline) {
3366 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3367 if (clipIds.isEmpty())
3369 m_projectListDock->raise();
3370 for (int i = 0; i < clipIds.count(); i++)
3371 m_projectList->selectItemById(clipIds.at(i));
3372 if (m_projectMonitor->isActive())
3373 slotSwitchMonitors();
3377 /*void MainWindow::slotClipToProjectTree()
3379 if (m_activeTimeline) {
3380 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3381 if (clips.isEmpty()) return;
3382 for (int i = 0; i < clips.count(); i++) {
3383 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3385 //m_projectList->selectItemById(clipIds.at(i));
3389 void MainWindow::slotSelectClipInTimeline()
3391 if (m_activeTimeline) {
3392 QAction *action = qobject_cast<QAction *>(sender());
3393 QStringList data = action->data().toStringList();
3394 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3398 void MainWindow::keyPressEvent(QKeyEvent *ke)
3400 if (m_findActivated) {
3401 if (ke->key() == Qt::Key_Backspace) {
3402 m_findString = m_findString.left(m_findString.length() - 1);
3404 if (!m_findString.isEmpty())
3409 m_findTimer.start(4000);
3412 } else if (ke->key() == Qt::Key_Escape) {
3416 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3417 m_findString += ke->text();
3421 m_findTimer.start(4000);
3426 KXmlGuiWindow::keyPressEvent(ke);
3431 /** Gets called when the window gets hidden */
3432 void MainWindow::hideEvent(QHideEvent */*event*/)
3434 if (isMinimized() && m_monitorManager)
3435 m_monitorManager->stopActiveMonitor();
3438 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3440 if (m_findActivated) {
3441 if (event->type() == QEvent::ShortcutOverride) {
3442 QKeyEvent* ke = (QKeyEvent*) event;
3443 if (ke->text().trimmed().isEmpty()) return false;
3450 // pass the event on to the parent class
3451 return QMainWindow::eventFilter(obj, event);
3456 void MainWindow::slotSaveZone(Render *render, QPoint zone)
3458 KDialog *dialog = new KDialog(this);
3459 dialog->setCaption("Save clip zone");
3460 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3462 QWidget *widget = new QWidget(dialog);
3463 dialog->setMainWidget(widget);
3465 QVBoxLayout *vbox = new QVBoxLayout(widget);
3466 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3467 QString path = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash);
3468 path.append("untitled.mlt");
3469 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
3470 url->setFilter("video/mlt-playlist");
3471 QLabel *label2 = new QLabel(i18n("Description:"), this);
3472 KLineEdit *edit = new KLineEdit(this);
3473 vbox->addWidget(label1);
3474 vbox->addWidget(url);
3475 vbox->addWidget(label2);
3476 vbox->addWidget(edit);
3477 if (dialog->exec() == QDialog::Accepted)
3478 render->saveZone(url->url(), edit->text(), zone);
3482 void MainWindow::slotSetInPoint()
3484 if (m_clipMonitor->isActive())
3485 m_clipMonitor->slotSetZoneStart();
3487 m_projectMonitor->slotSetZoneStart();
3488 //else m_activeTimeline->projectView()->setInPoint();
3491 void MainWindow::slotSetOutPoint()
3493 if (m_clipMonitor->isActive())
3494 m_clipMonitor->slotSetZoneEnd();
3496 m_projectMonitor->slotSetZoneEnd();
3497 // else m_activeTimeline->projectView()->setOutPoint();
3500 void MainWindow::slotResizeItemStart()
3502 if (m_activeTimeline)
3503 m_activeTimeline->projectView()->setInPoint();
3506 void MainWindow::slotResizeItemEnd()
3508 if (m_activeTimeline)
3509 m_activeTimeline->projectView()->setOutPoint();
3512 int MainWindow::getNewStuff(const QString &configFile)
3514 KNS3::Entry::List entries;
3515 #if KDE_IS_VERSION(4,3,80)
3516 KNS3::DownloadDialog dialog(configFile);
3518 entries = dialog.changedEntries();
3519 foreach(const KNS3::Entry & entry, entries) {
3520 if (entry.status() == KNS3::Entry::Installed)
3521 kDebug() << "// Installed files: " << entry.installedFiles();
3524 KNS::Engine engine(0);
3525 if (engine.init(configFile))
3526 entries = engine.downloadDialogModal(this);
3527 foreach(KNS::Entry * entry, entries) {
3528 if (entry->status() == KNS::Entry::Installed)
3529 kDebug() << "// Installed files: " << entry->installedFiles();
3531 #endif /* KDE_IS_VERSION(4,3,80) */
3532 return entries.size();
3535 void MainWindow::slotGetNewTitleStuff()
3537 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3538 TitleWidget::refreshTitleTemplates();
3541 void MainWindow::slotGetNewLumaStuff()
3543 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3544 initEffects::refreshLumas();
3545 m_activeTimeline->projectView()->reloadTransitionLumas();
3549 void MainWindow::slotGetNewRenderStuff()
3551 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3553 m_renderWidget->reloadProfiles();
3556 void MainWindow::slotGetNewMltProfileStuff()
3558 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3559 // update the list of profiles in settings dialog
3560 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3566 void MainWindow::slotAutoTransition()
3568 if (m_activeTimeline)
3569 m_activeTimeline->projectView()->autoTransition();
3572 void MainWindow::slotSplitAudio()
3574 if (m_activeTimeline)
3575 m_activeTimeline->projectView()->splitAudio();
3578 void MainWindow::slotUpdateClipType(QAction *action)
3580 if (m_activeTimeline) {
3581 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3582 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3583 else m_activeTimeline->projectView()->setAudioAndVideo();
3587 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3589 // We must stop the monitors since we create a new on in the dvd wizard
3590 m_clipMonitor->stop();
3591 m_projectMonitor->stop();
3592 DvdWizard w(url, profile, this);
3594 m_projectMonitor->start();
3597 void MainWindow::slotShowTimeline(bool show)
3599 if (show == false) {
3600 m_timelineState = saveState();
3601 centralWidget()->setHidden(true);
3603 centralWidget()->setHidden(false);
3604 restoreState(m_timelineState);
3608 void MainWindow::slotMaximizeCurrent(bool /*show*/)
3610 //TODO: is there a way to maximize current widget?
3613 m_timelineState = saveState();
3614 QWidget *par = focusWidget()->parentWidget();
3615 while (par->parentWidget() && par->parentWidget() != this)
3616 par = par->parentWidget();
3617 kDebug() << "CURRENT WIDGET: " << par->objectName();
3620 //centralWidget()->setHidden(false);
3621 //restoreState(m_timelineState);
3625 void MainWindow::loadTranscoders()
3627 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3630 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3631 KConfigGroup transConfig(config, "Transcoding");
3633 QMap< QString, QString > profiles = transConfig.entryMap();
3634 QMapIterator<QString, QString> i(profiles);
3635 while (i.hasNext()) {
3637 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3638 QAction *a = transMenu->addAction(i.key());
3640 if (data.count() > 1)
3641 a->setToolTip(data.at(1));
3642 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3646 void MainWindow::slotTranscode(KUrl::List urls)
3651 if (urls.isEmpty()) {
3652 QAction *action = qobject_cast<QAction *>(sender());
3653 QStringList data = action->data().toStringList();
3654 params = data.at(0);
3655 if (data.count() > 1) desc = data.at(1);
3656 if (data.count() > 2) condition = data.at(2);
3657 urls << m_projectList->getConditionalUrls(condition);
3658 urls.removeAll(KUrl());
3660 if (urls.isEmpty()) {
3661 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3664 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3665 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3667 //QProcess::startDetached("ffmpeg", parameters);
3670 void MainWindow::slotTranscodeClip()
3672 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3673 if (urls.isEmpty()) return;
3674 slotTranscode(urls);
3677 void MainWindow::slotSetDocumentRenderProfile(QMap <QString, QString> props)
3679 if (m_activeDocument == NULL) return;
3680 QMapIterator<QString, QString> i(props);
3681 while (i.hasNext()) {
3683 m_activeDocument->setDocumentProperty(i.key(), i.value());
3685 m_activeDocument->setModified(true);
3689 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3691 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3693 QString playlistPath;
3696 QString scriptsFolder = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "scripts/";
3697 QString path = m_renderWidget->getFreeScriptName();
3698 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3699 if (!ok || scriptPath.isEmpty()) return;
3700 scriptPath.prepend(scriptsFolder);
3701 QFile f(scriptPath);
3703 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3706 playlistPath = scriptPath + ".mlt";
3707 m_projectMonitor->saveSceneList(playlistPath);
3709 KTemporaryFile temp;
3710 temp.setAutoRemove(false);
3711 temp.setSuffix(".mlt");
3713 playlistPath = temp.fileName();
3714 m_projectMonitor->saveSceneList(playlistPath);
3717 if (!chapterFile.isEmpty()) {
3720 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3722 in = m_activeTimeline->inPoint();
3723 out = m_activeTimeline->outPoint();
3726 QDomElement chapters = doc.createElement("chapters");
3727 chapters.setAttribute("fps", m_activeDocument->fps());
3728 doc.appendChild(chapters);
3730 QDomElement guidesxml = m_activeDocument->guidesXml();
3731 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3732 for (int i = 0; i < nodes.count(); i++) {
3733 QDomElement e = nodes.item(i).toElement();
3735 QString comment = e.attribute("comment");
3736 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3737 if (time >= in && time < out) {
3738 if (zoneOnly) time = time - in;
3739 QDomElement chapter = doc.createElement("chapter");
3740 chapters.appendChild(chapter);
3741 chapter.setAttribute("title", comment);
3742 chapter.setAttribute("time", time);
3746 if (chapters.childNodes().count() > 0) {
3747 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3748 // Always insert a guide in pos 0
3749 QDomElement chapter = doc.createElement("chapter");
3750 chapters.insertBefore(chapter, QDomNode());
3751 chapter.setAttribute("title", i18n("Start"));
3752 chapter.setAttribute("time", "0");
3754 // save chapters file
3755 QFile file(chapterFile);
3756 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3757 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3759 file.write(doc.toString().toUtf8());
3760 if (file.error() != QFile::NoError) {
3761 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3768 if (m_renderWidget->automaticAudioExport()) {
3769 exportAudio = m_activeTimeline->checkProjectAudio();
3770 } else exportAudio = m_renderWidget->selectedAudioExport();
3771 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath, exportAudio);
3774 void MainWindow::slotUpdateTimecodeFormat(int ix)
3776 KdenliveSettings::setFrametimecode(ix == 1);
3777 m_clipMonitor->updateTimecodeFormat();
3778 m_projectMonitor->updateTimecodeFormat();
3779 m_transitionConfig->updateTimecodeFormat();
3780 m_effectStack->updateTimecodeFormat();
3781 //m_activeTimeline->projectView()->clearSelection();
3782 m_activeTimeline->updateRuler();
3785 void MainWindow::slotRemoveFocus()
3787 statusBar()->setFocus();
3788 statusBar()->clearFocus();
3791 void MainWindow::slotRevert()
3793 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;
3794 KUrl url = m_activeDocument->url();
3795 if (closeCurrentDocument(false))
3796 doOpenFile(url, NULL);
3800 void MainWindow::slotShutdown()
3802 if (m_activeDocument) m_activeDocument->setModified(false);
3804 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
3805 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
3806 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
3807 smserver.call("logout", 1, 2, 2);
3808 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
3809 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
3810 smserver.call("Shutdown");
3814 void MainWindow::slotUpdateTrackInfo()
3816 if (m_activeDocument)
3817 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
3820 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
3822 // Load the theme file
3824 if (action == NULL) theme = themename;
3825 else theme = action->data().toString();
3826 KdenliveSettings::setColortheme(theme);
3827 // Make palette for all widgets.
3829 if (theme.isEmpty())
3830 plt = QApplication::desktop()->palette();
3832 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
3833 plt = KGlobalSettings::createApplicationPalette(config);
3836 kapp->setPalette(plt);
3837 const QObjectList children = statusBar()->children();
3839 foreach(QObject * child, children) {
3840 if (child->isWidgetType())
3841 ((QWidget*)child)->setPalette(plt);
3842 const QObjectList subchildren = child->children();
3843 foreach(QObject * subchild, subchildren) {
3844 if (subchild->isWidgetType())
3845 ((QWidget*)subchild)->setPalette(plt);
3848 if (m_activeTimeline) {
3849 m_activeTimeline->projectView()->updatePalette();
3854 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
3856 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
3857 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
3858 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
3859 const QSize bitsSize(24, 2);
3860 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
3861 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
3863 QPixmap pixmap(23, 16);
3864 pixmap.fill(Qt::black); // ### use some color other than black for borders?
3866 KConfigGroup group(config, "WM");
3867 QPainter p(&pixmap);
3868 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
3869 p.fillRect(1, 1, 7, 7, windowScheme.background());
3870 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
3872 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
3873 p.fillRect(8, 1, 7, 7, buttonScheme.background());
3874 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
3876 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
3877 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
3879 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
3880 p.fillRect(1, 8, 7, 7, viewScheme.background());
3881 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
3883 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
3884 p.fillRect(8, 8, 7, 7, selectionScheme.background());
3885 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
3887 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
3888 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
3894 void MainWindow::slotSwitchMonitors()
3896 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
3897 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
3898 else m_projectList->focusTree();
3901 void MainWindow::slotSwitchFullscreen()
3903 if (m_projectMonitor->isActive()) m_projectMonitor->slotSwitchFullScreen();
3904 else m_clipMonitor->slotSwitchFullScreen();
3907 void MainWindow::slotInsertZoneToTree()
3909 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
3910 QStringList info = m_clipMonitor->getZoneInfo();
3911 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
3914 void MainWindow::slotInsertZoneToTimeline()
3916 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
3917 QStringList info = m_clipMonitor->getZoneInfo();
3918 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
3922 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
3924 if (m_activeDocument && m_activeTimeline) {
3925 if (!ids.isEmpty()) {
3926 for (int i = 0; i < ids.size(); ++i) {
3927 m_activeTimeline->slotDeleteClip(ids.at(i));
3929 m_activeDocument->clipManager()->slotDeleteClips(ids);
3931 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
3932 m_activeDocument->setModified(true);
3936 void MainWindow::slotShowTitleBars(bool show)
3938 QList <QDockWidget *> docks = findChildren<QDockWidget *>();
3939 for (int i = 0; i < docks.count(); i++) {
3940 QDockWidget* dock = docks.at(i);
3942 dock->setTitleBarWidget(0);
3944 if (!dock->isFloating()) {
3945 dock->setTitleBarWidget(new QWidget);
3949 KdenliveSettings::setShowtitlebars(show);
3952 void MainWindow::slotSwitchTitles()
3954 slotShowTitleBars(!KdenliveSettings::showtitlebars());
3957 QString MainWindow::getMimeType()
3959 QString mimetype = "application/x-kdenlive";
3960 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
3961 if (!mime) mimetype = "*.kdenlive";
3965 void MainWindow::slotMonitorRequestRenderFrame(bool request)
3968 m_projectMonitor->render->sendFrameForAnalysis = true;
3971 for (int i = 0; i < m_scopesList.count(); i++) {
3972 if (m_scopesList.at(i)->isVisible() && tabifiedDockWidgets(m_scopesList.at(i)).isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled()) {
3979 m_projectMonitor->render->sendFrameForAnalysis = false;
3983 void MainWindow::slotUpdateScopeFrameRequest()
3985 // We need a delay to make sure widgets are hidden after a close event for example
3986 QTimer::singleShot(500, this, SLOT(slotDoUpdateScopeFrameRequest()));
3989 void MainWindow::slotDoUpdateScopeFrameRequest()
3992 bool request = false;
3993 for (int i = 0; i < m_scopesList.count(); i++) {
3994 if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled()) {
3995 kDebug() << "SCOPE VISIBLE: " << static_cast<AbstractGfxScopeWidget *>(m_scopesList.at(i)->widget())->widgetName();
4001 if (!m_projectMonitor->effectSceneDisplayed())
4002 m_projectMonitor->render->sendFrameForAnalysis = false;
4003 m_clipMonitor->render->sendFrameForAnalysis = false;
4005 m_projectMonitor->render->sendFrameForAnalysis = true;
4006 m_clipMonitor->render->sendFrameForAnalysis = true;
4010 void MainWindow::slotUpdateColorScopes()
4012 bool request = false;
4013 for (int i = 0; i < m_scopesList.count(); i++) {
4014 // Check if we need the renderer to send a new frame for update
4015 if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractGfxScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;
4016 static_cast<AbstractGfxScopeWidget *>(m_scopesList.at(i)->widget())->slotActiveMonitorChanged(m_clipMonitor->isActive());
4019 if (m_clipMonitor->isActive()) m_clipMonitor->render->sendFrameUpdate();
4020 else m_projectMonitor->render->sendFrameUpdate();
4024 void MainWindow::slotOpenStopmotion()
4026 if (m_stopmotion == NULL) {
4027 m_stopmotion = new StopmotionWidget(m_activeDocument->projectFolder(), m_stopmotion_actions->actions(), this);
4028 connect(m_stopmotion, SIGNAL(addOrUpdateSequence(const QString)), m_projectList, SLOT(slotAddOrUpdateSequence(const QString)));
4029 for (int i = 0; i < m_scopesList.count(); i++) {
4030 // Check if we need the renderer to send a new frame for update
4031 /*if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;*/
4032 connect(m_stopmotion, SIGNAL(gotFrame(QImage)), static_cast<AbstractGfxScopeWidget *>(m_scopesList.at(i)->widget()), SLOT(slotRenderZoneUpdated(QImage)));
4033 //static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotMonitorCapture();
4036 m_stopmotion->show();
4039 void MainWindow::slotDeleteClip(const QString &id)
4041 QList <ClipProperties *> list = findChildren<ClipProperties *>();
4042 for (int i = 0; i < list.size(); ++i) {
4043 list.at(i)->disableClipId(id);
4045 m_projectList->slotDeleteClip(id);
4048 #include "mainwindow.moc"