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;
396 delete m_projectMonitor;
397 delete m_clipMonitor;
398 delete m_activeDocument;
399 delete m_shortcutRemoveFocus;
400 Mlt::Factory::close();
406 bool MainWindow::queryClose()
408 if (m_renderWidget) {
409 int waitingJobs = m_renderWidget->waitingJobsCount();
410 if (waitingJobs > 0) {
411 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")))) {
412 case KMessageBox::Yes :
413 // create script with waiting jobs and start it
414 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
416 case KMessageBox::No :
417 // Don't do anything, jobs will be deleted
425 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
426 if (m_activeDocument && m_activeDocument->isModified()) {
427 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
428 case KMessageBox::Yes :
429 // save document here. If saving fails, return false;
431 case KMessageBox::No :
432 // User does not want to save the changes, clear recovery files
433 m_activeDocument->m_autosave->resize(0);
443 void MainWindow::loadPlugins()
445 foreach(QObject *plugin, QPluginLoader::staticInstances())
446 populateMenus(plugin);
448 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
450 filters << "libkdenlive*";
451 foreach(const QString &folder, directories) {
452 kDebug() << "// PARSING FIOLER: " << folder;
453 QDir pluginsDir(folder);
454 foreach(const QString &fileName, pluginsDir.entryList(filters, QDir::Files)) {
455 kDebug() << "// FOUND PLUGIN: " << fileName << "= " << pluginsDir.absoluteFilePath(fileName);
456 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
457 QObject *plugin = loader.instance();
459 populateMenus(plugin);
460 m_pluginFileNames += fileName;
461 } else kDebug() << "// ERROR LOADING PLUGIN: " << fileName << ", " << loader.errorString();
467 void MainWindow::populateMenus(QObject *plugin)
469 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
470 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
472 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
476 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
477 QMenu *menu, const char *member,
478 QActionGroup *actionGroup)
480 kDebug() << "// ADD to MENU" << texts;
481 foreach(const QString &text, texts) {
482 QAction *action = new QAction(text, plugin);
483 action->setData(text);
484 connect(action, SIGNAL(triggered()), this, member);
485 menu->addAction(action);
488 action->setCheckable(true);
489 actionGroup->addAction(action);
494 void MainWindow::aboutPlugins()
496 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
501 void MainWindow::generateClip()
503 QAction *action = qobject_cast<QAction *>(sender());
504 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
506 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(), QStringList(), QStringList(), 25, 720, 576);
507 if (!clipUrl.isEmpty()) {
508 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
512 void MainWindow::saveProperties(KConfigGroup &config)
514 // save properties here,used by session management
516 KMainWindow::saveProperties(config);
520 void MainWindow::readProperties(const KConfigGroup &config)
522 // read properties here,used by session management
523 KMainWindow::readProperties(config);
524 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
525 openFile(KUrl(Lastproject));
528 void MainWindow::slotReloadEffects()
530 kDebug() << "START RELOAD; COUNR: " << m_customEffectsMenu->actions().count();
531 m_customEffectsMenu->clear();
532 kDebug() << "START RELOAD; CLR: " << m_customEffectsMenu->actions().count();
533 initEffects::parseCustomEffectsFile();
534 const QStringList effects = customEffects.effectNames();
535 kDebug() << "NEW EFFS: " << effects;
537 if (effects.isEmpty()) m_customEffectsMenu->setEnabled(false);
538 else m_customEffectsMenu->setEnabled(true);
540 foreach(const QString &name, effects) {
541 action = new QAction(name, this);
542 action->setData(name);
543 m_customEffectsMenu->addAction(action);
545 m_effectList->reloadEffectList();
548 #ifndef NO_JOGSHUTTLE
549 void MainWindow::activateShuttleDevice()
553 if (KdenliveSettings::enableshuttle() == false) return;
554 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
555 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
556 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
557 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
558 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
559 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
560 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
563 void MainWindow::slotShuttleButton(int code)
567 slotShuttleAction(KdenliveSettings::shuttle1());
570 slotShuttleAction(KdenliveSettings::shuttle2());
573 slotShuttleAction(KdenliveSettings::shuttle3());
576 slotShuttleAction(KdenliveSettings::shuttle4());
579 slotShuttleAction(KdenliveSettings::shuttle5());
584 void MainWindow::slotShuttleAction(int code)
590 m_monitorManager->slotPlay();
593 m_monitorManager->slotPlay();
597 #endif /* NO_JOGSHUTTLE */
599 void MainWindow::configureNotifications()
601 KNotifyConfigWidget::configure(this);
604 void MainWindow::slotFullScreen()
606 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
609 void MainWindow::slotAddEffect(const QDomElement effect, GenTime pos, int track)
611 if (!m_activeDocument) return;
612 if (effect.isNull()) {
613 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
616 QDomElement effectToAdd = effect.cloneNode().toElement();
617 m_activeTimeline->projectView()->slotAddEffect(effectToAdd, pos, track);
620 void MainWindow::slotRaiseMonitor(bool clipMonitor)
622 if (clipMonitor) m_clipMonitorDock->raise();
623 else m_projectMonitorDock->raise();
626 void MainWindow::slotUpdateClip(const QString &id)
628 if (!m_activeDocument) return;
629 m_activeTimeline->projectView()->slotUpdateClip(id);
632 void MainWindow::slotConnectMonitors()
635 m_projectList->setRenderer(m_projectMonitor->render);
636 connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
637 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
638 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, bool)));
639 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
640 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)));
642 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
644 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
646 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
647 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
649 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
650 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
653 void MainWindow::slotAdjustClipMonitor()
655 m_clipMonitorDock->updateGeometry();
656 m_clipMonitorDock->adjustSize();
657 m_clipMonitor->resetSize();
660 void MainWindow::slotAdjustProjectMonitor()
662 m_projectMonitorDock->updateGeometry();
663 m_projectMonitorDock->adjustSize();
664 m_projectMonitor->resetSize();
667 void MainWindow::setupActions()
670 KActionCollection* collection = actionCollection();
671 m_timecodeFormat = new KComboBox(this);
672 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
673 m_timecodeFormat->addItem(i18n("Frames"));
674 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
675 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
677 m_statusProgressBar = new QProgressBar(this);
678 m_statusProgressBar->setMinimum(0);
679 m_statusProgressBar->setMaximum(100);
680 m_statusProgressBar->setMaximumWidth(150);
681 m_statusProgressBar->setVisible(false);
683 QToolBar *toolbar = new QToolBar("statusToolBar", this);
684 toolbar->setMovable(false);
685 m_toolGroup = new QActionGroup(this);
687 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;}";
689 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
690 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
691 toolbar->addAction(m_buttonSelectTool);
692 m_buttonSelectTool->setCheckable(true);
693 m_buttonSelectTool->setChecked(true);
695 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
696 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
697 toolbar->addAction(m_buttonRazorTool);
698 m_buttonRazorTool->setCheckable(true);
699 m_buttonRazorTool->setChecked(false);
701 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
702 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
703 toolbar->addAction(m_buttonSpacerTool);
704 m_buttonSpacerTool->setCheckable(true);
705 m_buttonSpacerTool->setChecked(false);
707 m_toolGroup->addAction(m_buttonSelectTool);
708 m_toolGroup->addAction(m_buttonRazorTool);
709 m_toolGroup->addAction(m_buttonSpacerTool);
710 m_toolGroup->setExclusive(true);
711 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
713 QWidget * actionWidget;
714 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
715 actionWidget->setMaximumWidth(24);
716 actionWidget->setMinimumHeight(18);
718 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
719 actionWidget->setMaximumWidth(24);
720 actionWidget->setMinimumHeight(18);
722 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
723 actionWidget->setMaximumWidth(24);
724 actionWidget->setMinimumHeight(18);
726 toolbar->setStyleSheet(style1);
727 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
729 toolbar->addSeparator();
730 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
731 toolbar->addAction(m_buttonFitZoom);
732 m_buttonFitZoom->setCheckable(false);
733 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
735 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
736 actionWidget->setMaximumWidth(24);
737 actionWidget->setMinimumHeight(18);
739 m_zoomSlider = new QSlider(Qt::Horizontal, this);
740 m_zoomSlider->setMaximum(13);
741 m_zoomSlider->setPageStep(1);
743 m_zoomSlider->setMaximumWidth(150);
744 m_zoomSlider->setMinimumWidth(100);
745 toolbar->addWidget(m_zoomSlider);
747 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
748 toolbar->addAction(m_buttonVideoThumbs);
749 m_buttonVideoThumbs->setCheckable(true);
750 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
751 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
753 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
754 toolbar->addAction(m_buttonAudioThumbs);
755 m_buttonAudioThumbs->setCheckable(true);
756 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
757 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
759 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
760 toolbar->addAction(m_buttonShowMarkers);
761 m_buttonShowMarkers->setCheckable(true);
762 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
763 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
765 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
766 toolbar->addAction(m_buttonSnap);
767 m_buttonSnap->setCheckable(true);
768 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
769 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
771 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
772 actionWidget->setMaximumWidth(24);
773 actionWidget->setMinimumHeight(18);
775 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
776 actionWidget->setMaximumWidth(24);
777 actionWidget->setMinimumHeight(18);
779 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
780 actionWidget->setMaximumWidth(24);
781 actionWidget->setMinimumHeight(18);
783 actionWidget = toolbar->widgetForAction(m_buttonSnap);
784 actionWidget->setMaximumWidth(24);
785 actionWidget->setMinimumHeight(18);
787 m_messageLabel = new StatusBarMessageLabel(this);
788 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
790 statusBar()->addWidget(m_messageLabel, 10);
791 statusBar()->addWidget(m_statusProgressBar, 0);
792 statusBar()->addPermanentWidget(toolbar);
793 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
794 statusBar()->addPermanentWidget(m_timecodeFormat);
795 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
797 collection->addAction("select_tool", m_buttonSelectTool);
798 collection->addAction("razor_tool", m_buttonRazorTool);
799 collection->addAction("spacer_tool", m_buttonSpacerTool);
801 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
802 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
803 collection->addAction("show_markers", m_buttonShowMarkers);
804 collection->addAction("snap", m_buttonSnap);
805 collection->addAction("zoom_fit", m_buttonFitZoom);
807 KAction* zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
808 collection->addAction("zoom_in", zoomIn);
809 connect(zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
810 zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
812 KAction* zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
813 collection->addAction("zoom_out", zoomOut);
814 connect(zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
815 zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
817 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
818 collection->addAction("project_find", m_projectSearch);
819 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
820 m_projectSearch->setShortcut(Qt::Key_Slash);
822 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
823 collection->addAction("project_find_next", m_projectSearchNext);
824 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
825 m_projectSearchNext->setShortcut(Qt::Key_F3);
826 m_projectSearchNext->setEnabled(false);
828 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
829 collection->addAction("manage_profiles", profilesAction);
830 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
832 KNS::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
834 KNS::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
836 KNS::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
838 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
839 collection->addAction("run_wizard", wizAction);
840 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
842 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
843 collection->addAction("project_settings", projectAction);
844 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
846 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
847 collection->addAction("project_render", projectRender);
848 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
849 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
851 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
852 KShortcut playShortcut;
853 playShortcut.setPrimary(Qt::Key_Space);
854 playShortcut.setAlternate(Qt::Key_K);
855 monitorPlay->setShortcut(playShortcut);
856 collection->addAction("monitor_play", monitorPlay);
857 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
859 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
860 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
861 collection->addAction("monitor_play_zone", m_playZone);
862 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
864 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
865 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
866 collection->addAction("monitor_loop_zone", m_loopZone);
867 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
869 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
870 collection->addAction("dvd_wizard", dvdWizard);
871 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
873 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clip"), this);
874 collection->addAction("transcode_clip", transcodeClip);
875 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
877 KAction *markIn = collection->addAction("mark_in");
878 markIn->setText(i18n("Set In Point"));
879 markIn->setShortcut(Qt::Key_I);
880 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
882 KAction *markOut = collection->addAction("mark_out");
883 markOut->setText(i18n("Set Out Point"));
884 markOut->setShortcut(Qt::Key_O);
885 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
887 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
888 monitorSeekBackward->setShortcut(Qt::Key_J);
889 collection->addAction("monitor_seek_backward", monitorSeekBackward);
890 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
892 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
893 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
894 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
895 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
897 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
898 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
899 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
900 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
902 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
903 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
904 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
905 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
907 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
908 monitorSeekForward->setShortcut(Qt::Key_L);
909 collection->addAction("monitor_seek_forward", monitorSeekForward);
910 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
912 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
913 clipStart->setShortcut(Qt::Key_Home);
914 collection->addAction("seek_clip_start", clipStart);
915 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
917 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
918 clipEnd->setShortcut(Qt::Key_End);
919 collection->addAction("seek_clip_end", clipEnd);
920 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
922 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
923 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
924 collection->addAction("seek_start", projectStart);
925 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
927 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
928 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
929 collection->addAction("seek_end", projectEnd);
930 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
932 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
933 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
934 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
935 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
937 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
938 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
939 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
940 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
942 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
943 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
944 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
945 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
947 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
948 deleteTimelineClip->setShortcut(Qt::Key_Delete);
949 collection->addAction("delete_timeline_clip", deleteTimelineClip);
950 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
952 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
953 collection->addAction("change_clip_speed", editTimelineClipSpeed);
954 editTimelineClipSpeed->setData("change_speed");
955 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
957 KAction *stickTransition = collection->addAction("auto_transition");
958 stickTransition->setData(QString("auto"));
959 stickTransition->setCheckable(true);
960 stickTransition->setEnabled(false);
961 stickTransition->setText(i18n("Automatic Transition"));
962 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
964 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
965 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
966 collection->addAction("group_clip", groupClip);
967 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
969 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
970 collection->addAction("ungroup_clip", ungroupClip);
971 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
972 ungroupClip->setData("ungroup_clip");
973 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
975 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
976 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
977 collection->addAction("cut_timeline_clip", cutTimelineClip);
978 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
980 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
981 collection->addAction("add_clip_marker", addClipMarker);
982 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
984 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
985 collection->addAction("delete_clip_marker", deleteClipMarker);
986 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
988 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
989 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
990 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
992 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
993 collection->addAction("edit_clip_marker", editClipMarker);
994 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
996 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
997 collection->addAction("split_audio", splitAudio);
998 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1000 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1001 collection->addAction("clip_audio_only", audioOnly);
1002 audioOnly->setData("clip_audio_only");
1003 audioOnly->setCheckable(true);
1005 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1006 collection->addAction("clip_video_only", videoOnly);
1007 videoOnly->setData("clip_video_only");
1008 videoOnly->setCheckable(true);
1010 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1011 collection->addAction("clip_audio_and_video", audioAndVideo);
1012 audioAndVideo->setData("clip_audio_and_video");
1013 audioAndVideo->setCheckable(true);
1015 m_clipTypeGroup = new QActionGroup(this);
1016 m_clipTypeGroup->addAction(audioOnly);
1017 m_clipTypeGroup->addAction(videoOnly);
1018 m_clipTypeGroup->addAction(audioAndVideo);
1019 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1020 m_clipTypeGroup->setEnabled(false);
1022 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1023 collection->addAction("insert_space", insertSpace);
1024 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1026 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1027 collection->addAction("delete_space", removeSpace);
1028 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1030 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1031 collection->addAction("insert_track", insertTrack);
1032 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1034 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1035 collection->addAction("delete_track", deleteTrack);
1036 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1038 KAction *changeTrack = new KAction(KIcon(), i18n("Change Track"), this);
1039 collection->addAction("change_track", changeTrack);
1040 connect(changeTrack, SIGNAL(triggered()), this, SLOT(slotChangeTrack()));
1042 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1043 collection->addAction("add_guide", addGuide);
1044 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1046 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1047 collection->addAction("delete_guide", delGuide);
1048 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1050 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1051 collection->addAction("edit_guide", editGuide);
1052 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1054 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1055 collection->addAction("delete_all_guides", delAllGuides);
1056 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1058 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1059 collection->addAction("paste_effects", pasteEffects);
1060 pasteEffects->setData("paste_effects");
1061 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1063 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1064 collection->addAction("show_timeline", showTimeline);
1065 showTimeline->setCheckable(true);
1066 showTimeline->setChecked(true);
1067 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1069 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1070 collection->addAction("maximize_current", maxCurrent);
1071 maxCurrent->setCheckable(true);
1072 maxCurrent->setChecked(false);
1073 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1076 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1078 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1080 KStandardAction::open(this, SLOT(openFile()), collection);
1082 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1084 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1086 KStandardAction::openNew(this, SLOT(newFile()), collection);
1088 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1090 KStandardAction::configureNotifications(this , SLOT(configureNotifications()), collection);
1092 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1094 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1096 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1097 undo->setEnabled(false);
1098 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1100 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1101 redo->setEnabled(false);
1102 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1104 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1107 //TODO: Add status tooltip to actions ?
1108 connect(collection, SIGNAL(actionHovered(QAction*)),
1109 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1112 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1113 collection->addAction("add_clip", addClip);
1114 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1116 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1117 collection->addAction("add_color_clip", addColorClip);
1118 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1120 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1121 collection->addAction("add_slide_clip", addSlideClip);
1122 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1124 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1125 collection->addAction("add_text_clip", addTitleClip);
1126 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1128 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1129 collection->addAction("add_text_template_clip", addTitleTemplateClip);
1130 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1132 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1133 collection->addAction("add_folder", addFolderButton);
1134 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1136 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1137 collection->addAction("clip_properties", clipProperties);
1138 clipProperties->setData("clip_properties");
1139 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1140 clipProperties->setEnabled(false);
1142 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1143 collection->addAction("edit_clip", openClip);
1144 openClip->setData("edit_clip");
1145 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1146 openClip->setEnabled(false);
1148 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1149 collection->addAction("delete_clip", deleteClip);
1150 deleteClip->setData("delete_clip");
1151 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1152 deleteClip->setEnabled(false);
1154 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1155 collection->addAction("reload_clip", reloadClip);
1156 reloadClip->setData("reload_clip");
1157 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1158 reloadClip->setEnabled(false);
1160 QMenu *addClips = new QMenu();
1161 addClips->addAction(addClip);
1162 addClips->addAction(addColorClip);
1163 addClips->addAction(addSlideClip);
1164 addClips->addAction(addTitleClip);
1165 addClips->addAction(addTitleTemplateClip);
1166 addClips->addAction(addFolderButton);
1168 addClips->addAction(reloadClip);
1169 addClips->addAction(clipProperties);
1170 addClips->addAction(openClip);
1171 addClips->addAction(deleteClip);
1172 m_projectList->setupMenu(addClips, addClip);
1174 //connect(collection, SIGNAL( clearStatusText() ),
1175 //statusBar(), SLOT( clear() ) );
1178 void MainWindow::slotDisplayActionMessage(QAction *a)
1180 statusBar()->showMessage(a->data().toString(), 3000);
1183 void MainWindow::saveOptions()
1185 KdenliveSettings::self()->writeConfig();
1186 KSharedConfigPtr config = KGlobal::config();
1187 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1188 KConfigGroup treecolumns(config, "Project Tree");
1189 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1193 void MainWindow::readOptions()
1195 KSharedConfigPtr config = KGlobal::config();
1196 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1197 KConfigGroup initialGroup(config, "version");
1198 bool upgrade = false;
1199 if (initialGroup.exists()) {
1200 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1204 if (initialGroup.readEntry("version") == "0.7") {
1205 //Add new settings from 0.7.1
1206 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1207 QString path = QDir::homePath() + "/kdenlive";
1208 if (KStandardDirs::makeDir(path) == false) {
1209 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1210 } else KdenliveSettings::setDefaultprojectfolder(path);
1216 if (!initialGroup.exists() || upgrade) {
1217 // this is our first run, show Wizard
1218 Wizard *w = new Wizard(upgrade, this);
1219 if (w->exec() == QDialog::Accepted && w->isOk()) {
1220 w->adjustSettings();
1221 initialGroup.writeEntry("version", version);
1227 KConfigGroup treecolumns(config, "Project Tree");
1228 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1229 if (!state.isEmpty())
1230 m_projectList->setHeaderInfo(state);
1233 void MainWindow::slotRunWizard()
1235 Wizard *w = new Wizard(false, this);
1236 if (w->exec() == QDialog::Accepted && w->isOk()) {
1237 w->adjustSettings();
1242 void MainWindow::newFile(bool showProjectSettings)
1244 if (!m_timelineArea->isEnabled()) return;
1245 QString profileName;
1247 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1248 if (!showProjectSettings && m_timelineArea->count() == 0) {
1249 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1250 profileName = KdenliveSettings::default_profile();
1251 projectFolder = KdenliveSettings::defaultprojectfolder();
1253 ProjectSettings *w = new ProjectSettings(projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, this);
1254 if (w->exec() != QDialog::Accepted) return;
1255 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1256 KdenliveSettings::setVideothumbnails(w->enableVideoThumbs());
1257 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1258 KdenliveSettings::setAudiothumbnails(w->enableAudioThumbs());
1259 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1260 profileName = w->selectedProfile();
1261 projectFolder = w->selectedFolder();
1262 projectTracks = w->tracks();
1265 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1266 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1268 TrackView *trackView = new TrackView(doc, &ok, this);
1269 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1272 m_timelineArea->setEnabled(false);
1273 m_projectList->setEnabled(false);
1274 m_monitorManager->slotBlockMonitors();
1278 if (m_timelineArea->count() == 1) {
1279 connectDocumentInfo(doc);
1280 connectDocument(trackView, doc);
1281 } else m_timelineArea->setTabBarHidden(false);
1282 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1285 void MainWindow::activateDocument()
1287 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1288 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1289 KdenliveDoc *currentDoc = currentTab->document();
1290 connectDocumentInfo(currentDoc);
1291 connectDocument(currentTab, currentDoc);
1294 void MainWindow::closeCurrentDocument()
1296 QWidget *w = m_timelineArea->currentWidget();
1298 // closing current document
1299 int ix = m_timelineArea->currentIndex() + 1;
1300 if (ix == m_timelineArea->count()) ix = 0;
1301 m_timelineArea->setCurrentIndex(ix);
1302 TrackView *tabToClose = (TrackView *) w;
1303 KdenliveDoc *docToClose = tabToClose->document();
1304 if (docToClose && docToClose->isModified()) {
1305 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
1306 case KMessageBox::Yes :
1307 // save document here. If saving fails, return false;
1308 if (saveFile() == false) return;
1310 case KMessageBox::Cancel :
1317 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1318 if (m_timelineArea->count() == 1) {
1319 m_timelineArea->setTabBarHidden(true);
1320 m_closeAction->setEnabled(false);
1322 if (docToClose == m_activeDocument) {
1323 delete m_activeDocument;
1324 m_activeDocument = NULL;
1325 m_effectStack->clear();
1326 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1327 } else delete docToClose;
1328 if (w == m_activeTimeline) {
1329 delete m_activeTimeline;
1330 m_activeTimeline = NULL;
1334 bool MainWindow::saveFileAs(const QString &outputFileName)
1336 QString currentSceneList;
1337 if (KdenliveSettings::dropbframes()) {
1338 KdenliveSettings::setDropbframes(false);
1339 m_activeDocument->clipManager()->updatePreviewSettings();
1340 currentSceneList = m_projectMonitor->sceneList();
1341 KdenliveSettings::setDropbframes(true);
1342 m_activeDocument->clipManager()->updatePreviewSettings();
1343 } else currentSceneList = m_projectMonitor->sceneList();
1345 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1348 // Save timeline thumbnails
1349 m_activeTimeline->projectView()->saveThumbnails();
1350 m_activeDocument->setUrl(KUrl(outputFileName));
1351 if (m_activeDocument->m_autosave == NULL) {
1352 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1353 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1354 setCaption(m_activeDocument->description());
1355 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1356 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1357 m_activeDocument->setModified(false);
1358 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1362 bool MainWindow::saveFileAs()
1364 // Check that the Kdenlive mime type is correctly installed
1365 QString mimetype = "application/x-kdenlive";
1366 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1367 if (!mime) mimetype = "*.kdenlive";
1369 QString outputFile = KFileDialog::getSaveFileName(KUrl(), mimetype);
1370 if (outputFile.isEmpty()) return false;
1371 if (QFile::exists(outputFile)) {
1372 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it?")) == KMessageBox::No) return false;
1374 return saveFileAs(outputFile);
1377 bool MainWindow::saveFile()
1379 if (!m_activeDocument) return true;
1380 if (m_activeDocument->url().isEmpty()) {
1381 return saveFileAs();
1383 bool result = saveFileAs(m_activeDocument->url().path());
1384 m_activeDocument->m_autosave->resize(0);
1389 void MainWindow::openFile()
1391 // Check that the Kdenlive mime type is correctly installed
1392 QString mimetype = "application/x-kdenlive";
1393 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1394 if (!mime) mimetype = "*.kdenlive";
1396 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), mimetype);
1397 if (url.isEmpty()) return;
1398 m_fileOpenRecent->addUrl(url);
1402 void MainWindow::openLastFile()
1404 KSharedConfigPtr config = KGlobal::config();
1405 KUrl::List urls = m_fileOpenRecent->urls();
1406 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1407 if (urls.isEmpty()) newFile(false);
1408 else openFile(urls.last());
1411 void MainWindow::openFile(const KUrl &url)
1413 // Check if the document is already opened
1414 const int ct = m_timelineArea->count();
1415 bool isOpened = false;
1417 for (i = 0; i < ct; i++) {
1418 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1419 KdenliveDoc *doc = tab->document();
1420 if (doc->url() == url) {
1426 m_timelineArea->setCurrentIndex(i);
1430 // Check for backup file
1431 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1432 if (!staleFiles.isEmpty()) {
1433 if (KMessageBox::questionYesNo(this,
1434 i18n("Auto-saved files exist. Do you want to recover them now?"),
1435 i18n("File Recovery"),
1436 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1437 recoverFiles(staleFiles);
1440 // remove the stale files
1441 foreach(KAutoSaveFile *stale, staleFiles) {
1442 stale->open(QIODevice::ReadWrite);
1447 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1448 doOpenFile(url, NULL);
1451 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1453 if (!m_timelineArea->isEnabled()) return;
1454 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, this);
1455 if (stale == NULL) {
1456 stale = new KAutoSaveFile(url, doc);
1457 doc->m_autosave = stale;
1459 doc->m_autosave = stale;
1460 doc->setUrl(stale->managedFile());
1461 doc->setModified(true);
1462 stale->setParent(doc);
1464 connectDocumentInfo(doc);
1466 TrackView *trackView = new TrackView(doc, &ok, this);
1467 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1469 m_timelineArea->setEnabled(false);
1470 m_projectList->setEnabled(false);
1471 m_monitorManager->slotBlockMonitors();
1475 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1476 trackView->setDuration(trackView->duration());
1477 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1479 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1480 slotGotProgressInfo(QString(), -1);
1481 m_clipMonitor->refreshMonitor(true);
1482 m_projectMonitor->adjustRulerSize(trackView->duration());
1483 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1486 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1488 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1489 foreach(KAutoSaveFile *stale, staleFiles) {
1490 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1491 // show an error message; we could not steal the lockfile
1492 // maybe another application got to the file before us?
1496 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1497 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
1498 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1499 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1504 void MainWindow::parseProfiles(const QString &mltPath)
1506 // kDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
1508 //KdenliveSettings::setDefaulttmpfolder();
1509 if (!mltPath.isEmpty()) {
1510 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1511 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
1514 if (KdenliveSettings::mltpath().isEmpty()) {
1515 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1517 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
1518 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
1519 if (!QFile::exists(meltPath))
1520 meltPath = KStandardDirs::findExe("melt");
1521 KdenliveSettings::setRendererpath(meltPath);
1523 QStringList profilesFilter;
1524 profilesFilter << "*";
1525 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1527 if (profilesList.isEmpty()) {
1528 // Cannot find MLT path, try finding melt
1529 QString profilePath = KdenliveSettings::rendererpath();
1530 if (!profilePath.isEmpty()) {
1531 profilePath = profilePath.section('/', 0, -3);
1532 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1533 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1536 if (profilesList.isEmpty()) {
1537 // Cannot find the MLT profiles, ask for location
1538 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1539 getUrl->fileDialog()->setMode(KFile::Directory);
1540 if (getUrl->exec() == QDialog::Rejected) {
1543 KUrl mltPath = getUrl->selectedUrl();
1545 if (mltPath.isEmpty()) ::exit(0);
1546 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
1547 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1551 if (KdenliveSettings::rendererpath().isEmpty()) {
1552 // Cannot find the MLT melt renderer, ask for location
1553 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of Mlt)"), this);
1554 if (getUrl->exec() == QDialog::Rejected) {
1557 KUrl rendererPath = getUrl->selectedUrl();
1559 if (rendererPath.isEmpty()) ::exit(0);
1560 KdenliveSettings::setRendererpath(rendererPath.path());
1563 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1565 // Parse MLT profiles to build a list of available video formats
1566 if (profilesList.isEmpty()) parseProfiles();
1570 void MainWindow::slotEditProfiles()
1572 ProfilesDialog *w = new ProfilesDialog;
1573 if (w->exec() == QDialog::Accepted) {
1574 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1575 if (d) d->checkProfile();
1580 void MainWindow::slotDetectAudioDriver()
1582 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
1583 leading to no audio output, see bug #934 */
1585 //decide which audio driver is really best, in some cases SDL is wrong
1586 if (KdenliveSettings::audiodrivername().isEmpty()) {
1588 KProcess readProcess;
1589 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
1590 if (!KStandardDirs::findExe("pactl").isEmpty()) {
1591 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
1592 readProcess.setProgram("pactl", QStringList() << "stat");
1593 readProcess.execute(2000); // Kill it after 2 seconds
1595 QString result = QString(readProcess.readAllStandardOutput());
1596 kDebug() << "// / / / / / READING PACTL: ";
1598 if (!result.isEmpty()) {
1600 kDebug() << "// / / / / PULSEAUDIO DETECTED";
1604 KdenliveSettings::setAutoaudiodrivername(driver);
1608 void MainWindow::slotEditProjectSettings()
1610 QPoint p = m_activeDocument->getTracksCount();
1611 ProjectSettings *w = new ProjectSettings(p.x(), p.y(), m_activeDocument->projectFolder().path(), true, this);
1613 if (w->exec() == QDialog::Accepted) {
1614 QString profile = w->selectedProfile();
1615 m_activeDocument->setProjectFolder(w->selectedFolder());
1616 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path(KUrl::AddTrailingSlash));
1617 if (m_activeDocument->profilePath() != profile) {
1618 // Profile was changed
1619 double dar = m_activeDocument->dar();
1621 // Deselect current effect / transition
1622 m_effectStack->slotClipItemSelected(NULL, 0);
1623 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1624 m_clipMonitor->slotSetXml(NULL, 0);
1625 m_activeDocument->setProfilePath(profile);
1626 KdenliveSettings::setCurrent_profile(profile);
1627 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1628 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1630 m_activeDocument->clipManager()->clearUnusedProducers();
1631 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1633 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeTimeline->tracksNumber());
1634 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
1635 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1636 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1637 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1638 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
1639 m_activeTimeline->updateProjectFps();
1641 // We need to desactivate & reactivate monitors to get a refresh
1642 //m_monitorManager->switchMonitors();
1648 void MainWindow::slotRenderProject()
1650 if (!m_renderWidget) {
1651 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
1652 m_renderWidget = new RenderWidget(projectfolder, this);
1653 connect(m_renderWidget, SIGNAL(selectedRenderProfile(const QString &, const QString &, const QString&)), this, SLOT(slotSetDocumentRenderProfile(const QString &, const QString &, const QString&)));
1654 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
1655 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1656 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1657 if (m_activeDocument) {
1658 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1659 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1660 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
1661 m_renderWidget->setRenderProfile(m_activeDocument->getDocumentProperty("renderdestination"), m_activeDocument->getDocumentProperty("renderprofile"), m_activeDocument->getDocumentProperty("renderurl"));
1664 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1665 if (currentTab) m_renderWidget->setTimeline(currentTab);
1666 m_renderWidget->setDocument(m_activeDocument);*/
1667 m_renderWidget->show();
1668 m_renderWidget->showNormal();
1671 void MainWindow::setRenderingProgress(const QString &url, int progress)
1673 if (m_renderWidget) m_renderWidget->setRenderJob(url, progress);
1676 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
1678 if (m_renderWidget) m_renderWidget->setRenderStatus(url, status, error);
1681 void MainWindow::slotUpdateMousePosition(int pos)
1683 if (m_activeDocument)
1684 switch (m_timecodeFormat->currentIndex()) {
1686 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1689 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1693 void MainWindow::slotUpdateDocumentState(bool modified)
1695 if (!m_activeDocument) return;
1696 setCaption(m_activeDocument->description(), modified);
1697 m_saveAction->setEnabled(modified);
1699 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1700 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1702 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1703 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1707 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
1709 if (m_activeDocument) {
1710 if (m_activeDocument == doc) return;
1711 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1713 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1716 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
1718 //m_projectMonitor->stop();
1719 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1720 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1721 if (m_activeDocument) {
1722 if (m_activeDocument == doc) return;
1723 if (m_activeTimeline) {
1724 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1725 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1726 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1727 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1728 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
1730 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1731 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1732 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1733 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1734 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1735 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1736 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1737 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1738 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1739 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
1740 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1741 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1742 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1743 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1744 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1745 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1746 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1747 disconnect(m_activeTimeline, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1748 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1749 disconnect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1750 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1751 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1752 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1753 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1754 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1755 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1756 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
1757 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1758 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1759 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
1760 m_effectStack->clear();
1762 //m_activeDocument->setRenderer(NULL);
1763 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1764 disconnect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
1765 m_clipMonitor->stop();
1767 KdenliveSettings::setCurrent_profile(doc->profilePath());
1768 KdenliveSettings::setProject_fps(doc->fps());
1769 m_monitorManager->resetProfiles(doc->timecode());
1770 m_projectList->setDocument(doc);
1771 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), trackView->tracksNumber());
1772 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
1773 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1774 connect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
1775 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1776 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
1779 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1780 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1781 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1782 connect(trackView, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1783 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1784 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1785 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1786 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1787 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
1789 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1790 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1791 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1792 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1793 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1795 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1796 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1797 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1800 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1801 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1802 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
1803 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1804 m_zoomSlider->setValue(doc->zoom().x());
1805 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1806 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1807 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1808 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1810 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1813 connect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1814 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1815 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1816 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1817 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1818 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1819 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1820 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1822 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1823 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1824 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
1826 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup);
1827 m_activeTimeline = trackView;
1828 if (m_renderWidget) {
1829 m_renderWidget->setProfile(doc->mltProfile());
1830 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
1831 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
1832 m_renderWidget->setRenderProfile(doc->getDocumentProperty("renderdestination"), doc->getDocumentProperty("renderprofile"), doc->getDocumentProperty("renderurl"));
1834 //doc->setRenderer(m_projectMonitor->render);
1835 m_commandStack->setActiveStack(doc->commandStack());
1836 KdenliveSettings::setProject_display_ratio(doc->dar());
1837 //doc->clipManager()->checkAudioThumbs();
1839 //m_overView->setScene(trackView->projectScene());
1840 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1841 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1843 setCaption(doc->description(), doc->isModified());
1844 m_saveAction->setEnabled(doc->isModified());
1845 m_activeDocument = doc;
1846 m_activeTimeline->updateProjectFps();
1847 m_projectList->updateAllClips();
1848 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
1850 // set tool to select tool
1851 m_buttonSelectTool->setChecked(true);
1854 void MainWindow::slotZoneMoved(int start, int end)
1856 m_activeDocument->setZone(start, end);
1857 m_projectMonitor->slotZoneMoved(start, end);
1860 void MainWindow::slotGuidesUpdated()
1862 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1865 void MainWindow::slotPreferences(int page, int option)
1867 //An instance of your dialog could be already created and could be
1868 // cached, in which case you want to display the cached dialog
1869 // instead of creating another one
1870 if (KConfigDialog::showDialog("settings")) {
1871 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1872 if (page != -1) d->showPage(page, option);
1876 // KConfigDialog didn't find an instance of this dialog, so lets
1878 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1879 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1880 //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
1881 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1882 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1884 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
1886 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1888 if (page != -1) dialog->showPage(page, option);
1891 void MainWindow::slotUpdatePreviewSettings()
1893 if (m_activeDocument) {
1894 m_clipMonitor->slotSetXml(NULL, 0);
1895 m_activeDocument->updatePreviewSettings();
1899 void MainWindow::updateConfiguration()
1901 //TODO: we should apply settings to all projects, not only the current one
1902 if (m_activeTimeline) {
1903 m_activeTimeline->refresh();
1904 m_activeTimeline->projectView()->checkAutoScroll();
1905 m_activeTimeline->projectView()->checkTrackHeight();
1906 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1908 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1909 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1911 // Update list of transcoding profiles
1913 #ifndef NO_JOGSHUTTLE
1914 activateShuttleDevice();
1915 #endif /* NO_JOGSHUTTLE */
1920 void MainWindow::slotSwitchVideoThumbs()
1922 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1923 if (m_activeTimeline) {
1924 m_activeTimeline->projectView()->slotUpdateAllThumbs();
1926 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1929 void MainWindow::slotSwitchAudioThumbs()
1931 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
1932 if (m_activeTimeline) {
1933 m_activeTimeline->refresh();
1934 m_activeTimeline->projectView()->checkAutoScroll();
1935 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1937 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1940 void MainWindow::slotSwitchMarkersComments()
1942 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1943 if (m_activeTimeline) {
1944 m_activeTimeline->refresh();
1946 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1949 void MainWindow::slotSwitchSnap()
1951 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
1952 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1956 void MainWindow::slotDeleteTimelineClip()
1958 if (QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) m_projectList->slotRemoveClip();
1959 else if (m_activeTimeline) {
1960 m_activeTimeline->projectView()->deleteSelectedClips();
1964 void MainWindow::slotAddClipMarker()
1966 DocClipBase *clip = NULL;
1968 if (m_projectMonitor->isActive()) {
1969 if (m_activeTimeline) {
1970 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1972 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
1973 clip = item->baseClip();
1977 clip = m_clipMonitor->activeClip();
1978 pos = m_clipMonitor->position();
1981 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
1984 QString id = clip->getId();
1985 CommentedTime marker(pos, i18n("Marker"));
1986 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
1987 if (d.exec() == QDialog::Accepted) {
1988 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
1990 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
1993 void MainWindow::slotDeleteClipMarker()
1995 DocClipBase *clip = NULL;
1997 if (m_projectMonitor->isActive()) {
1998 if (m_activeTimeline) {
1999 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2001 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2002 clip = item->baseClip();
2006 clip = m_clipMonitor->activeClip();
2007 pos = m_clipMonitor->position();
2010 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2014 QString id = clip->getId();
2015 QString comment = clip->markerComment(pos);
2016 if (comment.isEmpty()) {
2017 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2020 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2021 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2025 void MainWindow::slotDeleteAllClipMarkers()
2027 DocClipBase *clip = NULL;
2028 if (m_projectMonitor->isActive()) {
2029 if (m_activeTimeline) {
2030 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2032 clip = item->baseClip();
2036 clip = m_clipMonitor->activeClip();
2039 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2042 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2043 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2046 void MainWindow::slotEditClipMarker()
2048 DocClipBase *clip = NULL;
2050 if (m_projectMonitor->isActive()) {
2051 if (m_activeTimeline) {
2052 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2054 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2055 clip = item->baseClip();
2059 clip = m_clipMonitor->activeClip();
2060 pos = m_clipMonitor->position();
2063 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2067 QString id = clip->getId();
2068 QString oldcomment = clip->markerComment(pos);
2069 if (oldcomment.isEmpty()) {
2070 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2074 CommentedTime marker(pos, oldcomment);
2075 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2076 if (d.exec() == QDialog::Accepted) {
2077 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2078 if (d.newMarker().time() != pos) {
2079 // remove old marker
2080 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2082 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2086 void MainWindow::slotAddGuide()
2088 if (m_activeTimeline)
2089 m_activeTimeline->projectView()->slotAddGuide();
2092 void MainWindow::slotInsertSpace()
2094 if (m_activeTimeline)
2095 m_activeTimeline->projectView()->slotInsertSpace();
2098 void MainWindow::slotRemoveSpace()
2100 if (m_activeTimeline)
2101 m_activeTimeline->projectView()->slotRemoveSpace();
2104 void MainWindow::slotInsertTrack(int ix)
2106 m_projectMonitor->activateMonitor();
2107 if (m_activeTimeline)
2108 m_activeTimeline->projectView()->slotInsertTrack(ix);
2111 void MainWindow::slotDeleteTrack(int ix)
2113 m_projectMonitor->activateMonitor();
2114 if (m_activeTimeline)
2115 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2118 void MainWindow::slotChangeTrack(int ix)
2120 m_projectMonitor->activateMonitor();
2121 if (m_activeTimeline)
2122 m_activeTimeline->projectView()->slotChangeTrack(ix);
2125 void MainWindow::slotEditGuide()
2127 if (m_activeTimeline)
2128 m_activeTimeline->projectView()->slotEditGuide();
2131 void MainWindow::slotDeleteGuide()
2133 if (m_activeTimeline)
2134 m_activeTimeline->projectView()->slotDeleteGuide();
2137 void MainWindow::slotDeleteAllGuides()
2139 if (m_activeTimeline)
2140 m_activeTimeline->projectView()->slotDeleteAllGuides();
2143 void MainWindow::slotCutTimelineClip()
2145 if (m_activeTimeline) {
2146 m_activeTimeline->projectView()->cutSelectedClips();
2150 void MainWindow::slotGroupClips()
2152 if (m_activeTimeline) {
2153 m_activeTimeline->projectView()->groupClips();
2157 void MainWindow::slotUnGroupClips()
2159 if (m_activeTimeline) {
2160 m_activeTimeline->projectView()->groupClips(false);
2164 void MainWindow::slotAddProjectClip(KUrl url)
2166 if (m_activeDocument)
2167 m_activeDocument->slotAddClipFile(url, QString());
2170 void MainWindow::slotAddTransition(QAction *result)
2172 if (!result) return;
2173 QStringList info = result->data().toStringList();
2174 if (info.isEmpty()) return;
2175 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2176 if (m_activeTimeline && !transition.isNull()) {
2177 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2181 void MainWindow::slotAddVideoEffect(QAction *result)
2183 if (!result) return;
2184 QStringList info = result->data().toStringList();
2185 if (info.isEmpty()) return;
2186 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2187 slotAddEffect(effect);
2190 void MainWindow::slotAddAudioEffect(QAction *result)
2192 if (!result) return;
2193 QStringList info = result->data().toStringList();
2194 if (info.isEmpty()) return;
2195 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2196 slotAddEffect(effect);
2199 void MainWindow::slotAddCustomEffect(QAction *result)
2201 if (!result) return;
2202 QStringList info = result->data().toStringList();
2203 if (info.isEmpty()) return;
2204 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2205 slotAddEffect(effect);
2208 void MainWindow::slotZoomIn()
2210 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2213 void MainWindow::slotZoomOut()
2215 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2218 void MainWindow::slotFitZoom()
2220 if (m_activeTimeline) {
2221 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2225 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2227 m_statusProgressBar->setValue(progress);
2228 if (progress >= 0) {
2229 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2230 m_statusProgressBar->setVisible(true);
2232 m_messageLabel->setMessage(QString(), DefaultMessage);
2233 m_statusProgressBar->setVisible(false);
2237 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2239 if (clip->clipType() == TEXT) {
2240 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
2241 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
2242 // template text clip
2244 // Get the list of existing templates
2246 filter << "*.kdenlivetitle";
2247 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
2249 QDialog *dia = new QDialog(this);
2250 Ui::TemplateClip_UI dia_ui;
2251 dia_ui.setupUi(dia);
2253 const QString templatePath = clip->getProperty("resource");
2254 for (int i = 0; i < templateFiles.size(); ++i) {
2255 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
2256 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
2258 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
2259 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
2260 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
2261 //warning: setting base directory doesn't work??
2262 KUrl startDir(titlepath);
2263 dia_ui.template_list->fileDialog()->setUrl(startDir);
2264 dia_ui.description->setText(clip->getProperty("description"));
2265 if (dia->exec() == QDialog::Accepted) {
2266 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
2267 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
2269 QMap <QString, QString> newprops;
2271 if (KUrl(textTemplate).path() != templatePath) {
2272 // The template was changed
2273 newprops.insert("resource", textTemplate);
2276 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
2277 newprops.insert("description", dia_ui.description->toPlainText());
2280 QString newtemplate = newprops.value("xmltemplate");
2281 if (newtemplate.isEmpty()) newtemplate = templatePath;
2283 // template modified we need to update xmldata
2284 QString description = newprops.value("description");
2285 if (description.isEmpty()) description = clip->getProperty("description");
2286 else newprops.insert("templatetext", description);
2287 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
2289 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2290 m_activeDocument->commandStack()->push(command);
2294 QString path = clip->getProperty("resource");
2295 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
2297 doc.setContent(clip->getProperty("xmldata"));
2298 dia_ui->setXml(doc);
2299 if (dia_ui->exec() == QDialog::Accepted) {
2300 QMap <QString, QString> newprops;
2301 newprops.insert("xmldata", dia_ui->xml().toString());
2302 newprops.insert("out", QString::number(dia_ui->duration()));
2303 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2304 m_activeDocument->commandStack()->push(command);
2305 m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
2306 m_activeDocument->setModified(true);
2310 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2313 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2314 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2315 if (dia.exec() == QDialog::Accepted) {
2316 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true);
2317 m_activeDocument->commandStack()->push(command);
2319 //m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
2320 if (dia.needsTimelineRefresh()) {
2321 // update clip occurences in timeline
2322 m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
2327 void MainWindow::customEvent(QEvent* e)
2329 if (e->type() == QEvent::User) {
2330 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
2333 void MainWindow::slotActivateEffectStackView()
2335 m_effectStack->raiseWindow(m_effectStackDock);
2338 void MainWindow::slotActivateTransitionView(Transition *t)
2340 if (t) m_transitionConfig->raiseWindow(m_transitionConfigDock);
2343 void MainWindow::slotSnapRewind()
2345 if (m_projectMonitor->isActive()) {
2346 if (m_activeTimeline)
2347 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2348 } else m_clipMonitor->slotSeekToPreviousSnap();
2351 void MainWindow::slotSnapForward()
2353 if (m_projectMonitor->isActive()) {
2354 if (m_activeTimeline)
2355 m_activeTimeline->projectView()->slotSeekToNextSnap();
2356 } else m_clipMonitor->slotSeekToNextSnap();
2359 void MainWindow::slotClipStart()
2361 if (m_projectMonitor->isActive()) {
2362 if (m_activeTimeline)
2363 m_activeTimeline->projectView()->clipStart();
2367 void MainWindow::slotClipEnd()
2369 if (m_projectMonitor->isActive()) {
2370 if (m_activeTimeline)
2371 m_activeTimeline->projectView()->clipEnd();
2375 void MainWindow::slotChangeTool(QAction * action)
2377 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
2378 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
2379 else if (action == m_buttonSpacerTool) slotSetTool(SPACERTOOL);
2382 void MainWindow::slotSetTool(PROJECTTOOL tool)
2384 if (m_activeDocument && m_activeTimeline) {
2385 //m_activeDocument->setTool(tool);
2386 m_activeTimeline->projectView()->setTool(tool);
2390 void MainWindow::slotCopy()
2392 if (!m_activeDocument || !m_activeTimeline) return;
2393 m_activeTimeline->projectView()->copyClip();
2396 void MainWindow::slotPaste()
2398 if (!m_activeDocument || !m_activeTimeline) return;
2399 m_activeTimeline->projectView()->pasteClip();
2402 void MainWindow::slotPasteEffects()
2404 if (!m_activeDocument || !m_activeTimeline) return;
2405 m_activeTimeline->projectView()->pasteClipEffects();
2408 void MainWindow::slotFind()
2410 if (!m_activeDocument || !m_activeTimeline) return;
2411 m_projectSearch->setEnabled(false);
2412 m_findActivated = true;
2413 m_findString.clear();
2414 m_activeTimeline->projectView()->initSearchStrings();
2415 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2416 m_findTimer.start(5000);
2417 qApp->installEventFilter(this);
2420 void MainWindow::slotFindNext()
2422 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
2423 statusBar()->showMessage(i18n("Found: %1", m_findString));
2425 statusBar()->showMessage(i18n("Reached end of project"));
2427 m_findTimer.start(4000);
2430 void MainWindow::findAhead()
2432 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
2433 m_projectSearchNext->setEnabled(true);
2434 statusBar()->showMessage(i18n("Found: %1", m_findString));
2436 m_projectSearchNext->setEnabled(false);
2437 statusBar()->showMessage(i18n("Not found: %1", m_findString));
2441 void MainWindow::findTimeout()
2443 m_projectSearchNext->setEnabled(false);
2444 m_findActivated = false;
2445 m_findString.clear();
2446 statusBar()->showMessage(i18n("Find stopped"), 3000);
2447 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
2448 m_projectSearch->setEnabled(true);
2449 removeEventFilter(this);
2452 void MainWindow::keyPressEvent(QKeyEvent *ke)
2454 if (m_findActivated) {
2455 if (ke->key() == Qt::Key_Backspace) {
2456 m_findString = m_findString.left(m_findString.length() - 1);
2458 if (!m_findString.isEmpty()) {
2464 m_findTimer.start(4000);
2467 } else if (ke->key() == Qt::Key_Escape) {
2471 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
2472 m_findString += ke->text();
2476 m_findTimer.start(4000);
2480 } else KXmlGuiWindow::keyPressEvent(ke);
2484 /** Gets called when the window gets hidden */
2485 void MainWindow::hideEvent(QHideEvent */*event*/)
2487 // kDebug() << "I was hidden";
2488 // issue http://www.kdenlive.org/mantis/view.php?id=231
2489 if (isMinimized()) {
2490 // kDebug() << "I am minimized";
2491 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
2495 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
2497 if (m_findActivated) {
2498 if (event->type() == QEvent::ShortcutOverride) {
2499 QKeyEvent* ke = (QKeyEvent*) event;
2500 if (ke->text().trimmed().isEmpty()) return false;
2503 } else return false;
2505 // pass the event on to the parent class
2506 return QMainWindow::eventFilter(obj, event);
2511 void MainWindow::slotSaveZone(Render *render, QPoint zone)
2513 KDialog *dialog = new KDialog(this);
2514 dialog->setCaption("Save clip zone");
2515 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
2517 QWidget *widget = new QWidget(dialog);
2518 dialog->setMainWidget(widget);
2520 QVBoxLayout *vbox = new QVBoxLayout(widget);
2521 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
2522 QString path = m_activeDocument->projectFolder().path();
2524 path.append("untitled.mlt");
2525 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
2526 url->setFilter("video/mlt-playlist");
2527 QLabel *label2 = new QLabel(i18n("Description:"), this);
2528 KLineEdit *edit = new KLineEdit(this);
2529 vbox->addWidget(label1);
2530 vbox->addWidget(url);
2531 vbox->addWidget(label2);
2532 vbox->addWidget(edit);
2533 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
2537 void MainWindow::slotSetInPoint()
2539 if (m_clipMonitor->isActive()) {
2540 m_clipMonitor->slotSetZoneStart();
2541 } else m_activeTimeline->projectView()->setInPoint();
2544 void MainWindow::slotSetOutPoint()
2546 if (m_clipMonitor->isActive()) {
2547 m_clipMonitor->slotSetZoneEnd();
2548 } else m_activeTimeline->projectView()->setOutPoint();
2551 void MainWindow::slotGetNewLumaStuff()
2553 //KNS::Entry::List download();
2554 KNS::Entry::List entries = KNS::Engine::download();
2555 // list of changed entries
2556 kDebug() << "// PARSING KNS";
2557 foreach(KNS::Entry* entry, entries) {
2558 // care only about installed ones
2559 if (entry->status() == KNS::Entry::Installed) {
2560 foreach(const QString &file, entry->installedFiles()) {
2561 kDebug() << "// CURRENTLY INSTALLED: " << file;
2565 qDeleteAll(entries);
2566 initEffects::refreshLumas();
2567 m_activeTimeline->projectView()->reloadTransitionLumas();
2570 void MainWindow::slotGetNewRenderStuff()
2572 //KNS::Entry::List download();
2574 KNS::Engine engine(0);
2575 if (engine.init("kdenlive_render.knsrc")) {
2576 KNS::Entry::List entries = engine.downloadDialogModal(this);
2578 if (entries.size() > 0) {
2579 foreach(KNS::Entry* entry, entries) {
2580 // care only about installed ones
2581 if (entry->status() == KNS::Entry::Installed) {
2582 foreach(const QString &file, entry->installedFiles()) {
2583 kDebug() << "// CURRENTLY INSTALLED: " << file;
2588 if (m_renderWidget) m_renderWidget->reloadProfiles();
2592 void MainWindow::slotGetNewMltProfileStuff()
2594 //KNS::Entry::List download();
2596 KNS::Engine engine(0);
2597 if (engine.init("kdenlive_mltprofiles.knsrc")) {
2598 KNS::Entry::List entries = engine.downloadDialogModal(this);
2600 if (entries.size() > 0) {
2601 foreach(KNS::Entry* entry, entries) {
2602 // care only about installed ones
2603 if (entry->status() == KNS::Entry::Installed) {
2604 foreach(const QString &file, entry->installedFiles()) {
2605 kDebug() << "// CURRENTLY INSTALLED: " << file;
2610 // update the list of profiles in settings dialog
2611 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2612 if (d) d->checkProfile();
2617 void MainWindow::slotAutoTransition()
2619 if (m_activeTimeline) m_activeTimeline->projectView()->autoTransition();
2622 void MainWindow::slotSplitAudio()
2624 if (m_activeTimeline) m_activeTimeline->projectView()->splitAudio();
2627 void MainWindow::slotUpdateClipType(QAction *action)
2629 if (m_activeTimeline) {
2630 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
2631 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
2632 else m_activeTimeline->projectView()->setAudioAndVideo();
2636 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
2638 DvdWizard *w = new DvdWizard(url, profile, this);
2642 void MainWindow::slotShowTimeline(bool show)
2644 if (show == false) {
2645 m_timelineState = saveState();
2646 centralWidget()->setHidden(true);
2648 centralWidget()->setHidden(false);
2649 restoreState(m_timelineState);
2653 void MainWindow::slotMaximizeCurrent(bool /*show*/)
2655 //TODO: is there a way to maximize current widget?
2658 m_timelineState = saveState();
2659 QWidget *par = focusWidget()->parentWidget();
2660 while (par->parentWidget() && par->parentWidget() != this) {
2661 par = par->parentWidget();
2663 kDebug() << "CURRENT WIDGET: " << par->objectName();
2666 //centralWidget()->setHidden(false);
2667 //restoreState(m_timelineState);
2671 void MainWindow::loadTranscoders()
2673 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
2676 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
2677 KConfigGroup transConfig(config, "Transcoding");
2679 QMap< QString, QString > profiles = transConfig.entryMap();
2680 QMapIterator<QString, QString> i(profiles);
2681 while (i.hasNext()) {
2683 QAction *a = transMenu->addAction(i.key());
2684 a->setData(i.value());
2685 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
2689 void MainWindow::slotTranscode(KUrl::List urls)
2692 if (urls.isEmpty()) {
2693 urls.append(m_projectList->currentClipUrl());
2694 QAction *action = qobject_cast<QAction *>(sender());
2695 params = action->data().toString();
2697 if (urls.isEmpty()) return;
2698 ClipTranscode *d = new ClipTranscode(urls, params);
2699 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
2701 //QProcess::startDetached("ffmpeg", parameters);
2704 void MainWindow::slotTranscodeClip()
2706 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
2707 if (urls.isEmpty()) return;
2708 slotTranscode(urls);
2711 void MainWindow::slotSetDocumentRenderProfile(const QString &dest, const QString &name, const QString &file)
2713 if (m_activeDocument == NULL) return;
2714 m_activeDocument->setDocumentProperty("renderdestination", dest);
2715 m_activeDocument->setDocumentProperty("renderprofile", name);
2716 m_activeDocument->setDocumentProperty("renderurl", file);
2717 m_activeDocument->setModified(true);
2721 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
2723 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
2725 QString playlistPath;
2728 QString scriptsFolder = m_activeDocument->projectFolder().path() + "/scripts/";
2729 QString path = m_renderWidget->getFreeScriptName();
2730 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
2731 if (!ok || scriptPath.isEmpty()) return;
2732 scriptPath.prepend(scriptsFolder);
2733 QFile f(scriptPath);
2735 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
2738 playlistPath = scriptPath + ".mlt";
2739 m_projectMonitor->saveSceneList(playlistPath);
2741 KTemporaryFile temp;
2742 temp.setAutoRemove(false);
2743 temp.setSuffix(".mlt");
2745 playlistPath = temp.fileName();
2746 m_projectMonitor->saveSceneList(playlistPath);
2749 if (!chapterFile.isEmpty()) {
2752 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
2754 in = m_activeTimeline->inPoint();
2755 out = m_activeTimeline->outPoint();
2758 QDomElement chapters = doc.createElement("chapters");
2759 chapters.setAttribute("fps", m_activeDocument->fps());
2760 doc.appendChild(chapters);
2762 QDomElement guidesxml = m_activeDocument->guidesXml();
2763 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
2764 for (int i = 0; i < nodes.count(); i++) {
2765 QDomElement e = nodes.item(i).toElement();
2767 QString comment = e.attribute("comment");
2768 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
2769 if (time >= in && time < out) {
2770 if (zoneOnly) time = time - in;
2771 QDomElement chapter = doc.createElement("chapter");
2772 chapters.appendChild(chapter);
2773 chapter.setAttribute("title", comment);
2774 chapter.setAttribute("time", time);
2778 if (chapters.childNodes().count() > 0) {
2779 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
2780 // Always insert a guide in pos 0
2781 QDomElement chapter = doc.createElement("chapter");
2782 chapters.insertBefore(chapter, QDomNode());
2783 chapter.setAttribute("title", i18n("Start"));
2784 chapter.setAttribute("time", "0");
2786 // save chapters file
2787 QFile file(chapterFile);
2788 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
2789 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
2791 file.write(doc.toString().toUtf8());
2792 if (file.error() != QFile::NoError) {
2793 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
2800 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath);
2803 void MainWindow::slotUpdateTimecodeFormat(int ix)
2805 KdenliveSettings::setFrametimecode(ix == 1);
2806 m_clipMonitor->updateTimecodeFormat();
2807 m_projectMonitor->updateTimecodeFormat();
2810 void MainWindow::slotRemoveFocus()
2812 statusBar()->setFocus();
2813 statusBar()->clearFocus();
2819 #include "mainwindow.moc"