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 *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1105 collection->addAction("add_text_template_clip", addTitleTemplateClip);
1106 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1108 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1109 collection->addAction("add_folder", addFolderButton);
1110 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1112 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1113 collection->addAction("clip_properties", clipProperties);
1114 clipProperties->setData("clip_properties");
1115 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1116 clipProperties->setEnabled(false);
1118 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1119 collection->addAction("edit_clip", openClip);
1120 openClip->setData("edit_clip");
1121 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1122 openClip->setEnabled(false);
1124 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1125 collection->addAction("delete_clip", deleteClip);
1126 deleteClip->setData("delete_clip");
1127 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1128 deleteClip->setEnabled(false);
1130 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1131 collection->addAction("reload_clip", reloadClip);
1132 reloadClip->setData("reload_clip");
1133 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1134 reloadClip->setEnabled(false);
1136 QMenu *addClips = new QMenu();
1137 addClips->addAction(addClip);
1138 addClips->addAction(addColorClip);
1139 addClips->addAction(addSlideClip);
1140 addClips->addAction(addTitleClip);
1141 addClips->addAction(addTitleTemplateClip);
1142 addClips->addAction(addFolderButton);
1144 addClips->addAction(reloadClip);
1145 addClips->addAction(clipProperties);
1146 addClips->addAction(openClip);
1147 addClips->addAction(deleteClip);
1148 m_projectList->setupMenu(addClips, addClip);
1150 //connect(collection, SIGNAL( clearStatusText() ),
1151 //statusBar(), SLOT( clear() ) );
1154 void MainWindow::slotDisplayActionMessage(QAction *a)
1156 statusBar()->showMessage(a->data().toString(), 3000);
1159 void MainWindow::saveOptions()
1161 KdenliveSettings::self()->writeConfig();
1162 KSharedConfigPtr config = KGlobal::config();
1163 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1164 KConfigGroup treecolumns(config, "Project Tree");
1165 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1169 void MainWindow::readOptions()
1171 KSharedConfigPtr config = KGlobal::config();
1172 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1173 KConfigGroup initialGroup(config, "version");
1174 bool upgrade = false;
1175 if (initialGroup.exists()) {
1176 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0))
1179 if (initialGroup.readEntry("version") == "0.7") {
1180 //Add new settings from 0.7.1
1181 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1182 QString path = QDir::homePath() + "/kdenlive";
1183 if (KStandardDirs::makeDir(path) == false) kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1184 KdenliveSettings::setDefaultprojectfolder(path);
1190 if (!initialGroup.exists() || upgrade) {
1191 // this is our first run, show Wizard
1192 Wizard *w = new Wizard(upgrade, this);
1193 if (w->exec() == QDialog::Accepted && w->isOk()) {
1194 w->adjustSettings();
1195 initialGroup.writeEntry("version", version);
1201 KConfigGroup treecolumns(config, "Project Tree");
1202 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1203 if (!state.isEmpty())
1204 m_projectList->setHeaderInfo(state);
1207 void MainWindow::slotRunWizard()
1209 Wizard *w = new Wizard(false, this);
1210 if (w->exec() == QDialog::Accepted && w->isOk()) {
1211 w->adjustSettings();
1216 void MainWindow::newFile(bool showProjectSettings)
1218 QString profileName;
1220 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1221 if (!showProjectSettings && m_timelineArea->count() == 0) {
1222 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1223 profileName = KdenliveSettings::default_profile();
1224 projectFolder = KdenliveSettings::defaultprojectfolder();
1226 ProjectSettings *w = new ProjectSettings(projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, this);
1227 if (w->exec() != QDialog::Accepted) return;
1228 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1229 KdenliveSettings::setVideothumbnails(w->enableVideoThumbs());
1230 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1231 KdenliveSettings::setAudiothumbnails(w->enableAudioThumbs());
1232 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1233 profileName = w->selectedProfile();
1234 projectFolder = w->selectedFolder();
1235 projectTracks = w->tracks();
1238 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1239 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1240 TrackView *trackView = new TrackView(doc, this);
1241 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1242 if (m_timelineArea->count() == 1) {
1243 connectDocumentInfo(doc);
1244 connectDocument(trackView, doc);
1245 } else m_timelineArea->setTabBarHidden(false);
1246 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1249 void MainWindow::activateDocument()
1251 if (m_timelineArea->currentWidget() == NULL) return;
1252 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1253 KdenliveDoc *currentDoc = currentTab->document();
1254 connectDocumentInfo(currentDoc);
1255 connectDocument(currentTab, currentDoc);
1258 void MainWindow::closeCurrentDocument()
1260 QWidget *w = m_timelineArea->currentWidget();
1262 // closing current document
1263 int ix = m_timelineArea->currentIndex() + 1;
1264 if (ix == m_timelineArea->count()) ix = 0;
1265 m_timelineArea->setCurrentIndex(ix);
1266 TrackView *tabToClose = (TrackView *) w;
1267 KdenliveDoc *docToClose = tabToClose->document();
1268 if (docToClose && docToClose->isModified()) {
1269 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
1270 case KMessageBox::Yes :
1271 // save document here. If saving fails, return false;
1272 if (saveFile() == false) return;
1274 case KMessageBox::Cancel :
1281 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1282 if (m_timelineArea->count() == 1) {
1283 m_timelineArea->setTabBarHidden(true);
1284 m_closeAction->setEnabled(false);
1286 if (docToClose == m_activeDocument) {
1287 delete m_activeDocument;
1288 m_activeDocument = NULL;
1289 m_effectStack->clear();
1290 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1291 } else delete docToClose;
1292 if (w == m_activeTimeline) {
1293 delete m_activeTimeline;
1294 m_activeTimeline = NULL;
1298 bool MainWindow::saveFileAs(const QString &outputFileName)
1300 QString currentSceneList;
1301 if (KdenliveSettings::dropbframes()) {
1302 KdenliveSettings::setDropbframes(false);
1303 m_activeDocument->clipManager()->updatePreviewSettings();
1304 currentSceneList = m_projectMonitor->sceneList();
1305 KdenliveSettings::setDropbframes(true);
1306 m_activeDocument->clipManager()->updatePreviewSettings();
1307 } else currentSceneList = m_projectMonitor->sceneList();
1309 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1312 // Save timeline thumbnails
1313 m_activeTimeline->projectView()->saveThumbnails();
1314 m_activeDocument->setUrl(KUrl(outputFileName));
1315 if (m_activeDocument->m_autosave == NULL) {
1316 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1317 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1318 setCaption(m_activeDocument->description());
1319 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1320 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1321 m_activeDocument->setModified(false);
1322 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1326 bool MainWindow::saveFileAs()
1328 // Check that the Kdenlive mime type is correctly installed
1329 QString mimetype = "application/x-kdenlive";
1330 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1331 if (!mime) mimetype = "*.kdenlive";
1333 QString outputFile = KFileDialog::getSaveFileName(KUrl(), mimetype);
1334 if (outputFile.isEmpty()) return false;
1335 if (QFile::exists(outputFile)) {
1336 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it?")) == KMessageBox::No) return false;
1338 return saveFileAs(outputFile);
1341 bool MainWindow::saveFile()
1343 if (!m_activeDocument) return true;
1344 if (m_activeDocument->url().isEmpty()) {
1345 return saveFileAs();
1347 bool result = saveFileAs(m_activeDocument->url().path());
1348 m_activeDocument->m_autosave->resize(0);
1353 void MainWindow::openFile()
1355 // Check that the Kdenlive mime type is correctly installed
1356 QString mimetype = "application/x-kdenlive";
1357 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1358 if (!mime) mimetype = "*.kdenlive";
1360 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), mimetype);
1361 if (url.isEmpty()) return;
1362 m_fileOpenRecent->addUrl(url);
1366 void MainWindow::openLastFile()
1368 KSharedConfigPtr config = KGlobal::config();
1369 KUrl::List urls = m_fileOpenRecent->urls();
1370 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1371 if (urls.isEmpty()) newFile(false);
1372 else openFile(urls.last());
1375 void MainWindow::openFile(const KUrl &url)
1377 // Check if the document is already opened
1378 const int ct = m_timelineArea->count();
1379 bool isOpened = false;
1381 for (i = 0; i < ct; i++) {
1382 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1383 KdenliveDoc *doc = tab->document();
1384 if (doc->url() == url) {
1390 m_timelineArea->setCurrentIndex(i);
1394 // Check for backup file
1395 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1396 if (!staleFiles.isEmpty()) {
1397 if (KMessageBox::questionYesNo(this,
1398 i18n("Auto-saved files exist. Do you want to recover them now?"),
1399 i18n("File Recovery"),
1400 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1401 recoverFiles(staleFiles);
1404 // remove the stale files
1405 foreach(KAutoSaveFile *stale, staleFiles) {
1406 stale->open(QIODevice::ReadWrite);
1411 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1412 doOpenFile(url, NULL);
1415 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1417 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, this);
1418 if (stale == NULL) {
1419 stale = new KAutoSaveFile(url, doc);
1420 doc->m_autosave = stale;
1422 doc->m_autosave = stale;
1423 doc->setUrl(stale->managedFile());
1424 doc->setModified(true);
1425 stale->setParent(doc);
1427 connectDocumentInfo(doc);
1428 TrackView *trackView = new TrackView(doc, this);
1429 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1430 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1431 trackView->setDuration(trackView->duration());
1432 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1434 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1435 slotGotProgressInfo(QString(), -1);
1436 m_clipMonitor->refreshMonitor(true);
1437 m_projectMonitor->adjustRulerSize(trackView->duration());
1438 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1441 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1443 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1444 foreach(KAutoSaveFile *stale, staleFiles) {
1445 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1446 // show an error message; we could not steal the lockfile
1447 // maybe another application got to the file before us?
1451 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1452 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
1453 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1454 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1459 void MainWindow::parseProfiles(const QString &mltPath)
1461 // kDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
1463 //KdenliveSettings::setDefaulttmpfolder();
1464 if (!mltPath.isEmpty()) {
1465 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1466 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
1469 if (KdenliveSettings::mltpath().isEmpty()) {
1470 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1472 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
1473 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
1474 if (!QFile::exists(meltPath))
1475 meltPath = KStandardDirs::findExe("melt");
1476 KdenliveSettings::setRendererpath(meltPath);
1478 QStringList profilesFilter;
1479 profilesFilter << "*";
1480 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1482 if (profilesList.isEmpty()) {
1483 // Cannot find MLT path, try finding melt
1484 QString profilePath = KdenliveSettings::rendererpath();
1485 if (!profilePath.isEmpty()) {
1486 profilePath = profilePath.section('/', 0, -3);
1487 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1488 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1491 if (profilesList.isEmpty()) {
1492 // Cannot find the MLT profiles, ask for location
1493 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1494 getUrl->fileDialog()->setMode(KFile::Directory);
1495 if (getUrl->exec() == QDialog::Rejected) {
1498 KUrl mltPath = getUrl->selectedUrl();
1500 if (mltPath.isEmpty()) ::exit(0);
1501 KdenliveSettings::setMltpath(mltPath.path());
1502 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1506 if (KdenliveSettings::rendererpath().isEmpty()) {
1507 // Cannot find the MLT melt renderer, ask for location
1508 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of Mlt)"), this);
1509 if (getUrl->exec() == QDialog::Rejected) {
1512 KUrl rendererPath = getUrl->selectedUrl();
1514 if (rendererPath.isEmpty()) ::exit(0);
1515 KdenliveSettings::setRendererpath(rendererPath.path());
1518 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1520 // Parse MLT profiles to build a list of available video formats
1521 if (profilesList.isEmpty()) parseProfiles();
1525 void MainWindow::slotEditProfiles()
1527 ProfilesDialog *w = new ProfilesDialog;
1528 if (w->exec() == QDialog::Accepted) {
1529 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1530 if (d) d->checkProfile();
1535 void MainWindow::slotDetectAudioDriver()
1537 //decide which audio driver is really best, in some cases SDL is wrong
1538 if (KdenliveSettings::audiodrivername().isEmpty()) {
1540 KProcess readProcess;
1541 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
1542 if (!KStandardDirs::findExe("pactl").isEmpty()) {
1543 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
1544 readProcess.setProgram("pactl", QStringList() << "stat");
1545 readProcess.execute(2000); // Kill it after 2 seconds
1547 QString result = QString(readProcess.readAllStandardOutput());
1548 kDebug() << "// / / / / / READING PACTL: ";
1550 if (!result.isEmpty()) {
1552 kDebug() << "// / / / / PULSEAUDIO DETECTED";
1556 KdenliveSettings::setAutoaudiodrivername(driver);
1560 void MainWindow::slotEditProjectSettings()
1562 QPoint p = m_activeDocument->getTracksCount();
1563 ProjectSettings *w = new ProjectSettings(p.x(), p.y(), m_activeDocument->projectFolder().path(), true, this);
1565 if (w->exec() == QDialog::Accepted) {
1566 QString profile = w->selectedProfile();
1567 m_activeDocument->setProjectFolder(w->selectedFolder());
1568 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path());
1569 if (m_activeDocument->profilePath() != profile) {
1570 // Profile was changed
1571 double dar = m_activeDocument->dar();
1572 m_activeDocument->setProfilePath(profile);
1573 KdenliveSettings::setCurrent_profile(profile);
1574 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1575 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1576 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1577 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1578 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1579 m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1580 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
1581 // We need to desactivate & reactivate monitors to get a refresh
1582 m_monitorManager->switchMonitors();
1588 void MainWindow::slotRenderProject()
1590 if (!m_renderWidget) {
1591 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path() : KdenliveSettings::defaultprojectfolder();
1592 m_renderWidget = new RenderWidget(projectfolder, this);
1593 connect(m_renderWidget, SIGNAL(doRender(const QStringList&, const QStringList&)), this, SLOT(slotDoRender(const QStringList&, const QStringList&)));
1594 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1595 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1596 if (m_activeDocument) {
1597 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1598 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1601 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1602 if (currentTab) m_renderWidget->setTimeline(currentTab);
1603 m_renderWidget->setDocument(m_activeDocument);*/
1604 m_renderWidget->show();
1607 void MainWindow::slotDoRender(const QStringList args, const QStringList overlay_args)
1609 QString dest = args.at(0);
1610 QString render = args.at(1);
1611 QStringList avformat_args = args.at(2).split(' ');
1612 bool zoneOnly = args.at(3).toInt();
1613 bool playAfter = args.at(4).toInt();
1614 double guideStart = args.at(5).toDouble();
1615 double guideEnd = args.at(6).toDouble();
1616 bool resizeProfile = args.at(7).toInt();
1617 QString scriptExport = args.at(8);
1618 bool createChapterFile = args.at(9).toInt();
1620 if (dest.isEmpty()) return;
1624 if (m_activeTimeline && zoneOnly) {
1625 in = m_activeTimeline->inPoint();
1626 out = m_activeTimeline->outPoint();
1629 KTemporaryFile temp;
1630 temp.setAutoRemove(false);
1631 temp.setSuffix(".mlt");
1632 if (!scriptExport.isEmpty() || temp.open()) {
1633 if (KdenliveSettings::dropbframes()) {
1634 KdenliveSettings::setDropbframes(false);
1635 m_activeDocument->clipManager()->updatePreviewSettings();
1636 if (!scriptExport.isEmpty()) m_projectMonitor->saveSceneList(scriptExport + ".mlt");
1637 else m_projectMonitor->saveSceneList(temp.fileName());
1638 KdenliveSettings::setDropbframes(true);
1639 m_activeDocument->clipManager()->updatePreviewSettings();
1641 if (!scriptExport.isEmpty()) m_projectMonitor->saveSceneList(scriptExport + ".mlt");
1642 else m_projectMonitor->saveSceneList(temp.fileName());
1646 if (scriptExport.isEmpty()) args << "-erase";
1647 if (KdenliveSettings::usekuiserver()) args << "-kuiserver";
1648 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
1649 else if (guideStart != -1) {
1650 args << "in=" + QString::number(GenTime(guideStart).frames(m_activeDocument->fps())) << "out=" + QString::number(GenTime(guideEnd).frames(m_activeDocument->fps()));
1652 if (!overlay_args.isEmpty()) args << "preargs=" + overlay_args.join(" ");
1653 QString videoPlayer = "-";
1655 videoPlayer = KdenliveSettings::defaultplayerapp();
1656 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."));
1658 if (!QFile::exists(KdenliveSettings::rendererpath())) {
1659 KMessageBox::sorry(this, i18n("Cannot find the melt program required for rendering (part of Mlt)"));
1660 setRenderingProgress(dest, -3);
1663 args << KdenliveSettings::rendererpath() << m_activeDocument->profilePath() << render << videoPlayer;
1665 for (int i = 0; i < avformat_args.count(); i++) {
1666 if (avformat_args.at(i).startsWith("profile=")) {
1667 if (avformat_args.at(i).section('=', 1) != m_activeDocument->profilePath()) resizeProfile = true;
1672 if (resizeProfile) {
1673 // The rendering profile is different from project profile, so use MLT's special producer_consumer
1674 if (scriptExport.isEmpty()) args << "consumer:" + temp.fileName();
1675 else args << "consumer:$SOURCE";
1677 if (scriptExport.isEmpty()) args << temp.fileName();
1678 else args << "$SOURCE";
1680 if (scriptExport.isEmpty()) args << dest;
1681 else args << "$TARGET";
1682 args << avformat_args;
1683 QString renderer = QCoreApplication::applicationDirPath() + QString("/kdenlive_render");
1684 if (!QFile::exists(renderer)) renderer = "kdenlive_render";
1685 if (scriptExport.isEmpty()) {
1686 QProcess::startDetached(renderer, args);
1687 KNotification::event("RenderStarted", i18n("Rendering <i>%1</i> started", dest), QPixmap(), this);
1689 // Generate script file
1690 QFile file(scriptExport);
1691 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
1692 KMessageBox::error(this, i18n("Cannot write to file %1", scriptExport));
1696 QTextStream outStream(&file);
1697 outStream << "#! /bin/sh" << "\n" << "\n";
1698 outStream << "SOURCE=" << "\"" + scriptExport + ".mlt\"" << "\n";
1699 outStream << "TARGET=" << "\"" + dest + "\"" << "\n";
1700 outStream << renderer << " " << args.join(" ") << "\n" << "\n";
1701 if (file.error() != QFile::NoError) {
1702 KMessageBox::error(this, i18n("Cannot write to file %1", scriptExport));
1707 QFile::setPermissions(scriptExport, file.permissions() | QFile::ExeUser);
1710 if (createChapterFile) {
1712 QDomElement chapters = doc.createElement("chapters");
1713 chapters.setAttribute("fps", m_activeDocument->fps());
1714 doc.appendChild(chapters);
1716 QDomElement guidesxml = m_activeDocument->guidesXml();
1717 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
1719 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
1720 for (int i = 0; i < nodes.count(); i++) {
1721 QDomElement e = nodes.item(i).toElement();
1723 QString comment = e.attribute("comment");
1724 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
1725 if (time >= in && time < out) {
1726 if (zoneOnly) time = time - in;
1727 QDomElement chapter = doc.createElement("chapter");
1728 chapters.appendChild(chapter);
1729 chapter.setAttribute("title", comment);
1730 chapter.setAttribute("time", time);
1734 if (chapters.childNodes().count() > 0) {
1735 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
1736 // Always insert a guide in pos 0
1737 QDomElement chapter = doc.createElement("chapter");
1738 chapters.insertBefore(chapter, QDomNode());
1739 chapter.setAttribute("title", i18n("Start"));
1740 chapter.setAttribute("time", "0");
1742 // save chapters file
1743 QFile file(dest + ".dvdchapter");
1744 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
1745 kWarning() << "////// ERROR writing DVD CHAPTER file: " << dest + ".dvdchapter";
1747 file.write(doc.toString().toUtf8());
1748 if (file.error() != QFile::NoError)
1749 kWarning() << "////// ERROR writing DVD CHAPTER file: " << dest + ".dvdchapter";
1757 void MainWindow::setRenderingProgress(const QString &url, int progress)
1759 if (m_renderWidget) m_renderWidget->setRenderJob(url, progress);
1762 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
1764 if (m_renderWidget) m_renderWidget->setRenderStatus(url, status, error);
1767 void MainWindow::slotUpdateMousePosition(int pos)
1769 if (m_activeDocument)
1770 switch (m_timecodeFormat->currentIndex()) {
1772 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1775 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1779 void MainWindow::slotUpdateDocumentState(bool modified)
1781 if (!m_activeDocument) return;
1782 setCaption(m_activeDocument->description(), modified);
1783 m_saveAction->setEnabled(modified);
1785 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1786 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1788 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1789 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1793 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
1795 if (m_activeDocument) {
1796 if (m_activeDocument == doc) return;
1797 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1799 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1802 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
1804 //m_projectMonitor->stop();
1805 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1806 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1807 if (m_activeDocument) {
1808 if (m_activeDocument == doc) return;
1809 if (m_activeTimeline) {
1810 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1811 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1812 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1813 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1814 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
1817 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1818 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1819 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1820 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1821 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1822 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1823 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1824 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1825 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1826 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
1827 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1828 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1829 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1830 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1831 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1832 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1833 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1834 disconnect(m_activeTimeline, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1835 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1836 disconnect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1837 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1838 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1839 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1840 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1841 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1842 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1843 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
1844 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1845 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1846 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
1847 m_effectStack->clear();
1849 //m_activeDocument->setRenderer(NULL);
1850 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1851 m_clipMonitor->stop();
1853 KdenliveSettings::setCurrent_profile(doc->profilePath());
1854 KdenliveSettings::setProject_fps(doc->fps());
1855 m_monitorManager->resetProfiles(doc->timecode());
1856 m_projectList->setDocument(doc);
1857 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), trackView->tracksNumber());
1858 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
1859 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1860 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1861 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
1864 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1865 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1866 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1867 connect(trackView, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1868 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1869 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1870 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1871 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1872 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
1873 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1874 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1875 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1876 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1877 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1879 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1880 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1881 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1884 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1885 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1886 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
1887 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1888 m_zoomSlider->setValue(doc->zoom());
1889 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1890 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1891 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1892 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1894 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1897 connect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1898 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1899 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1900 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1901 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1902 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1903 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1904 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1906 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1907 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1908 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
1910 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup);
1911 m_activeTimeline = trackView;
1912 if (m_renderWidget) {
1913 m_renderWidget->setProfile(doc->mltProfile());
1914 m_renderWidget->setDocumentPath(doc->projectFolder().path());
1916 //doc->setRenderer(m_projectMonitor->render);
1917 m_commandStack->setActiveStack(doc->commandStack());
1918 KdenliveSettings::setProject_display_ratio(doc->dar());
1919 m_projectList->updateAllClips();
1920 //doc->clipManager()->checkAudioThumbs();
1922 //m_overView->setScene(trackView->projectScene());
1923 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1924 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1926 setCaption(doc->description(), doc->isModified());
1927 m_saveAction->setEnabled(doc->isModified());
1928 m_activeDocument = doc;
1929 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
1931 // set tool to select tool
1932 m_buttonSelectTool->setChecked(true);
1935 void MainWindow::slotZoneMoved(int start, int end)
1937 m_activeDocument->setZone(start, end);
1938 m_projectMonitor->slotZoneMoved(start, end);
1941 void MainWindow::slotGuidesUpdated()
1943 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1946 void MainWindow::slotPreferences(int page, int option)
1948 //An instance of your dialog could be already created and could be
1949 // cached, in which case you want to display the cached dialog
1950 // instead of creating another one
1951 if (KConfigDialog::showDialog("settings")) {
1952 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1953 if (page != -1) d->showPage(page, option);
1957 // KConfigDialog didn't find an instance of this dialog, so lets
1959 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1960 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1961 connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
1962 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1963 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1964 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
1965 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1967 if (page != -1) dialog->showPage(page, option);
1970 void MainWindow::slotUpdatePreviewSettings()
1972 if (m_activeDocument) {
1973 m_clipMonitor->slotSetXml(NULL, 0);
1974 m_activeDocument->updatePreviewSettings();
1978 void MainWindow::updateConfiguration()
1980 //TODO: we should apply settings to all projects, not only the current one
1981 if (m_activeTimeline) {
1982 m_activeTimeline->refresh();
1983 m_activeTimeline->projectView()->checkAutoScroll();
1984 m_activeTimeline->projectView()->checkTrackHeight();
1985 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1987 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1988 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1990 // Update list of transcoding profiles
1992 #ifndef NO_JOGSHUTTLE
1993 activateShuttleDevice();
1994 #endif /* NO_JOGSHUTTLE */
1999 void MainWindow::slotSwitchVideoThumbs()
2001 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2002 if (m_activeTimeline) {
2003 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2005 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2008 void MainWindow::slotSwitchAudioThumbs()
2010 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2011 if (m_activeTimeline) {
2012 m_activeTimeline->refresh();
2013 m_activeTimeline->projectView()->checkAutoScroll();
2014 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
2016 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2019 void MainWindow::slotSwitchMarkersComments()
2021 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2022 if (m_activeTimeline) {
2023 m_activeTimeline->refresh();
2025 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2028 void MainWindow::slotSwitchSnap()
2030 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2031 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2035 void MainWindow::slotDeleteTimelineClip()
2037 if (QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) m_projectList->slotRemoveClip();
2038 else if (m_activeTimeline) {
2039 m_activeTimeline->projectView()->deleteSelectedClips();
2043 void MainWindow::slotChangeClipSpeed()
2045 if (m_activeTimeline) {
2046 m_activeTimeline->projectView()->changeClipSpeed();
2050 void MainWindow::slotAddClipMarker()
2052 DocClipBase *clip = NULL;
2054 if (m_projectMonitor->isActive()) {
2055 if (m_activeTimeline) {
2056 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2058 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
2059 clip = item->baseClip();
2063 clip = m_clipMonitor->activeClip();
2064 pos = m_clipMonitor->position();
2067 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2070 QString id = clip->getId();
2071 CommentedTime marker(pos, i18n("Marker"));
2072 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2073 if (d.exec() == QDialog::Accepted) {
2074 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2076 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2079 void MainWindow::slotDeleteClipMarker()
2081 DocClipBase *clip = NULL;
2083 if (m_projectMonitor->isActive()) {
2084 if (m_activeTimeline) {
2085 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2087 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
2088 clip = item->baseClip();
2092 clip = m_clipMonitor->activeClip();
2093 pos = m_clipMonitor->position();
2096 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2100 QString id = clip->getId();
2101 QString comment = clip->markerComment(pos);
2102 if (comment.isEmpty()) {
2103 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2106 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2107 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2111 void MainWindow::slotDeleteAllClipMarkers()
2113 DocClipBase *clip = NULL;
2114 if (m_projectMonitor->isActive()) {
2115 if (m_activeTimeline) {
2116 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2118 clip = item->baseClip();
2122 clip = m_clipMonitor->activeClip();
2125 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2128 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2129 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2132 void MainWindow::slotEditClipMarker()
2134 DocClipBase *clip = NULL;
2136 if (m_projectMonitor->isActive()) {
2137 if (m_activeTimeline) {
2138 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2140 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
2141 clip = item->baseClip();
2145 clip = m_clipMonitor->activeClip();
2146 pos = m_clipMonitor->position();
2149 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2153 QString id = clip->getId();
2154 QString oldcomment = clip->markerComment(pos);
2155 if (oldcomment.isEmpty()) {
2156 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2160 CommentedTime marker(pos, oldcomment);
2161 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2162 if (d.exec() == QDialog::Accepted) {
2163 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2164 if (d.newMarker().time() != pos) {
2165 // remove old marker
2166 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2168 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2172 void MainWindow::slotAddGuide()
2174 if (m_activeTimeline)
2175 m_activeTimeline->projectView()->slotAddGuide();
2178 void MainWindow::slotInsertSpace()
2180 if (m_activeTimeline)
2181 m_activeTimeline->projectView()->slotInsertSpace();
2184 void MainWindow::slotRemoveSpace()
2186 if (m_activeTimeline)
2187 m_activeTimeline->projectView()->slotRemoveSpace();
2190 void MainWindow::slotInsertTrack(int ix)
2192 m_projectMonitor->activateMonitor();
2193 if (m_activeTimeline)
2194 m_activeTimeline->projectView()->slotInsertTrack(ix);
2197 void MainWindow::slotDeleteTrack(int ix)
2199 m_projectMonitor->activateMonitor();
2200 if (m_activeTimeline)
2201 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2204 void MainWindow::slotChangeTrack(int ix)
2206 m_projectMonitor->activateMonitor();
2207 if (m_activeTimeline)
2208 m_activeTimeline->projectView()->slotChangeTrack(ix);
2211 void MainWindow::slotEditGuide()
2213 if (m_activeTimeline)
2214 m_activeTimeline->projectView()->slotEditGuide();
2217 void MainWindow::slotDeleteGuide()
2219 if (m_activeTimeline)
2220 m_activeTimeline->projectView()->slotDeleteGuide();
2223 void MainWindow::slotDeleteAllGuides()
2225 if (m_activeTimeline)
2226 m_activeTimeline->projectView()->slotDeleteAllGuides();
2229 void MainWindow::slotCutTimelineClip()
2231 if (m_activeTimeline) {
2232 m_activeTimeline->projectView()->cutSelectedClips();
2236 void MainWindow::slotGroupClips()
2238 if (m_activeTimeline) {
2239 m_activeTimeline->projectView()->groupClips();
2243 void MainWindow::slotUnGroupClips()
2245 if (m_activeTimeline) {
2246 m_activeTimeline->projectView()->groupClips(false);
2250 void MainWindow::slotAddProjectClip(KUrl url)
2252 if (m_activeDocument)
2253 m_activeDocument->slotAddClipFile(url, QString());
2256 void MainWindow::slotAddTransition(QAction *result)
2258 if (!result) return;
2259 QStringList info = result->data().toStringList();
2260 if (info.isEmpty()) return;
2261 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2262 if (m_activeTimeline && !transition.isNull()) {
2263 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2267 void MainWindow::slotAddVideoEffect(QAction *result)
2269 if (!result) return;
2270 QStringList info = result->data().toStringList();
2271 if (info.isEmpty()) return;
2272 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2273 slotAddEffect(effect);
2276 void MainWindow::slotAddAudioEffect(QAction *result)
2278 if (!result) return;
2279 QStringList info = result->data().toStringList();
2280 if (info.isEmpty()) return;
2281 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2282 slotAddEffect(effect);
2285 void MainWindow::slotAddCustomEffect(QAction *result)
2287 if (!result) return;
2288 QStringList info = result->data().toStringList();
2289 if (info.isEmpty()) return;
2290 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2291 slotAddEffect(effect);
2294 void MainWindow::slotZoomIn()
2296 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2299 void MainWindow::slotZoomOut()
2301 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2304 void MainWindow::slotFitZoom()
2306 if (m_activeTimeline) {
2307 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2311 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2313 m_statusProgressBar->setValue(progress);
2314 if (progress >= 0) {
2315 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2316 m_statusProgressBar->setVisible(true);
2318 m_messageLabel->setMessage(QString(), DefaultMessage);
2319 m_statusProgressBar->setVisible(false);
2323 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2325 if (clip->clipType() == TEXT) {
2326 QString titlepath = m_activeDocument->projectFolder().path() + "/titles/";
2327 if (!clip->getProperty("xmltemplate").isEmpty()) {
2328 // template text clip
2329 KUrl path = KUrlRequesterDialog::getUrl(clip->getProperty("xmltemplate"), this, i18n("Change template path"));
2330 if (!path.isEmpty() && (path.path() != clip->getProperty("xmltemplate"))) {
2331 // Clip template modified, update
2332 m_projectList->regenerateTemplate(clip->getId());
2336 QString path = clip->getProperty("resource");
2337 TitleWidget *dia_ui = new TitleWidget(KUrl(), titlepath, m_projectMonitor->render, this);
2339 doc.setContent(clip->getProperty("xmldata"));
2340 dia_ui->setXml(doc);
2341 if (dia_ui->exec() == QDialog::Accepted) {
2342 QImage pix = dia_ui->renderedPixmap();
2344 //slotAddClipFile(KUrl("/tmp/kdenlivetitle.png"), QString(), -1);
2345 //m_clipManager->slotEditTextClipFile(id, dia_ui->xml().toString());
2346 QMap <QString, QString> newprops;
2347 newprops.insert("xmldata", dia_ui->xml().toString());
2348 newprops.insert("frame_size", QString::number(pix.width()) + 'x' + QString::number(pix.height()));
2349 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2350 m_activeDocument->commandStack()->push(command);
2351 m_clipMonitor->refreshMonitor(true);
2352 m_activeDocument->setModified(true);
2356 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2359 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2360 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2361 if (dia.exec() == QDialog::Accepted) {
2362 EditClipCommand *command = new EditClipCommand(m_projectList, dia.clipId(), clip->properties(), dia.properties(), true);
2363 m_activeDocument->commandStack()->push(command);
2365 //m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
2366 if (dia.needsTimelineRefresh()) {
2367 // update clip occurences in timeline
2368 m_activeTimeline->projectView()->slotUpdateClip(dia.clipId());
2373 void MainWindow::customEvent(QEvent* e)
2375 if (e->type() == QEvent::User) {
2376 // The timeline playing position changed...
2377 kDebug() << "RECEIVED JOG EVEMNT!!!";
2380 void MainWindow::slotActivateEffectStackView()
2382 m_effectStack->raiseWindow(m_effectStackDock);
2385 void MainWindow::slotActivateTransitionView(Transition *t)
2387 if (t) m_transitionConfig->raiseWindow(m_transitionConfigDock);
2390 void MainWindow::slotSnapRewind()
2392 if (m_projectMonitor->isActive()) {
2393 if (m_activeTimeline)
2394 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2395 } else m_clipMonitor->slotSeekToPreviousSnap();
2398 void MainWindow::slotSnapForward()
2400 if (m_projectMonitor->isActive()) {
2401 if (m_activeTimeline)
2402 m_activeTimeline->projectView()->slotSeekToNextSnap();
2403 } else m_clipMonitor->slotSeekToNextSnap();
2406 void MainWindow::slotClipStart()
2408 if (m_projectMonitor->isActive()) {
2409 if (m_activeTimeline)
2410 m_activeTimeline->projectView()->clipStart();
2414 void MainWindow::slotClipEnd()
2416 if (m_projectMonitor->isActive()) {
2417 if (m_activeTimeline)
2418 m_activeTimeline->projectView()->clipEnd();
2422 void MainWindow::slotChangeTool(QAction * action)
2424 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
2425 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
2426 else if (action == m_buttonSpacerTool) slotSetTool(SPACERTOOL);
2429 void MainWindow::slotSetTool(PROJECTTOOL tool)
2431 if (m_activeDocument && m_activeTimeline) {
2432 //m_activeDocument->setTool(tool);
2433 m_activeTimeline->projectView()->setTool(tool);
2437 void MainWindow::slotCopy()
2439 if (!m_activeDocument || !m_activeTimeline) return;
2440 m_activeTimeline->projectView()->copyClip();
2443 void MainWindow::slotPaste()
2445 if (!m_activeDocument || !m_activeTimeline) return;
2446 m_activeTimeline->projectView()->pasteClip();
2449 void MainWindow::slotPasteEffects()
2451 if (!m_activeDocument || !m_activeTimeline) return;
2452 m_activeTimeline->projectView()->pasteClipEffects();
2455 void MainWindow::slotFind()
2457 if (!m_activeDocument || !m_activeTimeline) return;
2458 m_projectSearch->setEnabled(false);
2459 m_findActivated = true;
2460 m_findString.clear();
2461 m_activeTimeline->projectView()->initSearchStrings();
2462 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2463 m_findTimer.start(5000);
2464 qApp->installEventFilter(this);
2467 void MainWindow::slotFindNext()
2469 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
2470 statusBar()->showMessage(i18n("Found: %1", m_findString));
2472 statusBar()->showMessage(i18n("Reached end of project"));
2474 m_findTimer.start(4000);
2477 void MainWindow::findAhead()
2479 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
2480 m_projectSearchNext->setEnabled(true);
2481 statusBar()->showMessage(i18n("Found: %1", m_findString));
2483 m_projectSearchNext->setEnabled(false);
2484 statusBar()->showMessage(i18n("Not found: %1", m_findString));
2488 void MainWindow::findTimeout()
2490 m_projectSearchNext->setEnabled(false);
2491 m_findActivated = false;
2492 m_findString.clear();
2493 statusBar()->showMessage(i18n("Find stopped"), 3000);
2494 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
2495 m_projectSearch->setEnabled(true);
2496 removeEventFilter(this);
2499 void MainWindow::keyPressEvent(QKeyEvent *ke)
2501 if (m_findActivated) {
2502 if (ke->key() == Qt::Key_Backspace) {
2503 m_findString = m_findString.left(m_findString.length() - 1);
2505 if (!m_findString.isEmpty()) {
2511 m_findTimer.start(4000);
2514 } else if (ke->key() == Qt::Key_Escape) {
2518 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
2519 m_findString += ke->text();
2523 m_findTimer.start(4000);
2527 } else KXmlGuiWindow::keyPressEvent(ke);
2531 /** Gets called when the window gets hidden */
2532 void MainWindow::hideEvent(QHideEvent */*event*/)
2534 // kDebug() << "I was hidden";
2535 // issue http://www.kdenlive.org/mantis/view.php?id=231
2536 if (isMinimized()) {
2537 // kDebug() << "I am minimized";
2538 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
2542 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
2544 if (m_findActivated) {
2545 if (event->type() == QEvent::ShortcutOverride) {
2546 QKeyEvent* ke = (QKeyEvent*) event;
2547 if (ke->text().trimmed().isEmpty()) return false;
2550 } else return false;
2552 // pass the event on to the parent class
2553 return QMainWindow::eventFilter(obj, event);
2557 void MainWindow::slotSaveZone(Render *render, QPoint zone)
2559 KDialog *dialog = new KDialog(this);
2560 dialog->setCaption("Save clip zone");
2561 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
2563 QWidget *widget = new QWidget(dialog);
2564 dialog->setMainWidget(widget);
2566 QVBoxLayout *vbox = new QVBoxLayout(widget);
2567 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
2568 QString path = m_activeDocument->projectFolder().path();
2570 path.append("untitled.mlt");
2571 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
2572 url->setFilter("video/mlt-playlist");
2573 QLabel *label2 = new QLabel(i18n("Description:"), this);
2574 KLineEdit *edit = new KLineEdit(this);
2575 vbox->addWidget(label1);
2576 vbox->addWidget(url);
2577 vbox->addWidget(label2);
2578 vbox->addWidget(edit);
2579 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
2583 void MainWindow::slotSetInPoint()
2585 if (m_clipMonitor->isActive()) {
2586 m_clipMonitor->slotSetZoneStart();
2587 } else m_activeTimeline->projectView()->setInPoint();
2590 void MainWindow::slotSetOutPoint()
2592 if (m_clipMonitor->isActive()) {
2593 m_clipMonitor->slotSetZoneEnd();
2594 } else m_activeTimeline->projectView()->setOutPoint();
2597 void MainWindow::slotGetNewLumaStuff()
2599 //KNS::Entry::List download();
2600 KNS::Entry::List entries = KNS::Engine::download();
2601 // list of changed entries
2602 kDebug() << "// PARSING KNS";
2603 foreach(KNS::Entry* entry, entries) {
2604 // care only about installed ones
2605 if (entry->status() == KNS::Entry::Installed) {
2606 foreach(const QString &file, entry->installedFiles()) {
2607 kDebug() << "// CURRENTLY INSTALLED: " << file;
2611 qDeleteAll(entries);
2612 initEffects::refreshLumas();
2613 m_activeTimeline->projectView()->reloadTransitionLumas();
2616 void MainWindow::slotGetNewRenderStuff()
2618 //KNS::Entry::List download();
2620 KNS::Engine engine(0);
2621 if (engine.init("kdenlive_render.knsrc")) {
2622 KNS::Entry::List entries = engine.downloadDialogModal(this);
2624 if (entries.size() > 0) {
2625 foreach(KNS::Entry* entry, entries) {
2626 // care only about installed ones
2627 if (entry->status() == KNS::Entry::Installed) {
2628 foreach(const QString &file, entry->installedFiles()) {
2629 kDebug() << "// CURRENTLY INSTALLED: " << file;
2634 if (m_renderWidget) m_renderWidget->reloadProfiles();
2638 void MainWindow::slotGetNewMltProfileStuff()
2640 //KNS::Entry::List download();
2642 KNS::Engine engine(0);
2643 if (engine.init("kdenlive_mltprofiles.knsrc")) {
2644 KNS::Entry::List entries = engine.downloadDialogModal(this);
2646 if (entries.size() > 0) {
2647 foreach(KNS::Entry* entry, entries) {
2648 // care only about installed ones
2649 if (entry->status() == KNS::Entry::Installed) {
2650 foreach(const QString &file, entry->installedFiles()) {
2651 kDebug() << "// CURRENTLY INSTALLED: " << file;
2656 // update the list of profiles in settings dialog
2657 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2658 if (d) d->checkProfile();
2663 void MainWindow::slotAutoTransition()
2665 if (m_activeTimeline) m_activeTimeline->projectView()->autoTransition();
2668 void MainWindow::slotSplitAudio()
2670 if (m_activeTimeline) m_activeTimeline->projectView()->splitAudio();
2673 void MainWindow::slotUpdateClipType(QAction *action)
2675 if (m_activeTimeline) {
2676 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
2677 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
2678 else m_activeTimeline->projectView()->setAudioAndVideo();
2682 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
2684 DvdWizard *w = new DvdWizard(url, profile, this);
2688 void MainWindow::slotShowTimeline(bool show)
2690 if (show == false) {
2691 m_timelineState = saveState();
2692 centralWidget()->setHidden(true);
2694 centralWidget()->setHidden(false);
2695 restoreState(m_timelineState);
2699 void MainWindow::slotMaximizeCurrent(bool /*show*/)
2701 //TODO: is there a way to maximize current widget?
2704 m_timelineState = saveState();
2705 QWidget *par = focusWidget()->parentWidget();
2706 while (par->parentWidget() && par->parentWidget() != this) {
2707 par = par->parentWidget();
2709 kDebug() << "CURRENT WIDGET: " << par->objectName();
2712 //centralWidget()->setHidden(false);
2713 //restoreState(m_timelineState);
2717 void MainWindow::loadTranscoders()
2719 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
2722 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
2723 KConfigGroup transConfig(config, "Transcoding");
2725 QMap< QString, QString > profiles = transConfig.entryMap();
2726 QMapIterator<QString, QString> i(profiles);
2727 while (i.hasNext()) {
2729 QAction *a = transMenu->addAction(i.key());
2730 a->setData(i.value());
2731 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
2735 void MainWindow::slotTranscode(KUrl::List urls)
2738 if (urls.isEmpty()) {
2739 urls.append(m_projectList->currentClipUrl());
2740 QAction *action = qobject_cast<QAction *>(sender());
2741 params = action->data().toString();
2743 if (urls.isEmpty()) return;
2744 ClipTranscode *d = new ClipTranscode(urls, params);
2745 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
2747 //QProcess::startDetached("ffmpeg", parameters);
2750 void MainWindow::slotTranscodeClip()
2752 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
2753 if (urls.isEmpty()) return;
2754 slotTranscode(urls);
2757 #include "mainwindow.moc"