1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
21 #include "mainwindow.h"
22 #include "mainwindowadaptor.h"
23 #include "kdenlivesettings.h"
24 #include "kdenlivesettingsdialog.h"
25 #include "initeffects.h"
26 #include "profilesdialog.h"
27 #include "projectsettings.h"
29 #include "clipmanager.h"
30 #include "projectlist.h"
32 #include "recmonitor.h"
33 #include "monitormanager.h"
34 #include "kdenlivedoc.h"
35 #include "trackview.h"
36 #include "customtrackview.h"
37 #include "effectslistview.h"
38 #include "effectstackview.h"
39 #include "transitionsettings.h"
40 #include "renderwidget.h"
43 #include "jogshuttle.h"
44 #endif /* NO_JOGSHUTTLE */
45 #include "clipproperties.h"
47 #include "editclipcommand.h"
48 #include "titlewidget.h"
49 #include "markerdialog.h"
51 #include "interfaces.h"
52 #include "kdenlive-config.h"
53 #include "cliptranscode.h"
54 #include "ui_templateclip_ui.h"
56 #include <KApplication>
60 #include <KActionCollection>
61 #include <KStandardAction>
62 #include <KFileDialog>
63 #include <KMessageBox>
65 #include <KIO/NetAccess>
68 #include <KConfigDialog>
69 #include <KXMLGUIFactory>
71 #include <kstandarddirs.h>
72 #include <KUrlRequesterDialog>
73 #include <KTemporaryFile>
75 #include <KActionMenu>
78 #include <ktogglefullscreenaction.h>
80 #include <KNotification>
81 #include <KNotifyConfigWidget>
82 #include <knewstuff2/engine.h>
83 #include <knewstuff2/ui/knewstuffaction.h>
85 #include <QTextStream>
89 #include <QInputDialog>
93 static const char version[] = VERSION;
95 static const int ID_TIMELINE_POS = 0;
102 EffectsList MainWindow::videoEffects;
103 EffectsList MainWindow::audioEffects;
104 EffectsList MainWindow::customEffects;
105 EffectsList MainWindow::transitions;
107 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent) :
108 KXmlGuiWindow(parent),
109 m_activeDocument(NULL),
110 m_activeTimeline(NULL),
111 m_renderWidget(NULL),
112 #ifndef NO_JOGSHUTTLE
114 #endif /* NO_JOGSHUTTLE */
115 m_findActivated(false)
118 // Create DBus interface
119 new MainWindowAdaptor(this);
120 QDBusConnection dbus = QDBusConnection::sessionBus();
121 dbus.registerObject("/MainWindow", this);
123 setlocale(LC_NUMERIC, "POSIX");
124 setFont(KGlobalSettings::toolBarFont());
125 parseProfiles(MltPath);
126 m_commandStack = new QUndoGroup;
127 m_timelineArea = new KTabWidget(this);
128 m_timelineArea->setTabReorderingEnabled(true);
129 m_timelineArea->setTabBarHidden(true);
131 QToolButton *closeTabButton = new QToolButton;
132 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
133 closeTabButton->setIcon(KIcon("tab-close"));
134 closeTabButton->adjustSize();
135 closeTabButton->setToolTip(i18n("Close the current tab"));
136 m_timelineArea->setCornerWidget(closeTabButton);
137 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
139 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
140 m_findTimer.setSingleShot(true);
142 // FIXME: the next call returns a newly allocated object, which leaks
143 initEffects::parseEffectFiles();
144 //initEffects::parseCustomEffectsFile();
146 m_monitorManager = new MonitorManager();
148 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
149 m_projectListDock->setObjectName("project_tree");
150 m_projectList = new ProjectList(this);
151 m_projectListDock->setWidget(m_projectList);
152 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
154 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
155 m_effectListDock->setObjectName("effect_list");
156 m_effectList = new EffectsListView();
158 //m_effectList = new KListWidget(this);
159 m_effectListDock->setWidget(m_effectList);
160 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
162 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
163 m_effectStackDock->setObjectName("effect_stack");
164 m_effectStack = new EffectStackView(this);
165 m_effectStackDock->setWidget(m_effectStack);
166 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
168 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
169 m_transitionConfigDock->setObjectName("transition");
170 m_transitionConfig = new TransitionSettings(this);
171 m_transitionConfigDock->setWidget(m_transitionConfig);
172 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
174 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
175 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
179 slotDetectAudioDriver();
181 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
182 m_clipMonitorDock->setObjectName("clip_monitor");
183 m_clipMonitor = new Monitor("clip", m_monitorManager, this);
184 m_clipMonitorDock->setWidget(m_clipMonitor);
185 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
186 //m_clipMonitor->stop();
188 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
189 m_projectMonitorDock->setObjectName("project_monitor");
190 m_projectMonitor = new Monitor("project", m_monitorManager, this);
191 m_projectMonitorDock->setWidget(m_projectMonitor);
192 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
194 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
195 m_recMonitorDock->setObjectName("record_monitor");
196 m_recMonitor = new RecMonitor("record", this);
197 m_recMonitorDock->setWidget(m_recMonitor);
198 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
200 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
201 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
203 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
204 m_undoViewDock->setObjectName("undo_history");
205 m_undoView = new QUndoView(this);
206 m_undoView->setCleanIcon(KIcon("edit-clear"));
207 m_undoView->setEmptyLabel(i18n("Clean"));
208 m_undoViewDock->setWidget(m_undoView);
209 m_undoView->setGroup(m_commandStack);
210 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
212 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
213 //overviewDock->setObjectName("project_overview");
214 //m_overView = new CustomTrackView(NULL, NULL, this);
215 //overviewDock->setWidget(m_overView);
216 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
219 //tabifyDockWidget(projectListDock, effectListDock);
220 tabifyDockWidget(m_projectListDock, m_effectStackDock);
221 tabifyDockWidget(m_projectListDock, m_transitionConfigDock);
222 //tabifyDockWidget(projectListDock, undoViewDock);
225 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
226 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
227 setCentralWidget(m_timelineArea);
231 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
232 guiFactory()->addClient(sp);*/
236 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
238 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone);
239 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
240 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)), static_cast<QMenu*>(factory()->container("transcoders", this)));
242 // build effects menus
244 QMenu *videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
246 QStringList effectInfo;
247 QMap<QString, QStringList> effectsList;
248 for (int ix = 0; ix < videoEffects.count(); ix++) {
249 effectInfo = videoEffects.effectIdInfo(ix);
250 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
253 foreach(const QStringList &value, effectsList) {
254 action = new QAction(value.at(0), this);
255 action->setData(value);
256 videoEffectsMenu->addAction(action);
259 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
263 for (int ix = 0; ix < audioEffects.count(); ix++) {
264 effectInfo = audioEffects.effectIdInfo(ix);
265 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
268 foreach(const QStringList &value, effectsList) {
269 action = new QAction(value.at(0), this);
270 action->setData(value);
271 audioEffectsMenu->addAction(action);
274 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
276 if (customEffects.isEmpty()) m_customEffectsMenu->setEnabled(false);
277 else m_customEffectsMenu->setEnabled(true);
280 for (int ix = 0; ix < customEffects.count(); ix++) {
281 effectInfo = customEffects.effectIdInfo(ix);
282 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
285 foreach(const QStringList &value, effectsList) {
286 action = new QAction(value.at(0), this);
287 action->setData(value);
288 m_customEffectsMenu->addAction(action);
291 QMenu *newEffect = new QMenu(this);
292 newEffect->addMenu(videoEffectsMenu);
293 newEffect->addMenu(audioEffectsMenu);
294 newEffect->addMenu(m_customEffectsMenu);
295 m_effectStack->setMenu(newEffect);
298 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
299 const QList<QAction *> viewActions = createPopupMenu()->actions();
300 viewMenu->insertActions(NULL, viewActions);
302 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
303 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
304 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
306 m_timelineContextMenu = new QMenu(this);
307 m_timelineContextClipMenu = new QMenu(this);
308 m_timelineContextTransitionMenu = new QMenu(this);
311 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
312 QStringList effects = transitions.effectNames();
315 for (int ix = 0; ix < transitions.count(); ix++) {
316 effectInfo = transitions.effectIdInfo(ix);
317 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
319 foreach(const QStringList &value, effectsList) {
320 action = new QAction(value.at(0), this);
321 action->setData(value);
322 transitionsMenu->addAction(action);
324 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
326 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
327 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
328 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
330 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
331 m_timelineContextClipMenu->addAction(actionCollection()->action("change_clip_speed"));
332 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
333 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
334 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
335 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
336 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
337 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
339 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
340 m_timelineContextClipMenu->addMenu(markersMenu);
341 m_timelineContextClipMenu->addMenu(transitionsMenu);
342 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
343 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
344 //TODO: re-enable custom effects menu when it is implemented
345 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
347 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
348 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
350 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
352 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
353 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
354 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
355 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
356 connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
357 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
359 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
360 slotConnectMonitors();
362 // Open or create a file. Command line argument passed in Url has
363 // precedence, then "openlastproject", then just a plain empty file.
364 // If opening Url fails, openlastproject will _not_ be used.
365 if (!Url.isEmpty()) {
368 if (KdenliveSettings::openlastproject()) {
372 if (m_timelineArea->count() == 0) {
376 #ifndef NO_JOGSHUTTLE
377 activateShuttleDevice();
378 #endif /* NO_JOGSHUTTLE */
379 m_projectListDock->raise();
382 void MainWindow::queryQuit()
384 kDebug() << "----- SAVING CONFUIG";
386 Mlt::Factory::close();
392 bool MainWindow::queryClose()
394 if (m_renderWidget) {
395 int waitingJobs = m_renderWidget->waitingJobsCount();
396 if (waitingJobs > 0) {
397 switch (KMessageBox::warningYesNoCancel(this, i18n("You have %1 rendering jobs waiting in the queue.\nWhat do you want to do with these jobs?", waitingJobs), QString(), KGuiItem(i18n("Start them now")), KGuiItem(i18n("Delete them")))) {
398 case KMessageBox::Yes :
399 // create script with waiting jobs and start it
400 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
402 case KMessageBox::No :
403 // Don't do anything, jobs will be deleted
411 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
412 if (m_activeDocument && m_activeDocument->isModified()) {
413 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
414 case KMessageBox::Yes :
415 // save document here. If saving fails, return false;
417 case KMessageBox::No :
418 // User does not want to save the changes, clear recovery files
419 m_activeDocument->m_autosave->resize(0);
429 void MainWindow::loadPlugins()
431 foreach(QObject *plugin, QPluginLoader::staticInstances())
432 populateMenus(plugin);
434 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
436 filters << "libkdenlive*";
437 foreach(const QString &folder, directories) {
438 kDebug() << "// PARSING FIOLER: " << folder;
439 QDir pluginsDir(folder);
440 foreach(const QString &fileName, pluginsDir.entryList(filters, QDir::Files)) {
441 kDebug() << "// FOUND PLUGIN: " << fileName << "= " << pluginsDir.absoluteFilePath(fileName);
442 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
443 QObject *plugin = loader.instance();
445 populateMenus(plugin);
446 m_pluginFileNames += fileName;
447 } else kDebug() << "// ERROR LOADING PLUGIN: " << fileName << ", " << loader.errorString();
453 void MainWindow::populateMenus(QObject *plugin)
455 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
456 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
458 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
462 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
463 QMenu *menu, const char *member,
464 QActionGroup *actionGroup)
466 kDebug() << "// ADD to MENU" << texts;
467 foreach(const QString &text, texts) {
468 QAction *action = new QAction(text, plugin);
469 action->setData(text);
470 connect(action, SIGNAL(triggered()), this, member);
471 menu->addAction(action);
474 action->setCheckable(true);
475 actionGroup->addAction(action);
480 void MainWindow::aboutPlugins()
482 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
487 void MainWindow::generateClip()
489 QAction *action = qobject_cast<QAction *>(sender());
490 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
492 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(), QStringList(), QStringList(), 25, 720, 576);
493 if (!clipUrl.isEmpty()) {
494 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
498 void MainWindow::saveProperties(KConfigGroup &config)
500 // save properties here,used by session management
502 KMainWindow::saveProperties(config);
506 void MainWindow::readProperties(const KConfigGroup &config)
508 // read properties here,used by session management
509 KMainWindow::readProperties(config);
510 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
511 openFile(KUrl(Lastproject));
514 void MainWindow::slotReloadEffects()
516 initEffects::parseCustomEffectsFile();
517 m_customEffectsMenu->clear();
518 const QStringList effects = customEffects.effectNames();
520 if (effects.isEmpty()) m_customEffectsMenu->setEnabled(false);
521 else m_customEffectsMenu->setEnabled(true);
523 foreach(const QString &name, effects) {
524 action = new QAction(name, this);
525 action->setData(name);
526 m_customEffectsMenu->addAction(action);
528 m_effectList->reloadEffectList();
531 #ifndef NO_JOGSHUTTLE
532 void MainWindow::activateShuttleDevice()
536 if (KdenliveSettings::enableshuttle() == false) return;
537 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
538 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
539 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
540 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
541 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
542 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
543 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
546 void MainWindow::slotShuttleButton(int code)
550 slotShuttleAction(KdenliveSettings::shuttle1());
553 slotShuttleAction(KdenliveSettings::shuttle2());
556 slotShuttleAction(KdenliveSettings::shuttle3());
559 slotShuttleAction(KdenliveSettings::shuttle4());
562 slotShuttleAction(KdenliveSettings::shuttle5());
567 void MainWindow::slotShuttleAction(int code)
573 m_monitorManager->slotPlay();
576 m_monitorManager->slotPlay();
580 #endif /* NO_JOGSHUTTLE */
582 void MainWindow::configureNotifications()
584 KNotifyConfigWidget::configure(this);
587 void MainWindow::slotFullScreen()
589 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
592 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track)
594 if (!m_activeDocument) return;
595 if (effect.isNull()) {
596 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
599 m_activeTimeline->projectView()->slotAddEffect(effect.cloneNode().toElement(), pos, track);
602 void MainWindow::slotRaiseMonitor(bool clipMonitor)
604 if (clipMonitor) m_clipMonitorDock->raise();
605 else m_projectMonitorDock->raise();
608 void MainWindow::slotUpdateClip(const QString &id)
610 if (!m_activeDocument) return;
611 m_activeTimeline->projectView()->slotUpdateClip(id);
614 void MainWindow::slotConnectMonitors()
617 m_projectList->setRenderer(m_projectMonitor->render);
618 connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
619 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
620 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, const QString &, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement &, const QString &, bool)));
621 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
622 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)));
624 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
626 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
628 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
629 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
631 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
632 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
635 void MainWindow::slotAdjustClipMonitor()
637 m_clipMonitorDock->updateGeometry();
638 m_clipMonitorDock->adjustSize();
639 m_clipMonitor->resetSize();
642 void MainWindow::slotAdjustProjectMonitor()
644 m_projectMonitorDock->updateGeometry();
645 m_projectMonitorDock->adjustSize();
646 m_projectMonitor->resetSize();
649 void MainWindow::setupActions()
652 KActionCollection* collection = actionCollection();
653 m_timecodeFormat = new KComboBox(this);
654 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
655 m_timecodeFormat->addItem(i18n("Frames"));
657 m_statusProgressBar = new QProgressBar(this);
658 m_statusProgressBar->setMinimum(0);
659 m_statusProgressBar->setMaximum(100);
660 m_statusProgressBar->setMaximumWidth(150);
661 m_statusProgressBar->setVisible(false);
663 QWidget *w = new QWidget;
665 QHBoxLayout *layout = new QHBoxLayout;
666 w->setLayout(layout);
667 layout->setContentsMargins(5, 0, 5, 0);
668 QToolBar *toolbar = new QToolBar("statusToolBar", this);
671 m_toolGroup = new QActionGroup(this);
673 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;}";
675 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
676 toolbar->addAction(m_buttonSelectTool);
677 m_buttonSelectTool->setCheckable(true);
678 m_buttonSelectTool->setChecked(true);
680 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
681 toolbar->addAction(m_buttonRazorTool);
682 m_buttonRazorTool->setCheckable(true);
683 m_buttonRazorTool->setChecked(false);
685 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
686 toolbar->addAction(m_buttonSpacerTool);
687 m_buttonSpacerTool->setCheckable(true);
688 m_buttonSpacerTool->setChecked(false);
690 m_toolGroup->addAction(m_buttonSelectTool);
691 m_toolGroup->addAction(m_buttonRazorTool);
692 m_toolGroup->addAction(m_buttonSpacerTool);
693 m_toolGroup->setExclusive(true);
694 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
696 QWidget * actionWidget;
697 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
698 actionWidget->setMaximumWidth(24);
699 actionWidget->setMinimumHeight(18);
701 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
702 actionWidget->setMaximumWidth(24);
703 actionWidget->setMinimumHeight(18);
705 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
706 actionWidget->setMaximumWidth(24);
707 actionWidget->setMinimumHeight(18);
709 toolbar->setStyleSheet(style1);
710 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
712 toolbar->addSeparator();
713 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
714 toolbar->addAction(m_buttonFitZoom);
715 m_buttonFitZoom->setCheckable(false);
716 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
718 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
719 actionWidget->setMaximumWidth(24);
720 actionWidget->setMinimumHeight(18);
722 m_zoomSlider = new QSlider(Qt::Horizontal, this);
723 m_zoomSlider->setMaximum(13);
724 m_zoomSlider->setPageStep(1);
726 m_zoomSlider->setMaximumWidth(150);
727 m_zoomSlider->setMinimumWidth(100);
729 const int contentHeight = QFontMetrics(w->font()).height() + 8;
731 QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
732 style.append("QSlider::handle:horizontal { background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
734 m_zoomSlider->setStyleSheet(style);
736 //m_zoomSlider->height() + 5;
737 statusBar()->setMinimumHeight(contentHeight);
740 toolbar->addWidget(m_zoomSlider);
742 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
743 toolbar->addAction(m_buttonVideoThumbs);
744 m_buttonVideoThumbs->setCheckable(true);
745 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
746 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
748 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
749 toolbar->addAction(m_buttonAudioThumbs);
750 m_buttonAudioThumbs->setCheckable(true);
751 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
752 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
754 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
755 toolbar->addAction(m_buttonShowMarkers);
756 m_buttonShowMarkers->setCheckable(true);
757 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
758 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
760 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
761 toolbar->addAction(m_buttonSnap);
762 m_buttonSnap->setCheckable(true);
763 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
764 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
765 layout->addWidget(toolbar);
768 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
769 actionWidget->setMaximumWidth(24);
770 actionWidget->setMinimumHeight(18);
772 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
773 actionWidget->setMaximumWidth(24);
774 actionWidget->setMinimumHeight(18);
776 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
777 actionWidget->setMaximumWidth(24);
778 actionWidget->setMinimumHeight(18);
780 actionWidget = toolbar->widgetForAction(m_buttonSnap);
781 actionWidget->setMaximumWidth(24);
782 actionWidget->setMinimumHeight(18);
784 m_messageLabel = new StatusBarMessageLabel(this);
785 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
787 statusBar()->addWidget(m_messageLabel, 10);
788 statusBar()->addWidget(m_statusProgressBar, 0);
789 statusBar()->addPermanentWidget(w);
790 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
791 statusBar()->addPermanentWidget(m_timecodeFormat);
792 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
793 m_messageLabel->hide();
795 collection->addAction("select_tool", m_buttonSelectTool);
796 collection->addAction("razor_tool", m_buttonRazorTool);
797 collection->addAction("spacer_tool", m_buttonSpacerTool);
799 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
800 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
801 collection->addAction("show_markers", m_buttonShowMarkers);
802 collection->addAction("snap", m_buttonSnap);
803 collection->addAction("zoom_fit", m_buttonFitZoom);
805 KAction* zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
806 collection->addAction("zoom_in", zoomIn);
807 connect(zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
808 zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
810 KAction* zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
811 collection->addAction("zoom_out", zoomOut);
812 connect(zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
813 zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
815 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
816 collection->addAction("project_find", m_projectSearch);
817 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
818 m_projectSearch->setShortcut(Qt::Key_Slash);
820 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
821 collection->addAction("project_find_next", m_projectSearchNext);
822 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
823 m_projectSearchNext->setShortcut(Qt::Key_F3);
824 m_projectSearchNext->setEnabled(false);
826 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
827 collection->addAction("manage_profiles", profilesAction);
828 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
830 KNS::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
832 KNS::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
834 KNS::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
836 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
837 collection->addAction("run_wizard", wizAction);
838 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
840 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
841 collection->addAction("project_settings", projectAction);
842 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
844 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
845 collection->addAction("project_render", projectRender);
846 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
847 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
849 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
850 KShortcut playShortcut;
851 playShortcut.setPrimary(Qt::Key_Space);
852 playShortcut.setAlternate(Qt::Key_K);
853 monitorPlay->setShortcut(playShortcut);
854 collection->addAction("monitor_play", monitorPlay);
855 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
857 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
858 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
859 collection->addAction("monitor_play_zone", m_playZone);
860 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
862 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
863 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
864 collection->addAction("monitor_loop_zone", m_loopZone);
865 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
867 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
868 collection->addAction("dvd_wizard", dvdWizard);
869 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
871 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clip"), this);
872 collection->addAction("transcode_clip", transcodeClip);
873 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
875 KAction *markIn = collection->addAction("mark_in");
876 markIn->setText(i18n("Set In Point"));
877 markIn->setShortcut(Qt::Key_I);
878 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
880 KAction *markOut = collection->addAction("mark_out");
881 markOut->setText(i18n("Set Out Point"));
882 markOut->setShortcut(Qt::Key_O);
883 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
885 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
886 monitorSeekBackward->setShortcut(Qt::Key_J);
887 collection->addAction("monitor_seek_backward", monitorSeekBackward);
888 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
890 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
891 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
892 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
893 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
895 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
896 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
897 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
898 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
900 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
901 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
902 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
903 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
905 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
906 monitorSeekForward->setShortcut(Qt::Key_L);
907 collection->addAction("monitor_seek_forward", monitorSeekForward);
908 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
910 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
911 clipStart->setShortcut(Qt::Key_Home);
912 collection->addAction("seek_clip_start", clipStart);
913 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
915 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
916 clipEnd->setShortcut(Qt::Key_End);
917 collection->addAction("seek_clip_end", clipEnd);
918 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
920 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
921 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
922 collection->addAction("seek_start", projectStart);
923 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
925 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
926 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
927 collection->addAction("seek_end", projectEnd);
928 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
930 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
931 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
932 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
933 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
935 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
936 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
937 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
938 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
940 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
941 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
942 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
943 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
945 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
946 deleteTimelineClip->setShortcut(Qt::Key_Delete);
947 collection->addAction("delete_timeline_clip", deleteTimelineClip);
948 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
950 KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
951 collection->addAction("change_clip_speed", editTimelineClipSpeed);
952 editTimelineClipSpeed->setData("change_speed");
953 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));
955 KAction *stickTransition = collection->addAction("auto_transition");
956 stickTransition->setData(QString("auto"));
957 stickTransition->setCheckable(true);
958 stickTransition->setEnabled(false);
959 stickTransition->setText(i18n("Automatic Transition"));
960 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
962 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
963 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
964 collection->addAction("group_clip", groupClip);
965 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
967 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
968 collection->addAction("ungroup_clip", ungroupClip);
969 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
970 ungroupClip->setData("ungroup_clip");
971 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
973 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
974 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
975 collection->addAction("cut_timeline_clip", cutTimelineClip);
976 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
978 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
979 collection->addAction("add_clip_marker", addClipMarker);
980 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
982 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
983 collection->addAction("delete_clip_marker", deleteClipMarker);
984 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
986 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
987 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
988 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
990 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
991 collection->addAction("edit_clip_marker", editClipMarker);
992 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
994 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
995 collection->addAction("split_audio", splitAudio);
996 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
998 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
999 collection->addAction("clip_audio_only", audioOnly);
1000 audioOnly->setData("clip_audio_only");
1001 audioOnly->setCheckable(true);
1003 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1004 collection->addAction("clip_video_only", videoOnly);
1005 videoOnly->setData("clip_video_only");
1006 videoOnly->setCheckable(true);
1008 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1009 collection->addAction("clip_audio_and_video", audioAndVideo);
1010 audioAndVideo->setData("clip_audio_and_video");
1011 audioAndVideo->setCheckable(true);
1013 m_clipTypeGroup = new QActionGroup(this);
1014 m_clipTypeGroup->addAction(audioOnly);
1015 m_clipTypeGroup->addAction(videoOnly);
1016 m_clipTypeGroup->addAction(audioAndVideo);
1017 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1018 m_clipTypeGroup->setEnabled(false);
1020 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1021 collection->addAction("insert_space", insertSpace);
1022 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1024 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1025 collection->addAction("delete_space", removeSpace);
1026 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1028 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1029 collection->addAction("insert_track", insertTrack);
1030 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1032 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1033 collection->addAction("delete_track", deleteTrack);
1034 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1036 KAction *changeTrack = new KAction(KIcon(), i18n("Change Track"), this);
1037 collection->addAction("change_track", changeTrack);
1038 connect(changeTrack, SIGNAL(triggered()), this, SLOT(slotChangeTrack()));
1040 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1041 collection->addAction("add_guide", addGuide);
1042 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1044 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1045 collection->addAction("delete_guide", delGuide);
1046 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1048 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1049 collection->addAction("edit_guide", editGuide);
1050 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1052 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1053 collection->addAction("delete_all_guides", delAllGuides);
1054 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1056 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1057 collection->addAction("paste_effects", pasteEffects);
1058 pasteEffects->setData("paste_effects");
1059 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1061 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1062 collection->addAction("show_timeline", showTimeline);
1063 showTimeline->setCheckable(true);
1064 showTimeline->setChecked(true);
1065 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1067 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1068 collection->addAction("maximize_current", maxCurrent);
1069 maxCurrent->setCheckable(true);
1070 maxCurrent->setChecked(false);
1071 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1074 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1076 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1078 KStandardAction::open(this, SLOT(openFile()), collection);
1080 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1082 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1084 KStandardAction::openNew(this, SLOT(newFile()), collection);
1086 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1088 KStandardAction::configureNotifications(this , SLOT(configureNotifications()), collection);
1090 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1092 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1094 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1095 undo->setEnabled(false);
1096 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1098 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1099 redo->setEnabled(false);
1100 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1102 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1105 //TODO: Add status tooltip to actions ?
1106 connect(collection, SIGNAL(actionHovered(QAction*)),
1107 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1110 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1111 collection->addAction("add_clip", addClip);
1112 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1114 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1115 collection->addAction("add_color_clip", addColorClip);
1116 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1118 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1119 collection->addAction("add_slide_clip", addSlideClip);
1120 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1122 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1123 collection->addAction("add_text_clip", addTitleClip);
1124 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1126 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1127 collection->addAction("add_text_template_clip", addTitleTemplateClip);
1128 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1130 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1131 collection->addAction("add_folder", addFolderButton);
1132 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1134 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1135 collection->addAction("clip_properties", clipProperties);
1136 clipProperties->setData("clip_properties");
1137 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1138 clipProperties->setEnabled(false);
1140 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1141 collection->addAction("edit_clip", openClip);
1142 openClip->setData("edit_clip");
1143 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1144 openClip->setEnabled(false);
1146 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1147 collection->addAction("delete_clip", deleteClip);
1148 deleteClip->setData("delete_clip");
1149 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1150 deleteClip->setEnabled(false);
1152 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1153 collection->addAction("reload_clip", reloadClip);
1154 reloadClip->setData("reload_clip");
1155 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1156 reloadClip->setEnabled(false);
1158 QMenu *addClips = new QMenu();
1159 addClips->addAction(addClip);
1160 addClips->addAction(addColorClip);
1161 addClips->addAction(addSlideClip);
1162 addClips->addAction(addTitleClip);
1163 addClips->addAction(addTitleTemplateClip);
1164 addClips->addAction(addFolderButton);
1166 addClips->addAction(reloadClip);
1167 addClips->addAction(clipProperties);
1168 addClips->addAction(openClip);
1169 addClips->addAction(deleteClip);
1170 m_projectList->setupMenu(addClips, addClip);
1172 //connect(collection, SIGNAL( clearStatusText() ),
1173 //statusBar(), SLOT( clear() ) );
1176 void MainWindow::slotDisplayActionMessage(QAction *a)
1178 statusBar()->showMessage(a->data().toString(), 3000);
1181 void MainWindow::saveOptions()
1183 KdenliveSettings::self()->writeConfig();
1184 KSharedConfigPtr config = KGlobal::config();
1185 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1186 KConfigGroup treecolumns(config, "Project Tree");
1187 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1191 void MainWindow::readOptions()
1193 KSharedConfigPtr config = KGlobal::config();
1194 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1195 KConfigGroup initialGroup(config, "version");
1196 bool upgrade = false;
1197 if (initialGroup.exists()) {
1198 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0))
1201 if (initialGroup.readEntry("version") == "0.7") {
1202 //Add new settings from 0.7.1
1203 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1204 QString path = QDir::homePath() + "/kdenlive";
1205 if (KStandardDirs::makeDir(path) == false) kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1206 KdenliveSettings::setDefaultprojectfolder(path);
1212 if (!initialGroup.exists() || upgrade) {
1213 // this is our first run, show Wizard
1214 Wizard *w = new Wizard(upgrade, this);
1215 if (w->exec() == QDialog::Accepted && w->isOk()) {
1216 w->adjustSettings();
1217 initialGroup.writeEntry("version", version);
1223 KConfigGroup treecolumns(config, "Project Tree");
1224 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1225 if (!state.isEmpty())
1226 m_projectList->setHeaderInfo(state);
1229 void MainWindow::slotRunWizard()
1231 Wizard *w = new Wizard(false, this);
1232 if (w->exec() == QDialog::Accepted && w->isOk()) {
1233 w->adjustSettings();
1238 void MainWindow::newFile(bool showProjectSettings)
1240 QString profileName;
1242 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1243 if (!showProjectSettings && m_timelineArea->count() == 0) {
1244 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1245 profileName = KdenliveSettings::default_profile();
1246 projectFolder = KdenliveSettings::defaultprojectfolder();
1248 ProjectSettings *w = new ProjectSettings(projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, this);
1249 if (w->exec() != QDialog::Accepted) return;
1250 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1251 KdenliveSettings::setVideothumbnails(w->enableVideoThumbs());
1252 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1253 KdenliveSettings::setAudiothumbnails(w->enableAudioThumbs());
1254 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1255 profileName = w->selectedProfile();
1256 projectFolder = w->selectedFolder();
1257 projectTracks = w->tracks();
1260 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1261 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1262 TrackView *trackView = new TrackView(doc, this);
1263 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1264 if (m_timelineArea->count() == 1) {
1265 connectDocumentInfo(doc);
1266 connectDocument(trackView, doc);
1267 } else m_timelineArea->setTabBarHidden(false);
1268 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1271 void MainWindow::activateDocument()
1273 if (m_timelineArea->currentWidget() == NULL) return;
1274 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1275 KdenliveDoc *currentDoc = currentTab->document();
1276 connectDocumentInfo(currentDoc);
1277 connectDocument(currentTab, currentDoc);
1280 void MainWindow::closeCurrentDocument()
1282 QWidget *w = m_timelineArea->currentWidget();
1284 // closing current document
1285 int ix = m_timelineArea->currentIndex() + 1;
1286 if (ix == m_timelineArea->count()) ix = 0;
1287 m_timelineArea->setCurrentIndex(ix);
1288 TrackView *tabToClose = (TrackView *) w;
1289 KdenliveDoc *docToClose = tabToClose->document();
1290 if (docToClose && docToClose->isModified()) {
1291 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
1292 case KMessageBox::Yes :
1293 // save document here. If saving fails, return false;
1294 if (saveFile() == false) return;
1296 case KMessageBox::Cancel :
1303 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1304 if (m_timelineArea->count() == 1) {
1305 m_timelineArea->setTabBarHidden(true);
1306 m_closeAction->setEnabled(false);
1308 if (docToClose == m_activeDocument) {
1309 delete m_activeDocument;
1310 m_activeDocument = NULL;
1311 m_effectStack->clear();
1312 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1313 } else delete docToClose;
1314 if (w == m_activeTimeline) {
1315 delete m_activeTimeline;
1316 m_activeTimeline = NULL;
1320 bool MainWindow::saveFileAs(const QString &outputFileName)
1322 QString currentSceneList;
1323 if (KdenliveSettings::dropbframes()) {
1324 KdenliveSettings::setDropbframes(false);
1325 m_activeDocument->clipManager()->updatePreviewSettings();
1326 currentSceneList = m_projectMonitor->sceneList();
1327 KdenliveSettings::setDropbframes(true);
1328 m_activeDocument->clipManager()->updatePreviewSettings();
1329 } else currentSceneList = m_projectMonitor->sceneList();
1331 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1334 // Save timeline thumbnails
1335 m_activeTimeline->projectView()->saveThumbnails();
1336 m_activeDocument->setUrl(KUrl(outputFileName));
1337 if (m_activeDocument->m_autosave == NULL) {
1338 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1339 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1340 setCaption(m_activeDocument->description());
1341 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1342 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1343 m_activeDocument->setModified(false);
1344 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1348 bool MainWindow::saveFileAs()
1350 // Check that the Kdenlive mime type is correctly installed
1351 QString mimetype = "application/x-kdenlive";
1352 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1353 if (!mime) mimetype = "*.kdenlive";
1355 QString outputFile = KFileDialog::getSaveFileName(KUrl(), mimetype);
1356 if (outputFile.isEmpty()) return false;
1357 if (QFile::exists(outputFile)) {
1358 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it?")) == KMessageBox::No) return false;
1360 return saveFileAs(outputFile);
1363 bool MainWindow::saveFile()
1365 if (!m_activeDocument) return true;
1366 if (m_activeDocument->url().isEmpty()) {
1367 return saveFileAs();
1369 bool result = saveFileAs(m_activeDocument->url().path());
1370 m_activeDocument->m_autosave->resize(0);
1375 void MainWindow::openFile()
1377 // Check that the Kdenlive mime type is correctly installed
1378 QString mimetype = "application/x-kdenlive";
1379 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1380 if (!mime) mimetype = "*.kdenlive";
1382 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), mimetype);
1383 if (url.isEmpty()) return;
1384 m_fileOpenRecent->addUrl(url);
1388 void MainWindow::openLastFile()
1390 KSharedConfigPtr config = KGlobal::config();
1391 KUrl::List urls = m_fileOpenRecent->urls();
1392 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1393 if (urls.isEmpty()) newFile(false);
1394 else openFile(urls.last());
1397 void MainWindow::openFile(const KUrl &url)
1399 // Check if the document is already opened
1400 const int ct = m_timelineArea->count();
1401 bool isOpened = false;
1403 for (i = 0; i < ct; i++) {
1404 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1405 KdenliveDoc *doc = tab->document();
1406 if (doc->url() == url) {
1412 m_timelineArea->setCurrentIndex(i);
1416 // Check for backup file
1417 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1418 if (!staleFiles.isEmpty()) {
1419 if (KMessageBox::questionYesNo(this,
1420 i18n("Auto-saved files exist. Do you want to recover them now?"),
1421 i18n("File Recovery"),
1422 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1423 recoverFiles(staleFiles);
1426 // remove the stale files
1427 foreach(KAutoSaveFile *stale, staleFiles) {
1428 stale->open(QIODevice::ReadWrite);
1433 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1434 doOpenFile(url, NULL);
1437 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1439 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, this);
1440 if (stale == NULL) {
1441 stale = new KAutoSaveFile(url, doc);
1442 doc->m_autosave = stale;
1444 doc->m_autosave = stale;
1445 doc->setUrl(stale->managedFile());
1446 doc->setModified(true);
1447 stale->setParent(doc);
1449 connectDocumentInfo(doc);
1450 TrackView *trackView = new TrackView(doc, this);
1451 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1452 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1453 trackView->setDuration(trackView->duration());
1454 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1456 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1457 slotGotProgressInfo(QString(), -1);
1458 m_clipMonitor->refreshMonitor(true);
1459 m_projectMonitor->adjustRulerSize(trackView->duration());
1460 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1463 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1465 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1466 foreach(KAutoSaveFile *stale, staleFiles) {
1467 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1468 // show an error message; we could not steal the lockfile
1469 // maybe another application got to the file before us?
1473 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1474 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
1475 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1476 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1481 void MainWindow::parseProfiles(const QString &mltPath)
1483 // kDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
1485 //KdenliveSettings::setDefaulttmpfolder();
1486 if (!mltPath.isEmpty()) {
1487 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1488 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
1491 if (KdenliveSettings::mltpath().isEmpty()) {
1492 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1494 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
1495 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
1496 if (!QFile::exists(meltPath))
1497 meltPath = KStandardDirs::findExe("melt");
1498 KdenliveSettings::setRendererpath(meltPath);
1500 QStringList profilesFilter;
1501 profilesFilter << "*";
1502 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1504 if (profilesList.isEmpty()) {
1505 // Cannot find MLT path, try finding melt
1506 QString profilePath = KdenliveSettings::rendererpath();
1507 if (!profilePath.isEmpty()) {
1508 profilePath = profilePath.section('/', 0, -3);
1509 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1510 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1513 if (profilesList.isEmpty()) {
1514 // Cannot find the MLT profiles, ask for location
1515 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1516 getUrl->fileDialog()->setMode(KFile::Directory);
1517 if (getUrl->exec() == QDialog::Rejected) {
1520 KUrl mltPath = getUrl->selectedUrl();
1522 if (mltPath.isEmpty()) ::exit(0);
1523 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
1524 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1528 if (KdenliveSettings::rendererpath().isEmpty()) {
1529 // Cannot find the MLT melt renderer, ask for location
1530 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of Mlt)"), this);
1531 if (getUrl->exec() == QDialog::Rejected) {
1534 KUrl rendererPath = getUrl->selectedUrl();
1536 if (rendererPath.isEmpty()) ::exit(0);
1537 KdenliveSettings::setRendererpath(rendererPath.path());
1540 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1542 // Parse MLT profiles to build a list of available video formats
1543 if (profilesList.isEmpty()) parseProfiles();
1547 void MainWindow::slotEditProfiles()
1549 ProfilesDialog *w = new ProfilesDialog;
1550 if (w->exec() == QDialog::Accepted) {
1551 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1552 if (d) d->checkProfile();
1557 void MainWindow::slotDetectAudioDriver()
1559 //decide which audio driver is really best, in some cases SDL is wrong
1560 if (KdenliveSettings::audiodrivername().isEmpty()) {
1562 KProcess readProcess;
1563 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
1564 if (!KStandardDirs::findExe("pactl").isEmpty()) {
1565 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
1566 readProcess.setProgram("pactl", QStringList() << "stat");
1567 readProcess.execute(2000); // Kill it after 2 seconds
1569 QString result = QString(readProcess.readAllStandardOutput());
1570 kDebug() << "// / / / / / READING PACTL: ";
1572 if (!result.isEmpty()) {
1574 kDebug() << "// / / / / PULSEAUDIO DETECTED";
1578 KdenliveSettings::setAutoaudiodrivername(driver);
1582 void MainWindow::slotEditProjectSettings()
1584 QPoint p = m_activeDocument->getTracksCount();
1585 ProjectSettings *w = new ProjectSettings(p.x(), p.y(), m_activeDocument->projectFolder().path(), true, this);
1587 if (w->exec() == QDialog::Accepted) {
1588 QString profile = w->selectedProfile();
1589 m_activeDocument->setProjectFolder(w->selectedFolder());
1590 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path(KUrl::AddTrailingSlash));
1591 if (m_activeDocument->profilePath() != profile) {
1592 // Profile was changed
1593 double dar = m_activeDocument->dar();
1594 m_activeDocument->setProfilePath(profile);
1595 KdenliveSettings::setCurrent_profile(profile);
1596 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1597 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1598 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1599 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1600 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1601 m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1602 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
1603 // We need to desactivate & reactivate monitors to get a refresh
1604 m_monitorManager->switchMonitors();
1610 void MainWindow::slotRenderProject()
1612 if (!m_renderWidget) {
1613 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
1614 m_renderWidget = new RenderWidget(projectfolder, this);
1615 connect(m_renderWidget, SIGNAL(selectedRenderProfile(const QString &, const QString &)), this, SLOT(slotSetDocumentRenderProfile(const QString &, const QString &)));
1616 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
1617 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1618 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1619 if (m_activeDocument) {
1620 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1621 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1622 m_renderWidget->setRenderProfile(m_activeDocument->getDocumentProperty("renderdestination"), m_activeDocument->getDocumentProperty("renderprofile"));
1623 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
1626 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1627 if (currentTab) m_renderWidget->setTimeline(currentTab);
1628 m_renderWidget->setDocument(m_activeDocument);*/
1629 m_renderWidget->show();
1630 m_renderWidget->showNormal();
1633 void MainWindow::setRenderingProgress(const QString &url, int progress)
1635 if (m_renderWidget) m_renderWidget->setRenderJob(url, progress);
1638 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
1640 if (m_renderWidget) m_renderWidget->setRenderStatus(url, status, error);
1643 void MainWindow::slotUpdateMousePosition(int pos)
1645 if (m_activeDocument)
1646 switch (m_timecodeFormat->currentIndex()) {
1648 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1651 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1655 void MainWindow::slotUpdateDocumentState(bool modified)
1657 if (!m_activeDocument) return;
1658 setCaption(m_activeDocument->description(), modified);
1659 m_saveAction->setEnabled(modified);
1661 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1662 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1664 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1665 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1669 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
1671 if (m_activeDocument) {
1672 if (m_activeDocument == doc) return;
1673 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1675 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1678 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
1680 //m_projectMonitor->stop();
1681 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1682 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1683 if (m_activeDocument) {
1684 if (m_activeDocument == doc) return;
1685 if (m_activeTimeline) {
1686 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1687 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1688 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1689 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1690 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
1693 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1694 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1695 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1696 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1697 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1698 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1699 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1700 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1701 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1702 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
1703 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1704 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1705 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1706 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1707 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1708 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1709 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1710 disconnect(m_activeTimeline, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1711 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1712 disconnect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1713 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1714 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1715 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1716 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1717 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1718 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1719 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
1720 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1721 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1722 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
1723 m_effectStack->clear();
1725 //m_activeDocument->setRenderer(NULL);
1726 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1727 disconnect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
1728 m_clipMonitor->stop();
1730 KdenliveSettings::setCurrent_profile(doc->profilePath());
1731 KdenliveSettings::setProject_fps(doc->fps());
1732 m_monitorManager->resetProfiles(doc->timecode());
1733 m_projectList->setDocument(doc);
1734 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), trackView->tracksNumber());
1735 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
1736 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1737 connect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
1738 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1739 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
1742 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1743 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1744 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1745 connect(trackView, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1746 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1747 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1748 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1749 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1750 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
1751 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1752 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1753 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1754 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1755 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1757 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1758 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1759 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1762 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1763 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1764 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
1765 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1766 m_zoomSlider->setValue(doc->zoom().x());
1767 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1768 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1769 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1770 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1772 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1775 connect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1776 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1777 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1778 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1779 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1780 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1781 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1782 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1784 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1785 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1786 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
1788 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup);
1789 m_activeTimeline = trackView;
1790 if (m_renderWidget) {
1791 m_renderWidget->setProfile(doc->mltProfile());
1792 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
1793 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
1794 m_renderWidget->setRenderProfile(doc->getDocumentProperty("renderdestination"), doc->getDocumentProperty("renderprofile"));
1796 //doc->setRenderer(m_projectMonitor->render);
1797 m_commandStack->setActiveStack(doc->commandStack());
1798 KdenliveSettings::setProject_display_ratio(doc->dar());
1799 m_projectList->updateAllClips();
1800 //doc->clipManager()->checkAudioThumbs();
1802 //m_overView->setScene(trackView->projectScene());
1803 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1804 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1806 setCaption(doc->description(), doc->isModified());
1807 m_saveAction->setEnabled(doc->isModified());
1808 m_activeDocument = doc;
1809 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
1811 // set tool to select tool
1812 m_buttonSelectTool->setChecked(true);
1815 void MainWindow::slotZoneMoved(int start, int end)
1817 m_activeDocument->setZone(start, end);
1818 m_projectMonitor->slotZoneMoved(start, end);
1821 void MainWindow::slotGuidesUpdated()
1823 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1826 void MainWindow::slotPreferences(int page, int option)
1828 //An instance of your dialog could be already created and could be
1829 // cached, in which case you want to display the cached dialog
1830 // instead of creating another one
1831 if (KConfigDialog::showDialog("settings")) {
1832 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1833 if (page != -1) d->showPage(page, option);
1837 // KConfigDialog didn't find an instance of this dialog, so lets
1839 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1840 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1841 connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
1842 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1843 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1844 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
1845 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1847 if (page != -1) dialog->showPage(page, option);
1850 void MainWindow::slotUpdatePreviewSettings()
1852 if (m_activeDocument) {
1853 m_clipMonitor->slotSetXml(NULL, 0);
1854 m_activeDocument->updatePreviewSettings();
1858 void MainWindow::updateConfiguration()
1860 //TODO: we should apply settings to all projects, not only the current one
1861 if (m_activeTimeline) {
1862 m_activeTimeline->refresh();
1863 m_activeTimeline->projectView()->checkAutoScroll();
1864 m_activeTimeline->projectView()->checkTrackHeight();
1865 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1867 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1868 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1870 // Update list of transcoding profiles
1872 #ifndef NO_JOGSHUTTLE
1873 activateShuttleDevice();
1874 #endif /* NO_JOGSHUTTLE */
1879 void MainWindow::slotSwitchVideoThumbs()
1881 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1882 if (m_activeTimeline) {
1883 m_activeTimeline->projectView()->slotUpdateAllThumbs();
1885 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1888 void MainWindow::slotSwitchAudioThumbs()
1890 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
1891 if (m_activeTimeline) {
1892 m_activeTimeline->refresh();
1893 m_activeTimeline->projectView()->checkAutoScroll();
1894 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1896 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1899 void MainWindow::slotSwitchMarkersComments()
1901 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1902 if (m_activeTimeline) {
1903 m_activeTimeline->refresh();
1905 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1908 void MainWindow::slotSwitchSnap()
1910 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
1911 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1915 void MainWindow::slotDeleteTimelineClip()
1917 if (QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) m_projectList->slotRemoveClip();
1918 else if (m_activeTimeline) {
1919 m_activeTimeline->projectView()->deleteSelectedClips();
1923 void MainWindow::slotChangeClipSpeed()
1925 if (m_activeTimeline) {
1926 m_activeTimeline->projectView()->changeClipSpeed();
1930 void MainWindow::slotAddClipMarker()
1932 DocClipBase *clip = NULL;
1934 if (m_projectMonitor->isActive()) {
1935 if (m_activeTimeline) {
1936 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1938 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
1939 clip = item->baseClip();
1943 clip = m_clipMonitor->activeClip();
1944 pos = m_clipMonitor->position();
1947 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
1950 QString id = clip->getId();
1951 CommentedTime marker(pos, i18n("Marker"));
1952 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
1953 if (d.exec() == QDialog::Accepted) {
1954 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
1956 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
1959 void MainWindow::slotDeleteClipMarker()
1961 DocClipBase *clip = NULL;
1963 if (m_projectMonitor->isActive()) {
1964 if (m_activeTimeline) {
1965 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1967 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
1968 clip = item->baseClip();
1972 clip = m_clipMonitor->activeClip();
1973 pos = m_clipMonitor->position();
1976 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
1980 QString id = clip->getId();
1981 QString comment = clip->markerComment(pos);
1982 if (comment.isEmpty()) {
1983 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
1986 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
1987 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
1991 void MainWindow::slotDeleteAllClipMarkers()
1993 DocClipBase *clip = NULL;
1994 if (m_projectMonitor->isActive()) {
1995 if (m_activeTimeline) {
1996 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1998 clip = item->baseClip();
2002 clip = m_clipMonitor->activeClip();
2005 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2008 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2009 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2012 void MainWindow::slotEditClipMarker()
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()) / item->speed();
2021 clip = item->baseClip();
2025 clip = m_clipMonitor->activeClip();
2026 pos = m_clipMonitor->position();
2029 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2033 QString id = clip->getId();
2034 QString oldcomment = clip->markerComment(pos);
2035 if (oldcomment.isEmpty()) {
2036 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2040 CommentedTime marker(pos, oldcomment);
2041 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2042 if (d.exec() == QDialog::Accepted) {
2043 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2044 if (d.newMarker().time() != pos) {
2045 // remove old marker
2046 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2048 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2052 void MainWindow::slotAddGuide()
2054 if (m_activeTimeline)
2055 m_activeTimeline->projectView()->slotAddGuide();
2058 void MainWindow::slotInsertSpace()
2060 if (m_activeTimeline)
2061 m_activeTimeline->projectView()->slotInsertSpace();
2064 void MainWindow::slotRemoveSpace()
2066 if (m_activeTimeline)
2067 m_activeTimeline->projectView()->slotRemoveSpace();
2070 void MainWindow::slotInsertTrack(int ix)
2072 m_projectMonitor->activateMonitor();
2073 if (m_activeTimeline)
2074 m_activeTimeline->projectView()->slotInsertTrack(ix);
2077 void MainWindow::slotDeleteTrack(int ix)
2079 m_projectMonitor->activateMonitor();
2080 if (m_activeTimeline)
2081 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2084 void MainWindow::slotChangeTrack(int ix)
2086 m_projectMonitor->activateMonitor();
2087 if (m_activeTimeline)
2088 m_activeTimeline->projectView()->slotChangeTrack(ix);
2091 void MainWindow::slotEditGuide()
2093 if (m_activeTimeline)
2094 m_activeTimeline->projectView()->slotEditGuide();
2097 void MainWindow::slotDeleteGuide()
2099 if (m_activeTimeline)
2100 m_activeTimeline->projectView()->slotDeleteGuide();
2103 void MainWindow::slotDeleteAllGuides()
2105 if (m_activeTimeline)
2106 m_activeTimeline->projectView()->slotDeleteAllGuides();
2109 void MainWindow::slotCutTimelineClip()
2111 if (m_activeTimeline) {
2112 m_activeTimeline->projectView()->cutSelectedClips();
2116 void MainWindow::slotGroupClips()
2118 if (m_activeTimeline) {
2119 m_activeTimeline->projectView()->groupClips();
2123 void MainWindow::slotUnGroupClips()
2125 if (m_activeTimeline) {
2126 m_activeTimeline->projectView()->groupClips(false);
2130 void MainWindow::slotAddProjectClip(KUrl url)
2132 if (m_activeDocument)
2133 m_activeDocument->slotAddClipFile(url, QString());
2136 void MainWindow::slotAddTransition(QAction *result)
2138 if (!result) return;
2139 QStringList info = result->data().toStringList();
2140 if (info.isEmpty()) return;
2141 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2142 if (m_activeTimeline && !transition.isNull()) {
2143 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2147 void MainWindow::slotAddVideoEffect(QAction *result)
2149 if (!result) return;
2150 QStringList info = result->data().toStringList();
2151 if (info.isEmpty()) return;
2152 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2153 slotAddEffect(effect);
2156 void MainWindow::slotAddAudioEffect(QAction *result)
2158 if (!result) return;
2159 QStringList info = result->data().toStringList();
2160 if (info.isEmpty()) return;
2161 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2162 slotAddEffect(effect);
2165 void MainWindow::slotAddCustomEffect(QAction *result)
2167 if (!result) return;
2168 QStringList info = result->data().toStringList();
2169 if (info.isEmpty()) return;
2170 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2171 slotAddEffect(effect);
2174 void MainWindow::slotZoomIn()
2176 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2179 void MainWindow::slotZoomOut()
2181 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2184 void MainWindow::slotFitZoom()
2186 if (m_activeTimeline) {
2187 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2191 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2193 m_statusProgressBar->setValue(progress);
2194 if (progress >= 0) {
2195 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2196 m_statusProgressBar->setVisible(true);
2198 m_messageLabel->setMessage(QString(), DefaultMessage);
2199 m_statusProgressBar->setVisible(false);
2203 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2205 if (clip->clipType() == TEXT) {
2206 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
2207 if (!clip->getProperty("xmltemplate").isEmpty()) {
2208 // template text clip
2210 // Get the list of existing templates
2212 filter << "*.kdenlivetitle";
2213 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
2215 QDialog *dia = new QDialog(this);
2216 Ui::TemplateClip_UI dia_ui;
2217 dia_ui.setupUi(dia);
2219 const QString templatePath = clip->getProperty("xmltemplate");
2220 for (int i = 0; i < templateFiles.size(); ++i) {
2221 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
2222 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
2224 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
2225 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
2226 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
2227 //warning: setting base directory doesn't work??
2228 KUrl startDir(titlepath);
2229 dia_ui.template_list->fileDialog()->setUrl(startDir);
2230 dia_ui.description->setText(clip->getProperty("description"));
2231 dia_ui.clone_clip->setChecked(true);
2232 if (dia->exec() == QDialog::Accepted) {
2233 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
2234 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
2236 QMap <QString, QString> newprops;
2238 if (KUrl(textTemplate).path() != templatePath) {
2239 // The template was changed
2240 newprops.insert("xmltemplate", textTemplate);
2243 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
2244 newprops.insert("description", dia_ui.description->toPlainText());
2247 QString newtemplate = newprops.value("xmltemplate");
2248 if (newtemplate.isEmpty()) newtemplate = templatePath;
2250 // template modified we need to update xmldata
2251 QString description = newprops.value("description");
2252 if (description.isEmpty()) description = clip->getProperty("description");
2253 newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
2254 if (dia_ui.normal_clip->isChecked()) {
2255 // Switch clip to normal clip
2256 newprops.insert("xmltemplate", QString());
2258 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2259 m_activeDocument->commandStack()->push(command);
2263 QString path = clip->getProperty("resource");
2264 TitleWidget *dia_ui = new TitleWidget(KUrl(), titlepath, m_projectMonitor->render, this);
2266 doc.setContent(clip->getProperty("xmldata"));
2267 dia_ui->setXml(doc);
2268 if (dia_ui->exec() == QDialog::Accepted) {
2269 QRect rect = dia_ui->renderedRect();
2270 QMap <QString, QString> newprops;
2271 newprops.insert("xmldata", dia_ui->xml().toString());
2272 newprops.insert("frame_size", QString::number(rect.width()) + 'x' + QString::number(rect.height()));
2273 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2274 m_activeDocument->commandStack()->push(command);
2275 m_activeDocument->setModified(true);
2279 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2282 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2283 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2284 if (dia.exec() == QDialog::Accepted) {
2285 EditClipCommand *command = new EditClipCommand(m_projectList, dia.clipId(), clip->properties(), dia.properties(), true);
2286 m_activeDocument->commandStack()->push(command);
2288 //m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
2289 if (dia.needsTimelineRefresh()) {
2290 // update clip occurences in timeline
2291 m_activeTimeline->projectView()->slotUpdateClip(dia.clipId());
2296 void MainWindow::customEvent(QEvent* e)
2298 if (e->type() == QEvent::User) {
2299 // The timeline playing position changed...
2300 kDebug() << "RECEIVED JOG EVEMNT!!!";
2303 void MainWindow::slotActivateEffectStackView()
2305 m_effectStack->raiseWindow(m_effectStackDock);
2308 void MainWindow::slotActivateTransitionView(Transition *t)
2310 if (t) m_transitionConfig->raiseWindow(m_transitionConfigDock);
2313 void MainWindow::slotSnapRewind()
2315 if (m_projectMonitor->isActive()) {
2316 if (m_activeTimeline)
2317 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2318 } else m_clipMonitor->slotSeekToPreviousSnap();
2321 void MainWindow::slotSnapForward()
2323 if (m_projectMonitor->isActive()) {
2324 if (m_activeTimeline)
2325 m_activeTimeline->projectView()->slotSeekToNextSnap();
2326 } else m_clipMonitor->slotSeekToNextSnap();
2329 void MainWindow::slotClipStart()
2331 if (m_projectMonitor->isActive()) {
2332 if (m_activeTimeline)
2333 m_activeTimeline->projectView()->clipStart();
2337 void MainWindow::slotClipEnd()
2339 if (m_projectMonitor->isActive()) {
2340 if (m_activeTimeline)
2341 m_activeTimeline->projectView()->clipEnd();
2345 void MainWindow::slotChangeTool(QAction * action)
2347 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
2348 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
2349 else if (action == m_buttonSpacerTool) slotSetTool(SPACERTOOL);
2352 void MainWindow::slotSetTool(PROJECTTOOL tool)
2354 if (m_activeDocument && m_activeTimeline) {
2355 //m_activeDocument->setTool(tool);
2356 m_activeTimeline->projectView()->setTool(tool);
2360 void MainWindow::slotCopy()
2362 if (!m_activeDocument || !m_activeTimeline) return;
2363 m_activeTimeline->projectView()->copyClip();
2366 void MainWindow::slotPaste()
2368 if (!m_activeDocument || !m_activeTimeline) return;
2369 m_activeTimeline->projectView()->pasteClip();
2372 void MainWindow::slotPasteEffects()
2374 if (!m_activeDocument || !m_activeTimeline) return;
2375 m_activeTimeline->projectView()->pasteClipEffects();
2378 void MainWindow::slotFind()
2380 if (!m_activeDocument || !m_activeTimeline) return;
2381 m_projectSearch->setEnabled(false);
2382 m_findActivated = true;
2383 m_findString.clear();
2384 m_activeTimeline->projectView()->initSearchStrings();
2385 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2386 m_findTimer.start(5000);
2387 qApp->installEventFilter(this);
2390 void MainWindow::slotFindNext()
2392 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
2393 statusBar()->showMessage(i18n("Found: %1", m_findString));
2395 statusBar()->showMessage(i18n("Reached end of project"));
2397 m_findTimer.start(4000);
2400 void MainWindow::findAhead()
2402 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
2403 m_projectSearchNext->setEnabled(true);
2404 statusBar()->showMessage(i18n("Found: %1", m_findString));
2406 m_projectSearchNext->setEnabled(false);
2407 statusBar()->showMessage(i18n("Not found: %1", m_findString));
2411 void MainWindow::findTimeout()
2413 m_projectSearchNext->setEnabled(false);
2414 m_findActivated = false;
2415 m_findString.clear();
2416 statusBar()->showMessage(i18n("Find stopped"), 3000);
2417 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
2418 m_projectSearch->setEnabled(true);
2419 removeEventFilter(this);
2422 void MainWindow::keyPressEvent(QKeyEvent *ke)
2424 if (m_findActivated) {
2425 if (ke->key() == Qt::Key_Backspace) {
2426 m_findString = m_findString.left(m_findString.length() - 1);
2428 if (!m_findString.isEmpty()) {
2434 m_findTimer.start(4000);
2437 } else if (ke->key() == Qt::Key_Escape) {
2441 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
2442 m_findString += ke->text();
2446 m_findTimer.start(4000);
2450 } else KXmlGuiWindow::keyPressEvent(ke);
2454 /** Gets called when the window gets hidden */
2455 void MainWindow::hideEvent(QHideEvent */*event*/)
2457 // kDebug() << "I was hidden";
2458 // issue http://www.kdenlive.org/mantis/view.php?id=231
2459 if (isMinimized()) {
2460 // kDebug() << "I am minimized";
2461 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
2465 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
2467 if (m_findActivated) {
2468 if (event->type() == QEvent::ShortcutOverride) {
2469 QKeyEvent* ke = (QKeyEvent*) event;
2470 if (ke->text().trimmed().isEmpty()) return false;
2473 } else return false;
2475 // pass the event on to the parent class
2476 return QMainWindow::eventFilter(obj, event);
2480 void MainWindow::slotSaveZone(Render *render, QPoint zone)
2482 KDialog *dialog = new KDialog(this);
2483 dialog->setCaption("Save clip zone");
2484 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
2486 QWidget *widget = new QWidget(dialog);
2487 dialog->setMainWidget(widget);
2489 QVBoxLayout *vbox = new QVBoxLayout(widget);
2490 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
2491 QString path = m_activeDocument->projectFolder().path();
2493 path.append("untitled.mlt");
2494 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
2495 url->setFilter("video/mlt-playlist");
2496 QLabel *label2 = new QLabel(i18n("Description:"), this);
2497 KLineEdit *edit = new KLineEdit(this);
2498 vbox->addWidget(label1);
2499 vbox->addWidget(url);
2500 vbox->addWidget(label2);
2501 vbox->addWidget(edit);
2502 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
2506 void MainWindow::slotSetInPoint()
2508 if (m_clipMonitor->isActive()) {
2509 m_clipMonitor->slotSetZoneStart();
2510 } else m_activeTimeline->projectView()->setInPoint();
2513 void MainWindow::slotSetOutPoint()
2515 if (m_clipMonitor->isActive()) {
2516 m_clipMonitor->slotSetZoneEnd();
2517 } else m_activeTimeline->projectView()->setOutPoint();
2520 void MainWindow::slotGetNewLumaStuff()
2522 //KNS::Entry::List download();
2523 KNS::Entry::List entries = KNS::Engine::download();
2524 // list of changed entries
2525 kDebug() << "// PARSING KNS";
2526 foreach(KNS::Entry* entry, entries) {
2527 // care only about installed ones
2528 if (entry->status() == KNS::Entry::Installed) {
2529 foreach(const QString &file, entry->installedFiles()) {
2530 kDebug() << "// CURRENTLY INSTALLED: " << file;
2534 qDeleteAll(entries);
2535 initEffects::refreshLumas();
2536 m_activeTimeline->projectView()->reloadTransitionLumas();
2539 void MainWindow::slotGetNewRenderStuff()
2541 //KNS::Entry::List download();
2543 KNS::Engine engine(0);
2544 if (engine.init("kdenlive_render.knsrc")) {
2545 KNS::Entry::List entries = engine.downloadDialogModal(this);
2547 if (entries.size() > 0) {
2548 foreach(KNS::Entry* entry, entries) {
2549 // care only about installed ones
2550 if (entry->status() == KNS::Entry::Installed) {
2551 foreach(const QString &file, entry->installedFiles()) {
2552 kDebug() << "// CURRENTLY INSTALLED: " << file;
2557 if (m_renderWidget) m_renderWidget->reloadProfiles();
2561 void MainWindow::slotGetNewMltProfileStuff()
2563 //KNS::Entry::List download();
2565 KNS::Engine engine(0);
2566 if (engine.init("kdenlive_mltprofiles.knsrc")) {
2567 KNS::Entry::List entries = engine.downloadDialogModal(this);
2569 if (entries.size() > 0) {
2570 foreach(KNS::Entry* entry, entries) {
2571 // care only about installed ones
2572 if (entry->status() == KNS::Entry::Installed) {
2573 foreach(const QString &file, entry->installedFiles()) {
2574 kDebug() << "// CURRENTLY INSTALLED: " << file;
2579 // update the list of profiles in settings dialog
2580 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2581 if (d) d->checkProfile();
2586 void MainWindow::slotAutoTransition()
2588 if (m_activeTimeline) m_activeTimeline->projectView()->autoTransition();
2591 void MainWindow::slotSplitAudio()
2593 if (m_activeTimeline) m_activeTimeline->projectView()->splitAudio();
2596 void MainWindow::slotUpdateClipType(QAction *action)
2598 if (m_activeTimeline) {
2599 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
2600 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
2601 else m_activeTimeline->projectView()->setAudioAndVideo();
2605 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
2607 DvdWizard *w = new DvdWizard(url, profile, this);
2611 void MainWindow::slotShowTimeline(bool show)
2613 if (show == false) {
2614 m_timelineState = saveState();
2615 centralWidget()->setHidden(true);
2617 centralWidget()->setHidden(false);
2618 restoreState(m_timelineState);
2622 void MainWindow::slotMaximizeCurrent(bool /*show*/)
2624 //TODO: is there a way to maximize current widget?
2627 m_timelineState = saveState();
2628 QWidget *par = focusWidget()->parentWidget();
2629 while (par->parentWidget() && par->parentWidget() != this) {
2630 par = par->parentWidget();
2632 kDebug() << "CURRENT WIDGET: " << par->objectName();
2635 //centralWidget()->setHidden(false);
2636 //restoreState(m_timelineState);
2640 void MainWindow::loadTranscoders()
2642 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
2645 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
2646 KConfigGroup transConfig(config, "Transcoding");
2648 QMap< QString, QString > profiles = transConfig.entryMap();
2649 QMapIterator<QString, QString> i(profiles);
2650 while (i.hasNext()) {
2652 QAction *a = transMenu->addAction(i.key());
2653 a->setData(i.value());
2654 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
2658 void MainWindow::slotTranscode(KUrl::List urls)
2661 if (urls.isEmpty()) {
2662 urls.append(m_projectList->currentClipUrl());
2663 QAction *action = qobject_cast<QAction *>(sender());
2664 params = action->data().toString();
2666 if (urls.isEmpty()) return;
2667 ClipTranscode *d = new ClipTranscode(urls, params);
2668 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
2670 //QProcess::startDetached("ffmpeg", parameters);
2673 void MainWindow::slotTranscodeClip()
2675 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
2676 if (urls.isEmpty()) return;
2677 slotTranscode(urls);
2680 void MainWindow::slotSetDocumentRenderProfile(const QString &dest, const QString &name)
2682 if (m_activeDocument == NULL) return;
2683 m_activeDocument->setDocumentProperty("renderdestination", dest);
2684 m_activeDocument->setDocumentProperty("renderprofile", name);
2685 m_activeDocument->setModified(true);
2689 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
2691 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
2693 QString playlistPath;
2696 QString scriptsFolder = m_activeDocument->projectFolder().path() + "/scripts/";
2697 QString path = m_renderWidget->getFreeScriptName();
2698 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
2699 if (!ok || scriptPath.isEmpty()) return;
2700 scriptPath.prepend(scriptsFolder);
2701 QFile f(scriptPath);
2703 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
2706 playlistPath = scriptPath + ".mlt";
2707 m_projectMonitor->saveSceneList(playlistPath);
2709 KTemporaryFile temp;
2710 temp.setAutoRemove(false);
2711 temp.setSuffix(".mlt");
2713 playlistPath = temp.fileName();
2714 m_projectMonitor->saveSceneList(playlistPath);
2717 if (!chapterFile.isEmpty()) {
2720 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
2722 in = m_activeTimeline->inPoint();
2723 out = m_activeTimeline->outPoint();
2726 QDomElement chapters = doc.createElement("chapters");
2727 chapters.setAttribute("fps", m_activeDocument->fps());
2728 doc.appendChild(chapters);
2730 QDomElement guidesxml = m_activeDocument->guidesXml();
2731 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
2732 for (int i = 0; i < nodes.count(); i++) {
2733 QDomElement e = nodes.item(i).toElement();
2735 QString comment = e.attribute("comment");
2736 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
2737 if (time >= in && time < out) {
2738 if (zoneOnly) time = time - in;
2739 QDomElement chapter = doc.createElement("chapter");
2740 chapters.appendChild(chapter);
2741 chapter.setAttribute("title", comment);
2742 chapter.setAttribute("time", time);
2746 if (chapters.childNodes().count() > 0) {
2747 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
2748 // Always insert a guide in pos 0
2749 QDomElement chapter = doc.createElement("chapter");
2750 chapters.insertBefore(chapter, QDomNode());
2751 chapter.setAttribute("title", i18n("Start"));
2752 chapter.setAttribute("time", "0");
2754 // save chapters file
2755 QFile file(chapterFile);
2756 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
2757 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
2759 file.write(doc.toString().toUtf8());
2760 if (file.error() != QFile::NoError)
2761 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
2767 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath);
2770 #include "mainwindow.moc"