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"
55 #include <KApplication>
59 #include <KActionCollection>
60 #include <KStandardAction>
61 #include <KFileDialog>
62 #include <KMessageBox>
64 #include <KIO/NetAccess>
67 #include <KConfigDialog>
68 #include <KXMLGUIFactory>
70 #include <kstandarddirs.h>
71 #include <KUrlRequesterDialog>
72 #include <KTemporaryFile>
73 #include <KActionMenu>
76 #include <ktogglefullscreenaction.h>
78 #include <KNotification>
79 #include <KNotifyConfigWidget>
80 #include <knewstuff2/engine.h>
81 #include <knewstuff2/ui/knewstuffaction.h>
83 #include <QTextStream>
90 static const char version[] = VERSION;
92 static const int ID_TIMELINE_POS = 0;
99 EffectsList MainWindow::videoEffects;
100 EffectsList MainWindow::audioEffects;
101 EffectsList MainWindow::customEffects;
102 EffectsList MainWindow::transitions;
104 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent) :
105 KXmlGuiWindow(parent),
106 m_activeDocument(NULL),
107 m_activeTimeline(NULL),
108 m_renderWidget(NULL),
109 #ifndef NO_JOGSHUTTLE
111 #endif /* NO_JOGSHUTTLE */
112 m_findActivated(false)
115 // Create DBus interface
116 new MainWindowAdaptor(this);
117 QDBusConnection dbus = QDBusConnection::sessionBus();
118 dbus.registerObject("/MainWindow", this);
120 setlocale(LC_NUMERIC, "POSIX");
121 setFont(KGlobalSettings::toolBarFont());
122 parseProfiles(MltPath);
123 m_commandStack = new QUndoGroup;
124 m_timelineArea = new KTabWidget(this);
125 m_timelineArea->setTabReorderingEnabled(true);
126 m_timelineArea->setTabBarHidden(true);
128 QToolButton *closeTabButton = new QToolButton;
129 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
130 closeTabButton->setIcon(KIcon("tab-close"));
131 closeTabButton->adjustSize();
132 closeTabButton->setToolTip(i18n("Close the current tab"));
133 m_timelineArea->setCornerWidget(closeTabButton);
134 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
136 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
137 m_findTimer.setSingleShot(true);
139 // FIXME: the next call returns a newly allocated object, which leaks
140 initEffects::parseEffectFiles();
141 //initEffects::parseCustomEffectsFile();
143 m_monitorManager = new MonitorManager();
145 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
146 m_projectListDock->setObjectName("project_tree");
147 m_projectList = new ProjectList(this);
148 m_projectListDock->setWidget(m_projectList);
149 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
151 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
152 m_effectListDock->setObjectName("effect_list");
153 m_effectList = new EffectsListView();
155 //m_effectList = new KListWidget(this);
156 m_effectListDock->setWidget(m_effectList);
157 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
159 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
160 m_effectStackDock->setObjectName("effect_stack");
161 m_effectStack = new EffectStackView(this);
162 m_effectStackDock->setWidget(m_effectStack);
163 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
165 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
166 m_transitionConfigDock->setObjectName("transition");
167 m_transitionConfig = new TransitionSettings(this);
168 m_transitionConfigDock->setWidget(m_transitionConfig);
169 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
171 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
172 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
176 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
177 m_clipMonitorDock->setObjectName("clip_monitor");
178 m_clipMonitor = new Monitor("clip", m_monitorManager, this);
179 m_clipMonitorDock->setWidget(m_clipMonitor);
180 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
181 //m_clipMonitor->stop();
183 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
184 m_projectMonitorDock->setObjectName("project_monitor");
185 m_projectMonitor = new Monitor("project", m_monitorManager, this);
186 m_projectMonitorDock->setWidget(m_projectMonitor);
187 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
189 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
190 m_recMonitorDock->setObjectName("record_monitor");
191 m_recMonitor = new RecMonitor("record", this);
192 m_recMonitorDock->setWidget(m_recMonitor);
193 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
195 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
196 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
198 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
199 m_undoViewDock->setObjectName("undo_history");
200 m_undoView = new QUndoView(this);
201 m_undoView->setCleanIcon(KIcon("edit-clear"));
202 m_undoView->setEmptyLabel(i18n("Clean"));
203 m_undoViewDock->setWidget(m_undoView);
204 m_undoView->setGroup(m_commandStack);
205 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
207 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
208 //overviewDock->setObjectName("project_overview");
209 //m_overView = new CustomTrackView(NULL, NULL, this);
210 //overviewDock->setWidget(m_overView);
211 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
214 //tabifyDockWidget(projectListDock, effectListDock);
215 tabifyDockWidget(m_projectListDock, m_effectStackDock);
216 tabifyDockWidget(m_projectListDock, m_transitionConfigDock);
217 //tabifyDockWidget(projectListDock, undoViewDock);
220 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
221 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
222 setCentralWidget(m_timelineArea);
226 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
227 guiFactory()->addClient(sp);*/
231 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
233 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone);
234 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
235 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)), static_cast<QMenu*>(factory()->container("transcoders", this)));
237 // build effects menus
239 QMenu *videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
241 QStringList effectInfo;
242 QMap<QString, QStringList> effectsList;
243 for (int ix = 0; ix < videoEffects.count(); ix++) {
244 effectInfo = videoEffects.effectIdInfo(ix);
245 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
248 foreach(const QStringList &value, effectsList) {
249 action = new QAction(value.at(0), this);
250 action->setData(value);
251 videoEffectsMenu->addAction(action);
254 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
258 for (int ix = 0; ix < audioEffects.count(); ix++) {
259 effectInfo = audioEffects.effectIdInfo(ix);
260 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
263 foreach(const QStringList &value, effectsList) {
264 action = new QAction(value.at(0), this);
265 action->setData(value);
266 audioEffectsMenu->addAction(action);
269 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
271 if (customEffects.isEmpty()) m_customEffectsMenu->setEnabled(false);
272 else m_customEffectsMenu->setEnabled(true);
275 for (int ix = 0; ix < customEffects.count(); ix++) {
276 effectInfo = customEffects.effectIdInfo(ix);
277 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
280 foreach(const QStringList &value, effectsList) {
281 action = new QAction(value.at(0), this);
282 action->setData(value);
283 m_customEffectsMenu->addAction(action);
286 QMenu *newEffect = new QMenu(this);
287 newEffect->addMenu(videoEffectsMenu);
288 newEffect->addMenu(audioEffectsMenu);
289 newEffect->addMenu(m_customEffectsMenu);
290 m_effectStack->setMenu(newEffect);
293 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
294 const QList<QAction *> viewActions = createPopupMenu()->actions();
295 viewMenu->insertActions(NULL, viewActions);
297 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
298 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
299 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
301 m_timelineContextMenu = new QMenu(this);
302 m_timelineContextClipMenu = new QMenu(this);
303 m_timelineContextTransitionMenu = new QMenu(this);
306 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
307 QStringList effects = transitions.effectNames();
310 for (int ix = 0; ix < transitions.count(); ix++) {
311 effectInfo = transitions.effectIdInfo(ix);
312 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
314 foreach(const QStringList &value, effectsList) {
315 action = new QAction(value.at(0), this);
316 action->setData(value);
317 transitionsMenu->addAction(action);
319 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
321 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
322 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
323 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
325 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
326 m_timelineContextClipMenu->addAction(actionCollection()->action("change_clip_speed"));
327 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
328 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
329 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
330 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
331 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
332 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
334 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
335 m_timelineContextClipMenu->addMenu(markersMenu);
336 m_timelineContextClipMenu->addMenu(transitionsMenu);
337 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
338 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
339 //TODO: re-enable custom effects menu when it is implemented
340 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
342 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
343 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
345 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
347 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
348 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
349 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
350 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
351 connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
352 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
354 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
355 slotConnectMonitors();
357 // Open or create a file. Command line argument passed in Url has
358 // precedence, then "openlastproject", then just a plain empty file.
359 // If opening Url fails, openlastproject will _not_ be used.
360 if (!Url.isEmpty()) {
363 if (KdenliveSettings::openlastproject()) {
367 if (m_timelineArea->count() == 0) {
371 #ifndef NO_JOGSHUTTLE
372 activateShuttleDevice();
373 #endif /* NO_JOGSHUTTLE */
374 m_projectListDock->raise();
377 void MainWindow::queryQuit()
379 kDebug() << "----- SAVING CONFUIG";
380 if (queryClose()) kapp->quit();
384 bool MainWindow::queryClose()
387 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
388 if (m_activeDocument && m_activeDocument->isModified()) {
389 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
390 case KMessageBox::Yes :
391 // save document here. If saving fails, return false;
393 case KMessageBox::No :
394 // User does not want to save the changes, clear recovery files
395 m_activeDocument->m_autosave->resize(0);
405 void MainWindow::loadPlugins()
407 foreach(QObject *plugin, QPluginLoader::staticInstances())
408 populateMenus(plugin);
410 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
412 filters << "libkdenlive*";
413 foreach(const QString &folder, directories) {
414 kDebug() << "// PARSING FIOLER: " << folder;
415 QDir pluginsDir(folder);
416 foreach(const QString &fileName, pluginsDir.entryList(filters, QDir::Files)) {
417 kDebug() << "// FOUND PLUGIN: " << fileName << "= " << pluginsDir.absoluteFilePath(fileName);
418 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
419 QObject *plugin = loader.instance();
421 populateMenus(plugin);
422 m_pluginFileNames += fileName;
423 } else kDebug() << "// ERROR LOADING PLUGIN: " << fileName << ", " << loader.errorString();
429 void MainWindow::populateMenus(QObject *plugin)
431 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
432 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
434 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
438 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
439 QMenu *menu, const char *member,
440 QActionGroup *actionGroup)
442 kDebug() << "// ADD to MENU" << texts;
443 foreach(const QString &text, texts) {
444 QAction *action = new QAction(text, plugin);
445 action->setData(text);
446 connect(action, SIGNAL(triggered()), this, member);
447 menu->addAction(action);
450 action->setCheckable(true);
451 actionGroup->addAction(action);
456 void MainWindow::aboutPlugins()
458 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
463 void MainWindow::generateClip()
465 QAction *action = qobject_cast<QAction *>(sender());
466 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
468 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(), QStringList(), QStringList(), 25, 720, 576);
469 if (!clipUrl.isEmpty()) {
470 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
474 void MainWindow::saveProperties(KConfig*)
476 // save properties here,used by session management
481 void MainWindow::readProperties(KConfig *config)
483 // read properties here,used by session management
484 QString Lastproject = config->group("Recent Files").readPathEntry("File1", QString());
485 openFile(KUrl(Lastproject));
488 void MainWindow::slotReloadEffects()
490 initEffects::parseCustomEffectsFile();
491 m_customEffectsMenu->clear();
492 const QStringList effects = customEffects.effectNames();
494 if (effects.isEmpty()) m_customEffectsMenu->setEnabled(false);
495 else m_customEffectsMenu->setEnabled(true);
497 foreach(const QString &name, effects) {
498 action = new QAction(name, this);
499 action->setData(name);
500 m_customEffectsMenu->addAction(action);
502 m_effectList->reloadEffectList();
505 #ifndef NO_JOGSHUTTLE
506 void MainWindow::activateShuttleDevice()
510 if (KdenliveSettings::enableshuttle() == false) return;
511 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
512 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
513 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
514 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
515 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
516 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
517 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
520 void MainWindow::slotShuttleButton(int code)
524 slotShuttleAction(KdenliveSettings::shuttle1());
527 slotShuttleAction(KdenliveSettings::shuttle2());
530 slotShuttleAction(KdenliveSettings::shuttle3());
533 slotShuttleAction(KdenliveSettings::shuttle4());
536 slotShuttleAction(KdenliveSettings::shuttle5());
541 void MainWindow::slotShuttleAction(int code)
547 m_monitorManager->slotPlay();
550 m_monitorManager->slotPlay();
554 #endif /* NO_JOGSHUTTLE */
556 void MainWindow::configureNotifications()
558 KNotifyConfigWidget::configure(this);
561 void MainWindow::slotFullScreen()
563 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
566 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track)
568 if (!m_activeDocument) return;
569 if (effect.isNull()) {
570 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
573 m_activeTimeline->projectView()->slotAddEffect(effect.cloneNode().toElement(), pos, track);
576 void MainWindow::slotRaiseMonitor(bool clipMonitor)
578 if (clipMonitor) m_clipMonitorDock->raise();
579 else m_projectMonitorDock->raise();
582 void MainWindow::slotUpdateClip(const QString &id)
584 if (!m_activeDocument) return;
585 m_activeTimeline->projectView()->slotUpdateClip(id);
588 void MainWindow::slotConnectMonitors()
591 m_projectList->setRenderer(m_projectMonitor->render);
592 connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
593 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
594 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, const QString &, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement &, const QString &, bool)));
595 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
596 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)));
598 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
600 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
602 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
603 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
605 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
606 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
609 void MainWindow::slotAdjustClipMonitor()
611 m_clipMonitorDock->updateGeometry();
612 m_clipMonitorDock->adjustSize();
613 m_clipMonitor->resetSize();
616 void MainWindow::slotAdjustProjectMonitor()
618 m_projectMonitorDock->updateGeometry();
619 m_projectMonitorDock->adjustSize();
620 m_projectMonitor->resetSize();
623 void MainWindow::setupActions()
626 KActionCollection* collection = actionCollection();
627 m_timecodeFormat = new KComboBox(this);
628 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
629 m_timecodeFormat->addItem(i18n("Frames"));
631 m_statusProgressBar = new QProgressBar(this);
632 m_statusProgressBar->setMinimum(0);
633 m_statusProgressBar->setMaximum(100);
634 m_statusProgressBar->setMaximumWidth(150);
635 m_statusProgressBar->setVisible(false);
637 QWidget *w = new QWidget;
639 QHBoxLayout *layout = new QHBoxLayout;
640 w->setLayout(layout);
641 layout->setContentsMargins(5, 0, 5, 0);
642 QToolBar *toolbar = new QToolBar("statusToolBar", this);
645 m_toolGroup = new QActionGroup(this);
647 QString style1 = "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;}";
649 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
650 toolbar->addAction(m_buttonSelectTool);
651 m_buttonSelectTool->setCheckable(true);
652 m_buttonSelectTool->setChecked(true);
654 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
655 toolbar->addAction(m_buttonRazorTool);
656 m_buttonRazorTool->setCheckable(true);
657 m_buttonRazorTool->setChecked(false);
659 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
660 toolbar->addAction(m_buttonSpacerTool);
661 m_buttonSpacerTool->setCheckable(true);
662 m_buttonSpacerTool->setChecked(false);
664 m_toolGroup->addAction(m_buttonSelectTool);
665 m_toolGroup->addAction(m_buttonRazorTool);
666 m_toolGroup->addAction(m_buttonSpacerTool);
667 m_toolGroup->setExclusive(true);
668 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
670 QWidget * actionWidget;
671 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
672 actionWidget->setMaximumWidth(24);
673 actionWidget->setMinimumHeight(18);
675 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
676 actionWidget->setMaximumWidth(24);
677 actionWidget->setMinimumHeight(18);
679 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
680 actionWidget->setMaximumWidth(24);
681 actionWidget->setMinimumHeight(18);
683 toolbar->setStyleSheet(style1);
684 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
686 toolbar->addSeparator();
687 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
688 toolbar->addAction(m_buttonFitZoom);
689 m_buttonFitZoom->setCheckable(false);
690 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
692 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
693 actionWidget->setMaximumWidth(24);
694 actionWidget->setMinimumHeight(18);
696 m_zoomSlider = new QSlider(Qt::Horizontal, this);
697 m_zoomSlider->setMaximum(13);
698 m_zoomSlider->setPageStep(1);
700 m_zoomSlider->setMaximumWidth(150);
701 m_zoomSlider->setMinimumWidth(100);
703 const int contentHeight = QFontMetrics(w->font()).height() + 8;
705 QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
706 style.append("QSlider::handle:horizontal { background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
708 m_zoomSlider->setStyleSheet(style);
710 //m_zoomSlider->height() + 5;
711 statusBar()->setMinimumHeight(contentHeight);
714 toolbar->addWidget(m_zoomSlider);
716 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
717 toolbar->addAction(m_buttonVideoThumbs);
718 m_buttonVideoThumbs->setCheckable(true);
719 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
720 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
722 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
723 toolbar->addAction(m_buttonAudioThumbs);
724 m_buttonAudioThumbs->setCheckable(true);
725 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
726 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
728 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
729 toolbar->addAction(m_buttonShowMarkers);
730 m_buttonShowMarkers->setCheckable(true);
731 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
732 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
734 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
735 toolbar->addAction(m_buttonSnap);
736 m_buttonSnap->setCheckable(true);
737 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
738 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
739 layout->addWidget(toolbar);
742 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
743 actionWidget->setMaximumWidth(24);
744 actionWidget->setMinimumHeight(18);
746 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
747 actionWidget->setMaximumWidth(24);
748 actionWidget->setMinimumHeight(18);
750 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
751 actionWidget->setMaximumWidth(24);
752 actionWidget->setMinimumHeight(18);
754 actionWidget = toolbar->widgetForAction(m_buttonSnap);
755 actionWidget->setMaximumWidth(24);
756 actionWidget->setMinimumHeight(18);
758 m_messageLabel = new StatusBarMessageLabel(this);
759 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
761 statusBar()->addWidget(m_messageLabel, 10);
762 statusBar()->addWidget(m_statusProgressBar, 0);
763 statusBar()->addPermanentWidget(w);
764 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
765 statusBar()->addPermanentWidget(m_timecodeFormat);
766 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
767 m_messageLabel->hide();
769 collection->addAction("select_tool", m_buttonSelectTool);
770 collection->addAction("razor_tool", m_buttonRazorTool);
771 collection->addAction("spacer_tool", m_buttonSpacerTool);
773 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
774 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
775 collection->addAction("show_markers", m_buttonShowMarkers);
776 collection->addAction("snap", m_buttonSnap);
777 collection->addAction("zoom_fit", m_buttonFitZoom);
779 KAction* zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
780 collection->addAction("zoom_in", zoomIn);
781 connect(zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
782 zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
784 KAction* zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
785 collection->addAction("zoom_out", zoomOut);
786 connect(zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
787 zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
789 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
790 collection->addAction("project_find", m_projectSearch);
791 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
792 m_projectSearch->setShortcut(Qt::Key_Slash);
794 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
795 collection->addAction("project_find_next", m_projectSearchNext);
796 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
797 m_projectSearchNext->setShortcut(Qt::Key_F3);
798 m_projectSearchNext->setEnabled(false);
800 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
801 collection->addAction("manage_profiles", profilesAction);
802 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
804 KNS::standardAction(i18n("Download New Lumas..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
806 KNS::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
808 KNS::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
810 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
811 collection->addAction("run_wizard", wizAction);
812 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
814 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
815 collection->addAction("project_settings", projectAction);
816 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
818 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
819 collection->addAction("project_render", projectRender);
820 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
821 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
823 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
824 KShortcut playShortcut;
825 playShortcut.setPrimary(Qt::Key_Space);
826 playShortcut.setAlternate(Qt::Key_K);
827 monitorPlay->setShortcut(playShortcut);
828 collection->addAction("monitor_play", monitorPlay);
829 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
831 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
832 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
833 collection->addAction("monitor_play_zone", m_playZone);
834 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
836 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
837 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
838 collection->addAction("monitor_loop_zone", m_loopZone);
839 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
841 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
842 collection->addAction("dvd_wizard", dvdWizard);
843 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
845 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clip"), this);
846 collection->addAction("transcode_clip", transcodeClip);
847 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
849 KAction *markIn = collection->addAction("mark_in");
850 markIn->setText(i18n("Set In Point"));
851 markIn->setShortcut(Qt::Key_I);
852 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
854 KAction *markOut = collection->addAction("mark_out");
855 markOut->setText(i18n("Set Out Point"));
856 markOut->setShortcut(Qt::Key_O);
857 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
859 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
860 monitorSeekBackward->setShortcut(Qt::Key_J);
861 collection->addAction("monitor_seek_backward", monitorSeekBackward);
862 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
864 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
865 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
866 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
867 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
869 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
870 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
871 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
872 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
874 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
875 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
876 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
877 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
879 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
880 monitorSeekForward->setShortcut(Qt::Key_L);
881 collection->addAction("monitor_seek_forward", monitorSeekForward);
882 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
884 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
885 clipStart->setShortcut(Qt::Key_Home);
886 collection->addAction("seek_clip_start", clipStart);
887 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
889 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
890 clipEnd->setShortcut(Qt::Key_End);
891 collection->addAction("seek_clip_end", clipEnd);
892 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
894 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
895 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
896 collection->addAction("seek_start", projectStart);
897 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
899 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
900 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
901 collection->addAction("seek_end", projectEnd);
902 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
904 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
905 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
906 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
907 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
909 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
910 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
911 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
912 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
914 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
915 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
916 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
917 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
919 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
920 deleteTimelineClip->setShortcut(Qt::Key_Delete);
921 collection->addAction("delete_timeline_clip", deleteTimelineClip);
922 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
924 KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
925 collection->addAction("change_clip_speed", editTimelineClipSpeed);
926 editTimelineClipSpeed->setData("change_speed");
927 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));
929 KAction *stickTransition = collection->addAction("auto_transition");
930 stickTransition->setData(QString("auto"));
931 stickTransition->setCheckable(true);
932 stickTransition->setEnabled(false);
933 stickTransition->setText(i18n("Automatic Transition"));
934 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
936 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
937 collection->addAction("group_clip", groupClip);
938 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
940 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
941 collection->addAction("ungroup_clip", ungroupClip);
942 ungroupClip->setData("ungroup_clip");
943 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
945 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
946 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
947 collection->addAction("cut_timeline_clip", cutTimelineClip);
948 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
950 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
951 collection->addAction("add_clip_marker", addClipMarker);
952 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
954 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
955 collection->addAction("delete_clip_marker", deleteClipMarker);
956 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
958 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
959 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
960 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
962 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
963 collection->addAction("edit_clip_marker", editClipMarker);
964 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
966 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
967 collection->addAction("split_audio", splitAudio);
968 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
970 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
971 collection->addAction("clip_audio_only", audioOnly);
972 audioOnly->setData("clip_audio_only");
973 audioOnly->setCheckable(true);
975 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
976 collection->addAction("clip_video_only", videoOnly);
977 videoOnly->setData("clip_video_only");
978 videoOnly->setCheckable(true);
980 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
981 collection->addAction("clip_audio_and_video", audioAndVideo);
982 audioAndVideo->setData("clip_audio_and_video");
983 audioAndVideo->setCheckable(true);
985 m_clipTypeGroup = new QActionGroup(this);
986 m_clipTypeGroup->addAction(audioOnly);
987 m_clipTypeGroup->addAction(videoOnly);
988 m_clipTypeGroup->addAction(audioAndVideo);
989 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
990 m_clipTypeGroup->setEnabled(false);
992 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
993 collection->addAction("insert_space", insertSpace);
994 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
996 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
997 collection->addAction("delete_space", removeSpace);
998 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1000 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1001 collection->addAction("insert_track", insertTrack);
1002 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1004 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1005 collection->addAction("delete_track", deleteTrack);
1006 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1008 KAction *changeTrack = new KAction(KIcon(), i18n("Change Track"), this);
1009 collection->addAction("change_track", changeTrack);
1010 connect(changeTrack, SIGNAL(triggered()), this, SLOT(slotChangeTrack()));
1012 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1013 collection->addAction("add_guide", addGuide);
1014 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1016 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1017 collection->addAction("delete_guide", delGuide);
1018 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1020 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1021 collection->addAction("edit_guide", editGuide);
1022 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1024 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1025 collection->addAction("delete_all_guides", delAllGuides);
1026 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1028 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1029 collection->addAction("paste_effects", pasteEffects);
1030 pasteEffects->setData("paste_effects");
1031 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1033 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1034 collection->addAction("show_timeline", showTimeline);
1035 showTimeline->setCheckable(true);
1036 showTimeline->setChecked(true);
1037 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1039 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1040 collection->addAction("maximize_current", maxCurrent);
1041 maxCurrent->setCheckable(true);
1042 maxCurrent->setChecked(false);
1043 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1046 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1048 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1050 KStandardAction::open(this, SLOT(openFile()), collection);
1052 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1054 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1056 KStandardAction::openNew(this, SLOT(newFile()), collection);
1058 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1060 KStandardAction::configureNotifications(this , SLOT(configureNotifications()), collection);
1062 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1064 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1066 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1067 undo->setEnabled(false);
1068 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1070 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1071 redo->setEnabled(false);
1072 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1074 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1077 //TODO: Add status tooltip to actions ?
1078 connect(collection, SIGNAL(actionHovered(QAction*)),
1079 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1082 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1083 collection->addAction("add_clip", addClip);
1084 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1086 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1087 collection->addAction("add_color_clip", addColorClip);
1088 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1090 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1091 collection->addAction("add_slide_clip", addSlideClip);
1092 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1094 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1095 collection->addAction("add_text_clip", addTitleClip);
1096 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1098 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1099 collection->addAction("add_folder", addFolderButton);
1100 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1102 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1103 collection->addAction("clip_properties", clipProperties);
1104 clipProperties->setData("clip_properties");
1105 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1106 clipProperties->setEnabled(false);
1108 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1109 collection->addAction("edit_clip", openClip);
1110 openClip->setData("edit_clip");
1111 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1112 openClip->setEnabled(false);
1114 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1115 collection->addAction("delete_clip", deleteClip);
1116 deleteClip->setData("delete_clip");
1117 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1118 deleteClip->setEnabled(false);
1120 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1121 collection->addAction("reload_clip", reloadClip);
1122 reloadClip->setData("reload_clip");
1123 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1124 reloadClip->setEnabled(false);
1126 QMenu *addClips = new QMenu();
1127 addClips->addAction(addClip);
1128 addClips->addAction(addColorClip);
1129 addClips->addAction(addSlideClip);
1130 addClips->addAction(addTitleClip);
1131 addClips->addAction(addFolderButton);
1133 addClips->addAction(reloadClip);
1134 addClips->addAction(clipProperties);
1135 addClips->addAction(openClip);
1136 addClips->addAction(deleteClip);
1137 m_projectList->setupMenu(addClips, addClip);
1139 //connect(collection, SIGNAL( clearStatusText() ),
1140 //statusBar(), SLOT( clear() ) );
1143 void MainWindow::slotDisplayActionMessage(QAction *a)
1145 statusBar()->showMessage(a->data().toString(), 3000);
1148 void MainWindow::saveOptions()
1150 KdenliveSettings::self()->writeConfig();
1151 KSharedConfigPtr config = KGlobal::config();
1152 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1153 KConfigGroup treecolumns(config, "Project Tree");
1154 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1158 void MainWindow::readOptions()
1160 KSharedConfigPtr config = KGlobal::config();
1161 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1162 KConfigGroup initialGroup(config, "version");
1163 bool upgrade = false;
1164 if (initialGroup.exists()) {
1165 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0))
1168 if (initialGroup.readEntry("version") == "0.7") {
1169 //Add new settings from 0.7.1
1170 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1171 QString path = QDir::homePath() + "/kdenlive";
1172 if (KStandardDirs::makeDir(path) == false) kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1173 KdenliveSettings::setDefaultprojectfolder(path);
1179 if (!initialGroup.exists() || upgrade) {
1180 // this is our first run, show Wizard
1181 Wizard *w = new Wizard(upgrade, this);
1182 if (w->exec() == QDialog::Accepted && w->isOk()) {
1183 w->adjustSettings();
1184 initialGroup.writeEntry("version", version);
1190 KConfigGroup treecolumns(config, "Project Tree");
1191 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1192 if (!state.isEmpty())
1193 m_projectList->setHeaderInfo(state);
1196 void MainWindow::slotRunWizard()
1198 Wizard *w = new Wizard(false, this);
1199 if (w->exec() == QDialog::Accepted && w->isOk()) {
1200 w->adjustSettings();
1205 void MainWindow::newFile(bool showProjectSettings)
1207 QString profileName;
1209 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1210 if (!showProjectSettings && m_timelineArea->count() == 0) {
1211 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1212 profileName = KdenliveSettings::default_profile();
1214 ProjectSettings *w = new ProjectSettings(projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, this);
1215 if (w->exec() != QDialog::Accepted) return;
1216 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1217 KdenliveSettings::setVideothumbnails(w->enableVideoThumbs());
1218 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1219 KdenliveSettings::setAudiothumbnails(w->enableAudioThumbs());
1220 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1221 profileName = w->selectedProfile();
1222 projectFolder = w->selectedFolder();
1223 projectTracks = w->tracks();
1226 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1227 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1228 TrackView *trackView = new TrackView(doc, this);
1229 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1230 if (m_timelineArea->count() == 1) {
1231 connectDocumentInfo(doc);
1232 connectDocument(trackView, doc);
1233 } else m_timelineArea->setTabBarHidden(false);
1234 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1237 void MainWindow::activateDocument()
1239 if (m_timelineArea->currentWidget() == NULL) return;
1240 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1241 KdenliveDoc *currentDoc = currentTab->document();
1242 connectDocumentInfo(currentDoc);
1243 connectDocument(currentTab, currentDoc);
1246 void MainWindow::closeCurrentDocument()
1248 QWidget *w = m_timelineArea->currentWidget();
1250 // closing current document
1251 int ix = m_timelineArea->currentIndex() + 1;
1252 if (ix == m_timelineArea->count()) ix = 0;
1253 m_timelineArea->setCurrentIndex(ix);
1254 TrackView *tabToClose = (TrackView *) w;
1255 KdenliveDoc *docToClose = tabToClose->document();
1256 if (docToClose && docToClose->isModified()) {
1257 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
1258 case KMessageBox::Yes :
1259 // save document here. If saving fails, return false;
1260 if (saveFile() == false) return;
1262 case KMessageBox::Cancel :
1269 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1270 if (m_timelineArea->count() == 1) {
1271 m_timelineArea->setTabBarHidden(true);
1272 m_closeAction->setEnabled(false);
1274 if (docToClose == m_activeDocument) {
1275 delete m_activeDocument;
1276 m_activeDocument = NULL;
1277 m_effectStack->clear();
1278 m_transitionConfig->slotTransitionItemSelected(NULL, QPoint(), false);
1279 } else delete docToClose;
1280 if (w == m_activeTimeline) {
1281 delete m_activeTimeline;
1282 m_activeTimeline = NULL;
1286 bool MainWindow::saveFileAs(const QString &outputFileName)
1288 QString currentSceneList;
1289 if (KdenliveSettings::dropbframes()) {
1290 KdenliveSettings::setDropbframes(false);
1291 m_activeDocument->clipManager()->updatePreviewSettings();
1292 currentSceneList = m_projectMonitor->sceneList();
1293 KdenliveSettings::setDropbframes(true);
1294 m_activeDocument->clipManager()->updatePreviewSettings();
1295 } else currentSceneList = m_projectMonitor->sceneList();
1297 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1300 // Save timeline thumbnails
1301 m_activeTimeline->projectView()->saveThumbnails();
1302 m_activeDocument->setUrl(KUrl(outputFileName));
1303 if (m_activeDocument->m_autosave == NULL) {
1304 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1305 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1306 setCaption(m_activeDocument->description());
1307 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1308 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1309 m_activeDocument->setModified(false);
1310 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1314 bool MainWindow::saveFileAs()
1316 // Check that the Kdenlive mime type is correctly installed
1317 QString mimetype = "application/x-kdenlive";
1318 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1319 if (!mime) mimetype = "*.kdenlive";
1321 QString outputFile = KFileDialog::getSaveFileName(KUrl(), mimetype);
1322 if (outputFile.isEmpty()) return false;
1323 if (QFile::exists(outputFile)) {
1324 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it?")) == KMessageBox::No) return false;
1326 return saveFileAs(outputFile);
1329 bool MainWindow::saveFile()
1331 if (!m_activeDocument) return true;
1332 if (m_activeDocument->url().isEmpty()) {
1333 return saveFileAs();
1335 bool result = saveFileAs(m_activeDocument->url().path());
1336 m_activeDocument->m_autosave->resize(0);
1341 void MainWindow::openFile()
1343 // Check that the Kdenlive mime type is correctly installed
1344 QString mimetype = "application/x-kdenlive";
1345 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1346 if (!mime) mimetype = "*.kdenlive";
1348 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), mimetype);
1349 if (url.isEmpty()) return;
1350 m_fileOpenRecent->addUrl(url);
1354 void MainWindow::openLastFile()
1356 KSharedConfigPtr config = KGlobal::config();
1357 KUrl::List urls = m_fileOpenRecent->urls();
1358 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1359 if (urls.isEmpty()) newFile(false);
1360 else openFile(urls.last());
1363 void MainWindow::openFile(const KUrl &url)
1365 // Check if the document is already opened
1366 const int ct = m_timelineArea->count();
1367 bool isOpened = false;
1369 for (i = 0; i < ct; i++) {
1370 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1371 KdenliveDoc *doc = tab->document();
1372 if (doc->url() == url) {
1378 m_timelineArea->setCurrentIndex(i);
1382 // Check for backup file
1383 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1384 if (!staleFiles.isEmpty()) {
1385 if (KMessageBox::questionYesNo(this,
1386 i18n("Auto-saved files exist. Do you want to recover them now?"),
1387 i18n("File Recovery"),
1388 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1389 recoverFiles(staleFiles);
1392 // remove the stale files
1393 foreach(KAutoSaveFile *stale, staleFiles) {
1394 stale->open(QIODevice::ReadWrite);
1399 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1400 doOpenFile(url, NULL);
1403 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1405 KdenliveDoc *doc = new KdenliveDoc(url, KUrl(), m_commandStack, QString(), QPoint(3, 2), m_projectMonitor->render, this);
1406 if (stale == NULL) {
1407 stale = new KAutoSaveFile(url, doc);
1408 doc->m_autosave = stale;
1410 doc->m_autosave = stale;
1411 doc->setUrl(stale->managedFile());
1412 doc->setModified(true);
1413 stale->setParent(doc);
1415 connectDocumentInfo(doc);
1416 TrackView *trackView = new TrackView(doc, this);
1417 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1418 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1419 trackView->setDuration(trackView->duration());
1420 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1422 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1423 slotGotProgressInfo(QString(), -1);
1424 m_clipMonitor->refreshMonitor(true);
1425 m_projectMonitor->adjustRulerSize(trackView->duration());
1426 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1429 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1431 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1432 foreach(KAutoSaveFile *stale, staleFiles) {
1433 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1434 // show an error message; we could not steal the lockfile
1435 // maybe another application got to the file before us?
1439 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1440 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
1441 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1442 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1447 void MainWindow::parseProfiles(const QString &mltPath)
1449 // kDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
1451 //KdenliveSettings::setDefaulttmpfolder();
1452 if (!mltPath.isEmpty()) {
1453 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1454 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
1457 if (KdenliveSettings::mltpath().isEmpty()) {
1458 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1460 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
1461 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
1462 if (!QFile::exists(meltPath))
1463 meltPath = KStandardDirs::findExe("melt");
1464 KdenliveSettings::setRendererpath(meltPath);
1466 QStringList profilesFilter;
1467 profilesFilter << "*";
1468 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1470 if (profilesList.isEmpty()) {
1471 // Cannot find MLT path, try finding melt
1472 QString profilePath = KdenliveSettings::rendererpath();
1473 if (!profilePath.isEmpty()) {
1474 profilePath = profilePath.section('/', 0, -3);
1475 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1476 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1479 if (profilesList.isEmpty()) {
1480 // Cannot find the MLT profiles, ask for location
1481 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1482 getUrl->fileDialog()->setMode(KFile::Directory);
1483 if (getUrl->exec() == QDialog::Rejected) {
1486 KUrl mltPath = getUrl->selectedUrl();
1488 if (mltPath.isEmpty()) ::exit(0);
1489 KdenliveSettings::setMltpath(mltPath.path());
1490 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1494 if (KdenliveSettings::rendererpath().isEmpty()) {
1495 // Cannot find the MLT melt renderer, ask for location
1496 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of Mlt)"), this);
1497 if (getUrl->exec() == QDialog::Rejected) {
1500 KUrl rendererPath = getUrl->selectedUrl();
1502 if (rendererPath.isEmpty()) ::exit(0);
1503 KdenliveSettings::setRendererpath(rendererPath.path());
1506 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1508 // Parse MLT profiles to build a list of available video formats
1509 if (profilesList.isEmpty()) parseProfiles();
1513 void MainWindow::slotEditProfiles()
1515 ProfilesDialog *w = new ProfilesDialog;
1516 if (w->exec() == QDialog::Accepted) {
1517 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1518 if (d) d->checkProfile();
1523 void MainWindow::slotEditProjectSettings()
1525 QPoint p = m_activeDocument->getTracksCount();
1526 ProjectSettings *w = new ProjectSettings(p.x(), p.y(), m_activeDocument->projectFolder().path(), true, this);
1528 if (w->exec() == QDialog::Accepted) {
1529 QString profile = w->selectedProfile();
1530 m_activeDocument->setProjectFolder(w->selectedFolder());
1531 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path());
1532 if (m_activeDocument->profilePath() != profile) {
1533 // Profile was changed
1534 double dar = m_activeDocument->dar();
1535 m_activeDocument->setProfilePath(profile);
1536 KdenliveSettings::setCurrent_profile(profile);
1537 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1538 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1539 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1540 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1541 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1542 m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1543 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
1544 // We need to desactivate & reactivate monitors to get a refresh
1545 m_monitorManager->switchMonitors();
1551 void MainWindow::slotRenderProject()
1553 if (!m_renderWidget) {
1554 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path() : KdenliveSettings::defaultprojectfolder();
1555 m_renderWidget = new RenderWidget(projectfolder, this);
1556 connect(m_renderWidget, SIGNAL(doRender(const QStringList&, const QStringList&)), this, SLOT(slotDoRender(const QStringList&, const QStringList&)));
1557 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1558 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1559 if (m_activeDocument) {
1560 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1561 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1564 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1565 if (currentTab) m_renderWidget->setTimeline(currentTab);
1566 m_renderWidget->setDocument(m_activeDocument);*/
1567 m_renderWidget->show();
1570 void MainWindow::slotDoRender(const QStringList args, const QStringList overlay_args)
1572 QString dest = args.at(0);
1573 QString render = args.at(1);
1574 QStringList avformat_args = args.at(2).split(' ');
1575 bool zoneOnly = args.at(3).toInt();
1576 bool playAfter = args.at(4).toInt();
1577 double guideStart = args.at(5).toDouble();
1578 double guideEnd = args.at(6).toDouble();
1579 bool resizeProfile = args.at(7).toInt();
1580 QString scriptExport = args.at(8);
1581 bool createChapterFile = args.at(9).toInt();
1583 if (dest.isEmpty()) return;
1587 if (m_activeTimeline && zoneOnly) {
1588 in = m_activeTimeline->inPoint();
1589 out = m_activeTimeline->outPoint();
1592 KTemporaryFile temp;
1593 temp.setAutoRemove(false);
1594 temp.setSuffix(".mlt");
1595 if (!scriptExport.isEmpty() || temp.open()) {
1596 if (KdenliveSettings::dropbframes()) {
1597 KdenliveSettings::setDropbframes(false);
1598 m_activeDocument->clipManager()->updatePreviewSettings();
1599 if (!scriptExport.isEmpty()) m_projectMonitor->saveSceneList(scriptExport + ".mlt");
1600 else m_projectMonitor->saveSceneList(temp.fileName());
1601 KdenliveSettings::setDropbframes(true);
1602 m_activeDocument->clipManager()->updatePreviewSettings();
1604 if (!scriptExport.isEmpty()) m_projectMonitor->saveSceneList(scriptExport + ".mlt");
1605 else m_projectMonitor->saveSceneList(temp.fileName());
1609 if (scriptExport.isEmpty()) args << "-erase";
1610 if (KdenliveSettings::usekuiserver()) args << "-kuiserver";
1611 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
1612 else if (guideStart != -1) {
1613 args << "in=" + QString::number(GenTime(guideStart).frames(m_activeDocument->fps())) << "out=" + QString::number(GenTime(guideEnd).frames(m_activeDocument->fps()));
1615 if (!overlay_args.isEmpty()) args << "preargs=" + overlay_args.join(" ");
1616 QString videoPlayer = "-";
1618 videoPlayer = KdenliveSettings::defaultplayerapp();
1619 if (videoPlayer.isEmpty()) KMessageBox::sorry(this, i18n("Cannot play video after rendering because the default video player application is not set.\nPlease define it in Kdenlive settings dialog."));
1621 if (!QFile::exists(KdenliveSettings::rendererpath())) {
1622 KMessageBox::sorry(this, i18n("Cannot find the melt program required for rendering (part of Mlt)"));
1623 setRenderingProgress(dest, -3);
1626 args << KdenliveSettings::rendererpath() << m_activeDocument->profilePath() << render << videoPlayer;
1628 for (int i = 0; i < avformat_args.count(); i++) {
1629 if (avformat_args.at(i).startsWith("profile=")) {
1630 if (avformat_args.at(i).section('=', 1) != m_activeDocument->profilePath()) resizeProfile = true;
1635 if (resizeProfile) {
1636 // The rendering profile is different from project profile, so use MLT's special producer_consumer
1637 if (scriptExport.isEmpty()) args << "consumer:" + temp.fileName();
1638 else args << "consumer:$SOURCE";
1640 if (scriptExport.isEmpty()) args << temp.fileName();
1641 else args << "$SOURCE";
1643 if (scriptExport.isEmpty()) args << dest;
1644 else args << "$TARGET";
1645 args << avformat_args;
1646 QString renderer = QCoreApplication::applicationDirPath() + QString("/kdenlive_render");
1647 if (!QFile::exists(renderer)) renderer = "kdenlive_render";
1648 if (scriptExport.isEmpty()) {
1649 QProcess::startDetached(renderer, args);
1650 KNotification::event("RenderStarted", i18n("Rendering <i>%1</i> started", dest), QPixmap(), this);
1652 // Generate script file
1653 QFile file(scriptExport);
1654 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
1655 KMessageBox::error(this, i18n("Cannot write to file %1", scriptExport));
1659 QTextStream outStream(&file);
1660 outStream << "#! /bin/sh" << "\n" << "\n";
1661 outStream << "SOURCE=" << "\"" + scriptExport + ".mlt\"" << "\n";
1662 outStream << "TARGET=" << "\"" + dest + "\"" << "\n";
1663 outStream << renderer << " " << args.join(" ") << "\n" << "\n";
1664 if (file.error() != QFile::NoError) {
1665 KMessageBox::error(this, i18n("Cannot write to file %1", scriptExport));
1670 QFile::setPermissions(scriptExport, file.permissions() | QFile::ExeUser);
1673 if (createChapterFile) {
1675 QDomElement chapters = doc.createElement("chapters");
1676 chapters.setAttribute("fps", m_activeDocument->fps());
1677 doc.appendChild(chapters);
1679 QDomElement guidesxml = m_activeDocument->guidesXml();
1680 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
1682 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
1683 for (int i = 0; i < nodes.count(); i++) {
1684 QDomElement e = nodes.item(i).toElement();
1686 QString comment = e.attribute("comment");
1687 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
1688 if (time >= in && time < out) {
1689 if (zoneOnly) time = time - in;
1690 QDomElement chapter = doc.createElement("chapter");
1691 chapters.appendChild(chapter);
1692 chapter.setAttribute("title", comment);
1693 chapter.setAttribute("time", time);
1697 if (chapters.childNodes().count() > 0) {
1698 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
1699 // Always insert a guide in pos 0
1700 QDomElement chapter = doc.createElement("chapter");
1701 chapters.insertBefore(chapter, QDomNode());
1702 chapter.setAttribute("title", i18n("Start"));
1703 chapter.setAttribute("time", "0");
1705 // save chapters file
1706 QFile file(dest + ".dvdchapter");
1707 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
1708 kWarning() << "////// ERROR writing DVD CHAPTER file: " << dest + ".dvdchapter";
1710 file.write(doc.toString().toUtf8());
1711 if (file.error() != QFile::NoError)
1712 kWarning() << "////// ERROR writing DVD CHAPTER file: " << dest + ".dvdchapter";
1720 void MainWindow::setRenderingProgress(const QString &url, int progress)
1722 if (m_renderWidget) m_renderWidget->setRenderJob(url, progress);
1725 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
1727 if (m_renderWidget) m_renderWidget->setRenderStatus(url, status, error);
1730 void MainWindow::slotUpdateMousePosition(int pos)
1732 if (m_activeDocument)
1733 switch (m_timecodeFormat->currentIndex()) {
1735 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1738 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1742 void MainWindow::slotUpdateDocumentState(bool modified)
1744 if (!m_activeDocument) return;
1745 setCaption(m_activeDocument->description(), modified);
1746 m_saveAction->setEnabled(modified);
1748 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1749 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1751 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1752 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1756 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
1758 if (m_activeDocument) {
1759 if (m_activeDocument == doc) return;
1760 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1762 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1765 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
1767 //m_projectMonitor->stop();
1768 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1769 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1770 if (m_activeDocument) {
1771 if (m_activeDocument == doc) return;
1772 if (m_activeTimeline) {
1773 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1774 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1775 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1776 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1777 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
1780 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1781 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1782 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1783 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1784 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1785 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1786 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1787 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1788 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1789 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, QPoint, bool)));
1790 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1791 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1792 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1793 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1794 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1795 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1796 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1797 disconnect(m_activeTimeline, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1798 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1799 disconnect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1800 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1801 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1802 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1803 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1804 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1805 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1806 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
1807 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1808 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1809 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
1810 m_effectStack->clear();
1812 //m_activeDocument->setRenderer(NULL);
1813 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1814 m_clipMonitor->stop();
1816 KdenliveSettings::setCurrent_profile(doc->profilePath());
1817 KdenliveSettings::setProject_fps(doc->fps());
1818 m_monitorManager->resetProfiles(doc->timecode());
1819 m_projectList->setDocument(doc);
1820 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), trackView->tracksNumber());
1821 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
1822 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1823 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1824 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
1827 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1828 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1829 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1830 connect(trackView, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1831 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1832 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1833 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1834 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1835 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
1836 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1837 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1838 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1839 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1840 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1842 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1843 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1844 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1847 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1848 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1849 connect(trackView, SIGNAL(transitionItemSelected(Transition*, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, QPoint, bool)));
1850 connect(trackView, SIGNAL(transitionItemSelected(Transition*, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1851 m_zoomSlider->setValue(doc->zoom());
1852 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1853 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1854 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1855 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1857 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1860 connect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1861 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1862 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1863 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1864 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1865 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1866 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1867 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1869 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1870 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1871 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
1873 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup);
1874 m_activeTimeline = trackView;
1875 if (m_renderWidget) {
1876 m_renderWidget->setProfile(doc->mltProfile());
1877 m_renderWidget->setDocumentPath(doc->projectFolder().path());
1879 //doc->setRenderer(m_projectMonitor->render);
1880 m_commandStack->setActiveStack(doc->commandStack());
1881 KdenliveSettings::setProject_display_ratio(doc->dar());
1882 m_projectList->updateAllClips();
1883 //doc->clipManager()->checkAudioThumbs();
1885 //m_overView->setScene(trackView->projectScene());
1886 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1887 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1889 setCaption(doc->description(), doc->isModified());
1890 m_saveAction->setEnabled(doc->isModified());
1891 m_activeDocument = doc;
1892 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
1894 // set tool to select tool
1895 m_buttonSelectTool->setChecked(true);
1898 void MainWindow::slotZoneMoved(int start, int end)
1900 m_activeDocument->setZone(start, end);
1901 m_projectMonitor->slotZoneMoved(start, end);
1904 void MainWindow::slotGuidesUpdated()
1906 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1909 void MainWindow::slotPreferences(int page, int option)
1911 //An instance of your dialog could be already created and could be
1912 // cached, in which case you want to display the cached dialog
1913 // instead of creating another one
1914 if (KConfigDialog::showDialog("settings")) {
1915 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1916 if (page != -1) d->showPage(page, option);
1920 // KConfigDialog didn't find an instance of this dialog, so lets
1922 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1923 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1924 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1925 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1926 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
1927 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1929 if (page != -1) dialog->showPage(page, option);
1932 void MainWindow::slotUpdatePreviewSettings()
1934 if (m_activeDocument) {
1935 m_clipMonitor->slotSetXml(NULL, 0);
1936 m_activeDocument->updatePreviewSettings();
1940 void MainWindow::updateConfiguration()
1942 //TODO: we should apply settings to all projects, not only the current one
1943 if (m_activeTimeline) {
1944 m_activeTimeline->refresh();
1945 m_activeTimeline->projectView()->checkAutoScroll();
1946 m_activeTimeline->projectView()->checkTrackHeight();
1947 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1949 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1950 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1952 // Update list of transcoding profiles
1954 #ifndef NO_JOGSHUTTLE
1955 activateShuttleDevice();
1956 #endif /* NO_JOGSHUTTLE */
1961 void MainWindow::slotSwitchVideoThumbs()
1963 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1964 if (m_activeTimeline) {
1965 m_activeTimeline->projectView()->slotUpdateAllThumbs();
1967 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1970 void MainWindow::slotSwitchAudioThumbs()
1972 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
1973 if (m_activeTimeline) {
1974 m_activeTimeline->refresh();
1975 m_activeTimeline->projectView()->checkAutoScroll();
1976 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1978 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1981 void MainWindow::slotSwitchMarkersComments()
1983 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1984 if (m_activeTimeline) {
1985 m_activeTimeline->refresh();
1987 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1990 void MainWindow::slotSwitchSnap()
1992 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
1993 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1997 void MainWindow::slotDeleteTimelineClip()
1999 if (QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) m_projectList->slotRemoveClip();
2000 else if (m_activeTimeline) {
2001 m_activeTimeline->projectView()->deleteSelectedClips();
2005 void MainWindow::slotChangeClipSpeed()
2007 if (m_activeTimeline) {
2008 m_activeTimeline->projectView()->changeClipSpeed();
2012 void MainWindow::slotAddClipMarker()
2014 DocClipBase *clip = NULL;
2016 if (m_projectMonitor->isActive()) {
2017 if (m_activeTimeline) {
2018 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2020 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
2021 clip = item->baseClip();
2025 clip = m_clipMonitor->activeClip();
2026 pos = m_clipMonitor->position();
2029 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2032 QString id = clip->getId();
2033 CommentedTime marker(pos, i18n("Marker"));
2034 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2035 if (d.exec() == QDialog::Accepted) {
2036 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2038 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2041 void MainWindow::slotDeleteClipMarker()
2043 DocClipBase *clip = NULL;
2045 if (m_projectMonitor->isActive()) {
2046 if (m_activeTimeline) {
2047 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2049 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
2050 clip = item->baseClip();
2054 clip = m_clipMonitor->activeClip();
2055 pos = m_clipMonitor->position();
2058 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2062 QString id = clip->getId();
2063 QString comment = clip->markerComment(pos);
2064 if (comment.isEmpty()) {
2065 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2068 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2069 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2073 void MainWindow::slotDeleteAllClipMarkers()
2075 DocClipBase *clip = NULL;
2076 if (m_projectMonitor->isActive()) {
2077 if (m_activeTimeline) {
2078 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2080 clip = item->baseClip();
2084 clip = m_clipMonitor->activeClip();
2087 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2090 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2091 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2094 void MainWindow::slotEditClipMarker()
2096 DocClipBase *clip = NULL;
2098 if (m_projectMonitor->isActive()) {
2099 if (m_activeTimeline) {
2100 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2102 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
2103 clip = item->baseClip();
2107 clip = m_clipMonitor->activeClip();
2108 pos = m_clipMonitor->position();
2111 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2115 QString id = clip->getId();
2116 QString oldcomment = clip->markerComment(pos);
2117 if (oldcomment.isEmpty()) {
2118 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2122 CommentedTime marker(pos, oldcomment);
2123 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2124 if (d.exec() == QDialog::Accepted) {
2125 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2126 if (d.newMarker().time() != pos) {
2127 // remove old marker
2128 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2130 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2134 void MainWindow::slotAddGuide()
2136 if (m_activeTimeline)
2137 m_activeTimeline->projectView()->slotAddGuide();
2140 void MainWindow::slotInsertSpace()
2142 if (m_activeTimeline)
2143 m_activeTimeline->projectView()->slotInsertSpace();
2146 void MainWindow::slotRemoveSpace()
2148 if (m_activeTimeline)
2149 m_activeTimeline->projectView()->slotRemoveSpace();
2152 void MainWindow::slotInsertTrack(int ix)
2154 m_projectMonitor->activateMonitor();
2155 if (m_activeTimeline)
2156 m_activeTimeline->projectView()->slotInsertTrack(ix);
2159 void MainWindow::slotDeleteTrack(int ix)
2161 m_projectMonitor->activateMonitor();
2162 if (m_activeTimeline)
2163 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2166 void MainWindow::slotChangeTrack(int ix)
2168 m_projectMonitor->activateMonitor();
2169 if (m_activeTimeline)
2170 m_activeTimeline->projectView()->slotChangeTrack(ix);
2173 void MainWindow::slotEditGuide()
2175 if (m_activeTimeline)
2176 m_activeTimeline->projectView()->slotEditGuide();
2179 void MainWindow::slotDeleteGuide()
2181 if (m_activeTimeline)
2182 m_activeTimeline->projectView()->slotDeleteGuide();
2185 void MainWindow::slotDeleteAllGuides()
2187 if (m_activeTimeline)
2188 m_activeTimeline->projectView()->slotDeleteAllGuides();
2191 void MainWindow::slotCutTimelineClip()
2193 if (m_activeTimeline) {
2194 m_activeTimeline->projectView()->cutSelectedClips();
2198 void MainWindow::slotGroupClips()
2200 if (m_activeTimeline) {
2201 m_activeTimeline->projectView()->groupClips();
2205 void MainWindow::slotUnGroupClips()
2207 if (m_activeTimeline) {
2208 m_activeTimeline->projectView()->groupClips(false);
2212 void MainWindow::slotAddProjectClip(KUrl url)
2214 if (m_activeDocument)
2215 m_activeDocument->slotAddClipFile(url, QString());
2218 void MainWindow::slotAddTransition(QAction *result)
2220 if (!result) return;
2221 QStringList info = result->data().toStringList();
2222 if (info.isEmpty()) return;
2223 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2224 if (m_activeTimeline && !transition.isNull()) {
2225 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2229 void MainWindow::slotAddVideoEffect(QAction *result)
2231 if (!result) return;
2232 QStringList info = result->data().toStringList();
2233 if (info.isEmpty()) return;
2234 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2235 slotAddEffect(effect);
2238 void MainWindow::slotAddAudioEffect(QAction *result)
2240 if (!result) return;
2241 QStringList info = result->data().toStringList();
2242 if (info.isEmpty()) return;
2243 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2244 slotAddEffect(effect);
2247 void MainWindow::slotAddCustomEffect(QAction *result)
2249 if (!result) return;
2250 QStringList info = result->data().toStringList();
2251 if (info.isEmpty()) return;
2252 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2253 slotAddEffect(effect);
2256 void MainWindow::slotZoomIn()
2258 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2261 void MainWindow::slotZoomOut()
2263 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2266 void MainWindow::slotFitZoom()
2268 if (m_activeTimeline) {
2269 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2273 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2275 m_statusProgressBar->setValue(progress);
2276 if (progress >= 0) {
2277 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2278 m_statusProgressBar->setVisible(true);
2280 m_messageLabel->setMessage(QString(), DefaultMessage);
2281 m_statusProgressBar->setVisible(false);
2285 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2287 if (clip->clipType() == TEXT) {
2288 QString titlepath = m_activeDocument->projectFolder().path() + "/titles/";
2289 QString path = clip->getProperty("resource");
2290 TitleWidget *dia_ui = new TitleWidget(KUrl(), titlepath, m_projectMonitor->render, this);
2292 doc.setContent(clip->getProperty("xmldata"));
2293 dia_ui->setXml(doc);
2294 if (dia_ui->exec() == QDialog::Accepted) {
2295 QImage pix = dia_ui->renderedPixmap();
2297 //slotAddClipFile(KUrl("/tmp/kdenlivetitle.png"), QString(), -1);
2298 //m_clipManager->slotEditTextClipFile(id, dia_ui->xml().toString());
2299 QMap <QString, QString> newprops;
2300 newprops.insert("xmldata", dia_ui->xml().toString());
2301 newprops.insert("frame_size", QString::number(pix.width()) + 'x' + QString::number(pix.height()));
2302 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2303 m_activeDocument->commandStack()->push(command);
2304 m_clipMonitor->refreshMonitor(true);
2305 m_activeDocument->setModified(true);
2309 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2312 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2313 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2314 if (dia.exec() == QDialog::Accepted) {
2315 EditClipCommand *command = new EditClipCommand(m_projectList, dia.clipId(), clip->properties(), dia.properties(), true);
2316 m_activeDocument->commandStack()->push(command);
2318 //m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
2319 if (dia.needsTimelineRefresh()) {
2320 // update clip occurences in timeline
2321 m_activeTimeline->projectView()->slotUpdateClip(dia.clipId());
2326 void MainWindow::customEvent(QEvent* e)
2328 if (e->type() == QEvent::User) {
2329 // The timeline playing position changed...
2330 kDebug() << "RECEIVED JOG EVEMNT!!!";
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);
2510 void MainWindow::slotSaveZone(Render *render, QPoint zone)
2512 KDialog *dialog = new KDialog(this);
2513 dialog->setCaption("Save clip zone");
2514 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
2516 QWidget *widget = new QWidget(dialog);
2517 dialog->setMainWidget(widget);
2519 QVBoxLayout *vbox = new QVBoxLayout(widget);
2520 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
2521 QString path = m_activeDocument->projectFolder().path();
2523 path.append("untitled.mlt");
2524 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
2525 url->setFilter("video/mlt-playlist");
2526 QLabel *label2 = new QLabel(i18n("Description:"), this);
2527 KLineEdit *edit = new KLineEdit(this);
2528 vbox->addWidget(label1);
2529 vbox->addWidget(url);
2530 vbox->addWidget(label2);
2531 vbox->addWidget(edit);
2532 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
2536 void MainWindow::slotSetInPoint()
2538 if (m_clipMonitor->isActive()) {
2539 m_clipMonitor->slotSetZoneStart();
2540 } else m_activeTimeline->projectView()->setInPoint();
2543 void MainWindow::slotSetOutPoint()
2545 if (m_clipMonitor->isActive()) {
2546 m_clipMonitor->slotSetZoneEnd();
2547 } else m_activeTimeline->projectView()->setOutPoint();
2550 void MainWindow::slotGetNewLumaStuff()
2552 //KNS::Entry::List download();
2553 KNS::Entry::List entries = KNS::Engine::download();
2554 // list of changed entries
2555 kDebug() << "// PARSING KNS";
2556 foreach(KNS::Entry* entry, entries) {
2557 // care only about installed ones
2558 if (entry->status() == KNS::Entry::Installed) {
2559 foreach(const QString &file, entry->installedFiles()) {
2560 kDebug() << "// CURRENTLY INSTALLED: " << file;
2564 qDeleteAll(entries);
2565 initEffects::refreshLumas();
2568 void MainWindow::slotGetNewRenderStuff()
2570 //KNS::Entry::List download();
2572 KNS::Engine engine(0);
2573 if (engine.init("kdenlive_render.knsrc")) {
2574 KNS::Entry::List entries = engine.downloadDialogModal(this);
2576 if (entries.size() > 0) {
2577 foreach(KNS::Entry* entry, entries) {
2578 // care only about installed ones
2579 if (entry->status() == KNS::Entry::Installed) {
2580 foreach(const QString &file, entry->installedFiles()) {
2581 kDebug() << "// CURRENTLY INSTALLED: " << file;
2586 if (m_renderWidget) m_renderWidget->reloadProfiles();
2590 void MainWindow::slotGetNewMltProfileStuff()
2592 //KNS::Entry::List download();
2594 KNS::Engine engine(0);
2595 if (engine.init("kdenlive_mltprofiles.knsrc")) {
2596 KNS::Entry::List entries = engine.downloadDialogModal(this);
2598 if (entries.size() > 0) {
2599 foreach(KNS::Entry* entry, entries) {
2600 // care only about installed ones
2601 if (entry->status() == KNS::Entry::Installed) {
2602 foreach(const QString &file, entry->installedFiles()) {
2603 kDebug() << "// CURRENTLY INSTALLED: " << file;
2608 // update the list of profiles in settings dialog
2609 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2610 if (d) d->checkProfile();
2615 void MainWindow::slotAutoTransition()
2617 if (m_activeTimeline) m_activeTimeline->projectView()->autoTransition();
2620 void MainWindow::slotSplitAudio()
2622 if (m_activeTimeline) m_activeTimeline->projectView()->splitAudio();
2625 void MainWindow::slotUpdateClipType(QAction *action)
2627 if (m_activeTimeline) {
2628 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
2629 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
2630 else m_activeTimeline->projectView()->setAudioAndVideo();
2634 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
2636 DvdWizard *w = new DvdWizard(url, profile, this);
2640 void MainWindow::slotShowTimeline(bool show)
2642 if (show == false) {
2643 m_timelineState = saveState();
2644 centralWidget()->setHidden(true);
2646 centralWidget()->setHidden(false);
2647 restoreState(m_timelineState);
2651 void MainWindow::slotMaximizeCurrent(bool /*show*/)
2653 //TODO: is there a way to maximize current widget?
2656 m_timelineState = saveState();
2657 QWidget *par = focusWidget()->parentWidget();
2658 while (par->parentWidget() && par->parentWidget() != this) {
2659 par = par->parentWidget();
2661 kDebug() << "CURRENT WIDGET: " << par->objectName();
2664 //centralWidget()->setHidden(false);
2665 //restoreState(m_timelineState);
2669 void MainWindow::loadTranscoders()
2671 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
2674 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
2675 KConfigGroup transConfig(config, "Transcoding");
2677 QMap< QString, QString > profiles = transConfig.entryMap();
2678 QMapIterator<QString, QString> i(profiles);
2679 while (i.hasNext()) {
2681 QAction *a = transMenu->addAction(i.key());
2682 a->setData(i.value());
2683 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
2687 void MainWindow::slotTranscode(KUrl::List urls)
2690 if (urls.isEmpty()) {
2691 urls.append(m_projectList->currentClipUrl());
2692 QAction *action = qobject_cast<QAction *>(sender());
2693 params = action->data().toString();
2695 if (urls.isEmpty()) return;
2696 ClipTranscode *d = new ClipTranscode(urls, params);
2697 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
2699 //QProcess::startDetached("ffmpeg", parameters);
2702 void MainWindow::slotTranscodeClip()
2704 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
2705 if (urls.isEmpty()) return;
2706 slotTranscode(urls);
2709 #include "mainwindow.moc"