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"
43 #include "jogshuttle.h"
44 #endif /* NO_JOGSHUTTLE */
45 #include "clipproperties.h"
47 #include "editclipcommand.h"
48 #include "titlewidget.h"
49 #include "markerdialog.h"
51 #include "interfaces.h"
52 #include "kdenlive-config.h"
53 #include "cliptranscode.h"
54 #include "ui_templateclip_ui.h"
56 #include <KApplication>
60 #include <KActionCollection>
61 #include <KStandardAction>
62 #include <KFileDialog>
63 #include <KMessageBox>
65 #include <KIO/NetAccess>
68 #include <KConfigDialog>
69 #include <KXMLGUIFactory>
71 #include <kstandarddirs.h>
72 #include <KUrlRequesterDialog>
73 #include <KTemporaryFile>
75 #include <KActionMenu>
78 #include <ktogglefullscreenaction.h>
80 #include <KNotification>
81 #include <KNotifyConfigWidget>
82 #include <knewstuff2/engine.h>
83 #include <knewstuff2/ui/knewstuffaction.h>
85 #include <QTextStream>
89 #include <QInputDialog>
93 static const char version[] = VERSION;
95 static const int ID_TIMELINE_POS = 0;
102 EffectsList MainWindow::videoEffects;
103 EffectsList MainWindow::audioEffects;
104 EffectsList MainWindow::customEffects;
105 EffectsList MainWindow::transitions;
107 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent) :
108 KXmlGuiWindow(parent),
109 m_activeDocument(NULL),
110 m_activeTimeline(NULL),
111 m_renderWidget(NULL),
112 #ifndef NO_JOGSHUTTLE
114 #endif /* NO_JOGSHUTTLE */
115 m_findActivated(false)
118 // Create DBus interface
119 new MainWindowAdaptor(this);
120 QDBusConnection dbus = QDBusConnection::sessionBus();
121 dbus.registerObject("/MainWindow", this);
123 setlocale(LC_NUMERIC, "POSIX");
124 setFont(KGlobalSettings::toolBarFont());
125 parseProfiles(MltPath);
126 m_commandStack = new QUndoGroup;
127 m_timelineArea = new KTabWidget(this);
128 m_timelineArea->setTabReorderingEnabled(true);
129 m_timelineArea->setTabBarHidden(true);
131 QToolButton *closeTabButton = new QToolButton;
132 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
133 closeTabButton->setIcon(KIcon("tab-close"));
134 closeTabButton->adjustSize();
135 closeTabButton->setToolTip(i18n("Close the current tab"));
136 m_timelineArea->setCornerWidget(closeTabButton);
137 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
139 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
140 m_findTimer.setSingleShot(true);
142 // FIXME: the next call returns a newly allocated object, which leaks
143 initEffects::parseEffectFiles();
144 //initEffects::parseCustomEffectsFile();
146 m_monitorManager = new MonitorManager();
148 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
149 m_projectListDock->setObjectName("project_tree");
150 m_projectList = new ProjectList(this);
151 m_projectListDock->setWidget(m_projectList);
152 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
154 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
155 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
157 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
158 m_effectListDock->setObjectName("effect_list");
159 m_effectList = new EffectsListView();
161 //m_effectList = new KListWidget(this);
162 m_effectListDock->setWidget(m_effectList);
163 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
165 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
166 m_effectStackDock->setObjectName("effect_stack");
167 m_effectStack = new EffectStackView(this);
168 m_effectStackDock->setWidget(m_effectStack);
169 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
171 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
172 m_transitionConfigDock->setObjectName("transition");
173 m_transitionConfig = new TransitionSettings(this);
174 m_transitionConfigDock->setWidget(m_transitionConfig);
175 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
177 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
178 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
182 //slotDetectAudioDriver();
184 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
185 m_clipMonitorDock->setObjectName("clip_monitor");
186 m_clipMonitor = new Monitor("clip", m_monitorManager, this);
187 m_clipMonitorDock->setWidget(m_clipMonitor);
188 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
189 //m_clipMonitor->stop();
191 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
192 m_projectMonitorDock->setObjectName("project_monitor");
193 m_projectMonitor = new Monitor("project", m_monitorManager, this);
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", this);
201 m_recMonitorDock->setWidget(m_recMonitor);
202 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
204 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
205 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
208 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
209 m_undoViewDock->setObjectName("undo_history");
210 m_undoView = new QUndoView(this);
211 m_undoView->setCleanIcon(KIcon("edit-clear"));
212 m_undoView->setEmptyLabel(i18n("Clean"));
213 m_undoViewDock->setWidget(m_undoView);
214 m_undoView->setGroup(m_commandStack);
215 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
217 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
218 //overviewDock->setObjectName("project_overview");
219 //m_overView = new CustomTrackView(NULL, NULL, this);
220 //overviewDock->setWidget(m_overView);
221 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
224 //tabifyDockWidget(projectListDock, effectListDock);
225 tabifyDockWidget(m_projectListDock, m_effectStackDock);
226 tabifyDockWidget(m_projectListDock, m_transitionConfigDock);
227 //tabifyDockWidget(projectListDock, undoViewDock);
230 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
232 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
234 setCentralWidget(m_timelineArea);
239 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
240 guiFactory()->addClient(sp);*/
244 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
246 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone);
247 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
248 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)), static_cast<QMenu*>(factory()->container("transcoders", this)));
250 // build effects menus
252 QMenu *videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
254 QStringList effectInfo;
255 QMap<QString, QStringList> effectsList;
256 for (int ix = 0; ix < videoEffects.count(); ix++) {
257 effectInfo = videoEffects.effectIdInfo(ix);
258 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
261 foreach(const QStringList &value, effectsList) {
262 action = new QAction(value.at(0), this);
263 action->setData(value);
264 videoEffectsMenu->addAction(action);
267 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
271 for (int ix = 0; ix < audioEffects.count(); ix++) {
272 effectInfo = audioEffects.effectIdInfo(ix);
273 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
276 foreach(const QStringList &value, effectsList) {
277 action = new QAction(value.at(0), this);
278 action->setData(value);
279 audioEffectsMenu->addAction(action);
282 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
284 if (customEffects.isEmpty()) m_customEffectsMenu->setEnabled(false);
285 else m_customEffectsMenu->setEnabled(true);
288 for (int ix = 0; ix < customEffects.count(); ix++) {
289 effectInfo = customEffects.effectIdInfo(ix);
290 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
293 foreach(const QStringList &value, effectsList) {
294 action = new QAction(value.at(0), this);
295 action->setData(value);
296 m_customEffectsMenu->addAction(action);
299 QMenu *newEffect = new QMenu(this);
300 newEffect->addMenu(videoEffectsMenu);
301 newEffect->addMenu(audioEffectsMenu);
302 newEffect->addMenu(m_customEffectsMenu);
303 m_effectStack->setMenu(newEffect);
306 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
307 const QList<QAction *> viewActions = createPopupMenu()->actions();
308 viewMenu->insertActions(NULL, viewActions);
310 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
311 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
312 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
314 m_timelineContextMenu = new QMenu(this);
315 m_timelineContextClipMenu = new QMenu(this);
316 m_timelineContextTransitionMenu = new QMenu(this);
319 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
320 QStringList effects = transitions.effectNames();
323 for (int ix = 0; ix < transitions.count(); ix++) {
324 effectInfo = transitions.effectIdInfo(ix);
325 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
327 foreach(const QStringList &value, effectsList) {
328 action = new QAction(value.at(0), this);
329 action->setData(value);
330 transitionsMenu->addAction(action);
332 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
334 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
335 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
336 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
338 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
339 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
340 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
341 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
342 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
343 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
344 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
346 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
347 m_timelineContextClipMenu->addMenu(markersMenu);
348 m_timelineContextClipMenu->addMenu(transitionsMenu);
349 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
350 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
351 //TODO: re-enable custom effects menu when it is implemented
352 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
354 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
355 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
357 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
359 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
360 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
361 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
362 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
363 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
364 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
366 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
367 slotConnectMonitors();
369 // Open or create a file. Command line argument passed in Url has
370 // precedence, then "openlastproject", then just a plain empty file.
371 // If opening Url fails, openlastproject will _not_ be used.
372 if (!Url.isEmpty()) {
375 if (KdenliveSettings::openlastproject()) {
379 if (m_timelineArea->count() == 0) {
383 #ifndef NO_JOGSHUTTLE
384 activateShuttleDevice();
385 #endif /* NO_JOGSHUTTLE */
386 m_projectListDock->raise();
389 void MainWindow::queryQuit()
392 if (m_projectMonitor) m_projectMonitor->stop();
393 if (m_clipMonitor) m_clipMonitor->stop();
394 delete m_effectStack;
395 delete m_activeTimeline;
397 // This sometimes causes crash on exit on OS X for some reason.
398 delete m_projectMonitor;
399 delete m_clipMonitor;
401 delete m_activeDocument;
402 delete m_shortcutRemoveFocus;
403 Mlt::Factory::close();
409 bool MainWindow::queryClose()
411 if (m_renderWidget) {
412 int waitingJobs = m_renderWidget->waitingJobsCount();
413 if (waitingJobs > 0) {
414 switch (KMessageBox::warningYesNoCancel(this, i18n("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")))) {
415 case KMessageBox::Yes :
416 // create script with waiting jobs and start it
417 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
419 case KMessageBox::No :
420 // Don't do anything, jobs will be deleted
428 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
429 if (m_activeDocument && m_activeDocument->isModified()) {
430 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
431 case KMessageBox::Yes :
432 // save document here. If saving fails, return false;
434 case KMessageBox::No :
435 // User does not want to save the changes, clear recovery files
436 m_activeDocument->m_autosave->resize(0);
446 void MainWindow::loadPlugins()
448 foreach(QObject *plugin, QPluginLoader::staticInstances())
449 populateMenus(plugin);
451 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
453 filters << "libkdenlive*";
454 foreach(const QString &folder, directories) {
455 kDebug() << "// PARSING FIOLER: " << folder;
456 QDir pluginsDir(folder);
457 foreach(const QString &fileName, pluginsDir.entryList(filters, QDir::Files)) {
458 kDebug() << "// FOUND PLUGIN: " << fileName << "= " << pluginsDir.absoluteFilePath(fileName);
459 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
460 QObject *plugin = loader.instance();
462 populateMenus(plugin);
463 m_pluginFileNames += fileName;
464 } else kDebug() << "// ERROR LOADING PLUGIN: " << fileName << ", " << loader.errorString();
470 void MainWindow::populateMenus(QObject *plugin)
472 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
473 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
475 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
479 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
480 QMenu *menu, const char *member,
481 QActionGroup *actionGroup)
483 kDebug() << "// ADD to MENU" << texts;
484 foreach(const QString &text, texts) {
485 QAction *action = new QAction(text, plugin);
486 action->setData(text);
487 connect(action, SIGNAL(triggered()), this, member);
488 menu->addAction(action);
491 action->setCheckable(true);
492 actionGroup->addAction(action);
497 void MainWindow::aboutPlugins()
499 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
504 void MainWindow::generateClip()
506 QAction *action = qobject_cast<QAction *>(sender());
507 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
509 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(), QStringList(), QStringList(), 25, 720, 576);
510 if (!clipUrl.isEmpty()) {
511 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
515 void MainWindow::saveProperties(KConfigGroup &config)
517 // save properties here,used by session management
519 KMainWindow::saveProperties(config);
523 void MainWindow::readProperties(const KConfigGroup &config)
525 // read properties here,used by session management
526 KMainWindow::readProperties(config);
527 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
528 openFile(KUrl(Lastproject));
531 void MainWindow::slotReloadEffects()
533 kDebug() << "START RELOAD; COUNR: " << m_customEffectsMenu->actions().count();
534 m_customEffectsMenu->clear();
535 kDebug() << "START RELOAD; CLR: " << m_customEffectsMenu->actions().count();
536 initEffects::parseCustomEffectsFile();
537 const QStringList effects = customEffects.effectNames();
538 kDebug() << "NEW EFFS: " << effects;
540 if (effects.isEmpty()) m_customEffectsMenu->setEnabled(false);
541 else m_customEffectsMenu->setEnabled(true);
543 foreach(const QString &name, effects) {
544 action = new QAction(name, this);
545 action->setData(name);
546 m_customEffectsMenu->addAction(action);
548 m_effectList->reloadEffectList();
551 #ifndef NO_JOGSHUTTLE
552 void MainWindow::activateShuttleDevice()
556 if (KdenliveSettings::enableshuttle() == false) return;
557 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
558 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
559 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
560 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
561 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
562 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
563 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
566 void MainWindow::slotShuttleButton(int code)
570 slotShuttleAction(KdenliveSettings::shuttle1());
573 slotShuttleAction(KdenliveSettings::shuttle2());
576 slotShuttleAction(KdenliveSettings::shuttle3());
579 slotShuttleAction(KdenliveSettings::shuttle4());
582 slotShuttleAction(KdenliveSettings::shuttle5());
587 void MainWindow::slotShuttleAction(int code)
593 m_monitorManager->slotPlay();
596 m_monitorManager->slotPlay();
600 #endif /* NO_JOGSHUTTLE */
602 void MainWindow::configureNotifications()
604 KNotifyConfigWidget::configure(this);
607 void MainWindow::slotFullScreen()
609 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
612 void MainWindow::slotAddEffect(const QDomElement effect, GenTime pos, int track)
614 if (!m_activeDocument) return;
615 if (effect.isNull()) {
616 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
619 QDomElement effectToAdd = effect.cloneNode().toElement();
620 m_activeTimeline->projectView()->slotAddEffect(effectToAdd, pos, track);
623 void MainWindow::slotRaiseMonitor(bool clipMonitor)
625 if (clipMonitor) m_clipMonitorDock->raise();
626 else m_projectMonitorDock->raise();
629 void MainWindow::slotUpdateClip(const QString &id)
631 if (!m_activeDocument) return;
632 m_activeTimeline->projectView()->slotUpdateClip(id);
635 void MainWindow::slotConnectMonitors()
638 m_projectList->setRenderer(m_projectMonitor->render);
639 connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
640 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
641 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, bool)));
642 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
643 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)));
645 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
647 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
649 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
650 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
652 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
653 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
656 void MainWindow::slotAdjustClipMonitor()
658 m_clipMonitorDock->updateGeometry();
659 m_clipMonitorDock->adjustSize();
660 m_clipMonitor->resetSize();
663 void MainWindow::slotAdjustProjectMonitor()
665 m_projectMonitorDock->updateGeometry();
666 m_projectMonitorDock->adjustSize();
667 m_projectMonitor->resetSize();
670 void MainWindow::setupActions()
673 KActionCollection* collection = actionCollection();
674 m_timecodeFormat = new KComboBox(this);
675 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
676 m_timecodeFormat->addItem(i18n("Frames"));
677 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
678 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
680 m_statusProgressBar = new QProgressBar(this);
681 m_statusProgressBar->setMinimum(0);
682 m_statusProgressBar->setMaximum(100);
683 m_statusProgressBar->setMaximumWidth(150);
684 m_statusProgressBar->setVisible(false);
686 QToolBar *toolbar = new QToolBar("statusToolBar", this);
687 toolbar->setMovable(false);
688 m_toolGroup = new QActionGroup(this);
690 QString style1 = "QToolBar {border:0px} QToolButton {background-color: rgba(230, 230, 230, 220); border-style: inset; border:1px solid #999999;border-radius: 3px;margin: 0px 3px;padding: 0px;} QToolButton:checked { background-color: rgba(224, 224, 0, 100); border-style: inset; border:1px solid #cc6666;border-radius: 3px;}";
692 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
693 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
694 toolbar->addAction(m_buttonSelectTool);
695 m_buttonSelectTool->setCheckable(true);
696 m_buttonSelectTool->setChecked(true);
698 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
699 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
700 toolbar->addAction(m_buttonRazorTool);
701 m_buttonRazorTool->setCheckable(true);
702 m_buttonRazorTool->setChecked(false);
704 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
705 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
706 toolbar->addAction(m_buttonSpacerTool);
707 m_buttonSpacerTool->setCheckable(true);
708 m_buttonSpacerTool->setChecked(false);
710 m_toolGroup->addAction(m_buttonSelectTool);
711 m_toolGroup->addAction(m_buttonRazorTool);
712 m_toolGroup->addAction(m_buttonSpacerTool);
713 m_toolGroup->setExclusive(true);
714 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
716 QWidget * actionWidget;
717 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
718 actionWidget->setMaximumWidth(24);
719 actionWidget->setMinimumHeight(18);
721 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
722 actionWidget->setMaximumWidth(24);
723 actionWidget->setMinimumHeight(18);
725 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
726 actionWidget->setMaximumWidth(24);
727 actionWidget->setMinimumHeight(18);
729 toolbar->setStyleSheet(style1);
730 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
732 toolbar->addSeparator();
733 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
734 toolbar->addAction(m_buttonFitZoom);
735 m_buttonFitZoom->setCheckable(false);
736 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
738 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
739 actionWidget->setMaximumWidth(24);
740 actionWidget->setMinimumHeight(18);
742 m_zoomSlider = new QSlider(Qt::Horizontal, this);
743 m_zoomSlider->setMaximum(13);
744 m_zoomSlider->setPageStep(1);
746 m_zoomSlider->setMaximumWidth(150);
747 m_zoomSlider->setMinimumWidth(100);
748 toolbar->addWidget(m_zoomSlider);
750 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
751 toolbar->addAction(m_buttonVideoThumbs);
752 m_buttonVideoThumbs->setCheckable(true);
753 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
754 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
756 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
757 toolbar->addAction(m_buttonAudioThumbs);
758 m_buttonAudioThumbs->setCheckable(true);
759 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
760 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
762 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
763 toolbar->addAction(m_buttonShowMarkers);
764 m_buttonShowMarkers->setCheckable(true);
765 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
766 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
768 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
769 toolbar->addAction(m_buttonSnap);
770 m_buttonSnap->setCheckable(true);
771 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
772 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
774 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
775 actionWidget->setMaximumWidth(24);
776 actionWidget->setMinimumHeight(18);
778 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
779 actionWidget->setMaximumWidth(24);
780 actionWidget->setMinimumHeight(18);
782 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
783 actionWidget->setMaximumWidth(24);
784 actionWidget->setMinimumHeight(18);
786 actionWidget = toolbar->widgetForAction(m_buttonSnap);
787 actionWidget->setMaximumWidth(24);
788 actionWidget->setMinimumHeight(18);
790 m_messageLabel = new StatusBarMessageLabel(this);
791 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
793 statusBar()->addWidget(m_messageLabel, 10);
794 statusBar()->addWidget(m_statusProgressBar, 0);
795 statusBar()->addPermanentWidget(toolbar);
796 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
797 statusBar()->addPermanentWidget(m_timecodeFormat);
798 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
800 collection->addAction("select_tool", m_buttonSelectTool);
801 collection->addAction("razor_tool", m_buttonRazorTool);
802 collection->addAction("spacer_tool", m_buttonSpacerTool);
804 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
805 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
806 collection->addAction("show_markers", m_buttonShowMarkers);
807 collection->addAction("snap", m_buttonSnap);
808 collection->addAction("zoom_fit", m_buttonFitZoom);
810 KAction* zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
811 collection->addAction("zoom_in", zoomIn);
812 connect(zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
813 zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
815 KAction* zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
816 collection->addAction("zoom_out", zoomOut);
817 connect(zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
818 zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
820 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
821 collection->addAction("project_find", m_projectSearch);
822 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
823 m_projectSearch->setShortcut(Qt::Key_Slash);
825 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
826 collection->addAction("project_find_next", m_projectSearchNext);
827 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
828 m_projectSearchNext->setShortcut(Qt::Key_F3);
829 m_projectSearchNext->setEnabled(false);
831 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
832 collection->addAction("manage_profiles", profilesAction);
833 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
835 KNS::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
837 KNS::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
839 KNS::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
841 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
842 collection->addAction("run_wizard", wizAction);
843 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
845 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
846 collection->addAction("project_settings", projectAction);
847 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
849 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
850 collection->addAction("project_render", projectRender);
851 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
852 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
854 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
855 KShortcut playShortcut;
856 playShortcut.setPrimary(Qt::Key_Space);
857 playShortcut.setAlternate(Qt::Key_K);
858 monitorPlay->setShortcut(playShortcut);
859 collection->addAction("monitor_play", monitorPlay);
860 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
862 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
863 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
864 collection->addAction("monitor_play_zone", m_playZone);
865 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
867 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
868 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
869 collection->addAction("monitor_loop_zone", m_loopZone);
870 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
872 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
873 collection->addAction("dvd_wizard", dvdWizard);
874 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
876 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clip"), this);
877 collection->addAction("transcode_clip", transcodeClip);
878 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
880 KAction *markIn = collection->addAction("mark_in");
881 markIn->setText(i18n("Set In Point"));
882 markIn->setShortcut(Qt::Key_I);
883 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
885 KAction *markOut = collection->addAction("mark_out");
886 markOut->setText(i18n("Set Out Point"));
887 markOut->setShortcut(Qt::Key_O);
888 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
890 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
891 monitorSeekBackward->setShortcut(Qt::Key_J);
892 collection->addAction("monitor_seek_backward", monitorSeekBackward);
893 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
895 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
896 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
897 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
898 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
900 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
901 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
902 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
903 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
905 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
906 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
907 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
908 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
910 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
911 monitorSeekForward->setShortcut(Qt::Key_L);
912 collection->addAction("monitor_seek_forward", monitorSeekForward);
913 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
915 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
916 clipStart->setShortcut(Qt::Key_Home);
917 collection->addAction("seek_clip_start", clipStart);
918 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
920 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
921 clipEnd->setShortcut(Qt::Key_End);
922 collection->addAction("seek_clip_end", clipEnd);
923 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
925 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
926 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
927 collection->addAction("seek_start", projectStart);
928 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
930 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
931 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
932 collection->addAction("seek_end", projectEnd);
933 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
935 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
936 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
937 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
938 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
940 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
941 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
942 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
943 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
945 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
946 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
947 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
948 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
950 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
951 deleteTimelineClip->setShortcut(Qt::Key_Delete);
952 collection->addAction("delete_timeline_clip", deleteTimelineClip);
953 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
955 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
956 collection->addAction("change_clip_speed", editTimelineClipSpeed);
957 editTimelineClipSpeed->setData("change_speed");
958 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
960 KAction *stickTransition = collection->addAction("auto_transition");
961 stickTransition->setData(QString("auto"));
962 stickTransition->setCheckable(true);
963 stickTransition->setEnabled(false);
964 stickTransition->setText(i18n("Automatic Transition"));
965 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
967 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
968 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
969 collection->addAction("group_clip", groupClip);
970 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
972 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
973 collection->addAction("ungroup_clip", ungroupClip);
974 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
975 ungroupClip->setData("ungroup_clip");
976 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
978 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
979 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
980 collection->addAction("cut_timeline_clip", cutTimelineClip);
981 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
983 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
984 collection->addAction("add_clip_marker", addClipMarker);
985 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
987 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
988 collection->addAction("delete_clip_marker", deleteClipMarker);
989 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
991 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
992 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
993 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
995 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
996 collection->addAction("edit_clip_marker", editClipMarker);
997 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
999 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1000 collection->addAction("split_audio", splitAudio);
1001 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1003 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1004 collection->addAction("clip_audio_only", audioOnly);
1005 audioOnly->setData("clip_audio_only");
1006 audioOnly->setCheckable(true);
1008 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1009 collection->addAction("clip_video_only", videoOnly);
1010 videoOnly->setData("clip_video_only");
1011 videoOnly->setCheckable(true);
1013 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1014 collection->addAction("clip_audio_and_video", audioAndVideo);
1015 audioAndVideo->setData("clip_audio_and_video");
1016 audioAndVideo->setCheckable(true);
1018 m_clipTypeGroup = new QActionGroup(this);
1019 m_clipTypeGroup->addAction(audioOnly);
1020 m_clipTypeGroup->addAction(videoOnly);
1021 m_clipTypeGroup->addAction(audioAndVideo);
1022 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1023 m_clipTypeGroup->setEnabled(false);
1025 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1026 collection->addAction("insert_space", insertSpace);
1027 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1029 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1030 collection->addAction("delete_space", removeSpace);
1031 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1033 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1034 collection->addAction("insert_track", insertTrack);
1035 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1037 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1038 collection->addAction("delete_track", deleteTrack);
1039 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1041 KAction *changeTrack = new KAction(KIcon(), i18n("Change Track"), this);
1042 collection->addAction("change_track", changeTrack);
1043 connect(changeTrack, SIGNAL(triggered()), this, SLOT(slotChangeTrack()));
1045 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1046 collection->addAction("add_guide", addGuide);
1047 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1049 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1050 collection->addAction("delete_guide", delGuide);
1051 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1053 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1054 collection->addAction("edit_guide", editGuide);
1055 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1057 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1058 collection->addAction("delete_all_guides", delAllGuides);
1059 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1061 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1062 collection->addAction("paste_effects", pasteEffects);
1063 pasteEffects->setData("paste_effects");
1064 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1066 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1067 collection->addAction("show_timeline", showTimeline);
1068 showTimeline->setCheckable(true);
1069 showTimeline->setChecked(true);
1070 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1072 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1073 collection->addAction("maximize_current", maxCurrent);
1074 maxCurrent->setCheckable(true);
1075 maxCurrent->setChecked(false);
1076 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1079 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1081 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1083 KStandardAction::open(this, SLOT(openFile()), collection);
1085 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1087 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1089 KStandardAction::openNew(this, SLOT(newFile()), collection);
1091 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1093 KStandardAction::configureNotifications(this , SLOT(configureNotifications()), collection);
1095 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1097 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1099 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1100 undo->setEnabled(false);
1101 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1103 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1104 redo->setEnabled(false);
1105 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1107 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1110 //TODO: Add status tooltip to actions ?
1111 connect(collection, SIGNAL(actionHovered(QAction*)),
1112 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1115 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1116 collection->addAction("add_clip", addClip);
1117 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1119 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1120 collection->addAction("add_color_clip", addColorClip);
1121 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1123 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1124 collection->addAction("add_slide_clip", addSlideClip);
1125 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1127 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1128 collection->addAction("add_text_clip", addTitleClip);
1129 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1131 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1132 collection->addAction("add_text_template_clip", addTitleTemplateClip);
1133 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1135 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1136 collection->addAction("add_folder", addFolderButton);
1137 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1139 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1140 collection->addAction("clip_properties", clipProperties);
1141 clipProperties->setData("clip_properties");
1142 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1143 clipProperties->setEnabled(false);
1145 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1146 collection->addAction("edit_clip", openClip);
1147 openClip->setData("edit_clip");
1148 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1149 openClip->setEnabled(false);
1151 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1152 collection->addAction("delete_clip", deleteClip);
1153 deleteClip->setData("delete_clip");
1154 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1155 deleteClip->setEnabled(false);
1157 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1158 collection->addAction("reload_clip", reloadClip);
1159 reloadClip->setData("reload_clip");
1160 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1161 reloadClip->setEnabled(false);
1163 QMenu *addClips = new QMenu();
1164 addClips->addAction(addClip);
1165 addClips->addAction(addColorClip);
1166 addClips->addAction(addSlideClip);
1167 addClips->addAction(addTitleClip);
1168 addClips->addAction(addTitleTemplateClip);
1169 addClips->addAction(addFolderButton);
1171 addClips->addAction(reloadClip);
1172 addClips->addAction(clipProperties);
1173 addClips->addAction(openClip);
1174 addClips->addAction(deleteClip);
1175 m_projectList->setupMenu(addClips, addClip);
1177 //connect(collection, SIGNAL( clearStatusText() ),
1178 //statusBar(), SLOT( clear() ) );
1181 void MainWindow::slotDisplayActionMessage(QAction *a)
1183 statusBar()->showMessage(a->data().toString(), 3000);
1186 void MainWindow::saveOptions()
1188 KdenliveSettings::self()->writeConfig();
1189 KSharedConfigPtr config = KGlobal::config();
1190 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1191 KConfigGroup treecolumns(config, "Project Tree");
1192 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1196 void MainWindow::readOptions()
1198 KSharedConfigPtr config = KGlobal::config();
1199 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1200 KConfigGroup initialGroup(config, "version");
1201 bool upgrade = false;
1202 if (initialGroup.exists()) {
1203 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1207 if (initialGroup.readEntry("version") == "0.7") {
1208 //Add new settings from 0.7.1
1209 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1210 QString path = QDir::homePath() + "/kdenlive";
1211 if (KStandardDirs::makeDir(path) == false) {
1212 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1213 } else KdenliveSettings::setDefaultprojectfolder(path);
1219 if (!initialGroup.exists() || upgrade) {
1220 // this is our first run, show Wizard
1221 Wizard *w = new Wizard(upgrade, this);
1222 if (w->exec() == QDialog::Accepted && w->isOk()) {
1223 w->adjustSettings();
1224 initialGroup.writeEntry("version", version);
1230 KConfigGroup treecolumns(config, "Project Tree");
1231 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1232 if (!state.isEmpty())
1233 m_projectList->setHeaderInfo(state);
1236 void MainWindow::slotRunWizard()
1238 Wizard *w = new Wizard(false, this);
1239 if (w->exec() == QDialog::Accepted && w->isOk()) {
1240 w->adjustSettings();
1245 void MainWindow::newFile(bool showProjectSettings)
1247 if (!m_timelineArea->isEnabled()) return;
1248 QString profileName;
1250 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1251 if (!showProjectSettings && m_timelineArea->count() == 0) {
1252 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1253 profileName = KdenliveSettings::default_profile();
1254 projectFolder = KdenliveSettings::defaultprojectfolder();
1256 ProjectSettings *w = new ProjectSettings(projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, this);
1257 if (w->exec() != QDialog::Accepted) return;
1258 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1259 KdenliveSettings::setVideothumbnails(w->enableVideoThumbs());
1260 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1261 KdenliveSettings::setAudiothumbnails(w->enableAudioThumbs());
1262 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1263 profileName = w->selectedProfile();
1264 projectFolder = w->selectedFolder();
1265 projectTracks = w->tracks();
1268 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1269 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1271 TrackView *trackView = new TrackView(doc, &ok, this);
1272 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1275 m_timelineArea->setEnabled(false);
1276 m_projectList->setEnabled(false);
1277 m_monitorManager->slotBlockMonitors();
1281 if (m_timelineArea->count() == 1) {
1282 connectDocumentInfo(doc);
1283 connectDocument(trackView, doc);
1284 } else m_timelineArea->setTabBarHidden(false);
1285 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1288 void MainWindow::activateDocument()
1290 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1291 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1292 KdenliveDoc *currentDoc = currentTab->document();
1293 connectDocumentInfo(currentDoc);
1294 connectDocument(currentTab, currentDoc);
1297 void MainWindow::closeCurrentDocument()
1299 QWidget *w = m_timelineArea->currentWidget();
1301 // closing current document
1302 int ix = m_timelineArea->currentIndex() + 1;
1303 if (ix == m_timelineArea->count()) ix = 0;
1304 m_timelineArea->setCurrentIndex(ix);
1305 TrackView *tabToClose = (TrackView *) w;
1306 KdenliveDoc *docToClose = tabToClose->document();
1307 if (docToClose && docToClose->isModified()) {
1308 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
1309 case KMessageBox::Yes :
1310 // save document here. If saving fails, return false;
1311 if (saveFile() == false) return;
1313 case KMessageBox::Cancel :
1320 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1321 if (m_timelineArea->count() == 1) {
1322 m_timelineArea->setTabBarHidden(true);
1323 m_closeAction->setEnabled(false);
1325 if (docToClose == m_activeDocument) {
1326 delete m_activeDocument;
1327 m_activeDocument = NULL;
1328 m_effectStack->clear();
1329 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1330 } else delete docToClose;
1331 if (w == m_activeTimeline) {
1332 delete m_activeTimeline;
1333 m_activeTimeline = NULL;
1337 bool MainWindow::saveFileAs(const QString &outputFileName)
1339 QString currentSceneList;
1340 if (KdenliveSettings::dropbframes()) {
1341 KdenliveSettings::setDropbframes(false);
1342 m_activeDocument->clipManager()->updatePreviewSettings();
1343 currentSceneList = m_projectMonitor->sceneList();
1344 KdenliveSettings::setDropbframes(true);
1345 m_activeDocument->clipManager()->updatePreviewSettings();
1346 } else currentSceneList = m_projectMonitor->sceneList();
1348 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1351 // Save timeline thumbnails
1352 m_activeTimeline->projectView()->saveThumbnails();
1353 m_activeDocument->setUrl(KUrl(outputFileName));
1354 if (m_activeDocument->m_autosave == NULL) {
1355 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1356 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1357 setCaption(m_activeDocument->description());
1358 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1359 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1360 m_activeDocument->setModified(false);
1361 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1365 bool MainWindow::saveFileAs()
1367 // Check that the Kdenlive mime type is correctly installed
1368 QString mimetype = "application/x-kdenlive";
1369 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1370 if (!mime) mimetype = "*.kdenlive";
1372 QString outputFile = KFileDialog::getSaveFileName(KUrl(), mimetype);
1373 if (outputFile.isEmpty()) return false;
1374 if (QFile::exists(outputFile)) {
1375 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it?")) == KMessageBox::No) return false;
1377 return saveFileAs(outputFile);
1380 bool MainWindow::saveFile()
1382 if (!m_activeDocument) return true;
1383 if (m_activeDocument->url().isEmpty()) {
1384 return saveFileAs();
1386 bool result = saveFileAs(m_activeDocument->url().path());
1387 m_activeDocument->m_autosave->resize(0);
1392 void MainWindow::openFile()
1394 // Check that the Kdenlive mime type is correctly installed
1395 QString mimetype = "application/x-kdenlive";
1396 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1397 if (!mime) mimetype = "*.kdenlive";
1399 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), mimetype);
1400 if (url.isEmpty()) return;
1401 m_fileOpenRecent->addUrl(url);
1405 void MainWindow::openLastFile()
1407 KSharedConfigPtr config = KGlobal::config();
1408 KUrl::List urls = m_fileOpenRecent->urls();
1409 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1410 if (urls.isEmpty()) newFile(false);
1411 else openFile(urls.last());
1414 void MainWindow::openFile(const KUrl &url)
1416 // Check if the document is already opened
1417 const int ct = m_timelineArea->count();
1418 bool isOpened = false;
1420 for (i = 0; i < ct; i++) {
1421 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1422 KdenliveDoc *doc = tab->document();
1423 if (doc->url() == url) {
1429 m_timelineArea->setCurrentIndex(i);
1433 // Check for backup file
1434 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1435 if (!staleFiles.isEmpty()) {
1436 if (KMessageBox::questionYesNo(this,
1437 i18n("Auto-saved files exist. Do you want to recover them now?"),
1438 i18n("File Recovery"),
1439 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1440 recoverFiles(staleFiles);
1443 // remove the stale files
1444 foreach(KAutoSaveFile *stale, staleFiles) {
1445 stale->open(QIODevice::ReadWrite);
1450 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1451 doOpenFile(url, NULL);
1454 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1456 if (!m_timelineArea->isEnabled()) return;
1457 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, this);
1458 if (stale == NULL) {
1459 stale = new KAutoSaveFile(url, doc);
1460 doc->m_autosave = stale;
1462 doc->m_autosave = stale;
1463 doc->setUrl(stale->managedFile());
1464 doc->setModified(true);
1465 stale->setParent(doc);
1467 connectDocumentInfo(doc);
1469 TrackView *trackView = new TrackView(doc, &ok, this);
1470 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1472 m_timelineArea->setEnabled(false);
1473 m_projectList->setEnabled(false);
1474 m_monitorManager->slotBlockMonitors();
1478 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1479 trackView->setDuration(trackView->duration());
1480 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1482 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1483 slotGotProgressInfo(QString(), -1);
1484 m_clipMonitor->refreshMonitor(true);
1485 m_projectMonitor->adjustRulerSize(trackView->duration());
1486 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1489 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1491 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1492 foreach(KAutoSaveFile *stale, staleFiles) {
1493 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1494 // show an error message; we could not steal the lockfile
1495 // maybe another application got to the file before us?
1499 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1500 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
1501 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1502 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1507 void MainWindow::parseProfiles(const QString &mltPath)
1509 // kDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
1511 //KdenliveSettings::setDefaulttmpfolder();
1512 if (!mltPath.isEmpty()) {
1513 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1514 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
1517 if (KdenliveSettings::mltpath().isEmpty()) {
1518 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1520 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
1521 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
1522 if (!QFile::exists(meltPath))
1523 meltPath = KStandardDirs::findExe("melt");
1524 KdenliveSettings::setRendererpath(meltPath);
1526 QStringList profilesFilter;
1527 profilesFilter << "*";
1528 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1530 if (profilesList.isEmpty()) {
1531 // Cannot find MLT path, try finding melt
1532 QString profilePath = KdenliveSettings::rendererpath();
1533 if (!profilePath.isEmpty()) {
1534 profilePath = profilePath.section('/', 0, -3);
1535 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1536 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1539 if (profilesList.isEmpty()) {
1540 // Cannot find the MLT profiles, ask for location
1541 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1542 getUrl->fileDialog()->setMode(KFile::Directory);
1543 if (getUrl->exec() == QDialog::Rejected) {
1546 KUrl mltPath = getUrl->selectedUrl();
1548 if (mltPath.isEmpty()) ::exit(0);
1549 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
1550 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1554 if (KdenliveSettings::rendererpath().isEmpty()) {
1555 // Cannot find the MLT melt renderer, ask for location
1556 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of Mlt)"), this);
1557 if (getUrl->exec() == QDialog::Rejected) {
1560 KUrl rendererPath = getUrl->selectedUrl();
1562 if (rendererPath.isEmpty()) ::exit(0);
1563 KdenliveSettings::setRendererpath(rendererPath.path());
1566 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1568 // Parse MLT profiles to build a list of available video formats
1569 if (profilesList.isEmpty()) parseProfiles();
1573 void MainWindow::slotEditProfiles()
1575 ProfilesDialog *w = new ProfilesDialog;
1576 if (w->exec() == QDialog::Accepted) {
1577 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1578 if (d) d->checkProfile();
1583 void MainWindow::slotDetectAudioDriver()
1585 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
1586 leading to no audio output, see bug #934 */
1588 //decide which audio driver is really best, in some cases SDL is wrong
1589 if (KdenliveSettings::audiodrivername().isEmpty()) {
1591 KProcess readProcess;
1592 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
1593 if (!KStandardDirs::findExe("pactl").isEmpty()) {
1594 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
1595 readProcess.setProgram("pactl", QStringList() << "stat");
1596 readProcess.execute(2000); // Kill it after 2 seconds
1598 QString result = QString(readProcess.readAllStandardOutput());
1599 kDebug() << "// / / / / / READING PACTL: ";
1601 if (!result.isEmpty()) {
1603 kDebug() << "// / / / / PULSEAUDIO DETECTED";
1607 KdenliveSettings::setAutoaudiodrivername(driver);
1611 void MainWindow::slotEditProjectSettings()
1613 QPoint p = m_activeDocument->getTracksCount();
1614 ProjectSettings *w = new ProjectSettings(p.x(), p.y(), m_activeDocument->projectFolder().path(), true, this);
1616 if (w->exec() == QDialog::Accepted) {
1617 QString profile = w->selectedProfile();
1618 m_activeDocument->setProjectFolder(w->selectedFolder());
1619 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path(KUrl::AddTrailingSlash));
1620 if (m_activeDocument->profilePath() != profile) {
1621 // Profile was changed
1622 double dar = m_activeDocument->dar();
1624 // Deselect current effect / transition
1625 m_effectStack->slotClipItemSelected(NULL, 0);
1626 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1627 m_clipMonitor->slotSetXml(NULL, 0);
1628 m_activeDocument->setProfilePath(profile);
1629 KdenliveSettings::setCurrent_profile(profile);
1630 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1631 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1633 m_activeDocument->clipManager()->clearUnusedProducers();
1634 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1636 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeTimeline->tracksNumber());
1637 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
1638 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1639 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1640 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1641 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
1642 m_activeTimeline->updateProjectFps();
1644 // We need to desactivate & reactivate monitors to get a refresh
1645 //m_monitorManager->switchMonitors();
1651 void MainWindow::slotRenderProject()
1653 if (!m_renderWidget) {
1654 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
1655 m_renderWidget = new RenderWidget(projectfolder, this);
1656 connect(m_renderWidget, SIGNAL(selectedRenderProfile(const QString &, const QString &, const QString&)), this, SLOT(slotSetDocumentRenderProfile(const QString &, const QString &, const QString&)));
1657 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
1658 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1659 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1660 if (m_activeDocument) {
1661 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1662 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1663 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
1664 m_renderWidget->setRenderProfile(m_activeDocument->getDocumentProperty("renderdestination"), m_activeDocument->getDocumentProperty("renderprofile"), m_activeDocument->getDocumentProperty("renderurl"));
1667 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1668 if (currentTab) m_renderWidget->setTimeline(currentTab);
1669 m_renderWidget->setDocument(m_activeDocument);*/
1670 m_renderWidget->show();
1671 m_renderWidget->showNormal();
1674 void MainWindow::setRenderingProgress(const QString &url, int progress)
1676 if (m_renderWidget) m_renderWidget->setRenderJob(url, progress);
1679 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
1681 if (m_renderWidget) m_renderWidget->setRenderStatus(url, status, error);
1684 void MainWindow::slotUpdateMousePosition(int pos)
1686 if (m_activeDocument)
1687 switch (m_timecodeFormat->currentIndex()) {
1689 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1692 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1696 void MainWindow::slotUpdateDocumentState(bool modified)
1698 if (!m_activeDocument) return;
1699 setCaption(m_activeDocument->description(), modified);
1700 m_saveAction->setEnabled(modified);
1702 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1703 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1705 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1706 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1710 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
1712 if (m_activeDocument) {
1713 if (m_activeDocument == doc) return;
1714 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1716 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1719 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
1721 //m_projectMonitor->stop();
1722 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1723 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1724 if (m_activeDocument) {
1725 if (m_activeDocument == doc) return;
1726 if (m_activeTimeline) {
1727 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1728 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1729 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1730 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1731 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
1733 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1734 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1735 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1736 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1737 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1738 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1739 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1740 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1741 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1742 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
1743 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1744 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1745 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1746 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1747 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1748 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1749 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1750 disconnect(m_activeTimeline, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1751 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1752 disconnect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1753 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1754 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1755 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1756 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1757 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1758 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1759 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
1760 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1761 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1762 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
1763 m_effectStack->clear();
1765 //m_activeDocument->setRenderer(NULL);
1766 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1767 disconnect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
1768 m_clipMonitor->stop();
1770 KdenliveSettings::setCurrent_profile(doc->profilePath());
1771 KdenliveSettings::setProject_fps(doc->fps());
1772 m_monitorManager->resetProfiles(doc->timecode());
1773 m_projectList->setDocument(doc);
1774 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), trackView->tracksNumber());
1775 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
1776 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1777 connect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
1778 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1779 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
1782 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1783 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1784 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1785 connect(trackView, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1786 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1787 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1788 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1789 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1790 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
1792 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1793 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1794 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1795 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1796 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1798 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1799 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1800 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1803 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1804 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1805 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
1806 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1807 m_zoomSlider->setValue(doc->zoom().x());
1808 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1809 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1810 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1811 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1813 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1816 connect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1817 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1818 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1819 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1820 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1821 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1822 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1823 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1825 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1826 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1827 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
1829 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup);
1830 m_activeTimeline = trackView;
1831 if (m_renderWidget) {
1832 m_renderWidget->setProfile(doc->mltProfile());
1833 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
1834 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
1835 m_renderWidget->setRenderProfile(doc->getDocumentProperty("renderdestination"), doc->getDocumentProperty("renderprofile"), doc->getDocumentProperty("renderurl"));
1837 //doc->setRenderer(m_projectMonitor->render);
1838 m_commandStack->setActiveStack(doc->commandStack());
1839 KdenliveSettings::setProject_display_ratio(doc->dar());
1840 //doc->clipManager()->checkAudioThumbs();
1842 //m_overView->setScene(trackView->projectScene());
1843 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1844 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1846 setCaption(doc->description(), doc->isModified());
1847 m_saveAction->setEnabled(doc->isModified());
1848 m_activeDocument = doc;
1849 m_activeTimeline->updateProjectFps();
1850 m_projectList->updateAllClips();
1851 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
1853 // set tool to select tool
1854 m_buttonSelectTool->setChecked(true);
1857 void MainWindow::slotZoneMoved(int start, int end)
1859 m_activeDocument->setZone(start, end);
1860 m_projectMonitor->slotZoneMoved(start, end);
1863 void MainWindow::slotGuidesUpdated()
1865 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1868 void MainWindow::slotPreferences(int page, int option)
1870 //An instance of your dialog could be already created and could be
1871 // cached, in which case you want to display the cached dialog
1872 // instead of creating another one
1873 if (KConfigDialog::showDialog("settings")) {
1874 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1875 if (page != -1) d->showPage(page, option);
1879 // KConfigDialog didn't find an instance of this dialog, so lets
1881 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1882 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1883 //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
1884 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1885 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1887 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
1889 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1891 if (page != -1) dialog->showPage(page, option);
1894 void MainWindow::slotUpdatePreviewSettings()
1896 if (m_activeDocument) {
1897 m_clipMonitor->slotSetXml(NULL, 0);
1898 m_activeDocument->updatePreviewSettings();
1902 void MainWindow::updateConfiguration()
1904 //TODO: we should apply settings to all projects, not only the current one
1905 if (m_activeTimeline) {
1906 m_activeTimeline->refresh();
1907 m_activeTimeline->projectView()->checkAutoScroll();
1908 m_activeTimeline->projectView()->checkTrackHeight();
1909 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1911 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1912 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1914 // Update list of transcoding profiles
1916 #ifndef NO_JOGSHUTTLE
1917 activateShuttleDevice();
1918 #endif /* NO_JOGSHUTTLE */
1923 void MainWindow::slotSwitchVideoThumbs()
1925 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1926 if (m_activeTimeline) {
1927 m_activeTimeline->projectView()->slotUpdateAllThumbs();
1929 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1932 void MainWindow::slotSwitchAudioThumbs()
1934 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
1935 if (m_activeTimeline) {
1936 m_activeTimeline->refresh();
1937 m_activeTimeline->projectView()->checkAutoScroll();
1938 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1940 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1943 void MainWindow::slotSwitchMarkersComments()
1945 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1946 if (m_activeTimeline) {
1947 m_activeTimeline->refresh();
1949 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1952 void MainWindow::slotSwitchSnap()
1954 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
1955 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1959 void MainWindow::slotDeleteTimelineClip()
1961 if (QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) m_projectList->slotRemoveClip();
1962 else if (m_activeTimeline) {
1963 m_activeTimeline->projectView()->deleteSelectedClips();
1967 void MainWindow::slotAddClipMarker()
1969 DocClipBase *clip = NULL;
1971 if (m_projectMonitor->isActive()) {
1972 if (m_activeTimeline) {
1973 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1975 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
1976 clip = item->baseClip();
1980 clip = m_clipMonitor->activeClip();
1981 pos = m_clipMonitor->position();
1984 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
1987 QString id = clip->getId();
1988 CommentedTime marker(pos, i18n("Marker"));
1989 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
1990 if (d.exec() == QDialog::Accepted) {
1991 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
1993 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
1996 void MainWindow::slotDeleteClipMarker()
1998 DocClipBase *clip = NULL;
2000 if (m_projectMonitor->isActive()) {
2001 if (m_activeTimeline) {
2002 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2004 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2005 clip = item->baseClip();
2009 clip = m_clipMonitor->activeClip();
2010 pos = m_clipMonitor->position();
2013 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2017 QString id = clip->getId();
2018 QString comment = clip->markerComment(pos);
2019 if (comment.isEmpty()) {
2020 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2023 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2024 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2028 void MainWindow::slotDeleteAllClipMarkers()
2030 DocClipBase *clip = NULL;
2031 if (m_projectMonitor->isActive()) {
2032 if (m_activeTimeline) {
2033 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2035 clip = item->baseClip();
2039 clip = m_clipMonitor->activeClip();
2042 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2045 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2046 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2049 void MainWindow::slotEditClipMarker()
2051 DocClipBase *clip = NULL;
2053 if (m_projectMonitor->isActive()) {
2054 if (m_activeTimeline) {
2055 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2057 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2058 clip = item->baseClip();
2062 clip = m_clipMonitor->activeClip();
2063 pos = m_clipMonitor->position();
2066 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2070 QString id = clip->getId();
2071 QString oldcomment = clip->markerComment(pos);
2072 if (oldcomment.isEmpty()) {
2073 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2077 CommentedTime marker(pos, oldcomment);
2078 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2079 if (d.exec() == QDialog::Accepted) {
2080 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2081 if (d.newMarker().time() != pos) {
2082 // remove old marker
2083 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2085 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2089 void MainWindow::slotAddGuide()
2091 if (m_activeTimeline)
2092 m_activeTimeline->projectView()->slotAddGuide();
2095 void MainWindow::slotInsertSpace()
2097 if (m_activeTimeline)
2098 m_activeTimeline->projectView()->slotInsertSpace();
2101 void MainWindow::slotRemoveSpace()
2103 if (m_activeTimeline)
2104 m_activeTimeline->projectView()->slotRemoveSpace();
2107 void MainWindow::slotInsertTrack(int ix)
2109 m_projectMonitor->activateMonitor();
2110 if (m_activeTimeline)
2111 m_activeTimeline->projectView()->slotInsertTrack(ix);
2114 void MainWindow::slotDeleteTrack(int ix)
2116 m_projectMonitor->activateMonitor();
2117 if (m_activeTimeline)
2118 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2121 void MainWindow::slotChangeTrack(int ix)
2123 m_projectMonitor->activateMonitor();
2124 if (m_activeTimeline)
2125 m_activeTimeline->projectView()->slotChangeTrack(ix);
2128 void MainWindow::slotEditGuide()
2130 if (m_activeTimeline)
2131 m_activeTimeline->projectView()->slotEditGuide();
2134 void MainWindow::slotDeleteGuide()
2136 if (m_activeTimeline)
2137 m_activeTimeline->projectView()->slotDeleteGuide();
2140 void MainWindow::slotDeleteAllGuides()
2142 if (m_activeTimeline)
2143 m_activeTimeline->projectView()->slotDeleteAllGuides();
2146 void MainWindow::slotCutTimelineClip()
2148 if (m_activeTimeline) {
2149 m_activeTimeline->projectView()->cutSelectedClips();
2153 void MainWindow::slotGroupClips()
2155 if (m_activeTimeline) {
2156 m_activeTimeline->projectView()->groupClips();
2160 void MainWindow::slotUnGroupClips()
2162 if (m_activeTimeline) {
2163 m_activeTimeline->projectView()->groupClips(false);
2167 void MainWindow::slotAddProjectClip(KUrl url)
2169 if (m_activeDocument)
2170 m_activeDocument->slotAddClipFile(url, QString());
2173 void MainWindow::slotAddTransition(QAction *result)
2175 if (!result) return;
2176 QStringList info = result->data().toStringList();
2177 if (info.isEmpty()) return;
2178 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2179 if (m_activeTimeline && !transition.isNull()) {
2180 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2184 void MainWindow::slotAddVideoEffect(QAction *result)
2186 if (!result) return;
2187 QStringList info = result->data().toStringList();
2188 if (info.isEmpty()) return;
2189 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2190 slotAddEffect(effect);
2193 void MainWindow::slotAddAudioEffect(QAction *result)
2195 if (!result) return;
2196 QStringList info = result->data().toStringList();
2197 if (info.isEmpty()) return;
2198 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2199 slotAddEffect(effect);
2202 void MainWindow::slotAddCustomEffect(QAction *result)
2204 if (!result) return;
2205 QStringList info = result->data().toStringList();
2206 if (info.isEmpty()) return;
2207 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2208 slotAddEffect(effect);
2211 void MainWindow::slotZoomIn()
2213 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2216 void MainWindow::slotZoomOut()
2218 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2221 void MainWindow::slotFitZoom()
2223 if (m_activeTimeline) {
2224 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2228 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2230 m_statusProgressBar->setValue(progress);
2231 if (progress >= 0) {
2232 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2233 m_statusProgressBar->setVisible(true);
2235 m_messageLabel->setMessage(QString(), DefaultMessage);
2236 m_statusProgressBar->setVisible(false);
2240 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2242 if (clip->clipType() == TEXT) {
2243 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
2244 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
2245 // template text clip
2247 // Get the list of existing templates
2249 filter << "*.kdenlivetitle";
2250 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
2252 QDialog *dia = new QDialog(this);
2253 Ui::TemplateClip_UI dia_ui;
2254 dia_ui.setupUi(dia);
2256 const QString templatePath = clip->getProperty("resource");
2257 for (int i = 0; i < templateFiles.size(); ++i) {
2258 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
2259 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
2261 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
2262 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
2263 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
2264 //warning: setting base directory doesn't work??
2265 KUrl startDir(titlepath);
2266 dia_ui.template_list->fileDialog()->setUrl(startDir);
2267 dia_ui.description->setText(clip->getProperty("description"));
2268 if (dia->exec() == QDialog::Accepted) {
2269 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
2270 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
2272 QMap <QString, QString> newprops;
2274 if (KUrl(textTemplate).path() != templatePath) {
2275 // The template was changed
2276 newprops.insert("resource", textTemplate);
2279 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
2280 newprops.insert("description", dia_ui.description->toPlainText());
2283 QString newtemplate = newprops.value("xmltemplate");
2284 if (newtemplate.isEmpty()) newtemplate = templatePath;
2286 // template modified we need to update xmldata
2287 QString description = newprops.value("description");
2288 if (description.isEmpty()) description = clip->getProperty("description");
2289 else newprops.insert("templatetext", description);
2290 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
2292 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2293 m_activeDocument->commandStack()->push(command);
2297 QString path = clip->getProperty("resource");
2298 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
2300 doc.setContent(clip->getProperty("xmldata"));
2301 dia_ui->setXml(doc);
2302 if (dia_ui->exec() == QDialog::Accepted) {
2303 QMap <QString, QString> newprops;
2304 newprops.insert("xmldata", dia_ui->xml().toString());
2305 newprops.insert("out", QString::number(dia_ui->duration()));
2306 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2307 m_activeDocument->commandStack()->push(command);
2308 m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
2309 m_activeDocument->setModified(true);
2313 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2316 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2317 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2318 if (dia.exec() == QDialog::Accepted) {
2319 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true);
2320 m_activeDocument->commandStack()->push(command);
2322 //m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
2323 if (dia.needsTimelineRefresh()) {
2324 // update clip occurences in timeline
2325 m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
2330 void MainWindow::customEvent(QEvent* e)
2332 if (e->type() == QEvent::User) {
2333 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
2336 void MainWindow::slotActivateEffectStackView()
2338 m_effectStack->raiseWindow(m_effectStackDock);
2341 void MainWindow::slotActivateTransitionView(Transition *t)
2343 if (t) m_transitionConfig->raiseWindow(m_transitionConfigDock);
2346 void MainWindow::slotSnapRewind()
2348 if (m_projectMonitor->isActive()) {
2349 if (m_activeTimeline)
2350 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2351 } else m_clipMonitor->slotSeekToPreviousSnap();
2354 void MainWindow::slotSnapForward()
2356 if (m_projectMonitor->isActive()) {
2357 if (m_activeTimeline)
2358 m_activeTimeline->projectView()->slotSeekToNextSnap();
2359 } else m_clipMonitor->slotSeekToNextSnap();
2362 void MainWindow::slotClipStart()
2364 if (m_projectMonitor->isActive()) {
2365 if (m_activeTimeline)
2366 m_activeTimeline->projectView()->clipStart();
2370 void MainWindow::slotClipEnd()
2372 if (m_projectMonitor->isActive()) {
2373 if (m_activeTimeline)
2374 m_activeTimeline->projectView()->clipEnd();
2378 void MainWindow::slotChangeTool(QAction * action)
2380 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
2381 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
2382 else if (action == m_buttonSpacerTool) slotSetTool(SPACERTOOL);
2385 void MainWindow::slotSetTool(PROJECTTOOL tool)
2387 if (m_activeDocument && m_activeTimeline) {
2388 //m_activeDocument->setTool(tool);
2389 m_activeTimeline->projectView()->setTool(tool);
2393 void MainWindow::slotCopy()
2395 if (!m_activeDocument || !m_activeTimeline) return;
2396 m_activeTimeline->projectView()->copyClip();
2399 void MainWindow::slotPaste()
2401 if (!m_activeDocument || !m_activeTimeline) return;
2402 m_activeTimeline->projectView()->pasteClip();
2405 void MainWindow::slotPasteEffects()
2407 if (!m_activeDocument || !m_activeTimeline) return;
2408 m_activeTimeline->projectView()->pasteClipEffects();
2411 void MainWindow::slotFind()
2413 if (!m_activeDocument || !m_activeTimeline) return;
2414 m_projectSearch->setEnabled(false);
2415 m_findActivated = true;
2416 m_findString.clear();
2417 m_activeTimeline->projectView()->initSearchStrings();
2418 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2419 m_findTimer.start(5000);
2420 qApp->installEventFilter(this);
2423 void MainWindow::slotFindNext()
2425 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
2426 statusBar()->showMessage(i18n("Found: %1", m_findString));
2428 statusBar()->showMessage(i18n("Reached end of project"));
2430 m_findTimer.start(4000);
2433 void MainWindow::findAhead()
2435 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
2436 m_projectSearchNext->setEnabled(true);
2437 statusBar()->showMessage(i18n("Found: %1", m_findString));
2439 m_projectSearchNext->setEnabled(false);
2440 statusBar()->showMessage(i18n("Not found: %1", m_findString));
2444 void MainWindow::findTimeout()
2446 m_projectSearchNext->setEnabled(false);
2447 m_findActivated = false;
2448 m_findString.clear();
2449 statusBar()->showMessage(i18n("Find stopped"), 3000);
2450 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
2451 m_projectSearch->setEnabled(true);
2452 removeEventFilter(this);
2455 void MainWindow::keyPressEvent(QKeyEvent *ke)
2457 if (m_findActivated) {
2458 if (ke->key() == Qt::Key_Backspace) {
2459 m_findString = m_findString.left(m_findString.length() - 1);
2461 if (!m_findString.isEmpty()) {
2467 m_findTimer.start(4000);
2470 } else if (ke->key() == Qt::Key_Escape) {
2474 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
2475 m_findString += ke->text();
2479 m_findTimer.start(4000);
2483 } else KXmlGuiWindow::keyPressEvent(ke);
2487 /** Gets called when the window gets hidden */
2488 void MainWindow::hideEvent(QHideEvent */*event*/)
2490 // kDebug() << "I was hidden";
2491 // issue http://www.kdenlive.org/mantis/view.php?id=231
2492 if (isMinimized()) {
2493 // kDebug() << "I am minimized";
2494 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
2498 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
2500 if (m_findActivated) {
2501 if (event->type() == QEvent::ShortcutOverride) {
2502 QKeyEvent* ke = (QKeyEvent*) event;
2503 if (ke->text().trimmed().isEmpty()) return false;
2506 } else return false;
2508 // pass the event on to the parent class
2509 return QMainWindow::eventFilter(obj, event);
2514 void MainWindow::slotSaveZone(Render *render, QPoint zone)
2516 KDialog *dialog = new KDialog(this);
2517 dialog->setCaption("Save clip zone");
2518 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
2520 QWidget *widget = new QWidget(dialog);
2521 dialog->setMainWidget(widget);
2523 QVBoxLayout *vbox = new QVBoxLayout(widget);
2524 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
2525 QString path = m_activeDocument->projectFolder().path();
2527 path.append("untitled.mlt");
2528 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
2529 url->setFilter("video/mlt-playlist");
2530 QLabel *label2 = new QLabel(i18n("Description:"), this);
2531 KLineEdit *edit = new KLineEdit(this);
2532 vbox->addWidget(label1);
2533 vbox->addWidget(url);
2534 vbox->addWidget(label2);
2535 vbox->addWidget(edit);
2536 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
2540 void MainWindow::slotSetInPoint()
2542 if (m_clipMonitor->isActive()) {
2543 m_clipMonitor->slotSetZoneStart();
2544 } else m_activeTimeline->projectView()->setInPoint();
2547 void MainWindow::slotSetOutPoint()
2549 if (m_clipMonitor->isActive()) {
2550 m_clipMonitor->slotSetZoneEnd();
2551 } else m_activeTimeline->projectView()->setOutPoint();
2554 void MainWindow::slotGetNewLumaStuff()
2556 //KNS::Entry::List download();
2557 KNS::Entry::List entries = KNS::Engine::download();
2558 // list of changed entries
2559 kDebug() << "// PARSING KNS";
2560 foreach(KNS::Entry* entry, entries) {
2561 // care only about installed ones
2562 if (entry->status() == KNS::Entry::Installed) {
2563 foreach(const QString &file, entry->installedFiles()) {
2564 kDebug() << "// CURRENTLY INSTALLED: " << file;
2568 qDeleteAll(entries);
2569 initEffects::refreshLumas();
2570 m_activeTimeline->projectView()->reloadTransitionLumas();
2573 void MainWindow::slotGetNewRenderStuff()
2575 //KNS::Entry::List download();
2577 KNS::Engine engine(0);
2578 if (engine.init("kdenlive_render.knsrc")) {
2579 KNS::Entry::List entries = engine.downloadDialogModal(this);
2581 if (entries.size() > 0) {
2582 foreach(KNS::Entry* entry, entries) {
2583 // care only about installed ones
2584 if (entry->status() == KNS::Entry::Installed) {
2585 foreach(const QString &file, entry->installedFiles()) {
2586 kDebug() << "// CURRENTLY INSTALLED: " << file;
2591 if (m_renderWidget) m_renderWidget->reloadProfiles();
2595 void MainWindow::slotGetNewMltProfileStuff()
2597 //KNS::Entry::List download();
2599 KNS::Engine engine(0);
2600 if (engine.init("kdenlive_mltprofiles.knsrc")) {
2601 KNS::Entry::List entries = engine.downloadDialogModal(this);
2603 if (entries.size() > 0) {
2604 foreach(KNS::Entry* entry, entries) {
2605 // care only about installed ones
2606 if (entry->status() == KNS::Entry::Installed) {
2607 foreach(const QString &file, entry->installedFiles()) {
2608 kDebug() << "// CURRENTLY INSTALLED: " << file;
2613 // update the list of profiles in settings dialog
2614 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2615 if (d) d->checkProfile();
2620 void MainWindow::slotAutoTransition()
2622 if (m_activeTimeline) m_activeTimeline->projectView()->autoTransition();
2625 void MainWindow::slotSplitAudio()
2627 if (m_activeTimeline) m_activeTimeline->projectView()->splitAudio();
2630 void MainWindow::slotUpdateClipType(QAction *action)
2632 if (m_activeTimeline) {
2633 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
2634 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
2635 else m_activeTimeline->projectView()->setAudioAndVideo();
2639 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
2641 DvdWizard *w = new DvdWizard(url, profile, this);
2645 void MainWindow::slotShowTimeline(bool show)
2647 if (show == false) {
2648 m_timelineState = saveState();
2649 centralWidget()->setHidden(true);
2651 centralWidget()->setHidden(false);
2652 restoreState(m_timelineState);
2656 void MainWindow::slotMaximizeCurrent(bool /*show*/)
2658 //TODO: is there a way to maximize current widget?
2661 m_timelineState = saveState();
2662 QWidget *par = focusWidget()->parentWidget();
2663 while (par->parentWidget() && par->parentWidget() != this) {
2664 par = par->parentWidget();
2666 kDebug() << "CURRENT WIDGET: " << par->objectName();
2669 //centralWidget()->setHidden(false);
2670 //restoreState(m_timelineState);
2674 void MainWindow::loadTranscoders()
2676 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
2679 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
2680 KConfigGroup transConfig(config, "Transcoding");
2682 QMap< QString, QString > profiles = transConfig.entryMap();
2683 QMapIterator<QString, QString> i(profiles);
2684 while (i.hasNext()) {
2686 QAction *a = transMenu->addAction(i.key());
2687 a->setData(i.value());
2688 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
2692 void MainWindow::slotTranscode(KUrl::List urls)
2695 if (urls.isEmpty()) {
2696 urls.append(m_projectList->currentClipUrl());
2697 QAction *action = qobject_cast<QAction *>(sender());
2698 params = action->data().toString();
2700 if (urls.isEmpty()) return;
2701 ClipTranscode *d = new ClipTranscode(urls, params);
2702 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
2704 //QProcess::startDetached("ffmpeg", parameters);
2707 void MainWindow::slotTranscodeClip()
2709 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
2710 if (urls.isEmpty()) return;
2711 slotTranscode(urls);
2714 void MainWindow::slotSetDocumentRenderProfile(const QString &dest, const QString &name, const QString &file)
2716 if (m_activeDocument == NULL) return;
2717 m_activeDocument->setDocumentProperty("renderdestination", dest);
2718 m_activeDocument->setDocumentProperty("renderprofile", name);
2719 m_activeDocument->setDocumentProperty("renderurl", file);
2720 m_activeDocument->setModified(true);
2724 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
2726 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
2728 QString playlistPath;
2731 QString scriptsFolder = m_activeDocument->projectFolder().path() + "/scripts/";
2732 QString path = m_renderWidget->getFreeScriptName();
2733 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
2734 if (!ok || scriptPath.isEmpty()) return;
2735 scriptPath.prepend(scriptsFolder);
2736 QFile f(scriptPath);
2738 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
2741 playlistPath = scriptPath + ".mlt";
2742 m_projectMonitor->saveSceneList(playlistPath);
2744 KTemporaryFile temp;
2745 temp.setAutoRemove(false);
2746 temp.setSuffix(".mlt");
2748 playlistPath = temp.fileName();
2749 m_projectMonitor->saveSceneList(playlistPath);
2752 if (!chapterFile.isEmpty()) {
2755 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
2757 in = m_activeTimeline->inPoint();
2758 out = m_activeTimeline->outPoint();
2761 QDomElement chapters = doc.createElement("chapters");
2762 chapters.setAttribute("fps", m_activeDocument->fps());
2763 doc.appendChild(chapters);
2765 QDomElement guidesxml = m_activeDocument->guidesXml();
2766 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
2767 for (int i = 0; i < nodes.count(); i++) {
2768 QDomElement e = nodes.item(i).toElement();
2770 QString comment = e.attribute("comment");
2771 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
2772 if (time >= in && time < out) {
2773 if (zoneOnly) time = time - in;
2774 QDomElement chapter = doc.createElement("chapter");
2775 chapters.appendChild(chapter);
2776 chapter.setAttribute("title", comment);
2777 chapter.setAttribute("time", time);
2781 if (chapters.childNodes().count() > 0) {
2782 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
2783 // Always insert a guide in pos 0
2784 QDomElement chapter = doc.createElement("chapter");
2785 chapters.insertBefore(chapter, QDomNode());
2786 chapter.setAttribute("title", i18n("Start"));
2787 chapter.setAttribute("time", "0");
2789 // save chapters file
2790 QFile file(chapterFile);
2791 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
2792 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
2794 file.write(doc.toString().toUtf8());
2795 if (file.error() != QFile::NoError) {
2796 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
2803 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath);
2806 void MainWindow::slotUpdateTimecodeFormat(int ix)
2808 KdenliveSettings::setFrametimecode(ix == 1);
2809 m_clipMonitor->updateTimecodeFormat();
2810 m_projectMonitor->updateTimecodeFormat();
2813 void MainWindow::slotRemoveFocus()
2815 statusBar()->setFocus();
2816 statusBar()->clearFocus();
2822 #include "mainwindow.moc"