1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
21 #include "mainwindow.h"
22 #include "mainwindowadaptor.h"
23 #include "kdenlivesettings.h"
24 #include "kdenlivesettingsdialog.h"
25 #include "initeffects.h"
26 #include "profilesdialog.h"
27 #include "projectsettings.h"
29 #include "clipmanager.h"
30 #include "projectlist.h"
32 #include "recmonitor.h"
33 #include "monitormanager.h"
34 #include "kdenlivedoc.h"
35 #include "trackview.h"
36 #include "customtrackview.h"
37 #include "effectslistview.h"
38 #include "effectstackview.h"
39 #include "transitionsettings.h"
40 #include "renderwidget.h"
43 #include "jogshuttle.h"
44 #endif /* NO_JOGSHUTTLE */
45 #include "clipproperties.h"
47 #include "editclipcommand.h"
48 #include "titlewidget.h"
49 #include "markerdialog.h"
51 #include "interfaces.h"
52 #include "kdenlive-config.h"
53 #include "cliptranscode.h"
54 #include "ui_templateclip_ui.h"
56 #include <KApplication>
60 #include <KActionCollection>
61 #include <KStandardAction>
62 #include <KFileDialog>
63 #include <KMessageBox>
65 #include <KIO/NetAccess>
68 #include <KConfigDialog>
69 #include <KXMLGUIFactory>
71 #include <kstandarddirs.h>
72 #include <KUrlRequesterDialog>
73 #include <KTemporaryFile>
75 #include <KActionMenu>
78 #include <ktogglefullscreenaction.h>
80 #include <KNotification>
81 #include <KNotifyConfigWidget>
82 #include <knewstuff2/engine.h>
83 #include <knewstuff2/ui/knewstuffaction.h>
85 #include <QTextStream>
92 static const char version[] = VERSION;
94 static const int ID_TIMELINE_POS = 0;
101 EffectsList MainWindow::videoEffects;
102 EffectsList MainWindow::audioEffects;
103 EffectsList MainWindow::customEffects;
104 EffectsList MainWindow::transitions;
106 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent) :
107 KXmlGuiWindow(parent),
108 m_activeDocument(NULL),
109 m_activeTimeline(NULL),
110 m_renderWidget(NULL),
111 #ifndef NO_JOGSHUTTLE
113 #endif /* NO_JOGSHUTTLE */
114 m_findActivated(false)
117 // Create DBus interface
118 new MainWindowAdaptor(this);
119 QDBusConnection dbus = QDBusConnection::sessionBus();
120 dbus.registerObject("/MainWindow", this);
122 setlocale(LC_NUMERIC, "POSIX");
123 setFont(KGlobalSettings::toolBarFont());
124 parseProfiles(MltPath);
125 m_commandStack = new QUndoGroup;
126 m_timelineArea = new KTabWidget(this);
127 m_timelineArea->setTabReorderingEnabled(true);
128 m_timelineArea->setTabBarHidden(true);
130 QToolButton *closeTabButton = new QToolButton;
131 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
132 closeTabButton->setIcon(KIcon("tab-close"));
133 closeTabButton->adjustSize();
134 closeTabButton->setToolTip(i18n("Close the current tab"));
135 m_timelineArea->setCornerWidget(closeTabButton);
136 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
138 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
139 m_findTimer.setSingleShot(true);
141 // FIXME: the next call returns a newly allocated object, which leaks
142 initEffects::parseEffectFiles();
143 //initEffects::parseCustomEffectsFile();
145 m_monitorManager = new MonitorManager();
147 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
148 m_projectListDock->setObjectName("project_tree");
149 m_projectList = new ProjectList(this);
150 m_projectListDock->setWidget(m_projectList);
151 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
153 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
154 m_effectListDock->setObjectName("effect_list");
155 m_effectList = new EffectsListView();
157 //m_effectList = new KListWidget(this);
158 m_effectListDock->setWidget(m_effectList);
159 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
161 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
162 m_effectStackDock->setObjectName("effect_stack");
163 m_effectStack = new EffectStackView(this);
164 m_effectStackDock->setWidget(m_effectStack);
165 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
167 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
168 m_transitionConfigDock->setObjectName("transition");
169 m_transitionConfig = new TransitionSettings(this);
170 m_transitionConfigDock->setWidget(m_transitionConfig);
171 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
173 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
174 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
178 slotDetectAudioDriver();
180 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
181 m_clipMonitorDock->setObjectName("clip_monitor");
182 m_clipMonitor = new Monitor("clip", m_monitorManager, this);
183 m_clipMonitorDock->setWidget(m_clipMonitor);
184 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
185 //m_clipMonitor->stop();
187 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
188 m_projectMonitorDock->setObjectName("project_monitor");
189 m_projectMonitor = new Monitor("project", m_monitorManager, this);
190 m_projectMonitorDock->setWidget(m_projectMonitor);
191 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
193 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
194 m_recMonitorDock->setObjectName("record_monitor");
195 m_recMonitor = new RecMonitor("record", this);
196 m_recMonitorDock->setWidget(m_recMonitor);
197 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
199 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
200 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
202 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
203 m_undoViewDock->setObjectName("undo_history");
204 m_undoView = new QUndoView(this);
205 m_undoView->setCleanIcon(KIcon("edit-clear"));
206 m_undoView->setEmptyLabel(i18n("Clean"));
207 m_undoViewDock->setWidget(m_undoView);
208 m_undoView->setGroup(m_commandStack);
209 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
211 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
212 //overviewDock->setObjectName("project_overview");
213 //m_overView = new CustomTrackView(NULL, NULL, this);
214 //overviewDock->setWidget(m_overView);
215 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
218 //tabifyDockWidget(projectListDock, effectListDock);
219 tabifyDockWidget(m_projectListDock, m_effectStackDock);
220 tabifyDockWidget(m_projectListDock, m_transitionConfigDock);
221 //tabifyDockWidget(projectListDock, undoViewDock);
224 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
225 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
226 setCentralWidget(m_timelineArea);
230 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
231 guiFactory()->addClient(sp);*/
235 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
237 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone);
238 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
239 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)), static_cast<QMenu*>(factory()->container("transcoders", this)));
241 // build effects menus
243 QMenu *videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
245 QStringList effectInfo;
246 QMap<QString, QStringList> effectsList;
247 for (int ix = 0; ix < videoEffects.count(); ix++) {
248 effectInfo = videoEffects.effectIdInfo(ix);
249 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
252 foreach(const QStringList &value, effectsList) {
253 action = new QAction(value.at(0), this);
254 action->setData(value);
255 videoEffectsMenu->addAction(action);
258 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
262 for (int ix = 0; ix < audioEffects.count(); ix++) {
263 effectInfo = audioEffects.effectIdInfo(ix);
264 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
267 foreach(const QStringList &value, effectsList) {
268 action = new QAction(value.at(0), this);
269 action->setData(value);
270 audioEffectsMenu->addAction(action);
273 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
275 if (customEffects.isEmpty()) m_customEffectsMenu->setEnabled(false);
276 else m_customEffectsMenu->setEnabled(true);
279 for (int ix = 0; ix < customEffects.count(); ix++) {
280 effectInfo = customEffects.effectIdInfo(ix);
281 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
284 foreach(const QStringList &value, effectsList) {
285 action = new QAction(value.at(0), this);
286 action->setData(value);
287 m_customEffectsMenu->addAction(action);
290 QMenu *newEffect = new QMenu(this);
291 newEffect->addMenu(videoEffectsMenu);
292 newEffect->addMenu(audioEffectsMenu);
293 newEffect->addMenu(m_customEffectsMenu);
294 m_effectStack->setMenu(newEffect);
297 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
298 const QList<QAction *> viewActions = createPopupMenu()->actions();
299 viewMenu->insertActions(NULL, viewActions);
301 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
302 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
303 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
305 m_timelineContextMenu = new QMenu(this);
306 m_timelineContextClipMenu = new QMenu(this);
307 m_timelineContextTransitionMenu = new QMenu(this);
310 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
311 QStringList effects = transitions.effectNames();
314 for (int ix = 0; ix < transitions.count(); ix++) {
315 effectInfo = transitions.effectIdInfo(ix);
316 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
318 foreach(const QStringList &value, effectsList) {
319 action = new QAction(value.at(0), this);
320 action->setData(value);
321 transitionsMenu->addAction(action);
323 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
325 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
326 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
327 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
329 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
330 m_timelineContextClipMenu->addAction(actionCollection()->action("change_clip_speed"));
331 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
332 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
333 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
334 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
335 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
336 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
338 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
339 m_timelineContextClipMenu->addMenu(markersMenu);
340 m_timelineContextClipMenu->addMenu(transitionsMenu);
341 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
342 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
343 //TODO: re-enable custom effects menu when it is implemented
344 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
346 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
347 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
349 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
351 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
352 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
353 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
354 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
355 connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
356 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
358 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
359 slotConnectMonitors();
361 // Open or create a file. Command line argument passed in Url has
362 // precedence, then "openlastproject", then just a plain empty file.
363 // If opening Url fails, openlastproject will _not_ be used.
364 if (!Url.isEmpty()) {
367 if (KdenliveSettings::openlastproject()) {
371 if (m_timelineArea->count() == 0) {
375 #ifndef NO_JOGSHUTTLE
376 activateShuttleDevice();
377 #endif /* NO_JOGSHUTTLE */
378 m_projectListDock->raise();
381 void MainWindow::queryQuit()
383 kDebug() << "----- SAVING CONFUIG";
385 Mlt::Factory::close();
391 bool MainWindow::queryClose()
394 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
395 if (m_activeDocument && m_activeDocument->isModified()) {
396 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
397 case KMessageBox::Yes :
398 // save document here. If saving fails, return false;
400 case KMessageBox::No :
401 // User does not want to save the changes, clear recovery files
402 m_activeDocument->m_autosave->resize(0);
412 void MainWindow::loadPlugins()
414 foreach(QObject *plugin, QPluginLoader::staticInstances())
415 populateMenus(plugin);
417 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
419 filters << "libkdenlive*";
420 foreach(const QString &folder, directories) {
421 kDebug() << "// PARSING FIOLER: " << folder;
422 QDir pluginsDir(folder);
423 foreach(const QString &fileName, pluginsDir.entryList(filters, QDir::Files)) {
424 kDebug() << "// FOUND PLUGIN: " << fileName << "= " << pluginsDir.absoluteFilePath(fileName);
425 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
426 QObject *plugin = loader.instance();
428 populateMenus(plugin);
429 m_pluginFileNames += fileName;
430 } else kDebug() << "// ERROR LOADING PLUGIN: " << fileName << ", " << loader.errorString();
436 void MainWindow::populateMenus(QObject *plugin)
438 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
439 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
441 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
445 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
446 QMenu *menu, const char *member,
447 QActionGroup *actionGroup)
449 kDebug() << "// ADD to MENU" << texts;
450 foreach(const QString &text, texts) {
451 QAction *action = new QAction(text, plugin);
452 action->setData(text);
453 connect(action, SIGNAL(triggered()), this, member);
454 menu->addAction(action);
457 action->setCheckable(true);
458 actionGroup->addAction(action);
463 void MainWindow::aboutPlugins()
465 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
470 void MainWindow::generateClip()
472 QAction *action = qobject_cast<QAction *>(sender());
473 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
475 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(), QStringList(), QStringList(), 25, 720, 576);
476 if (!clipUrl.isEmpty()) {
477 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
481 void MainWindow::saveProperties(KConfig*)
483 // save properties here,used by session management
488 void MainWindow::readProperties(KConfig *config)
490 // read properties here,used by session management
491 QString Lastproject = config->group("Recent Files").readPathEntry("File1", QString());
492 openFile(KUrl(Lastproject));
495 void MainWindow::slotReloadEffects()
497 initEffects::parseCustomEffectsFile();
498 m_customEffectsMenu->clear();
499 const QStringList effects = customEffects.effectNames();
501 if (effects.isEmpty()) m_customEffectsMenu->setEnabled(false);
502 else m_customEffectsMenu->setEnabled(true);
504 foreach(const QString &name, effects) {
505 action = new QAction(name, this);
506 action->setData(name);
507 m_customEffectsMenu->addAction(action);
509 m_effectList->reloadEffectList();
512 #ifndef NO_JOGSHUTTLE
513 void MainWindow::activateShuttleDevice()
517 if (KdenliveSettings::enableshuttle() == false) return;
518 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
519 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
520 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
521 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
522 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
523 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
524 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
527 void MainWindow::slotShuttleButton(int code)
531 slotShuttleAction(KdenliveSettings::shuttle1());
534 slotShuttleAction(KdenliveSettings::shuttle2());
537 slotShuttleAction(KdenliveSettings::shuttle3());
540 slotShuttleAction(KdenliveSettings::shuttle4());
543 slotShuttleAction(KdenliveSettings::shuttle5());
548 void MainWindow::slotShuttleAction(int code)
554 m_monitorManager->slotPlay();
557 m_monitorManager->slotPlay();
561 #endif /* NO_JOGSHUTTLE */
563 void MainWindow::configureNotifications()
565 KNotifyConfigWidget::configure(this);
568 void MainWindow::slotFullScreen()
570 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
573 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track)
575 if (!m_activeDocument) return;
576 if (effect.isNull()) {
577 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
580 m_activeTimeline->projectView()->slotAddEffect(effect.cloneNode().toElement(), pos, track);
583 void MainWindow::slotRaiseMonitor(bool clipMonitor)
585 if (clipMonitor) m_clipMonitorDock->raise();
586 else m_projectMonitorDock->raise();
589 void MainWindow::slotUpdateClip(const QString &id)
591 if (!m_activeDocument) return;
592 m_activeTimeline->projectView()->slotUpdateClip(id);
595 void MainWindow::slotConnectMonitors()
598 m_projectList->setRenderer(m_projectMonitor->render);
599 connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
600 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
601 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, const QString &, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement &, const QString &, bool)));
602 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
603 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)));
605 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
607 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
609 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
610 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
612 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
613 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
616 void MainWindow::slotAdjustClipMonitor()
618 m_clipMonitorDock->updateGeometry();
619 m_clipMonitorDock->adjustSize();
620 m_clipMonitor->resetSize();
623 void MainWindow::slotAdjustProjectMonitor()
625 m_projectMonitorDock->updateGeometry();
626 m_projectMonitorDock->adjustSize();
627 m_projectMonitor->resetSize();
630 void MainWindow::setupActions()
633 KActionCollection* collection = actionCollection();
634 m_timecodeFormat = new KComboBox(this);
635 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
636 m_timecodeFormat->addItem(i18n("Frames"));
638 m_statusProgressBar = new QProgressBar(this);
639 m_statusProgressBar->setMinimum(0);
640 m_statusProgressBar->setMaximum(100);
641 m_statusProgressBar->setMaximumWidth(150);
642 m_statusProgressBar->setVisible(false);
644 QWidget *w = new QWidget;
646 QHBoxLayout *layout = new QHBoxLayout;
647 w->setLayout(layout);
648 layout->setContentsMargins(5, 0, 5, 0);
649 QToolBar *toolbar = new QToolBar("statusToolBar", this);
652 m_toolGroup = new QActionGroup(this);
654 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;}";
656 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
657 toolbar->addAction(m_buttonSelectTool);
658 m_buttonSelectTool->setCheckable(true);
659 m_buttonSelectTool->setChecked(true);
661 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
662 toolbar->addAction(m_buttonRazorTool);
663 m_buttonRazorTool->setCheckable(true);
664 m_buttonRazorTool->setChecked(false);
666 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
667 toolbar->addAction(m_buttonSpacerTool);
668 m_buttonSpacerTool->setCheckable(true);
669 m_buttonSpacerTool->setChecked(false);
671 m_toolGroup->addAction(m_buttonSelectTool);
672 m_toolGroup->addAction(m_buttonRazorTool);
673 m_toolGroup->addAction(m_buttonSpacerTool);
674 m_toolGroup->setExclusive(true);
675 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
677 QWidget * actionWidget;
678 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
679 actionWidget->setMaximumWidth(24);
680 actionWidget->setMinimumHeight(18);
682 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
683 actionWidget->setMaximumWidth(24);
684 actionWidget->setMinimumHeight(18);
686 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
687 actionWidget->setMaximumWidth(24);
688 actionWidget->setMinimumHeight(18);
690 toolbar->setStyleSheet(style1);
691 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
693 toolbar->addSeparator();
694 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
695 toolbar->addAction(m_buttonFitZoom);
696 m_buttonFitZoom->setCheckable(false);
697 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
699 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
700 actionWidget->setMaximumWidth(24);
701 actionWidget->setMinimumHeight(18);
703 m_zoomSlider = new QSlider(Qt::Horizontal, this);
704 m_zoomSlider->setMaximum(13);
705 m_zoomSlider->setPageStep(1);
707 m_zoomSlider->setMaximumWidth(150);
708 m_zoomSlider->setMinimumWidth(100);
710 const int contentHeight = QFontMetrics(w->font()).height() + 8;
712 QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
713 style.append("QSlider::handle:horizontal { background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
715 m_zoomSlider->setStyleSheet(style);
717 //m_zoomSlider->height() + 5;
718 statusBar()->setMinimumHeight(contentHeight);
721 toolbar->addWidget(m_zoomSlider);
723 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
724 toolbar->addAction(m_buttonVideoThumbs);
725 m_buttonVideoThumbs->setCheckable(true);
726 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
727 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
729 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
730 toolbar->addAction(m_buttonAudioThumbs);
731 m_buttonAudioThumbs->setCheckable(true);
732 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
733 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
735 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
736 toolbar->addAction(m_buttonShowMarkers);
737 m_buttonShowMarkers->setCheckable(true);
738 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
739 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
741 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
742 toolbar->addAction(m_buttonSnap);
743 m_buttonSnap->setCheckable(true);
744 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
745 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
746 layout->addWidget(toolbar);
749 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
750 actionWidget->setMaximumWidth(24);
751 actionWidget->setMinimumHeight(18);
753 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
754 actionWidget->setMaximumWidth(24);
755 actionWidget->setMinimumHeight(18);
757 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
758 actionWidget->setMaximumWidth(24);
759 actionWidget->setMinimumHeight(18);
761 actionWidget = toolbar->widgetForAction(m_buttonSnap);
762 actionWidget->setMaximumWidth(24);
763 actionWidget->setMinimumHeight(18);
765 m_messageLabel = new StatusBarMessageLabel(this);
766 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
768 statusBar()->addWidget(m_messageLabel, 10);
769 statusBar()->addWidget(m_statusProgressBar, 0);
770 statusBar()->addPermanentWidget(w);
771 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
772 statusBar()->addPermanentWidget(m_timecodeFormat);
773 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
774 m_messageLabel->hide();
776 collection->addAction("select_tool", m_buttonSelectTool);
777 collection->addAction("razor_tool", m_buttonRazorTool);
778 collection->addAction("spacer_tool", m_buttonSpacerTool);
780 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
781 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
782 collection->addAction("show_markers", m_buttonShowMarkers);
783 collection->addAction("snap", m_buttonSnap);
784 collection->addAction("zoom_fit", m_buttonFitZoom);
786 KAction* zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
787 collection->addAction("zoom_in", zoomIn);
788 connect(zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
789 zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
791 KAction* zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
792 collection->addAction("zoom_out", zoomOut);
793 connect(zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
794 zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
796 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
797 collection->addAction("project_find", m_projectSearch);
798 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
799 m_projectSearch->setShortcut(Qt::Key_Slash);
801 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
802 collection->addAction("project_find_next", m_projectSearchNext);
803 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
804 m_projectSearchNext->setShortcut(Qt::Key_F3);
805 m_projectSearchNext->setEnabled(false);
807 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
808 collection->addAction("manage_profiles", profilesAction);
809 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
811 KNS::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
813 KNS::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
815 KNS::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
817 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
818 collection->addAction("run_wizard", wizAction);
819 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
821 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
822 collection->addAction("project_settings", projectAction);
823 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
825 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
826 collection->addAction("project_render", projectRender);
827 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
828 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
830 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
831 KShortcut playShortcut;
832 playShortcut.setPrimary(Qt::Key_Space);
833 playShortcut.setAlternate(Qt::Key_K);
834 monitorPlay->setShortcut(playShortcut);
835 collection->addAction("monitor_play", monitorPlay);
836 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
838 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
839 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
840 collection->addAction("monitor_play_zone", m_playZone);
841 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
843 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
844 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
845 collection->addAction("monitor_loop_zone", m_loopZone);
846 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
848 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
849 collection->addAction("dvd_wizard", dvdWizard);
850 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
852 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clip"), this);
853 collection->addAction("transcode_clip", transcodeClip);
854 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
856 KAction *markIn = collection->addAction("mark_in");
857 markIn->setText(i18n("Set In Point"));
858 markIn->setShortcut(Qt::Key_I);
859 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
861 KAction *markOut = collection->addAction("mark_out");
862 markOut->setText(i18n("Set Out Point"));
863 markOut->setShortcut(Qt::Key_O);
864 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
866 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
867 monitorSeekBackward->setShortcut(Qt::Key_J);
868 collection->addAction("monitor_seek_backward", monitorSeekBackward);
869 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
871 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
872 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
873 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
874 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
876 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
877 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
878 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
879 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
881 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
882 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
883 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
884 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
886 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
887 monitorSeekForward->setShortcut(Qt::Key_L);
888 collection->addAction("monitor_seek_forward", monitorSeekForward);
889 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
891 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
892 clipStart->setShortcut(Qt::Key_Home);
893 collection->addAction("seek_clip_start", clipStart);
894 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
896 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
897 clipEnd->setShortcut(Qt::Key_End);
898 collection->addAction("seek_clip_end", clipEnd);
899 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
901 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
902 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
903 collection->addAction("seek_start", projectStart);
904 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
906 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
907 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
908 collection->addAction("seek_end", projectEnd);
909 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
911 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
912 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
913 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
914 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
916 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
917 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
918 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
919 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
921 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
922 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
923 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
924 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
926 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
927 deleteTimelineClip->setShortcut(Qt::Key_Delete);
928 collection->addAction("delete_timeline_clip", deleteTimelineClip);
929 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
931 KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
932 collection->addAction("change_clip_speed", editTimelineClipSpeed);
933 editTimelineClipSpeed->setData("change_speed");
934 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));
936 KAction *stickTransition = collection->addAction("auto_transition");
937 stickTransition->setData(QString("auto"));
938 stickTransition->setCheckable(true);
939 stickTransition->setEnabled(false);
940 stickTransition->setText(i18n("Automatic Transition"));
941 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
943 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
944 collection->addAction("group_clip", groupClip);
945 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
947 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
948 collection->addAction("ungroup_clip", ungroupClip);
949 ungroupClip->setData("ungroup_clip");
950 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
952 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
953 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
954 collection->addAction("cut_timeline_clip", cutTimelineClip);
955 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
957 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
958 collection->addAction("add_clip_marker", addClipMarker);
959 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
961 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
962 collection->addAction("delete_clip_marker", deleteClipMarker);
963 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
965 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
966 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
967 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
969 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
970 collection->addAction("edit_clip_marker", editClipMarker);
971 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
973 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
974 collection->addAction("split_audio", splitAudio);
975 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
977 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
978 collection->addAction("clip_audio_only", audioOnly);
979 audioOnly->setData("clip_audio_only");
980 audioOnly->setCheckable(true);
982 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
983 collection->addAction("clip_video_only", videoOnly);
984 videoOnly->setData("clip_video_only");
985 videoOnly->setCheckable(true);
987 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
988 collection->addAction("clip_audio_and_video", audioAndVideo);
989 audioAndVideo->setData("clip_audio_and_video");
990 audioAndVideo->setCheckable(true);
992 m_clipTypeGroup = new QActionGroup(this);
993 m_clipTypeGroup->addAction(audioOnly);
994 m_clipTypeGroup->addAction(videoOnly);
995 m_clipTypeGroup->addAction(audioAndVideo);
996 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
997 m_clipTypeGroup->setEnabled(false);
999 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1000 collection->addAction("insert_space", insertSpace);
1001 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1003 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1004 collection->addAction("delete_space", removeSpace);
1005 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1007 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1008 collection->addAction("insert_track", insertTrack);
1009 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1011 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1012 collection->addAction("delete_track", deleteTrack);
1013 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1015 KAction *changeTrack = new KAction(KIcon(), i18n("Change Track"), this);
1016 collection->addAction("change_track", changeTrack);
1017 connect(changeTrack, SIGNAL(triggered()), this, SLOT(slotChangeTrack()));
1019 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1020 collection->addAction("add_guide", addGuide);
1021 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1023 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1024 collection->addAction("delete_guide", delGuide);
1025 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1027 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1028 collection->addAction("edit_guide", editGuide);
1029 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1031 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1032 collection->addAction("delete_all_guides", delAllGuides);
1033 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1035 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1036 collection->addAction("paste_effects", pasteEffects);
1037 pasteEffects->setData("paste_effects");
1038 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1040 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1041 collection->addAction("show_timeline", showTimeline);
1042 showTimeline->setCheckable(true);
1043 showTimeline->setChecked(true);
1044 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1046 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1047 collection->addAction("maximize_current", maxCurrent);
1048 maxCurrent->setCheckable(true);
1049 maxCurrent->setChecked(false);
1050 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1053 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1055 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1057 KStandardAction::open(this, SLOT(openFile()), collection);
1059 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1061 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1063 KStandardAction::openNew(this, SLOT(newFile()), collection);
1065 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1067 KStandardAction::configureNotifications(this , SLOT(configureNotifications()), collection);
1069 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1071 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1073 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1074 undo->setEnabled(false);
1075 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1077 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1078 redo->setEnabled(false);
1079 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1081 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1084 //TODO: Add status tooltip to actions ?
1085 connect(collection, SIGNAL(actionHovered(QAction*)),
1086 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1089 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1090 collection->addAction("add_clip", addClip);
1091 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1093 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1094 collection->addAction("add_color_clip", addColorClip);
1095 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1097 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1098 collection->addAction("add_slide_clip", addSlideClip);
1099 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1101 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1102 collection->addAction("add_text_clip", addTitleClip);
1103 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1105 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1106 collection->addAction("add_text_template_clip", addTitleTemplateClip);
1107 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1109 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1110 collection->addAction("add_folder", addFolderButton);
1111 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1113 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1114 collection->addAction("clip_properties", clipProperties);
1115 clipProperties->setData("clip_properties");
1116 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1117 clipProperties->setEnabled(false);
1119 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1120 collection->addAction("edit_clip", openClip);
1121 openClip->setData("edit_clip");
1122 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1123 openClip->setEnabled(false);
1125 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1126 collection->addAction("delete_clip", deleteClip);
1127 deleteClip->setData("delete_clip");
1128 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1129 deleteClip->setEnabled(false);
1131 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1132 collection->addAction("reload_clip", reloadClip);
1133 reloadClip->setData("reload_clip");
1134 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1135 reloadClip->setEnabled(false);
1137 QMenu *addClips = new QMenu();
1138 addClips->addAction(addClip);
1139 addClips->addAction(addColorClip);
1140 addClips->addAction(addSlideClip);
1141 addClips->addAction(addTitleClip);
1142 addClips->addAction(addTitleTemplateClip);
1143 addClips->addAction(addFolderButton);
1145 addClips->addAction(reloadClip);
1146 addClips->addAction(clipProperties);
1147 addClips->addAction(openClip);
1148 addClips->addAction(deleteClip);
1149 m_projectList->setupMenu(addClips, addClip);
1151 //connect(collection, SIGNAL( clearStatusText() ),
1152 //statusBar(), SLOT( clear() ) );
1155 void MainWindow::slotDisplayActionMessage(QAction *a)
1157 statusBar()->showMessage(a->data().toString(), 3000);
1160 void MainWindow::saveOptions()
1162 KdenliveSettings::self()->writeConfig();
1163 KSharedConfigPtr config = KGlobal::config();
1164 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1165 KConfigGroup treecolumns(config, "Project Tree");
1166 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1170 void MainWindow::readOptions()
1172 KSharedConfigPtr config = KGlobal::config();
1173 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1174 KConfigGroup initialGroup(config, "version");
1175 bool upgrade = false;
1176 if (initialGroup.exists()) {
1177 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0))
1180 if (initialGroup.readEntry("version") == "0.7") {
1181 //Add new settings from 0.7.1
1182 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1183 QString path = QDir::homePath() + "/kdenlive";
1184 if (KStandardDirs::makeDir(path) == false) kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1185 KdenliveSettings::setDefaultprojectfolder(path);
1191 if (!initialGroup.exists() || upgrade) {
1192 // this is our first run, show Wizard
1193 Wizard *w = new Wizard(upgrade, this);
1194 if (w->exec() == QDialog::Accepted && w->isOk()) {
1195 w->adjustSettings();
1196 initialGroup.writeEntry("version", version);
1202 KConfigGroup treecolumns(config, "Project Tree");
1203 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1204 if (!state.isEmpty())
1205 m_projectList->setHeaderInfo(state);
1208 void MainWindow::slotRunWizard()
1210 Wizard *w = new Wizard(false, this);
1211 if (w->exec() == QDialog::Accepted && w->isOk()) {
1212 w->adjustSettings();
1217 void MainWindow::newFile(bool showProjectSettings)
1219 QString profileName;
1221 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1222 if (!showProjectSettings && m_timelineArea->count() == 0) {
1223 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1224 profileName = KdenliveSettings::default_profile();
1225 projectFolder = KdenliveSettings::defaultprojectfolder();
1227 ProjectSettings *w = new ProjectSettings(projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, this);
1228 if (w->exec() != QDialog::Accepted) return;
1229 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1230 KdenliveSettings::setVideothumbnails(w->enableVideoThumbs());
1231 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1232 KdenliveSettings::setAudiothumbnails(w->enableAudioThumbs());
1233 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1234 profileName = w->selectedProfile();
1235 projectFolder = w->selectedFolder();
1236 projectTracks = w->tracks();
1239 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1240 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1241 TrackView *trackView = new TrackView(doc, this);
1242 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1243 if (m_timelineArea->count() == 1) {
1244 connectDocumentInfo(doc);
1245 connectDocument(trackView, doc);
1246 } else m_timelineArea->setTabBarHidden(false);
1247 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1250 void MainWindow::activateDocument()
1252 if (m_timelineArea->currentWidget() == NULL) return;
1253 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1254 KdenliveDoc *currentDoc = currentTab->document();
1255 connectDocumentInfo(currentDoc);
1256 connectDocument(currentTab, currentDoc);
1259 void MainWindow::closeCurrentDocument()
1261 QWidget *w = m_timelineArea->currentWidget();
1263 // closing current document
1264 int ix = m_timelineArea->currentIndex() + 1;
1265 if (ix == m_timelineArea->count()) ix = 0;
1266 m_timelineArea->setCurrentIndex(ix);
1267 TrackView *tabToClose = (TrackView *) w;
1268 KdenliveDoc *docToClose = tabToClose->document();
1269 if (docToClose && docToClose->isModified()) {
1270 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
1271 case KMessageBox::Yes :
1272 // save document here. If saving fails, return false;
1273 if (saveFile() == false) return;
1275 case KMessageBox::Cancel :
1282 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1283 if (m_timelineArea->count() == 1) {
1284 m_timelineArea->setTabBarHidden(true);
1285 m_closeAction->setEnabled(false);
1287 if (docToClose == m_activeDocument) {
1288 delete m_activeDocument;
1289 m_activeDocument = NULL;
1290 m_effectStack->clear();
1291 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1292 } else delete docToClose;
1293 if (w == m_activeTimeline) {
1294 delete m_activeTimeline;
1295 m_activeTimeline = NULL;
1299 bool MainWindow::saveFileAs(const QString &outputFileName)
1301 QString currentSceneList;
1302 if (KdenliveSettings::dropbframes()) {
1303 KdenliveSettings::setDropbframes(false);
1304 m_activeDocument->clipManager()->updatePreviewSettings();
1305 currentSceneList = m_projectMonitor->sceneList();
1306 KdenliveSettings::setDropbframes(true);
1307 m_activeDocument->clipManager()->updatePreviewSettings();
1308 } else currentSceneList = m_projectMonitor->sceneList();
1310 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1313 // Save timeline thumbnails
1314 m_activeTimeline->projectView()->saveThumbnails();
1315 m_activeDocument->setUrl(KUrl(outputFileName));
1316 if (m_activeDocument->m_autosave == NULL) {
1317 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1318 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1319 setCaption(m_activeDocument->description());
1320 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1321 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1322 m_activeDocument->setModified(false);
1323 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1327 bool MainWindow::saveFileAs()
1329 // Check that the Kdenlive mime type is correctly installed
1330 QString mimetype = "application/x-kdenlive";
1331 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1332 if (!mime) mimetype = "*.kdenlive";
1334 QString outputFile = KFileDialog::getSaveFileName(KUrl(), mimetype);
1335 if (outputFile.isEmpty()) return false;
1336 if (QFile::exists(outputFile)) {
1337 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it?")) == KMessageBox::No) return false;
1339 return saveFileAs(outputFile);
1342 bool MainWindow::saveFile()
1344 if (!m_activeDocument) return true;
1345 if (m_activeDocument->url().isEmpty()) {
1346 return saveFileAs();
1348 bool result = saveFileAs(m_activeDocument->url().path());
1349 m_activeDocument->m_autosave->resize(0);
1354 void MainWindow::openFile()
1356 // Check that the Kdenlive mime type is correctly installed
1357 QString mimetype = "application/x-kdenlive";
1358 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1359 if (!mime) mimetype = "*.kdenlive";
1361 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), mimetype);
1362 if (url.isEmpty()) return;
1363 m_fileOpenRecent->addUrl(url);
1367 void MainWindow::openLastFile()
1369 KSharedConfigPtr config = KGlobal::config();
1370 KUrl::List urls = m_fileOpenRecent->urls();
1371 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1372 if (urls.isEmpty()) newFile(false);
1373 else openFile(urls.last());
1376 void MainWindow::openFile(const KUrl &url)
1378 // Check if the document is already opened
1379 const int ct = m_timelineArea->count();
1380 bool isOpened = false;
1382 for (i = 0; i < ct; i++) {
1383 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1384 KdenliveDoc *doc = tab->document();
1385 if (doc->url() == url) {
1391 m_timelineArea->setCurrentIndex(i);
1395 // Check for backup file
1396 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1397 if (!staleFiles.isEmpty()) {
1398 if (KMessageBox::questionYesNo(this,
1399 i18n("Auto-saved files exist. Do you want to recover them now?"),
1400 i18n("File Recovery"),
1401 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1402 recoverFiles(staleFiles);
1405 // remove the stale files
1406 foreach(KAutoSaveFile *stale, staleFiles) {
1407 stale->open(QIODevice::ReadWrite);
1412 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1413 doOpenFile(url, NULL);
1416 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1418 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, this);
1419 if (stale == NULL) {
1420 stale = new KAutoSaveFile(url, doc);
1421 doc->m_autosave = stale;
1423 doc->m_autosave = stale;
1424 doc->setUrl(stale->managedFile());
1425 doc->setModified(true);
1426 stale->setParent(doc);
1428 connectDocumentInfo(doc);
1429 TrackView *trackView = new TrackView(doc, this);
1430 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1431 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1432 trackView->setDuration(trackView->duration());
1433 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1435 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1436 slotGotProgressInfo(QString(), -1);
1437 m_clipMonitor->refreshMonitor(true);
1438 m_projectMonitor->adjustRulerSize(trackView->duration());
1439 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1442 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1444 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1445 foreach(KAutoSaveFile *stale, staleFiles) {
1446 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1447 // show an error message; we could not steal the lockfile
1448 // maybe another application got to the file before us?
1452 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1453 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
1454 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1455 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1460 void MainWindow::parseProfiles(const QString &mltPath)
1462 // kDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
1464 //KdenliveSettings::setDefaulttmpfolder();
1465 if (!mltPath.isEmpty()) {
1466 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1467 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
1470 if (KdenliveSettings::mltpath().isEmpty()) {
1471 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1473 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
1474 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
1475 if (!QFile::exists(meltPath))
1476 meltPath = KStandardDirs::findExe("melt");
1477 KdenliveSettings::setRendererpath(meltPath);
1479 QStringList profilesFilter;
1480 profilesFilter << "*";
1481 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1483 if (profilesList.isEmpty()) {
1484 // Cannot find MLT path, try finding melt
1485 QString profilePath = KdenliveSettings::rendererpath();
1486 if (!profilePath.isEmpty()) {
1487 profilePath = profilePath.section('/', 0, -3);
1488 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1489 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1492 if (profilesList.isEmpty()) {
1493 // Cannot find the MLT profiles, ask for location
1494 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1495 getUrl->fileDialog()->setMode(KFile::Directory);
1496 if (getUrl->exec() == QDialog::Rejected) {
1499 KUrl mltPath = getUrl->selectedUrl();
1501 if (mltPath.isEmpty()) ::exit(0);
1502 KdenliveSettings::setMltpath(mltPath.path());
1503 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1507 if (KdenliveSettings::rendererpath().isEmpty()) {
1508 // Cannot find the MLT melt renderer, ask for location
1509 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of Mlt)"), this);
1510 if (getUrl->exec() == QDialog::Rejected) {
1513 KUrl rendererPath = getUrl->selectedUrl();
1515 if (rendererPath.isEmpty()) ::exit(0);
1516 KdenliveSettings::setRendererpath(rendererPath.path());
1519 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1521 // Parse MLT profiles to build a list of available video formats
1522 if (profilesList.isEmpty()) parseProfiles();
1526 void MainWindow::slotEditProfiles()
1528 ProfilesDialog *w = new ProfilesDialog;
1529 if (w->exec() == QDialog::Accepted) {
1530 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1531 if (d) d->checkProfile();
1536 void MainWindow::slotDetectAudioDriver()
1538 //decide which audio driver is really best, in some cases SDL is wrong
1539 if (KdenliveSettings::audiodrivername().isEmpty()) {
1541 KProcess readProcess;
1542 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
1543 if (!KStandardDirs::findExe("pactl").isEmpty()) {
1544 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
1545 readProcess.setProgram("pactl", QStringList() << "stat");
1546 readProcess.execute(2000); // Kill it after 2 seconds
1548 QString result = QString(readProcess.readAllStandardOutput());
1549 kDebug() << "// / / / / / READING PACTL: ";
1551 if (!result.isEmpty()) {
1553 kDebug() << "// / / / / PULSEAUDIO DETECTED";
1557 KdenliveSettings::setAutoaudiodrivername(driver);
1561 void MainWindow::slotEditProjectSettings()
1563 QPoint p = m_activeDocument->getTracksCount();
1564 ProjectSettings *w = new ProjectSettings(p.x(), p.y(), m_activeDocument->projectFolder().path(), true, this);
1566 if (w->exec() == QDialog::Accepted) {
1567 QString profile = w->selectedProfile();
1568 m_activeDocument->setProjectFolder(w->selectedFolder());
1569 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path());
1570 if (m_activeDocument->profilePath() != profile) {
1571 // Profile was changed
1572 double dar = m_activeDocument->dar();
1573 m_activeDocument->setProfilePath(profile);
1574 KdenliveSettings::setCurrent_profile(profile);
1575 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1576 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1577 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1578 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1579 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1580 m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1581 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
1582 // We need to desactivate & reactivate monitors to get a refresh
1583 m_monitorManager->switchMonitors();
1589 void MainWindow::slotRenderProject()
1591 if (!m_renderWidget) {
1592 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path() : KdenliveSettings::defaultprojectfolder();
1593 m_renderWidget = new RenderWidget(projectfolder, this);
1594 connect(m_renderWidget, SIGNAL(doRender(const QStringList&, const QStringList&)), this, SLOT(slotDoRender(const QStringList&, const QStringList&)));
1595 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1596 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1597 if (m_activeDocument) {
1598 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1599 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1602 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1603 if (currentTab) m_renderWidget->setTimeline(currentTab);
1604 m_renderWidget->setDocument(m_activeDocument);*/
1605 m_renderWidget->show();
1608 void MainWindow::slotDoRender(const QStringList args, const QStringList overlay_args)
1610 QString dest = args.at(0);
1611 QString render = args.at(1);
1612 QStringList avformat_args = args.at(2).split(' ');
1613 bool zoneOnly = args.at(3).toInt();
1614 bool playAfter = args.at(4).toInt();
1615 double guideStart = args.at(5).toDouble();
1616 double guideEnd = args.at(6).toDouble();
1617 bool resizeProfile = args.at(7).toInt();
1618 QString scriptExport = args.at(8);
1619 bool createChapterFile = args.at(9).toInt();
1621 if (dest.isEmpty()) return;
1625 if (m_activeTimeline && zoneOnly) {
1626 in = m_activeTimeline->inPoint();
1627 out = m_activeTimeline->outPoint();
1630 KTemporaryFile temp;
1631 temp.setAutoRemove(false);
1632 temp.setSuffix(".mlt");
1633 if (!scriptExport.isEmpty() || temp.open()) {
1634 if (KdenliveSettings::dropbframes()) {
1635 KdenliveSettings::setDropbframes(false);
1636 m_activeDocument->clipManager()->updatePreviewSettings();
1637 if (!scriptExport.isEmpty()) m_projectMonitor->saveSceneList(scriptExport + ".mlt");
1638 else m_projectMonitor->saveSceneList(temp.fileName());
1639 KdenliveSettings::setDropbframes(true);
1640 m_activeDocument->clipManager()->updatePreviewSettings();
1642 if (!scriptExport.isEmpty()) m_projectMonitor->saveSceneList(scriptExport + ".mlt");
1643 else m_projectMonitor->saveSceneList(temp.fileName());
1647 if (scriptExport.isEmpty()) args << "-erase";
1648 if (KdenliveSettings::usekuiserver()) args << "-kuiserver";
1649 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
1650 else if (guideStart != -1) {
1651 args << "in=" + QString::number(GenTime(guideStart).frames(m_activeDocument->fps())) << "out=" + QString::number(GenTime(guideEnd).frames(m_activeDocument->fps()));
1653 if (!overlay_args.isEmpty()) args << "preargs=" + overlay_args.join(" ");
1654 QString videoPlayer = "-";
1656 videoPlayer = KdenliveSettings::defaultplayerapp();
1657 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."));
1659 if (!QFile::exists(KdenliveSettings::rendererpath())) {
1660 KMessageBox::sorry(this, i18n("Cannot find the melt program required for rendering (part of Mlt)"));
1661 setRenderingProgress(dest, -3);
1664 args << KdenliveSettings::rendererpath() << m_activeDocument->profilePath() << render << videoPlayer;
1666 for (int i = 0; i < avformat_args.count(); i++) {
1667 if (avformat_args.at(i).startsWith("profile=")) {
1668 if (avformat_args.at(i).section('=', 1) != m_activeDocument->profilePath()) resizeProfile = true;
1673 if (resizeProfile) {
1674 // The rendering profile is different from project profile, so use MLT's special producer_consumer
1675 if (scriptExport.isEmpty()) args << "consumer:" + temp.fileName();
1676 else args << "consumer:$SOURCE";
1678 if (scriptExport.isEmpty()) args << temp.fileName();
1679 else args << "$SOURCE";
1681 if (scriptExport.isEmpty()) args << dest;
1682 else args << "$TARGET";
1683 args << avformat_args;
1684 QString renderer = QCoreApplication::applicationDirPath() + QString("/kdenlive_render");
1685 if (!QFile::exists(renderer)) renderer = "kdenlive_render";
1686 if (scriptExport.isEmpty()) {
1687 QProcess::startDetached(renderer, args);
1688 KNotification::event("RenderStarted", i18n("Rendering <i>%1</i> started", dest), QPixmap(), this);
1690 // Generate script file
1691 QFile file(scriptExport);
1692 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
1693 KMessageBox::error(this, i18n("Cannot write to file %1", scriptExport));
1697 QTextStream outStream(&file);
1698 outStream << "#! /bin/sh" << "\n" << "\n";
1699 outStream << "SOURCE=" << "\"" + scriptExport + ".mlt\"" << "\n";
1700 outStream << "TARGET=" << "\"" + dest + "\"" << "\n";
1701 outStream << renderer << " " << args.join(" ") << "\n" << "\n";
1702 if (file.error() != QFile::NoError) {
1703 KMessageBox::error(this, i18n("Cannot write to file %1", scriptExport));
1708 QFile::setPermissions(scriptExport, file.permissions() | QFile::ExeUser);
1711 if (createChapterFile) {
1713 QDomElement chapters = doc.createElement("chapters");
1714 chapters.setAttribute("fps", m_activeDocument->fps());
1715 doc.appendChild(chapters);
1717 QDomElement guidesxml = m_activeDocument->guidesXml();
1718 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
1720 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
1721 for (int i = 0; i < nodes.count(); i++) {
1722 QDomElement e = nodes.item(i).toElement();
1724 QString comment = e.attribute("comment");
1725 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
1726 if (time >= in && time < out) {
1727 if (zoneOnly) time = time - in;
1728 QDomElement chapter = doc.createElement("chapter");
1729 chapters.appendChild(chapter);
1730 chapter.setAttribute("title", comment);
1731 chapter.setAttribute("time", time);
1735 if (chapters.childNodes().count() > 0) {
1736 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
1737 // Always insert a guide in pos 0
1738 QDomElement chapter = doc.createElement("chapter");
1739 chapters.insertBefore(chapter, QDomNode());
1740 chapter.setAttribute("title", i18n("Start"));
1741 chapter.setAttribute("time", "0");
1743 // save chapters file
1744 QFile file(dest + ".dvdchapter");
1745 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
1746 kWarning() << "////// ERROR writing DVD CHAPTER file: " << dest + ".dvdchapter";
1748 file.write(doc.toString().toUtf8());
1749 if (file.error() != QFile::NoError)
1750 kWarning() << "////// ERROR writing DVD CHAPTER file: " << dest + ".dvdchapter";
1758 void MainWindow::setRenderingProgress(const QString &url, int progress)
1760 if (m_renderWidget) m_renderWidget->setRenderJob(url, progress);
1763 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
1765 if (m_renderWidget) m_renderWidget->setRenderStatus(url, status, error);
1768 void MainWindow::slotUpdateMousePosition(int pos)
1770 if (m_activeDocument)
1771 switch (m_timecodeFormat->currentIndex()) {
1773 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1776 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1780 void MainWindow::slotUpdateDocumentState(bool modified)
1782 if (!m_activeDocument) return;
1783 setCaption(m_activeDocument->description(), modified);
1784 m_saveAction->setEnabled(modified);
1786 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1787 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1789 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1790 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1794 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
1796 if (m_activeDocument) {
1797 if (m_activeDocument == doc) return;
1798 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1800 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1803 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
1805 //m_projectMonitor->stop();
1806 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1807 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1808 if (m_activeDocument) {
1809 if (m_activeDocument == doc) return;
1810 if (m_activeTimeline) {
1811 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1812 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1813 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1814 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1815 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
1818 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1819 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1820 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1821 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1822 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1823 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1824 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1825 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1826 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1827 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
1828 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1829 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1830 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1831 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1832 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1833 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1834 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1835 disconnect(m_activeTimeline, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1836 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1837 disconnect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1838 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1839 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1840 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1841 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1842 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1843 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1844 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
1845 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1846 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1847 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
1848 m_effectStack->clear();
1850 //m_activeDocument->setRenderer(NULL);
1851 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1852 disconnect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
1853 m_clipMonitor->stop();
1855 KdenliveSettings::setCurrent_profile(doc->profilePath());
1856 KdenliveSettings::setProject_fps(doc->fps());
1857 m_monitorManager->resetProfiles(doc->timecode());
1858 m_projectList->setDocument(doc);
1859 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), trackView->tracksNumber());
1860 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
1861 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1862 connect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
1863 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1864 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
1867 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1868 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1869 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1870 connect(trackView, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1871 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1872 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1873 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1874 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1875 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
1876 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1877 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1878 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1879 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1880 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1882 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1883 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1884 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1887 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1888 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1889 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
1890 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1891 m_zoomSlider->setValue(doc->zoom());
1892 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1893 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1894 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1895 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1897 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1900 connect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1901 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1902 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1903 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1904 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1905 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1906 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1907 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1909 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1910 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1911 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
1913 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup);
1914 m_activeTimeline = trackView;
1915 if (m_renderWidget) {
1916 m_renderWidget->setProfile(doc->mltProfile());
1917 m_renderWidget->setDocumentPath(doc->projectFolder().path());
1919 //doc->setRenderer(m_projectMonitor->render);
1920 m_commandStack->setActiveStack(doc->commandStack());
1921 KdenliveSettings::setProject_display_ratio(doc->dar());
1922 m_projectList->updateAllClips();
1923 //doc->clipManager()->checkAudioThumbs();
1925 //m_overView->setScene(trackView->projectScene());
1926 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1927 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1929 setCaption(doc->description(), doc->isModified());
1930 m_saveAction->setEnabled(doc->isModified());
1931 m_activeDocument = doc;
1932 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
1934 // set tool to select tool
1935 m_buttonSelectTool->setChecked(true);
1938 void MainWindow::slotZoneMoved(int start, int end)
1940 m_activeDocument->setZone(start, end);
1941 m_projectMonitor->slotZoneMoved(start, end);
1944 void MainWindow::slotGuidesUpdated()
1946 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1949 void MainWindow::slotPreferences(int page, int option)
1951 //An instance of your dialog could be already created and could be
1952 // cached, in which case you want to display the cached dialog
1953 // instead of creating another one
1954 if (KConfigDialog::showDialog("settings")) {
1955 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1956 if (page != -1) d->showPage(page, option);
1960 // KConfigDialog didn't find an instance of this dialog, so lets
1962 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1963 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1964 connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
1965 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1966 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1967 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
1968 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1970 if (page != -1) dialog->showPage(page, option);
1973 void MainWindow::slotUpdatePreviewSettings()
1975 if (m_activeDocument) {
1976 m_clipMonitor->slotSetXml(NULL, 0);
1977 m_activeDocument->updatePreviewSettings();
1981 void MainWindow::updateConfiguration()
1983 //TODO: we should apply settings to all projects, not only the current one
1984 if (m_activeTimeline) {
1985 m_activeTimeline->refresh();
1986 m_activeTimeline->projectView()->checkAutoScroll();
1987 m_activeTimeline->projectView()->checkTrackHeight();
1988 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1990 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1991 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1993 // Update list of transcoding profiles
1995 #ifndef NO_JOGSHUTTLE
1996 activateShuttleDevice();
1997 #endif /* NO_JOGSHUTTLE */
2002 void MainWindow::slotSwitchVideoThumbs()
2004 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2005 if (m_activeTimeline) {
2006 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2008 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2011 void MainWindow::slotSwitchAudioThumbs()
2013 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2014 if (m_activeTimeline) {
2015 m_activeTimeline->refresh();
2016 m_activeTimeline->projectView()->checkAutoScroll();
2017 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
2019 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2022 void MainWindow::slotSwitchMarkersComments()
2024 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2025 if (m_activeTimeline) {
2026 m_activeTimeline->refresh();
2028 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2031 void MainWindow::slotSwitchSnap()
2033 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2034 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2038 void MainWindow::slotDeleteTimelineClip()
2040 if (QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) m_projectList->slotRemoveClip();
2041 else if (m_activeTimeline) {
2042 m_activeTimeline->projectView()->deleteSelectedClips();
2046 void MainWindow::slotChangeClipSpeed()
2048 if (m_activeTimeline) {
2049 m_activeTimeline->projectView()->changeClipSpeed();
2053 void MainWindow::slotAddClipMarker()
2055 DocClipBase *clip = NULL;
2057 if (m_projectMonitor->isActive()) {
2058 if (m_activeTimeline) {
2059 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2061 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
2062 clip = item->baseClip();
2066 clip = m_clipMonitor->activeClip();
2067 pos = m_clipMonitor->position();
2070 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2073 QString id = clip->getId();
2074 CommentedTime marker(pos, i18n("Marker"));
2075 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2076 if (d.exec() == QDialog::Accepted) {
2077 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2079 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2082 void MainWindow::slotDeleteClipMarker()
2084 DocClipBase *clip = NULL;
2086 if (m_projectMonitor->isActive()) {
2087 if (m_activeTimeline) {
2088 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2090 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
2091 clip = item->baseClip();
2095 clip = m_clipMonitor->activeClip();
2096 pos = m_clipMonitor->position();
2099 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2103 QString id = clip->getId();
2104 QString comment = clip->markerComment(pos);
2105 if (comment.isEmpty()) {
2106 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2109 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2110 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2114 void MainWindow::slotDeleteAllClipMarkers()
2116 DocClipBase *clip = NULL;
2117 if (m_projectMonitor->isActive()) {
2118 if (m_activeTimeline) {
2119 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2121 clip = item->baseClip();
2125 clip = m_clipMonitor->activeClip();
2128 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2131 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2132 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2135 void MainWindow::slotEditClipMarker()
2137 DocClipBase *clip = NULL;
2139 if (m_projectMonitor->isActive()) {
2140 if (m_activeTimeline) {
2141 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2143 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
2144 clip = item->baseClip();
2148 clip = m_clipMonitor->activeClip();
2149 pos = m_clipMonitor->position();
2152 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2156 QString id = clip->getId();
2157 QString oldcomment = clip->markerComment(pos);
2158 if (oldcomment.isEmpty()) {
2159 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2163 CommentedTime marker(pos, oldcomment);
2164 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2165 if (d.exec() == QDialog::Accepted) {
2166 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2167 if (d.newMarker().time() != pos) {
2168 // remove old marker
2169 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2171 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2175 void MainWindow::slotAddGuide()
2177 if (m_activeTimeline)
2178 m_activeTimeline->projectView()->slotAddGuide();
2181 void MainWindow::slotInsertSpace()
2183 if (m_activeTimeline)
2184 m_activeTimeline->projectView()->slotInsertSpace();
2187 void MainWindow::slotRemoveSpace()
2189 if (m_activeTimeline)
2190 m_activeTimeline->projectView()->slotRemoveSpace();
2193 void MainWindow::slotInsertTrack(int ix)
2195 m_projectMonitor->activateMonitor();
2196 if (m_activeTimeline)
2197 m_activeTimeline->projectView()->slotInsertTrack(ix);
2200 void MainWindow::slotDeleteTrack(int ix)
2202 m_projectMonitor->activateMonitor();
2203 if (m_activeTimeline)
2204 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2207 void MainWindow::slotChangeTrack(int ix)
2209 m_projectMonitor->activateMonitor();
2210 if (m_activeTimeline)
2211 m_activeTimeline->projectView()->slotChangeTrack(ix);
2214 void MainWindow::slotEditGuide()
2216 if (m_activeTimeline)
2217 m_activeTimeline->projectView()->slotEditGuide();
2220 void MainWindow::slotDeleteGuide()
2222 if (m_activeTimeline)
2223 m_activeTimeline->projectView()->slotDeleteGuide();
2226 void MainWindow::slotDeleteAllGuides()
2228 if (m_activeTimeline)
2229 m_activeTimeline->projectView()->slotDeleteAllGuides();
2232 void MainWindow::slotCutTimelineClip()
2234 if (m_activeTimeline) {
2235 m_activeTimeline->projectView()->cutSelectedClips();
2239 void MainWindow::slotGroupClips()
2241 if (m_activeTimeline) {
2242 m_activeTimeline->projectView()->groupClips();
2246 void MainWindow::slotUnGroupClips()
2248 if (m_activeTimeline) {
2249 m_activeTimeline->projectView()->groupClips(false);
2253 void MainWindow::slotAddProjectClip(KUrl url)
2255 if (m_activeDocument)
2256 m_activeDocument->slotAddClipFile(url, QString());
2259 void MainWindow::slotAddTransition(QAction *result)
2261 if (!result) return;
2262 QStringList info = result->data().toStringList();
2263 if (info.isEmpty()) return;
2264 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2265 if (m_activeTimeline && !transition.isNull()) {
2266 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2270 void MainWindow::slotAddVideoEffect(QAction *result)
2272 if (!result) return;
2273 QStringList info = result->data().toStringList();
2274 if (info.isEmpty()) return;
2275 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2276 slotAddEffect(effect);
2279 void MainWindow::slotAddAudioEffect(QAction *result)
2281 if (!result) return;
2282 QStringList info = result->data().toStringList();
2283 if (info.isEmpty()) return;
2284 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2285 slotAddEffect(effect);
2288 void MainWindow::slotAddCustomEffect(QAction *result)
2290 if (!result) return;
2291 QStringList info = result->data().toStringList();
2292 if (info.isEmpty()) return;
2293 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2294 slotAddEffect(effect);
2297 void MainWindow::slotZoomIn()
2299 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2302 void MainWindow::slotZoomOut()
2304 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2307 void MainWindow::slotFitZoom()
2309 if (m_activeTimeline) {
2310 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2314 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2316 m_statusProgressBar->setValue(progress);
2317 if (progress >= 0) {
2318 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2319 m_statusProgressBar->setVisible(true);
2321 m_messageLabel->setMessage(QString(), DefaultMessage);
2322 m_statusProgressBar->setVisible(false);
2326 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2328 if (clip->clipType() == TEXT) {
2329 QString titlepath = m_activeDocument->projectFolder().path() + "/titles/";
2330 if (!clip->getProperty("xmltemplate").isEmpty()) {
2331 // template text clip
2333 // Get the list of existing templates
2335 filter << "*.kdenlivetitle";
2336 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
2338 QDialog *dia = new QDialog(this);
2339 Ui::TemplateClip_UI dia_ui;
2340 dia_ui.setupUi(dia);
2342 const QString templatePath = clip->getProperty("xmltemplate");
2343 for (int i = 0; i < templateFiles.size(); ++i) {
2344 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
2345 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
2347 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
2348 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
2349 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
2350 //warning: setting base directory doesn't work??
2351 KUrl startDir(titlepath);
2352 dia_ui.template_list->fileDialog()->setUrl(startDir);
2353 dia_ui.description->setText(clip->getProperty("description"));
2354 dia_ui.clone_clip->setChecked(true);
2355 if (dia->exec() == QDialog::Accepted) {
2356 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
2357 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
2359 QMap <QString, QString> newprops;
2361 if (KUrl(textTemplate).path() != templatePath) {
2362 // The template was changed
2363 newprops.insert("xmltemplate", textTemplate);
2366 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
2367 newprops.insert("description", dia_ui.description->toPlainText());
2370 QString newtemplate = newprops.value("xmltemplate");
2371 if (newtemplate.isEmpty()) newtemplate = templatePath;
2373 // template modified we need to update xmldata
2374 QString description = newprops.value("description");
2375 if (description.isEmpty()) description = clip->getProperty("description");
2376 newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
2377 if (dia_ui.normal_clip->isChecked()) {
2378 // Switch clip to normal clip
2379 newprops.insert("xmltemplate", QString());
2381 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2382 m_activeDocument->commandStack()->push(command);
2386 QString path = clip->getProperty("resource");
2387 TitleWidget *dia_ui = new TitleWidget(KUrl(), titlepath, m_projectMonitor->render, this);
2389 doc.setContent(clip->getProperty("xmldata"));
2390 dia_ui->setXml(doc);
2391 if (dia_ui->exec() == QDialog::Accepted) {
2392 QRect rect = dia_ui->renderedRect();
2393 QMap <QString, QString> newprops;
2394 newprops.insert("xmldata", dia_ui->xml().toString());
2395 newprops.insert("frame_size", QString::number(rect.width()) + 'x' + QString::number(rect.height()));
2396 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2397 m_activeDocument->commandStack()->push(command);
2398 m_activeDocument->setModified(true);
2402 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2405 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2406 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2407 if (dia.exec() == QDialog::Accepted) {
2408 EditClipCommand *command = new EditClipCommand(m_projectList, dia.clipId(), clip->properties(), dia.properties(), true);
2409 m_activeDocument->commandStack()->push(command);
2411 //m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
2412 if (dia.needsTimelineRefresh()) {
2413 // update clip occurences in timeline
2414 m_activeTimeline->projectView()->slotUpdateClip(dia.clipId());
2419 void MainWindow::customEvent(QEvent* e)
2421 if (e->type() == QEvent::User) {
2422 // The timeline playing position changed...
2423 kDebug() << "RECEIVED JOG EVEMNT!!!";
2426 void MainWindow::slotActivateEffectStackView()
2428 m_effectStack->raiseWindow(m_effectStackDock);
2431 void MainWindow::slotActivateTransitionView(Transition *t)
2433 if (t) m_transitionConfig->raiseWindow(m_transitionConfigDock);
2436 void MainWindow::slotSnapRewind()
2438 if (m_projectMonitor->isActive()) {
2439 if (m_activeTimeline)
2440 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2441 } else m_clipMonitor->slotSeekToPreviousSnap();
2444 void MainWindow::slotSnapForward()
2446 if (m_projectMonitor->isActive()) {
2447 if (m_activeTimeline)
2448 m_activeTimeline->projectView()->slotSeekToNextSnap();
2449 } else m_clipMonitor->slotSeekToNextSnap();
2452 void MainWindow::slotClipStart()
2454 if (m_projectMonitor->isActive()) {
2455 if (m_activeTimeline)
2456 m_activeTimeline->projectView()->clipStart();
2460 void MainWindow::slotClipEnd()
2462 if (m_projectMonitor->isActive()) {
2463 if (m_activeTimeline)
2464 m_activeTimeline->projectView()->clipEnd();
2468 void MainWindow::slotChangeTool(QAction * action)
2470 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
2471 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
2472 else if (action == m_buttonSpacerTool) slotSetTool(SPACERTOOL);
2475 void MainWindow::slotSetTool(PROJECTTOOL tool)
2477 if (m_activeDocument && m_activeTimeline) {
2478 //m_activeDocument->setTool(tool);
2479 m_activeTimeline->projectView()->setTool(tool);
2483 void MainWindow::slotCopy()
2485 if (!m_activeDocument || !m_activeTimeline) return;
2486 m_activeTimeline->projectView()->copyClip();
2489 void MainWindow::slotPaste()
2491 if (!m_activeDocument || !m_activeTimeline) return;
2492 m_activeTimeline->projectView()->pasteClip();
2495 void MainWindow::slotPasteEffects()
2497 if (!m_activeDocument || !m_activeTimeline) return;
2498 m_activeTimeline->projectView()->pasteClipEffects();
2501 void MainWindow::slotFind()
2503 if (!m_activeDocument || !m_activeTimeline) return;
2504 m_projectSearch->setEnabled(false);
2505 m_findActivated = true;
2506 m_findString.clear();
2507 m_activeTimeline->projectView()->initSearchStrings();
2508 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2509 m_findTimer.start(5000);
2510 qApp->installEventFilter(this);
2513 void MainWindow::slotFindNext()
2515 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
2516 statusBar()->showMessage(i18n("Found: %1", m_findString));
2518 statusBar()->showMessage(i18n("Reached end of project"));
2520 m_findTimer.start(4000);
2523 void MainWindow::findAhead()
2525 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
2526 m_projectSearchNext->setEnabled(true);
2527 statusBar()->showMessage(i18n("Found: %1", m_findString));
2529 m_projectSearchNext->setEnabled(false);
2530 statusBar()->showMessage(i18n("Not found: %1", m_findString));
2534 void MainWindow::findTimeout()
2536 m_projectSearchNext->setEnabled(false);
2537 m_findActivated = false;
2538 m_findString.clear();
2539 statusBar()->showMessage(i18n("Find stopped"), 3000);
2540 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
2541 m_projectSearch->setEnabled(true);
2542 removeEventFilter(this);
2545 void MainWindow::keyPressEvent(QKeyEvent *ke)
2547 if (m_findActivated) {
2548 if (ke->key() == Qt::Key_Backspace) {
2549 m_findString = m_findString.left(m_findString.length() - 1);
2551 if (!m_findString.isEmpty()) {
2557 m_findTimer.start(4000);
2560 } else if (ke->key() == Qt::Key_Escape) {
2564 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
2565 m_findString += ke->text();
2569 m_findTimer.start(4000);
2573 } else KXmlGuiWindow::keyPressEvent(ke);
2577 /** Gets called when the window gets hidden */
2578 void MainWindow::hideEvent(QHideEvent */*event*/)
2580 // kDebug() << "I was hidden";
2581 // issue http://www.kdenlive.org/mantis/view.php?id=231
2582 if (isMinimized()) {
2583 // kDebug() << "I am minimized";
2584 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
2588 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
2590 if (m_findActivated) {
2591 if (event->type() == QEvent::ShortcutOverride) {
2592 QKeyEvent* ke = (QKeyEvent*) event;
2593 if (ke->text().trimmed().isEmpty()) return false;
2596 } else return false;
2598 // pass the event on to the parent class
2599 return QMainWindow::eventFilter(obj, event);
2603 void MainWindow::slotSaveZone(Render *render, QPoint zone)
2605 KDialog *dialog = new KDialog(this);
2606 dialog->setCaption("Save clip zone");
2607 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
2609 QWidget *widget = new QWidget(dialog);
2610 dialog->setMainWidget(widget);
2612 QVBoxLayout *vbox = new QVBoxLayout(widget);
2613 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
2614 QString path = m_activeDocument->projectFolder().path();
2616 path.append("untitled.mlt");
2617 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
2618 url->setFilter("video/mlt-playlist");
2619 QLabel *label2 = new QLabel(i18n("Description:"), this);
2620 KLineEdit *edit = new KLineEdit(this);
2621 vbox->addWidget(label1);
2622 vbox->addWidget(url);
2623 vbox->addWidget(label2);
2624 vbox->addWidget(edit);
2625 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
2629 void MainWindow::slotSetInPoint()
2631 if (m_clipMonitor->isActive()) {
2632 m_clipMonitor->slotSetZoneStart();
2633 } else m_activeTimeline->projectView()->setInPoint();
2636 void MainWindow::slotSetOutPoint()
2638 if (m_clipMonitor->isActive()) {
2639 m_clipMonitor->slotSetZoneEnd();
2640 } else m_activeTimeline->projectView()->setOutPoint();
2643 void MainWindow::slotGetNewLumaStuff()
2645 //KNS::Entry::List download();
2646 KNS::Entry::List entries = KNS::Engine::download();
2647 // list of changed entries
2648 kDebug() << "// PARSING KNS";
2649 foreach(KNS::Entry* entry, entries) {
2650 // care only about installed ones
2651 if (entry->status() == KNS::Entry::Installed) {
2652 foreach(const QString &file, entry->installedFiles()) {
2653 kDebug() << "// CURRENTLY INSTALLED: " << file;
2657 qDeleteAll(entries);
2658 initEffects::refreshLumas();
2659 m_activeTimeline->projectView()->reloadTransitionLumas();
2662 void MainWindow::slotGetNewRenderStuff()
2664 //KNS::Entry::List download();
2666 KNS::Engine engine(0);
2667 if (engine.init("kdenlive_render.knsrc")) {
2668 KNS::Entry::List entries = engine.downloadDialogModal(this);
2670 if (entries.size() > 0) {
2671 foreach(KNS::Entry* entry, entries) {
2672 // care only about installed ones
2673 if (entry->status() == KNS::Entry::Installed) {
2674 foreach(const QString &file, entry->installedFiles()) {
2675 kDebug() << "// CURRENTLY INSTALLED: " << file;
2680 if (m_renderWidget) m_renderWidget->reloadProfiles();
2684 void MainWindow::slotGetNewMltProfileStuff()
2686 //KNS::Entry::List download();
2688 KNS::Engine engine(0);
2689 if (engine.init("kdenlive_mltprofiles.knsrc")) {
2690 KNS::Entry::List entries = engine.downloadDialogModal(this);
2692 if (entries.size() > 0) {
2693 foreach(KNS::Entry* entry, entries) {
2694 // care only about installed ones
2695 if (entry->status() == KNS::Entry::Installed) {
2696 foreach(const QString &file, entry->installedFiles()) {
2697 kDebug() << "// CURRENTLY INSTALLED: " << file;
2702 // update the list of profiles in settings dialog
2703 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2704 if (d) d->checkProfile();
2709 void MainWindow::slotAutoTransition()
2711 if (m_activeTimeline) m_activeTimeline->projectView()->autoTransition();
2714 void MainWindow::slotSplitAudio()
2716 if (m_activeTimeline) m_activeTimeline->projectView()->splitAudio();
2719 void MainWindow::slotUpdateClipType(QAction *action)
2721 if (m_activeTimeline) {
2722 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
2723 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
2724 else m_activeTimeline->projectView()->setAudioAndVideo();
2728 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
2730 DvdWizard *w = new DvdWizard(url, profile, this);
2734 void MainWindow::slotShowTimeline(bool show)
2736 if (show == false) {
2737 m_timelineState = saveState();
2738 centralWidget()->setHidden(true);
2740 centralWidget()->setHidden(false);
2741 restoreState(m_timelineState);
2745 void MainWindow::slotMaximizeCurrent(bool /*show*/)
2747 //TODO: is there a way to maximize current widget?
2750 m_timelineState = saveState();
2751 QWidget *par = focusWidget()->parentWidget();
2752 while (par->parentWidget() && par->parentWidget() != this) {
2753 par = par->parentWidget();
2755 kDebug() << "CURRENT WIDGET: " << par->objectName();
2758 //centralWidget()->setHidden(false);
2759 //restoreState(m_timelineState);
2763 void MainWindow::loadTranscoders()
2765 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
2768 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
2769 KConfigGroup transConfig(config, "Transcoding");
2771 QMap< QString, QString > profiles = transConfig.entryMap();
2772 QMapIterator<QString, QString> i(profiles);
2773 while (i.hasNext()) {
2775 QAction *a = transMenu->addAction(i.key());
2776 a->setData(i.value());
2777 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
2781 void MainWindow::slotTranscode(KUrl::List urls)
2784 if (urls.isEmpty()) {
2785 urls.append(m_projectList->currentClipUrl());
2786 QAction *action = qobject_cast<QAction *>(sender());
2787 params = action->data().toString();
2789 if (urls.isEmpty()) return;
2790 ClipTranscode *d = new ClipTranscode(urls, params);
2791 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
2793 //QProcess::startDetached("ffmpeg", parameters);
2796 void MainWindow::slotTranscodeClip()
2798 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
2799 if (urls.isEmpty()) return;
2800 slotTranscode(urls);
2803 #include "mainwindow.moc"