1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
21 #include "mainwindow.h"
22 #include "mainwindowadaptor.h"
23 #include "kdenlivesettings.h"
24 #include "kdenlivesettingsdialog.h"
25 #include "initeffects.h"
26 #include "profilesdialog.h"
27 #include "projectsettings.h"
29 #include "clipmanager.h"
30 #include "projectlist.h"
32 #include "recmonitor.h"
33 #include "monitormanager.h"
34 #include "kdenlivedoc.h"
35 #include "trackview.h"
36 #include "customtrackview.h"
37 #include "effectslistview.h"
38 #include "effectstackview.h"
39 #include "transitionsettings.h"
40 #include "renderwidget.h"
43 #include "jogshuttle.h"
44 #endif /* NO_JOGSHUTTLE */
45 #include "clipproperties.h"
47 #include "editclipcommand.h"
48 #include "titlewidget.h"
49 #include "markerdialog.h"
51 #include "interfaces.h"
52 #include "kdenlive-config.h"
53 #include "cliptranscode.h"
55 #include <KApplication>
59 #include <KActionCollection>
60 #include <KStandardAction>
61 #include <KFileDialog>
62 #include <KMessageBox>
64 #include <KIO/NetAccess>
67 #include <KConfigDialog>
68 #include <KXMLGUIFactory>
70 #include <kstandarddirs.h>
71 #include <KUrlRequesterDialog>
72 #include <KTemporaryFile>
74 #include <KActionMenu>
77 #include <ktogglefullscreenaction.h>
79 #include <KNotification>
80 #include <KNotifyConfigWidget>
81 #include <knewstuff2/engine.h>
82 #include <knewstuff2/ui/knewstuffaction.h>
84 #include <QTextStream>
91 static const char version[] = VERSION;
93 static const int ID_TIMELINE_POS = 0;
100 EffectsList MainWindow::videoEffects;
101 EffectsList MainWindow::audioEffects;
102 EffectsList MainWindow::customEffects;
103 EffectsList MainWindow::transitions;
105 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent) :
106 KXmlGuiWindow(parent),
107 m_activeDocument(NULL),
108 m_activeTimeline(NULL),
109 m_renderWidget(NULL),
110 #ifndef NO_JOGSHUTTLE
112 #endif /* NO_JOGSHUTTLE */
113 m_findActivated(false)
116 // Create DBus interface
117 new MainWindowAdaptor(this);
118 QDBusConnection dbus = QDBusConnection::sessionBus();
119 dbus.registerObject("/MainWindow", this);
121 setlocale(LC_NUMERIC, "POSIX");
122 setFont(KGlobalSettings::toolBarFont());
123 parseProfiles(MltPath);
124 m_commandStack = new QUndoGroup;
125 m_timelineArea = new KTabWidget(this);
126 m_timelineArea->setTabReorderingEnabled(true);
127 m_timelineArea->setTabBarHidden(true);
129 QToolButton *closeTabButton = new QToolButton;
130 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
131 closeTabButton->setIcon(KIcon("tab-close"));
132 closeTabButton->adjustSize();
133 closeTabButton->setToolTip(i18n("Close the current tab"));
134 m_timelineArea->setCornerWidget(closeTabButton);
135 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
137 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
138 m_findTimer.setSingleShot(true);
140 // FIXME: the next call returns a newly allocated object, which leaks
141 initEffects::parseEffectFiles();
142 //initEffects::parseCustomEffectsFile();
144 m_monitorManager = new MonitorManager();
146 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
147 m_projectListDock->setObjectName("project_tree");
148 m_projectList = new ProjectList(this);
149 m_projectListDock->setWidget(m_projectList);
150 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
152 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
153 m_effectListDock->setObjectName("effect_list");
154 m_effectList = new EffectsListView();
156 //m_effectList = new KListWidget(this);
157 m_effectListDock->setWidget(m_effectList);
158 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
160 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
161 m_effectStackDock->setObjectName("effect_stack");
162 m_effectStack = new EffectStackView(this);
163 m_effectStackDock->setWidget(m_effectStack);
164 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
166 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
167 m_transitionConfigDock->setObjectName("transition");
168 m_transitionConfig = new TransitionSettings(this);
169 m_transitionConfigDock->setWidget(m_transitionConfig);
170 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
172 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
173 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
177 slotDetectAudioDriver();
179 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
180 m_clipMonitorDock->setObjectName("clip_monitor");
181 m_clipMonitor = new Monitor("clip", m_monitorManager, this);
182 m_clipMonitorDock->setWidget(m_clipMonitor);
183 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
184 //m_clipMonitor->stop();
186 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
187 m_projectMonitorDock->setObjectName("project_monitor");
188 m_projectMonitor = new Monitor("project", m_monitorManager, this);
189 m_projectMonitorDock->setWidget(m_projectMonitor);
190 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
192 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
193 m_recMonitorDock->setObjectName("record_monitor");
194 m_recMonitor = new RecMonitor("record", this);
195 m_recMonitorDock->setWidget(m_recMonitor);
196 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
198 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
199 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
201 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
202 m_undoViewDock->setObjectName("undo_history");
203 m_undoView = new QUndoView(this);
204 m_undoView->setCleanIcon(KIcon("edit-clear"));
205 m_undoView->setEmptyLabel(i18n("Clean"));
206 m_undoViewDock->setWidget(m_undoView);
207 m_undoView->setGroup(m_commandStack);
208 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
210 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
211 //overviewDock->setObjectName("project_overview");
212 //m_overView = new CustomTrackView(NULL, NULL, this);
213 //overviewDock->setWidget(m_overView);
214 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
217 //tabifyDockWidget(projectListDock, effectListDock);
218 tabifyDockWidget(m_projectListDock, m_effectStackDock);
219 tabifyDockWidget(m_projectListDock, m_transitionConfigDock);
220 //tabifyDockWidget(projectListDock, undoViewDock);
223 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
224 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
225 setCentralWidget(m_timelineArea);
229 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
230 guiFactory()->addClient(sp);*/
234 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
236 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone);
237 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
238 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)), static_cast<QMenu*>(factory()->container("transcoders", this)));
240 // build effects menus
242 QMenu *videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
244 QStringList effectInfo;
245 QMap<QString, QStringList> effectsList;
246 for (int ix = 0; ix < videoEffects.count(); ix++) {
247 effectInfo = videoEffects.effectIdInfo(ix);
248 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
251 foreach(const QStringList &value, effectsList) {
252 action = new QAction(value.at(0), this);
253 action->setData(value);
254 videoEffectsMenu->addAction(action);
257 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
261 for (int ix = 0; ix < audioEffects.count(); ix++) {
262 effectInfo = audioEffects.effectIdInfo(ix);
263 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
266 foreach(const QStringList &value, effectsList) {
267 action = new QAction(value.at(0), this);
268 action->setData(value);
269 audioEffectsMenu->addAction(action);
272 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
274 if (customEffects.isEmpty()) m_customEffectsMenu->setEnabled(false);
275 else m_customEffectsMenu->setEnabled(true);
278 for (int ix = 0; ix < customEffects.count(); ix++) {
279 effectInfo = customEffects.effectIdInfo(ix);
280 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
283 foreach(const QStringList &value, effectsList) {
284 action = new QAction(value.at(0), this);
285 action->setData(value);
286 m_customEffectsMenu->addAction(action);
289 QMenu *newEffect = new QMenu(this);
290 newEffect->addMenu(videoEffectsMenu);
291 newEffect->addMenu(audioEffectsMenu);
292 newEffect->addMenu(m_customEffectsMenu);
293 m_effectStack->setMenu(newEffect);
296 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
297 const QList<QAction *> viewActions = createPopupMenu()->actions();
298 viewMenu->insertActions(NULL, viewActions);
300 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
301 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
302 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
304 m_timelineContextMenu = new QMenu(this);
305 m_timelineContextClipMenu = new QMenu(this);
306 m_timelineContextTransitionMenu = new QMenu(this);
309 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
310 QStringList effects = transitions.effectNames();
313 for (int ix = 0; ix < transitions.count(); ix++) {
314 effectInfo = transitions.effectIdInfo(ix);
315 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
317 foreach(const QStringList &value, effectsList) {
318 action = new QAction(value.at(0), this);
319 action->setData(value);
320 transitionsMenu->addAction(action);
322 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
324 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
325 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
326 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
328 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
329 m_timelineContextClipMenu->addAction(actionCollection()->action("change_clip_speed"));
330 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
331 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
332 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
333 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
334 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
335 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
337 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
338 m_timelineContextClipMenu->addMenu(markersMenu);
339 m_timelineContextClipMenu->addMenu(transitionsMenu);
340 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
341 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
342 //TODO: re-enable custom effects menu when it is implemented
343 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
345 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
346 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
348 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
350 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
351 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
352 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
353 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
354 connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
355 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
357 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
358 slotConnectMonitors();
360 // Open or create a file. Command line argument passed in Url has
361 // precedence, then "openlastproject", then just a plain empty file.
362 // If opening Url fails, openlastproject will _not_ be used.
363 if (!Url.isEmpty()) {
366 if (KdenliveSettings::openlastproject()) {
370 if (m_timelineArea->count() == 0) {
374 #ifndef NO_JOGSHUTTLE
375 activateShuttleDevice();
376 #endif /* NO_JOGSHUTTLE */
377 m_projectListDock->raise();
380 void MainWindow::queryQuit()
382 kDebug() << "----- SAVING CONFUIG";
384 Mlt::Factory::close();
390 bool MainWindow::queryClose()
393 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
394 if (m_activeDocument && m_activeDocument->isModified()) {
395 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
396 case KMessageBox::Yes :
397 // save document here. If saving fails, return false;
399 case KMessageBox::No :
400 // User does not want to save the changes, clear recovery files
401 m_activeDocument->m_autosave->resize(0);
411 void MainWindow::loadPlugins()
413 foreach(QObject *plugin, QPluginLoader::staticInstances())
414 populateMenus(plugin);
416 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
418 filters << "libkdenlive*";
419 foreach(const QString &folder, directories) {
420 kDebug() << "// PARSING FIOLER: " << folder;
421 QDir pluginsDir(folder);
422 foreach(const QString &fileName, pluginsDir.entryList(filters, QDir::Files)) {
423 kDebug() << "// FOUND PLUGIN: " << fileName << "= " << pluginsDir.absoluteFilePath(fileName);
424 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
425 QObject *plugin = loader.instance();
427 populateMenus(plugin);
428 m_pluginFileNames += fileName;
429 } else kDebug() << "// ERROR LOADING PLUGIN: " << fileName << ", " << loader.errorString();
435 void MainWindow::populateMenus(QObject *plugin)
437 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
438 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
440 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
444 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
445 QMenu *menu, const char *member,
446 QActionGroup *actionGroup)
448 kDebug() << "// ADD to MENU" << texts;
449 foreach(const QString &text, texts) {
450 QAction *action = new QAction(text, plugin);
451 action->setData(text);
452 connect(action, SIGNAL(triggered()), this, member);
453 menu->addAction(action);
456 action->setCheckable(true);
457 actionGroup->addAction(action);
462 void MainWindow::aboutPlugins()
464 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
469 void MainWindow::generateClip()
471 QAction *action = qobject_cast<QAction *>(sender());
472 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
474 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(), QStringList(), QStringList(), 25, 720, 576);
475 if (!clipUrl.isEmpty()) {
476 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
480 void MainWindow::saveProperties(KConfig*)
482 // save properties here,used by session management
487 void MainWindow::readProperties(KConfig *config)
489 // read properties here,used by session management
490 QString Lastproject = config->group("Recent Files").readPathEntry("File1", QString());
491 openFile(KUrl(Lastproject));
494 void MainWindow::slotReloadEffects()
496 initEffects::parseCustomEffectsFile();
497 m_customEffectsMenu->clear();
498 const QStringList effects = customEffects.effectNames();
500 if (effects.isEmpty()) m_customEffectsMenu->setEnabled(false);
501 else m_customEffectsMenu->setEnabled(true);
503 foreach(const QString &name, effects) {
504 action = new QAction(name, this);
505 action->setData(name);
506 m_customEffectsMenu->addAction(action);
508 m_effectList->reloadEffectList();
511 #ifndef NO_JOGSHUTTLE
512 void MainWindow::activateShuttleDevice()
516 if (KdenliveSettings::enableshuttle() == false) return;
517 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
518 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
519 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
520 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
521 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
522 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
523 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
526 void MainWindow::slotShuttleButton(int code)
530 slotShuttleAction(KdenliveSettings::shuttle1());
533 slotShuttleAction(KdenliveSettings::shuttle2());
536 slotShuttleAction(KdenliveSettings::shuttle3());
539 slotShuttleAction(KdenliveSettings::shuttle4());
542 slotShuttleAction(KdenliveSettings::shuttle5());
547 void MainWindow::slotShuttleAction(int code)
553 m_monitorManager->slotPlay();
556 m_monitorManager->slotPlay();
560 #endif /* NO_JOGSHUTTLE */
562 void MainWindow::configureNotifications()
564 KNotifyConfigWidget::configure(this);
567 void MainWindow::slotFullScreen()
569 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
572 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track)
574 if (!m_activeDocument) return;
575 if (effect.isNull()) {
576 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
579 m_activeTimeline->projectView()->slotAddEffect(effect.cloneNode().toElement(), pos, track);
582 void MainWindow::slotRaiseMonitor(bool clipMonitor)
584 if (clipMonitor) m_clipMonitorDock->raise();
585 else m_projectMonitorDock->raise();
588 void MainWindow::slotUpdateClip(const QString &id)
590 if (!m_activeDocument) return;
591 m_activeTimeline->projectView()->slotUpdateClip(id);
594 void MainWindow::slotConnectMonitors()
597 m_projectList->setRenderer(m_projectMonitor->render);
598 connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
599 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
600 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, const QString &, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement &, const QString &, bool)));
601 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
602 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)));
604 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
606 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
608 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
609 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
611 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
612 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
615 void MainWindow::slotAdjustClipMonitor()
617 m_clipMonitorDock->updateGeometry();
618 m_clipMonitorDock->adjustSize();
619 m_clipMonitor->resetSize();
622 void MainWindow::slotAdjustProjectMonitor()
624 m_projectMonitorDock->updateGeometry();
625 m_projectMonitorDock->adjustSize();
626 m_projectMonitor->resetSize();
629 void MainWindow::setupActions()
632 KActionCollection* collection = actionCollection();
633 m_timecodeFormat = new KComboBox(this);
634 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
635 m_timecodeFormat->addItem(i18n("Frames"));
637 m_statusProgressBar = new QProgressBar(this);
638 m_statusProgressBar->setMinimum(0);
639 m_statusProgressBar->setMaximum(100);
640 m_statusProgressBar->setMaximumWidth(150);
641 m_statusProgressBar->setVisible(false);
643 QWidget *w = new QWidget;
645 QHBoxLayout *layout = new QHBoxLayout;
646 w->setLayout(layout);
647 layout->setContentsMargins(5, 0, 5, 0);
648 QToolBar *toolbar = new QToolBar("statusToolBar", this);
651 m_toolGroup = new QActionGroup(this);
653 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;}";
655 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
656 toolbar->addAction(m_buttonSelectTool);
657 m_buttonSelectTool->setCheckable(true);
658 m_buttonSelectTool->setChecked(true);
660 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
661 toolbar->addAction(m_buttonRazorTool);
662 m_buttonRazorTool->setCheckable(true);
663 m_buttonRazorTool->setChecked(false);
665 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
666 toolbar->addAction(m_buttonSpacerTool);
667 m_buttonSpacerTool->setCheckable(true);
668 m_buttonSpacerTool->setChecked(false);
670 m_toolGroup->addAction(m_buttonSelectTool);
671 m_toolGroup->addAction(m_buttonRazorTool);
672 m_toolGroup->addAction(m_buttonSpacerTool);
673 m_toolGroup->setExclusive(true);
674 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
676 QWidget * actionWidget;
677 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
678 actionWidget->setMaximumWidth(24);
679 actionWidget->setMinimumHeight(18);
681 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
682 actionWidget->setMaximumWidth(24);
683 actionWidget->setMinimumHeight(18);
685 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
686 actionWidget->setMaximumWidth(24);
687 actionWidget->setMinimumHeight(18);
689 toolbar->setStyleSheet(style1);
690 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
692 toolbar->addSeparator();
693 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
694 toolbar->addAction(m_buttonFitZoom);
695 m_buttonFitZoom->setCheckable(false);
696 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
698 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
699 actionWidget->setMaximumWidth(24);
700 actionWidget->setMinimumHeight(18);
702 m_zoomSlider = new QSlider(Qt::Horizontal, this);
703 m_zoomSlider->setMaximum(13);
704 m_zoomSlider->setPageStep(1);
706 m_zoomSlider->setMaximumWidth(150);
707 m_zoomSlider->setMinimumWidth(100);
709 const int contentHeight = QFontMetrics(w->font()).height() + 8;
711 QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
712 style.append("QSlider::handle:horizontal { background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
714 m_zoomSlider->setStyleSheet(style);
716 //m_zoomSlider->height() + 5;
717 statusBar()->setMinimumHeight(contentHeight);
720 toolbar->addWidget(m_zoomSlider);
722 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
723 toolbar->addAction(m_buttonVideoThumbs);
724 m_buttonVideoThumbs->setCheckable(true);
725 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
726 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
728 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
729 toolbar->addAction(m_buttonAudioThumbs);
730 m_buttonAudioThumbs->setCheckable(true);
731 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
732 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
734 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
735 toolbar->addAction(m_buttonShowMarkers);
736 m_buttonShowMarkers->setCheckable(true);
737 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
738 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
740 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
741 toolbar->addAction(m_buttonSnap);
742 m_buttonSnap->setCheckable(true);
743 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
744 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
745 layout->addWidget(toolbar);
748 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
749 actionWidget->setMaximumWidth(24);
750 actionWidget->setMinimumHeight(18);
752 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
753 actionWidget->setMaximumWidth(24);
754 actionWidget->setMinimumHeight(18);
756 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
757 actionWidget->setMaximumWidth(24);
758 actionWidget->setMinimumHeight(18);
760 actionWidget = toolbar->widgetForAction(m_buttonSnap);
761 actionWidget->setMaximumWidth(24);
762 actionWidget->setMinimumHeight(18);
764 m_messageLabel = new StatusBarMessageLabel(this);
765 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
767 statusBar()->addWidget(m_messageLabel, 10);
768 statusBar()->addWidget(m_statusProgressBar, 0);
769 statusBar()->addPermanentWidget(w);
770 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
771 statusBar()->addPermanentWidget(m_timecodeFormat);
772 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
773 m_messageLabel->hide();
775 collection->addAction("select_tool", m_buttonSelectTool);
776 collection->addAction("razor_tool", m_buttonRazorTool);
777 collection->addAction("spacer_tool", m_buttonSpacerTool);
779 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
780 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
781 collection->addAction("show_markers", m_buttonShowMarkers);
782 collection->addAction("snap", m_buttonSnap);
783 collection->addAction("zoom_fit", m_buttonFitZoom);
785 KAction* zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
786 collection->addAction("zoom_in", zoomIn);
787 connect(zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
788 zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
790 KAction* zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
791 collection->addAction("zoom_out", zoomOut);
792 connect(zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
793 zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
795 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
796 collection->addAction("project_find", m_projectSearch);
797 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
798 m_projectSearch->setShortcut(Qt::Key_Slash);
800 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
801 collection->addAction("project_find_next", m_projectSearchNext);
802 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
803 m_projectSearchNext->setShortcut(Qt::Key_F3);
804 m_projectSearchNext->setEnabled(false);
806 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
807 collection->addAction("manage_profiles", profilesAction);
808 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
810 KNS::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
812 KNS::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
814 KNS::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
816 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
817 collection->addAction("run_wizard", wizAction);
818 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
820 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
821 collection->addAction("project_settings", projectAction);
822 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
824 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
825 collection->addAction("project_render", projectRender);
826 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
827 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
829 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
830 KShortcut playShortcut;
831 playShortcut.setPrimary(Qt::Key_Space);
832 playShortcut.setAlternate(Qt::Key_K);
833 monitorPlay->setShortcut(playShortcut);
834 collection->addAction("monitor_play", monitorPlay);
835 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
837 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
838 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
839 collection->addAction("monitor_play_zone", m_playZone);
840 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
842 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
843 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
844 collection->addAction("monitor_loop_zone", m_loopZone);
845 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
847 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
848 collection->addAction("dvd_wizard", dvdWizard);
849 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
851 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clip"), this);
852 collection->addAction("transcode_clip", transcodeClip);
853 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
855 KAction *markIn = collection->addAction("mark_in");
856 markIn->setText(i18n("Set In Point"));
857 markIn->setShortcut(Qt::Key_I);
858 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
860 KAction *markOut = collection->addAction("mark_out");
861 markOut->setText(i18n("Set Out Point"));
862 markOut->setShortcut(Qt::Key_O);
863 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
865 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
866 monitorSeekBackward->setShortcut(Qt::Key_J);
867 collection->addAction("monitor_seek_backward", monitorSeekBackward);
868 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
870 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
871 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
872 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
873 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
875 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
876 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
877 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
878 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
880 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
881 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
882 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
883 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
885 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
886 monitorSeekForward->setShortcut(Qt::Key_L);
887 collection->addAction("monitor_seek_forward", monitorSeekForward);
888 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
890 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
891 clipStart->setShortcut(Qt::Key_Home);
892 collection->addAction("seek_clip_start", clipStart);
893 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
895 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
896 clipEnd->setShortcut(Qt::Key_End);
897 collection->addAction("seek_clip_end", clipEnd);
898 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
900 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
901 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
902 collection->addAction("seek_start", projectStart);
903 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
905 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
906 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
907 collection->addAction("seek_end", projectEnd);
908 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
910 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
911 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
912 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
913 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
915 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
916 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
917 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
918 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
920 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
921 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
922 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
923 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
925 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
926 deleteTimelineClip->setShortcut(Qt::Key_Delete);
927 collection->addAction("delete_timeline_clip", deleteTimelineClip);
928 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
930 KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
931 collection->addAction("change_clip_speed", editTimelineClipSpeed);
932 editTimelineClipSpeed->setData("change_speed");
933 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));
935 KAction *stickTransition = collection->addAction("auto_transition");
936 stickTransition->setData(QString("auto"));
937 stickTransition->setCheckable(true);
938 stickTransition->setEnabled(false);
939 stickTransition->setText(i18n("Automatic Transition"));
940 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
942 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
943 collection->addAction("group_clip", groupClip);
944 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
946 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
947 collection->addAction("ungroup_clip", ungroupClip);
948 ungroupClip->setData("ungroup_clip");
949 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
951 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
952 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
953 collection->addAction("cut_timeline_clip", cutTimelineClip);
954 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
956 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
957 collection->addAction("add_clip_marker", addClipMarker);
958 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
960 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
961 collection->addAction("delete_clip_marker", deleteClipMarker);
962 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
964 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
965 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
966 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
968 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
969 collection->addAction("edit_clip_marker", editClipMarker);
970 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
972 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
973 collection->addAction("split_audio", splitAudio);
974 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
976 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
977 collection->addAction("clip_audio_only", audioOnly);
978 audioOnly->setData("clip_audio_only");
979 audioOnly->setCheckable(true);
981 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
982 collection->addAction("clip_video_only", videoOnly);
983 videoOnly->setData("clip_video_only");
984 videoOnly->setCheckable(true);
986 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
987 collection->addAction("clip_audio_and_video", audioAndVideo);
988 audioAndVideo->setData("clip_audio_and_video");
989 audioAndVideo->setCheckable(true);
991 m_clipTypeGroup = new QActionGroup(this);
992 m_clipTypeGroup->addAction(audioOnly);
993 m_clipTypeGroup->addAction(videoOnly);
994 m_clipTypeGroup->addAction(audioAndVideo);
995 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
996 m_clipTypeGroup->setEnabled(false);
998 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
999 collection->addAction("insert_space", insertSpace);
1000 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1002 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1003 collection->addAction("delete_space", removeSpace);
1004 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1006 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1007 collection->addAction("insert_track", insertTrack);
1008 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1010 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1011 collection->addAction("delete_track", deleteTrack);
1012 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1014 KAction *changeTrack = new KAction(KIcon(), i18n("Change Track"), this);
1015 collection->addAction("change_track", changeTrack);
1016 connect(changeTrack, SIGNAL(triggered()), this, SLOT(slotChangeTrack()));
1018 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1019 collection->addAction("add_guide", addGuide);
1020 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1022 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1023 collection->addAction("delete_guide", delGuide);
1024 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1026 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1027 collection->addAction("edit_guide", editGuide);
1028 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1030 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1031 collection->addAction("delete_all_guides", delAllGuides);
1032 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1034 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1035 collection->addAction("paste_effects", pasteEffects);
1036 pasteEffects->setData("paste_effects");
1037 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1039 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1040 collection->addAction("show_timeline", showTimeline);
1041 showTimeline->setCheckable(true);
1042 showTimeline->setChecked(true);
1043 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1045 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1046 collection->addAction("maximize_current", maxCurrent);
1047 maxCurrent->setCheckable(true);
1048 maxCurrent->setChecked(false);
1049 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1052 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1054 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1056 KStandardAction::open(this, SLOT(openFile()), collection);
1058 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1060 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1062 KStandardAction::openNew(this, SLOT(newFile()), collection);
1064 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1066 KStandardAction::configureNotifications(this , SLOT(configureNotifications()), collection);
1068 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1070 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1072 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1073 undo->setEnabled(false);
1074 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1076 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1077 redo->setEnabled(false);
1078 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1080 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1083 //TODO: Add status tooltip to actions ?
1084 connect(collection, SIGNAL(actionHovered(QAction*)),
1085 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1088 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1089 collection->addAction("add_clip", addClip);
1090 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1092 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1093 collection->addAction("add_color_clip", addColorClip);
1094 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1096 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1097 collection->addAction("add_slide_clip", addSlideClip);
1098 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1100 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1101 collection->addAction("add_text_clip", addTitleClip);
1102 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1104 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1105 collection->addAction("add_folder", addFolderButton);
1106 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1108 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1109 collection->addAction("clip_properties", clipProperties);
1110 clipProperties->setData("clip_properties");
1111 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1112 clipProperties->setEnabled(false);
1114 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1115 collection->addAction("edit_clip", openClip);
1116 openClip->setData("edit_clip");
1117 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1118 openClip->setEnabled(false);
1120 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1121 collection->addAction("delete_clip", deleteClip);
1122 deleteClip->setData("delete_clip");
1123 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1124 deleteClip->setEnabled(false);
1126 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1127 collection->addAction("reload_clip", reloadClip);
1128 reloadClip->setData("reload_clip");
1129 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1130 reloadClip->setEnabled(false);
1132 QMenu *addClips = new QMenu();
1133 addClips->addAction(addClip);
1134 addClips->addAction(addColorClip);
1135 addClips->addAction(addSlideClip);
1136 addClips->addAction(addTitleClip);
1137 addClips->addAction(addFolderButton);
1139 addClips->addAction(reloadClip);
1140 addClips->addAction(clipProperties);
1141 addClips->addAction(openClip);
1142 addClips->addAction(deleteClip);
1143 m_projectList->setupMenu(addClips, addClip);
1145 //connect(collection, SIGNAL( clearStatusText() ),
1146 //statusBar(), SLOT( clear() ) );
1149 void MainWindow::slotDisplayActionMessage(QAction *a)
1151 statusBar()->showMessage(a->data().toString(), 3000);
1154 void MainWindow::saveOptions()
1156 KdenliveSettings::self()->writeConfig();
1157 KSharedConfigPtr config = KGlobal::config();
1158 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1159 KConfigGroup treecolumns(config, "Project Tree");
1160 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1164 void MainWindow::readOptions()
1166 KSharedConfigPtr config = KGlobal::config();
1167 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1168 KConfigGroup initialGroup(config, "version");
1169 bool upgrade = false;
1170 if (initialGroup.exists()) {
1171 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0))
1174 if (initialGroup.readEntry("version") == "0.7") {
1175 //Add new settings from 0.7.1
1176 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1177 QString path = QDir::homePath() + "/kdenlive";
1178 if (KStandardDirs::makeDir(path) == false) kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1179 KdenliveSettings::setDefaultprojectfolder(path);
1185 if (!initialGroup.exists() || upgrade) {
1186 // this is our first run, show Wizard
1187 Wizard *w = new Wizard(upgrade, this);
1188 if (w->exec() == QDialog::Accepted && w->isOk()) {
1189 w->adjustSettings();
1190 initialGroup.writeEntry("version", version);
1196 KConfigGroup treecolumns(config, "Project Tree");
1197 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1198 if (!state.isEmpty())
1199 m_projectList->setHeaderInfo(state);
1202 void MainWindow::slotRunWizard()
1204 Wizard *w = new Wizard(false, this);
1205 if (w->exec() == QDialog::Accepted && w->isOk()) {
1206 w->adjustSettings();
1211 void MainWindow::newFile(bool showProjectSettings)
1213 QString profileName;
1215 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1216 if (!showProjectSettings && m_timelineArea->count() == 0) {
1217 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1218 profileName = KdenliveSettings::default_profile();
1219 projectFolder = KdenliveSettings::defaultprojectfolder();
1221 ProjectSettings *w = new ProjectSettings(projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, this);
1222 if (w->exec() != QDialog::Accepted) return;
1223 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1224 KdenliveSettings::setVideothumbnails(w->enableVideoThumbs());
1225 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1226 KdenliveSettings::setAudiothumbnails(w->enableAudioThumbs());
1227 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1228 profileName = w->selectedProfile();
1229 projectFolder = w->selectedFolder();
1230 projectTracks = w->tracks();
1233 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1234 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1235 TrackView *trackView = new TrackView(doc, this);
1236 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1237 if (m_timelineArea->count() == 1) {
1238 connectDocumentInfo(doc);
1239 connectDocument(trackView, doc);
1240 } else m_timelineArea->setTabBarHidden(false);
1241 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1244 void MainWindow::activateDocument()
1246 if (m_timelineArea->currentWidget() == NULL) return;
1247 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1248 KdenliveDoc *currentDoc = currentTab->document();
1249 connectDocumentInfo(currentDoc);
1250 connectDocument(currentTab, currentDoc);
1253 void MainWindow::closeCurrentDocument()
1255 QWidget *w = m_timelineArea->currentWidget();
1257 // closing current document
1258 int ix = m_timelineArea->currentIndex() + 1;
1259 if (ix == m_timelineArea->count()) ix = 0;
1260 m_timelineArea->setCurrentIndex(ix);
1261 TrackView *tabToClose = (TrackView *) w;
1262 KdenliveDoc *docToClose = tabToClose->document();
1263 if (docToClose && docToClose->isModified()) {
1264 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
1265 case KMessageBox::Yes :
1266 // save document here. If saving fails, return false;
1267 if (saveFile() == false) return;
1269 case KMessageBox::Cancel :
1276 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1277 if (m_timelineArea->count() == 1) {
1278 m_timelineArea->setTabBarHidden(true);
1279 m_closeAction->setEnabled(false);
1281 if (docToClose == m_activeDocument) {
1282 delete m_activeDocument;
1283 m_activeDocument = NULL;
1284 m_effectStack->clear();
1285 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1286 } else delete docToClose;
1287 if (w == m_activeTimeline) {
1288 delete m_activeTimeline;
1289 m_activeTimeline = NULL;
1293 bool MainWindow::saveFileAs(const QString &outputFileName)
1295 QString currentSceneList;
1296 if (KdenliveSettings::dropbframes()) {
1297 KdenliveSettings::setDropbframes(false);
1298 m_activeDocument->clipManager()->updatePreviewSettings();
1299 currentSceneList = m_projectMonitor->sceneList();
1300 KdenliveSettings::setDropbframes(true);
1301 m_activeDocument->clipManager()->updatePreviewSettings();
1302 } else currentSceneList = m_projectMonitor->sceneList();
1304 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1307 // Save timeline thumbnails
1308 m_activeTimeline->projectView()->saveThumbnails();
1309 m_activeDocument->setUrl(KUrl(outputFileName));
1310 if (m_activeDocument->m_autosave == NULL) {
1311 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1312 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1313 setCaption(m_activeDocument->description());
1314 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1315 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1316 m_activeDocument->setModified(false);
1317 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1321 bool MainWindow::saveFileAs()
1323 // Check that the Kdenlive mime type is correctly installed
1324 QString mimetype = "application/x-kdenlive";
1325 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1326 if (!mime) mimetype = "*.kdenlive";
1328 QString outputFile = KFileDialog::getSaveFileName(KUrl(), mimetype);
1329 if (outputFile.isEmpty()) return false;
1330 if (QFile::exists(outputFile)) {
1331 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it?")) == KMessageBox::No) return false;
1333 return saveFileAs(outputFile);
1336 bool MainWindow::saveFile()
1338 if (!m_activeDocument) return true;
1339 if (m_activeDocument->url().isEmpty()) {
1340 return saveFileAs();
1342 bool result = saveFileAs(m_activeDocument->url().path());
1343 m_activeDocument->m_autosave->resize(0);
1348 void MainWindow::openFile()
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 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), mimetype);
1356 if (url.isEmpty()) return;
1357 m_fileOpenRecent->addUrl(url);
1361 void MainWindow::openLastFile()
1363 KSharedConfigPtr config = KGlobal::config();
1364 KUrl::List urls = m_fileOpenRecent->urls();
1365 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1366 if (urls.isEmpty()) newFile(false);
1367 else openFile(urls.last());
1370 void MainWindow::openFile(const KUrl &url)
1372 // Check if the document is already opened
1373 const int ct = m_timelineArea->count();
1374 bool isOpened = false;
1376 for (i = 0; i < ct; i++) {
1377 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1378 KdenliveDoc *doc = tab->document();
1379 if (doc->url() == url) {
1385 m_timelineArea->setCurrentIndex(i);
1389 // Check for backup file
1390 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1391 if (!staleFiles.isEmpty()) {
1392 if (KMessageBox::questionYesNo(this,
1393 i18n("Auto-saved files exist. Do you want to recover them now?"),
1394 i18n("File Recovery"),
1395 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1396 recoverFiles(staleFiles);
1399 // remove the stale files
1400 foreach(KAutoSaveFile *stale, staleFiles) {
1401 stale->open(QIODevice::ReadWrite);
1406 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1407 doOpenFile(url, NULL);
1410 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1412 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, this);
1413 if (stale == NULL) {
1414 stale = new KAutoSaveFile(url, doc);
1415 doc->m_autosave = stale;
1417 doc->m_autosave = stale;
1418 doc->setUrl(stale->managedFile());
1419 doc->setModified(true);
1420 stale->setParent(doc);
1422 connectDocumentInfo(doc);
1423 TrackView *trackView = new TrackView(doc, this);
1424 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1425 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1426 trackView->setDuration(trackView->duration());
1427 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1429 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1430 slotGotProgressInfo(QString(), -1);
1431 m_clipMonitor->refreshMonitor(true);
1432 m_projectMonitor->adjustRulerSize(trackView->duration());
1433 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1436 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1438 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1439 foreach(KAutoSaveFile *stale, staleFiles) {
1440 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1441 // show an error message; we could not steal the lockfile
1442 // maybe another application got to the file before us?
1446 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1447 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
1448 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1449 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1454 void MainWindow::parseProfiles(const QString &mltPath)
1456 // kDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
1458 //KdenliveSettings::setDefaulttmpfolder();
1459 if (!mltPath.isEmpty()) {
1460 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1461 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
1464 if (KdenliveSettings::mltpath().isEmpty()) {
1465 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1467 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
1468 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
1469 if (!QFile::exists(meltPath))
1470 meltPath = KStandardDirs::findExe("melt");
1471 KdenliveSettings::setRendererpath(meltPath);
1473 QStringList profilesFilter;
1474 profilesFilter << "*";
1475 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1477 if (profilesList.isEmpty()) {
1478 // Cannot find MLT path, try finding melt
1479 QString profilePath = KdenliveSettings::rendererpath();
1480 if (!profilePath.isEmpty()) {
1481 profilePath = profilePath.section('/', 0, -3);
1482 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1483 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1486 if (profilesList.isEmpty()) {
1487 // Cannot find the MLT profiles, ask for location
1488 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1489 getUrl->fileDialog()->setMode(KFile::Directory);
1490 if (getUrl->exec() == QDialog::Rejected) {
1493 KUrl mltPath = getUrl->selectedUrl();
1495 if (mltPath.isEmpty()) ::exit(0);
1496 KdenliveSettings::setMltpath(mltPath.path());
1497 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1501 if (KdenliveSettings::rendererpath().isEmpty()) {
1502 // Cannot find the MLT melt renderer, ask for location
1503 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of Mlt)"), this);
1504 if (getUrl->exec() == QDialog::Rejected) {
1507 KUrl rendererPath = getUrl->selectedUrl();
1509 if (rendererPath.isEmpty()) ::exit(0);
1510 KdenliveSettings::setRendererpath(rendererPath.path());
1513 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1515 // Parse MLT profiles to build a list of available video formats
1516 if (profilesList.isEmpty()) parseProfiles();
1520 void MainWindow::slotEditProfiles()
1522 ProfilesDialog *w = new ProfilesDialog;
1523 if (w->exec() == QDialog::Accepted) {
1524 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1525 if (d) d->checkProfile();
1530 void MainWindow::slotDetectAudioDriver()
1532 //decide which audio driver is really best, in some cases SDL is wrong
1533 if (KdenliveSettings::audiodrivername().isEmpty()) {
1535 KProcess readProcess;
1536 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
1537 if (!KStandardDirs::findExe("pactl").isEmpty()) {
1538 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
1539 readProcess.setProgram("pactl", QStringList() << "stat");
1540 readProcess.execute(2000); // Kill it after 2 seconds
1542 QString result = QString(readProcess.readAllStandardOutput());
1543 kDebug() << "// / / / / / READING PACTL: ";
1545 if (!result.isEmpty()) {
1547 kDebug() << "// / / / / PULSEAUDIO DETECTED";
1551 KdenliveSettings::setAutoaudiodrivername(driver);
1555 void MainWindow::slotEditProjectSettings()
1557 QPoint p = m_activeDocument->getTracksCount();
1558 ProjectSettings *w = new ProjectSettings(p.x(), p.y(), m_activeDocument->projectFolder().path(), true, this);
1560 if (w->exec() == QDialog::Accepted) {
1561 QString profile = w->selectedProfile();
1562 m_activeDocument->setProjectFolder(w->selectedFolder());
1563 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path());
1564 if (m_activeDocument->profilePath() != profile) {
1565 // Profile was changed
1566 double dar = m_activeDocument->dar();
1567 m_activeDocument->setProfilePath(profile);
1568 KdenliveSettings::setCurrent_profile(profile);
1569 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1570 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1571 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1572 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1573 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1574 m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1575 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
1576 // We need to desactivate & reactivate monitors to get a refresh
1577 m_monitorManager->switchMonitors();
1583 void MainWindow::slotRenderProject()
1585 if (!m_renderWidget) {
1586 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path() : KdenliveSettings::defaultprojectfolder();
1587 m_renderWidget = new RenderWidget(projectfolder, this);
1588 connect(m_renderWidget, SIGNAL(doRender(const QStringList&, const QStringList&)), this, SLOT(slotDoRender(const QStringList&, const QStringList&)));
1589 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1590 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1591 if (m_activeDocument) {
1592 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1593 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1596 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1597 if (currentTab) m_renderWidget->setTimeline(currentTab);
1598 m_renderWidget->setDocument(m_activeDocument);*/
1599 m_renderWidget->show();
1602 void MainWindow::slotDoRender(const QStringList args, const QStringList overlay_args)
1604 QString dest = args.at(0);
1605 QString render = args.at(1);
1606 QStringList avformat_args = args.at(2).split(' ');
1607 bool zoneOnly = args.at(3).toInt();
1608 bool playAfter = args.at(4).toInt();
1609 double guideStart = args.at(5).toDouble();
1610 double guideEnd = args.at(6).toDouble();
1611 bool resizeProfile = args.at(7).toInt();
1612 QString scriptExport = args.at(8);
1613 bool createChapterFile = args.at(9).toInt();
1615 if (dest.isEmpty()) return;
1619 if (m_activeTimeline && zoneOnly) {
1620 in = m_activeTimeline->inPoint();
1621 out = m_activeTimeline->outPoint();
1624 KTemporaryFile temp;
1625 temp.setAutoRemove(false);
1626 temp.setSuffix(".mlt");
1627 if (!scriptExport.isEmpty() || temp.open()) {
1628 if (KdenliveSettings::dropbframes()) {
1629 KdenliveSettings::setDropbframes(false);
1630 m_activeDocument->clipManager()->updatePreviewSettings();
1631 if (!scriptExport.isEmpty()) m_projectMonitor->saveSceneList(scriptExport + ".mlt");
1632 else m_projectMonitor->saveSceneList(temp.fileName());
1633 KdenliveSettings::setDropbframes(true);
1634 m_activeDocument->clipManager()->updatePreviewSettings();
1636 if (!scriptExport.isEmpty()) m_projectMonitor->saveSceneList(scriptExport + ".mlt");
1637 else m_projectMonitor->saveSceneList(temp.fileName());
1641 if (scriptExport.isEmpty()) args << "-erase";
1642 if (KdenliveSettings::usekuiserver()) args << "-kuiserver";
1643 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
1644 else if (guideStart != -1) {
1645 args << "in=" + QString::number(GenTime(guideStart).frames(m_activeDocument->fps())) << "out=" + QString::number(GenTime(guideEnd).frames(m_activeDocument->fps()));
1647 if (!overlay_args.isEmpty()) args << "preargs=" + overlay_args.join(" ");
1648 QString videoPlayer = "-";
1650 videoPlayer = KdenliveSettings::defaultplayerapp();
1651 if (videoPlayer.isEmpty()) KMessageBox::sorry(this, i18n("Cannot play video after rendering because the default video player application is not set.\nPlease define it in Kdenlive settings dialog."));
1653 if (!QFile::exists(KdenliveSettings::rendererpath())) {
1654 KMessageBox::sorry(this, i18n("Cannot find the melt program required for rendering (part of Mlt)"));
1655 setRenderingProgress(dest, -3);
1658 args << KdenliveSettings::rendererpath() << m_activeDocument->profilePath() << render << videoPlayer;
1660 for (int i = 0; i < avformat_args.count(); i++) {
1661 if (avformat_args.at(i).startsWith("profile=")) {
1662 if (avformat_args.at(i).section('=', 1) != m_activeDocument->profilePath()) resizeProfile = true;
1667 if (resizeProfile) {
1668 // The rendering profile is different from project profile, so use MLT's special producer_consumer
1669 if (scriptExport.isEmpty()) args << "consumer:" + temp.fileName();
1670 else args << "consumer:$SOURCE";
1672 if (scriptExport.isEmpty()) args << temp.fileName();
1673 else args << "$SOURCE";
1675 if (scriptExport.isEmpty()) args << dest;
1676 else args << "$TARGET";
1677 args << avformat_args;
1678 QString renderer = QCoreApplication::applicationDirPath() + QString("/kdenlive_render");
1679 if (!QFile::exists(renderer)) renderer = "kdenlive_render";
1680 if (scriptExport.isEmpty()) {
1681 QProcess::startDetached(renderer, args);
1682 KNotification::event("RenderStarted", i18n("Rendering <i>%1</i> started", dest), QPixmap(), this);
1684 // Generate script file
1685 QFile file(scriptExport);
1686 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
1687 KMessageBox::error(this, i18n("Cannot write to file %1", scriptExport));
1691 QTextStream outStream(&file);
1692 outStream << "#! /bin/sh" << "\n" << "\n";
1693 outStream << "SOURCE=" << "\"" + scriptExport + ".mlt\"" << "\n";
1694 outStream << "TARGET=" << "\"" + dest + "\"" << "\n";
1695 outStream << renderer << " " << args.join(" ") << "\n" << "\n";
1696 if (file.error() != QFile::NoError) {
1697 KMessageBox::error(this, i18n("Cannot write to file %1", scriptExport));
1702 QFile::setPermissions(scriptExport, file.permissions() | QFile::ExeUser);
1705 if (createChapterFile) {
1707 QDomElement chapters = doc.createElement("chapters");
1708 chapters.setAttribute("fps", m_activeDocument->fps());
1709 doc.appendChild(chapters);
1711 QDomElement guidesxml = m_activeDocument->guidesXml();
1712 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
1714 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
1715 for (int i = 0; i < nodes.count(); i++) {
1716 QDomElement e = nodes.item(i).toElement();
1718 QString comment = e.attribute("comment");
1719 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
1720 if (time >= in && time < out) {
1721 if (zoneOnly) time = time - in;
1722 QDomElement chapter = doc.createElement("chapter");
1723 chapters.appendChild(chapter);
1724 chapter.setAttribute("title", comment);
1725 chapter.setAttribute("time", time);
1729 if (chapters.childNodes().count() > 0) {
1730 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
1731 // Always insert a guide in pos 0
1732 QDomElement chapter = doc.createElement("chapter");
1733 chapters.insertBefore(chapter, QDomNode());
1734 chapter.setAttribute("title", i18n("Start"));
1735 chapter.setAttribute("time", "0");
1737 // save chapters file
1738 QFile file(dest + ".dvdchapter");
1739 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
1740 kWarning() << "////// ERROR writing DVD CHAPTER file: " << dest + ".dvdchapter";
1742 file.write(doc.toString().toUtf8());
1743 if (file.error() != QFile::NoError)
1744 kWarning() << "////// ERROR writing DVD CHAPTER file: " << dest + ".dvdchapter";
1752 void MainWindow::setRenderingProgress(const QString &url, int progress)
1754 if (m_renderWidget) m_renderWidget->setRenderJob(url, progress);
1757 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
1759 if (m_renderWidget) m_renderWidget->setRenderStatus(url, status, error);
1762 void MainWindow::slotUpdateMousePosition(int pos)
1764 if (m_activeDocument)
1765 switch (m_timecodeFormat->currentIndex()) {
1767 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1770 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1774 void MainWindow::slotUpdateDocumentState(bool modified)
1776 if (!m_activeDocument) return;
1777 setCaption(m_activeDocument->description(), modified);
1778 m_saveAction->setEnabled(modified);
1780 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1781 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1783 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1784 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1788 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
1790 if (m_activeDocument) {
1791 if (m_activeDocument == doc) return;
1792 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1794 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1797 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
1799 //m_projectMonitor->stop();
1800 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1801 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1802 if (m_activeDocument) {
1803 if (m_activeDocument == doc) return;
1804 if (m_activeTimeline) {
1805 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1806 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1807 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1808 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1809 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
1812 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1813 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1814 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1815 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1816 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1817 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1818 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1819 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1820 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1821 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
1822 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1823 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1824 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1825 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1826 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1827 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1828 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1829 disconnect(m_activeTimeline, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1830 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1831 disconnect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1832 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1833 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1834 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1835 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1836 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1837 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1838 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
1839 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1840 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1841 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
1842 m_effectStack->clear();
1844 //m_activeDocument->setRenderer(NULL);
1845 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1846 m_clipMonitor->stop();
1848 KdenliveSettings::setCurrent_profile(doc->profilePath());
1849 KdenliveSettings::setProject_fps(doc->fps());
1850 m_monitorManager->resetProfiles(doc->timecode());
1851 m_projectList->setDocument(doc);
1852 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), trackView->tracksNumber());
1853 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
1854 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1855 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1856 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
1859 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1860 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1861 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1862 connect(trackView, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1863 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1864 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1865 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1866 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1867 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
1868 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1869 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1870 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1871 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1872 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1874 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1875 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1876 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1879 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1880 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1881 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
1882 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1883 m_zoomSlider->setValue(doc->zoom());
1884 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1885 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1886 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1887 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1889 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1892 connect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1893 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1894 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1895 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1896 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1897 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1898 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1899 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1901 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1902 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1903 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
1905 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup);
1906 m_activeTimeline = trackView;
1907 if (m_renderWidget) {
1908 m_renderWidget->setProfile(doc->mltProfile());
1909 m_renderWidget->setDocumentPath(doc->projectFolder().path());
1911 //doc->setRenderer(m_projectMonitor->render);
1912 m_commandStack->setActiveStack(doc->commandStack());
1913 KdenliveSettings::setProject_display_ratio(doc->dar());
1914 m_projectList->updateAllClips();
1915 //doc->clipManager()->checkAudioThumbs();
1917 //m_overView->setScene(trackView->projectScene());
1918 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1919 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1921 setCaption(doc->description(), doc->isModified());
1922 m_saveAction->setEnabled(doc->isModified());
1923 m_activeDocument = doc;
1924 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
1926 // set tool to select tool
1927 m_buttonSelectTool->setChecked(true);
1930 void MainWindow::slotZoneMoved(int start, int end)
1932 m_activeDocument->setZone(start, end);
1933 m_projectMonitor->slotZoneMoved(start, end);
1936 void MainWindow::slotGuidesUpdated()
1938 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1941 void MainWindow::slotPreferences(int page, int option)
1943 //An instance of your dialog could be already created and could be
1944 // cached, in which case you want to display the cached dialog
1945 // instead of creating another one
1946 if (KConfigDialog::showDialog("settings")) {
1947 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1948 if (page != -1) d->showPage(page, option);
1952 // KConfigDialog didn't find an instance of this dialog, so lets
1954 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1955 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1956 connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
1957 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1958 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1959 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
1960 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1962 if (page != -1) dialog->showPage(page, option);
1965 void MainWindow::slotUpdatePreviewSettings()
1967 if (m_activeDocument) {
1968 m_clipMonitor->slotSetXml(NULL, 0);
1969 m_activeDocument->updatePreviewSettings();
1973 void MainWindow::updateConfiguration()
1975 //TODO: we should apply settings to all projects, not only the current one
1976 if (m_activeTimeline) {
1977 m_activeTimeline->refresh();
1978 m_activeTimeline->projectView()->checkAutoScroll();
1979 m_activeTimeline->projectView()->checkTrackHeight();
1980 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1982 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1983 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1985 // Update list of transcoding profiles
1987 #ifndef NO_JOGSHUTTLE
1988 activateShuttleDevice();
1989 #endif /* NO_JOGSHUTTLE */
1994 void MainWindow::slotSwitchVideoThumbs()
1996 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1997 if (m_activeTimeline) {
1998 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2000 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2003 void MainWindow::slotSwitchAudioThumbs()
2005 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2006 if (m_activeTimeline) {
2007 m_activeTimeline->refresh();
2008 m_activeTimeline->projectView()->checkAutoScroll();
2009 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
2011 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2014 void MainWindow::slotSwitchMarkersComments()
2016 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2017 if (m_activeTimeline) {
2018 m_activeTimeline->refresh();
2020 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2023 void MainWindow::slotSwitchSnap()
2025 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2026 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2030 void MainWindow::slotDeleteTimelineClip()
2032 if (QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) m_projectList->slotRemoveClip();
2033 else if (m_activeTimeline) {
2034 m_activeTimeline->projectView()->deleteSelectedClips();
2038 void MainWindow::slotChangeClipSpeed()
2040 if (m_activeTimeline) {
2041 m_activeTimeline->projectView()->changeClipSpeed();
2045 void MainWindow::slotAddClipMarker()
2047 DocClipBase *clip = NULL;
2049 if (m_projectMonitor->isActive()) {
2050 if (m_activeTimeline) {
2051 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2053 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
2054 clip = item->baseClip();
2058 clip = m_clipMonitor->activeClip();
2059 pos = m_clipMonitor->position();
2062 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2065 QString id = clip->getId();
2066 CommentedTime marker(pos, i18n("Marker"));
2067 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2068 if (d.exec() == QDialog::Accepted) {
2069 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2071 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2074 void MainWindow::slotDeleteClipMarker()
2076 DocClipBase *clip = NULL;
2078 if (m_projectMonitor->isActive()) {
2079 if (m_activeTimeline) {
2080 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2082 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
2083 clip = item->baseClip();
2087 clip = m_clipMonitor->activeClip();
2088 pos = m_clipMonitor->position();
2091 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2095 QString id = clip->getId();
2096 QString comment = clip->markerComment(pos);
2097 if (comment.isEmpty()) {
2098 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2101 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2102 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2106 void MainWindow::slotDeleteAllClipMarkers()
2108 DocClipBase *clip = NULL;
2109 if (m_projectMonitor->isActive()) {
2110 if (m_activeTimeline) {
2111 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2113 clip = item->baseClip();
2117 clip = m_clipMonitor->activeClip();
2120 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2123 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2124 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2127 void MainWindow::slotEditClipMarker()
2129 DocClipBase *clip = NULL;
2131 if (m_projectMonitor->isActive()) {
2132 if (m_activeTimeline) {
2133 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2135 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
2136 clip = item->baseClip();
2140 clip = m_clipMonitor->activeClip();
2141 pos = m_clipMonitor->position();
2144 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2148 QString id = clip->getId();
2149 QString oldcomment = clip->markerComment(pos);
2150 if (oldcomment.isEmpty()) {
2151 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2155 CommentedTime marker(pos, oldcomment);
2156 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2157 if (d.exec() == QDialog::Accepted) {
2158 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2159 if (d.newMarker().time() != pos) {
2160 // remove old marker
2161 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2163 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2167 void MainWindow::slotAddGuide()
2169 if (m_activeTimeline)
2170 m_activeTimeline->projectView()->slotAddGuide();
2173 void MainWindow::slotInsertSpace()
2175 if (m_activeTimeline)
2176 m_activeTimeline->projectView()->slotInsertSpace();
2179 void MainWindow::slotRemoveSpace()
2181 if (m_activeTimeline)
2182 m_activeTimeline->projectView()->slotRemoveSpace();
2185 void MainWindow::slotInsertTrack(int ix)
2187 m_projectMonitor->activateMonitor();
2188 if (m_activeTimeline)
2189 m_activeTimeline->projectView()->slotInsertTrack(ix);
2192 void MainWindow::slotDeleteTrack(int ix)
2194 m_projectMonitor->activateMonitor();
2195 if (m_activeTimeline)
2196 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2199 void MainWindow::slotChangeTrack(int ix)
2201 m_projectMonitor->activateMonitor();
2202 if (m_activeTimeline)
2203 m_activeTimeline->projectView()->slotChangeTrack(ix);
2206 void MainWindow::slotEditGuide()
2208 if (m_activeTimeline)
2209 m_activeTimeline->projectView()->slotEditGuide();
2212 void MainWindow::slotDeleteGuide()
2214 if (m_activeTimeline)
2215 m_activeTimeline->projectView()->slotDeleteGuide();
2218 void MainWindow::slotDeleteAllGuides()
2220 if (m_activeTimeline)
2221 m_activeTimeline->projectView()->slotDeleteAllGuides();
2224 void MainWindow::slotCutTimelineClip()
2226 if (m_activeTimeline) {
2227 m_activeTimeline->projectView()->cutSelectedClips();
2231 void MainWindow::slotGroupClips()
2233 if (m_activeTimeline) {
2234 m_activeTimeline->projectView()->groupClips();
2238 void MainWindow::slotUnGroupClips()
2240 if (m_activeTimeline) {
2241 m_activeTimeline->projectView()->groupClips(false);
2245 void MainWindow::slotAddProjectClip(KUrl url)
2247 if (m_activeDocument)
2248 m_activeDocument->slotAddClipFile(url, QString());
2251 void MainWindow::slotAddTransition(QAction *result)
2253 if (!result) return;
2254 QStringList info = result->data().toStringList();
2255 if (info.isEmpty()) return;
2256 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2257 if (m_activeTimeline && !transition.isNull()) {
2258 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2262 void MainWindow::slotAddVideoEffect(QAction *result)
2264 if (!result) return;
2265 QStringList info = result->data().toStringList();
2266 if (info.isEmpty()) return;
2267 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2268 slotAddEffect(effect);
2271 void MainWindow::slotAddAudioEffect(QAction *result)
2273 if (!result) return;
2274 QStringList info = result->data().toStringList();
2275 if (info.isEmpty()) return;
2276 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2277 slotAddEffect(effect);
2280 void MainWindow::slotAddCustomEffect(QAction *result)
2282 if (!result) return;
2283 QStringList info = result->data().toStringList();
2284 if (info.isEmpty()) return;
2285 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2286 slotAddEffect(effect);
2289 void MainWindow::slotZoomIn()
2291 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2294 void MainWindow::slotZoomOut()
2296 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2299 void MainWindow::slotFitZoom()
2301 if (m_activeTimeline) {
2302 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2306 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2308 m_statusProgressBar->setValue(progress);
2309 if (progress >= 0) {
2310 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2311 m_statusProgressBar->setVisible(true);
2313 m_messageLabel->setMessage(QString(), DefaultMessage);
2314 m_statusProgressBar->setVisible(false);
2318 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2320 if (clip->clipType() == TEXT) {
2321 QString titlepath = m_activeDocument->projectFolder().path() + "/titles/";
2322 QString path = clip->getProperty("resource");
2323 TitleWidget *dia_ui = new TitleWidget(KUrl(), titlepath, m_projectMonitor->render, this);
2325 doc.setContent(clip->getProperty("xmldata"));
2326 dia_ui->setXml(doc);
2327 if (dia_ui->exec() == QDialog::Accepted) {
2328 QImage pix = dia_ui->renderedPixmap();
2330 //slotAddClipFile(KUrl("/tmp/kdenlivetitle.png"), QString(), -1);
2331 //m_clipManager->slotEditTextClipFile(id, dia_ui->xml().toString());
2332 QMap <QString, QString> newprops;
2333 newprops.insert("xmldata", dia_ui->xml().toString());
2334 newprops.insert("frame_size", QString::number(pix.width()) + 'x' + QString::number(pix.height()));
2335 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2336 m_activeDocument->commandStack()->push(command);
2337 m_clipMonitor->refreshMonitor(true);
2338 m_activeDocument->setModified(true);
2342 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2345 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2346 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2347 if (dia.exec() == QDialog::Accepted) {
2348 EditClipCommand *command = new EditClipCommand(m_projectList, dia.clipId(), clip->properties(), dia.properties(), true);
2349 m_activeDocument->commandStack()->push(command);
2351 //m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
2352 if (dia.needsTimelineRefresh()) {
2353 // update clip occurences in timeline
2354 m_activeTimeline->projectView()->slotUpdateClip(dia.clipId());
2359 void MainWindow::customEvent(QEvent* e)
2361 if (e->type() == QEvent::User) {
2362 // The timeline playing position changed...
2363 kDebug() << "RECEIVED JOG EVEMNT!!!";
2366 void MainWindow::slotActivateEffectStackView()
2368 m_effectStack->raiseWindow(m_effectStackDock);
2371 void MainWindow::slotActivateTransitionView(Transition *t)
2373 if (t) m_transitionConfig->raiseWindow(m_transitionConfigDock);
2376 void MainWindow::slotSnapRewind()
2378 if (m_projectMonitor->isActive()) {
2379 if (m_activeTimeline)
2380 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2381 } else m_clipMonitor->slotSeekToPreviousSnap();
2384 void MainWindow::slotSnapForward()
2386 if (m_projectMonitor->isActive()) {
2387 if (m_activeTimeline)
2388 m_activeTimeline->projectView()->slotSeekToNextSnap();
2389 } else m_clipMonitor->slotSeekToNextSnap();
2392 void MainWindow::slotClipStart()
2394 if (m_projectMonitor->isActive()) {
2395 if (m_activeTimeline)
2396 m_activeTimeline->projectView()->clipStart();
2400 void MainWindow::slotClipEnd()
2402 if (m_projectMonitor->isActive()) {
2403 if (m_activeTimeline)
2404 m_activeTimeline->projectView()->clipEnd();
2408 void MainWindow::slotChangeTool(QAction * action)
2410 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
2411 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
2412 else if (action == m_buttonSpacerTool) slotSetTool(SPACERTOOL);
2415 void MainWindow::slotSetTool(PROJECTTOOL tool)
2417 if (m_activeDocument && m_activeTimeline) {
2418 //m_activeDocument->setTool(tool);
2419 m_activeTimeline->projectView()->setTool(tool);
2423 void MainWindow::slotCopy()
2425 if (!m_activeDocument || !m_activeTimeline) return;
2426 m_activeTimeline->projectView()->copyClip();
2429 void MainWindow::slotPaste()
2431 if (!m_activeDocument || !m_activeTimeline) return;
2432 m_activeTimeline->projectView()->pasteClip();
2435 void MainWindow::slotPasteEffects()
2437 if (!m_activeDocument || !m_activeTimeline) return;
2438 m_activeTimeline->projectView()->pasteClipEffects();
2441 void MainWindow::slotFind()
2443 if (!m_activeDocument || !m_activeTimeline) return;
2444 m_projectSearch->setEnabled(false);
2445 m_findActivated = true;
2446 m_findString.clear();
2447 m_activeTimeline->projectView()->initSearchStrings();
2448 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2449 m_findTimer.start(5000);
2450 qApp->installEventFilter(this);
2453 void MainWindow::slotFindNext()
2455 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
2456 statusBar()->showMessage(i18n("Found: %1", m_findString));
2458 statusBar()->showMessage(i18n("Reached end of project"));
2460 m_findTimer.start(4000);
2463 void MainWindow::findAhead()
2465 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
2466 m_projectSearchNext->setEnabled(true);
2467 statusBar()->showMessage(i18n("Found: %1", m_findString));
2469 m_projectSearchNext->setEnabled(false);
2470 statusBar()->showMessage(i18n("Not found: %1", m_findString));
2474 void MainWindow::findTimeout()
2476 m_projectSearchNext->setEnabled(false);
2477 m_findActivated = false;
2478 m_findString.clear();
2479 statusBar()->showMessage(i18n("Find stopped"), 3000);
2480 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
2481 m_projectSearch->setEnabled(true);
2482 removeEventFilter(this);
2485 void MainWindow::keyPressEvent(QKeyEvent *ke)
2487 if (m_findActivated) {
2488 if (ke->key() == Qt::Key_Backspace) {
2489 m_findString = m_findString.left(m_findString.length() - 1);
2491 if (!m_findString.isEmpty()) {
2497 m_findTimer.start(4000);
2500 } else if (ke->key() == Qt::Key_Escape) {
2504 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
2505 m_findString += ke->text();
2509 m_findTimer.start(4000);
2513 } else KXmlGuiWindow::keyPressEvent(ke);
2517 /** Gets called when the window gets hidden */
2518 void MainWindow::hideEvent(QHideEvent */*event*/)
2520 // kDebug() << "I was hidden";
2521 // issue http://www.kdenlive.org/mantis/view.php?id=231
2522 if (isMinimized()) {
2523 // kDebug() << "I am minimized";
2524 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
2528 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
2530 if (m_findActivated) {
2531 if (event->type() == QEvent::ShortcutOverride) {
2532 QKeyEvent* ke = (QKeyEvent*) event;
2533 if (ke->text().trimmed().isEmpty()) return false;
2536 } else return false;
2538 // pass the event on to the parent class
2539 return QMainWindow::eventFilter(obj, event);
2543 void MainWindow::slotSaveZone(Render *render, QPoint zone)
2545 KDialog *dialog = new KDialog(this);
2546 dialog->setCaption("Save clip zone");
2547 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
2549 QWidget *widget = new QWidget(dialog);
2550 dialog->setMainWidget(widget);
2552 QVBoxLayout *vbox = new QVBoxLayout(widget);
2553 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
2554 QString path = m_activeDocument->projectFolder().path();
2556 path.append("untitled.mlt");
2557 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
2558 url->setFilter("video/mlt-playlist");
2559 QLabel *label2 = new QLabel(i18n("Description:"), this);
2560 KLineEdit *edit = new KLineEdit(this);
2561 vbox->addWidget(label1);
2562 vbox->addWidget(url);
2563 vbox->addWidget(label2);
2564 vbox->addWidget(edit);
2565 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
2569 void MainWindow::slotSetInPoint()
2571 if (m_clipMonitor->isActive()) {
2572 m_clipMonitor->slotSetZoneStart();
2573 } else m_activeTimeline->projectView()->setInPoint();
2576 void MainWindow::slotSetOutPoint()
2578 if (m_clipMonitor->isActive()) {
2579 m_clipMonitor->slotSetZoneEnd();
2580 } else m_activeTimeline->projectView()->setOutPoint();
2583 void MainWindow::slotGetNewLumaStuff()
2585 //KNS::Entry::List download();
2586 KNS::Entry::List entries = KNS::Engine::download();
2587 // list of changed entries
2588 kDebug() << "// PARSING KNS";
2589 foreach(KNS::Entry* entry, entries) {
2590 // care only about installed ones
2591 if (entry->status() == KNS::Entry::Installed) {
2592 foreach(const QString &file, entry->installedFiles()) {
2593 kDebug() << "// CURRENTLY INSTALLED: " << file;
2597 qDeleteAll(entries);
2598 initEffects::refreshLumas();
2599 m_activeTimeline->projectView()->reloadTransitionLumas();
2602 void MainWindow::slotGetNewRenderStuff()
2604 //KNS::Entry::List download();
2606 KNS::Engine engine(0);
2607 if (engine.init("kdenlive_render.knsrc")) {
2608 KNS::Entry::List entries = engine.downloadDialogModal(this);
2610 if (entries.size() > 0) {
2611 foreach(KNS::Entry* entry, entries) {
2612 // care only about installed ones
2613 if (entry->status() == KNS::Entry::Installed) {
2614 foreach(const QString &file, entry->installedFiles()) {
2615 kDebug() << "// CURRENTLY INSTALLED: " << file;
2620 if (m_renderWidget) m_renderWidget->reloadProfiles();
2624 void MainWindow::slotGetNewMltProfileStuff()
2626 //KNS::Entry::List download();
2628 KNS::Engine engine(0);
2629 if (engine.init("kdenlive_mltprofiles.knsrc")) {
2630 KNS::Entry::List entries = engine.downloadDialogModal(this);
2632 if (entries.size() > 0) {
2633 foreach(KNS::Entry* entry, entries) {
2634 // care only about installed ones
2635 if (entry->status() == KNS::Entry::Installed) {
2636 foreach(const QString &file, entry->installedFiles()) {
2637 kDebug() << "// CURRENTLY INSTALLED: " << file;
2642 // update the list of profiles in settings dialog
2643 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2644 if (d) d->checkProfile();
2649 void MainWindow::slotAutoTransition()
2651 if (m_activeTimeline) m_activeTimeline->projectView()->autoTransition();
2654 void MainWindow::slotSplitAudio()
2656 if (m_activeTimeline) m_activeTimeline->projectView()->splitAudio();
2659 void MainWindow::slotUpdateClipType(QAction *action)
2661 if (m_activeTimeline) {
2662 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
2663 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
2664 else m_activeTimeline->projectView()->setAudioAndVideo();
2668 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
2670 DvdWizard *w = new DvdWizard(url, profile, this);
2674 void MainWindow::slotShowTimeline(bool show)
2676 if (show == false) {
2677 m_timelineState = saveState();
2678 centralWidget()->setHidden(true);
2680 centralWidget()->setHidden(false);
2681 restoreState(m_timelineState);
2685 void MainWindow::slotMaximizeCurrent(bool /*show*/)
2687 //TODO: is there a way to maximize current widget?
2690 m_timelineState = saveState();
2691 QWidget *par = focusWidget()->parentWidget();
2692 while (par->parentWidget() && par->parentWidget() != this) {
2693 par = par->parentWidget();
2695 kDebug() << "CURRENT WIDGET: " << par->objectName();
2698 //centralWidget()->setHidden(false);
2699 //restoreState(m_timelineState);
2703 void MainWindow::loadTranscoders()
2705 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
2708 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
2709 KConfigGroup transConfig(config, "Transcoding");
2711 QMap< QString, QString > profiles = transConfig.entryMap();
2712 QMapIterator<QString, QString> i(profiles);
2713 while (i.hasNext()) {
2715 QAction *a = transMenu->addAction(i.key());
2716 a->setData(i.value());
2717 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
2721 void MainWindow::slotTranscode(KUrl::List urls)
2724 if (urls.isEmpty()) {
2725 urls.append(m_projectList->currentClipUrl());
2726 QAction *action = qobject_cast<QAction *>(sender());
2727 params = action->data().toString();
2729 if (urls.isEmpty()) return;
2730 ClipTranscode *d = new ClipTranscode(urls, params);
2731 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
2733 //QProcess::startDetached("ffmpeg", parameters);
2736 void MainWindow::slotTranscodeClip()
2738 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
2739 if (urls.isEmpty()) return;
2740 slotTranscode(urls);
2743 #include "mainwindow.moc"