1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
21 #include "mainwindow.h"
22 #include "mainwindowadaptor.h"
23 #include "kdenlivesettings.h"
24 #include "kdenlivesettingsdialog.h"
25 #include "initeffects.h"
26 #include "profilesdialog.h"
27 #include "projectsettings.h"
29 #include "clipmanager.h"
30 #include "projectlist.h"
32 #include "recmonitor.h"
33 #include "monitormanager.h"
34 #include "kdenlivedoc.h"
35 #include "trackview.h"
36 #include "customtrackview.h"
37 #include "effectslistview.h"
38 #include "effectstackview.h"
39 #include "transitionsettings.h"
40 #include "renderwidget.h"
43 #include "jogshuttle.h"
44 #endif /* NO_JOGSHUTTLE */
45 #include "clipproperties.h"
47 #include "editclipcommand.h"
48 #include "titlewidget.h"
49 #include "markerdialog.h"
51 #include "interfaces.h"
52 #include "kdenlive-config.h"
53 #include "cliptranscode.h"
54 #include "ui_templateclip_ui.h"
56 #include <KApplication>
60 #include <KActionCollection>
61 #include <KStandardAction>
62 #include <KFileDialog>
63 #include <KMessageBox>
65 #include <KIO/NetAccess>
68 #include <KConfigDialog>
69 #include <KXMLGUIFactory>
71 #include <kstandarddirs.h>
72 #include <KUrlRequesterDialog>
73 #include <KTemporaryFile>
75 #include <KActionMenu>
78 #include <ktogglefullscreenaction.h>
80 #include <KNotification>
81 #include <KNotifyConfigWidget>
82 #include <knewstuff2/engine.h>
83 #include <knewstuff2/ui/knewstuffaction.h>
85 #include <QTextStream>
89 #include <QInputDialog>
93 static const char version[] = VERSION;
95 static const int ID_TIMELINE_POS = 0;
102 EffectsList MainWindow::videoEffects;
103 EffectsList MainWindow::audioEffects;
104 EffectsList MainWindow::customEffects;
105 EffectsList MainWindow::transitions;
107 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent) :
108 KXmlGuiWindow(parent),
109 m_activeDocument(NULL),
110 m_activeTimeline(NULL),
111 m_renderWidget(NULL),
112 #ifndef NO_JOGSHUTTLE
114 #endif /* NO_JOGSHUTTLE */
115 m_findActivated(false)
118 // Create DBus interface
119 new MainWindowAdaptor(this);
120 QDBusConnection dbus = QDBusConnection::sessionBus();
121 dbus.registerObject("/MainWindow", this);
123 setlocale(LC_NUMERIC, "POSIX");
124 setFont(KGlobalSettings::toolBarFont());
125 parseProfiles(MltPath);
126 m_commandStack = new QUndoGroup;
127 m_timelineArea = new KTabWidget(this);
128 m_timelineArea->setTabReorderingEnabled(true);
129 m_timelineArea->setTabBarHidden(true);
131 QToolButton *closeTabButton = new QToolButton;
132 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
133 closeTabButton->setIcon(KIcon("tab-close"));
134 closeTabButton->adjustSize();
135 closeTabButton->setToolTip(i18n("Close the current tab"));
136 m_timelineArea->setCornerWidget(closeTabButton);
137 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
139 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
140 m_findTimer.setSingleShot(true);
142 // FIXME: the next call returns a newly allocated object, which leaks
143 initEffects::parseEffectFiles();
144 //initEffects::parseCustomEffectsFile();
146 m_monitorManager = new MonitorManager();
148 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
149 m_projectListDock->setObjectName("project_tree");
150 m_projectList = new ProjectList(this);
151 m_projectListDock->setWidget(m_projectList);
152 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
154 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
155 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
157 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
158 m_effectListDock->setObjectName("effect_list");
159 m_effectList = new EffectsListView();
161 //m_effectList = new KListWidget(this);
162 m_effectListDock->setWidget(m_effectList);
163 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
165 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
166 m_effectStackDock->setObjectName("effect_stack");
167 m_effectStack = new EffectStackView(this);
168 m_effectStackDock->setWidget(m_effectStack);
169 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
171 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
172 m_transitionConfigDock->setObjectName("transition");
173 m_transitionConfig = new TransitionSettings(this);
174 m_transitionConfigDock->setWidget(m_transitionConfig);
175 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
177 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
178 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
182 //slotDetectAudioDriver();
184 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
185 m_clipMonitorDock->setObjectName("clip_monitor");
186 m_clipMonitor = new Monitor("clip", m_monitorManager, this);
187 m_clipMonitorDock->setWidget(m_clipMonitor);
188 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
189 //m_clipMonitor->stop();
191 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
192 m_projectMonitorDock->setObjectName("project_monitor");
193 m_projectMonitor = new Monitor("project", m_monitorManager, this);
194 m_projectMonitorDock->setWidget(m_projectMonitor);
195 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
198 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
199 m_recMonitorDock->setObjectName("record_monitor");
200 m_recMonitor = new RecMonitor("record", this);
201 m_recMonitorDock->setWidget(m_recMonitor);
202 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
204 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
205 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
208 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
209 m_undoViewDock->setObjectName("undo_history");
210 m_undoView = new QUndoView(this);
211 m_undoView->setCleanIcon(KIcon("edit-clear"));
212 m_undoView->setEmptyLabel(i18n("Clean"));
213 m_undoViewDock->setWidget(m_undoView);
214 m_undoView->setGroup(m_commandStack);
215 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
217 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
218 //overviewDock->setObjectName("project_overview");
219 //m_overView = new CustomTrackView(NULL, NULL, this);
220 //overviewDock->setWidget(m_overView);
221 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
224 //tabifyDockWidget(projectListDock, effectListDock);
225 tabifyDockWidget(m_projectListDock, m_effectStackDock);
226 tabifyDockWidget(m_projectListDock, m_transitionConfigDock);
227 //tabifyDockWidget(projectListDock, undoViewDock);
230 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
232 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
234 setCentralWidget(m_timelineArea);
238 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
239 guiFactory()->addClient(sp);*/
243 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
245 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone);
246 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
247 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)), static_cast<QMenu*>(factory()->container("transcoders", this)));
249 // build effects menus
251 QMenu *videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
253 QStringList effectInfo;
254 QMap<QString, QStringList> effectsList;
255 for (int ix = 0; ix < videoEffects.count(); ix++) {
256 effectInfo = videoEffects.effectIdInfo(ix);
257 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
260 foreach(const QStringList &value, effectsList) {
261 action = new QAction(value.at(0), this);
262 action->setData(value);
263 videoEffectsMenu->addAction(action);
266 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
270 for (int ix = 0; ix < audioEffects.count(); ix++) {
271 effectInfo = audioEffects.effectIdInfo(ix);
272 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
275 foreach(const QStringList &value, effectsList) {
276 action = new QAction(value.at(0), this);
277 action->setData(value);
278 audioEffectsMenu->addAction(action);
281 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
283 if (customEffects.isEmpty()) m_customEffectsMenu->setEnabled(false);
284 else m_customEffectsMenu->setEnabled(true);
287 for (int ix = 0; ix < customEffects.count(); ix++) {
288 effectInfo = customEffects.effectIdInfo(ix);
289 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
292 foreach(const QStringList &value, effectsList) {
293 action = new QAction(value.at(0), this);
294 action->setData(value);
295 m_customEffectsMenu->addAction(action);
298 QMenu *newEffect = new QMenu(this);
299 newEffect->addMenu(videoEffectsMenu);
300 newEffect->addMenu(audioEffectsMenu);
301 newEffect->addMenu(m_customEffectsMenu);
302 m_effectStack->setMenu(newEffect);
305 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
306 const QList<QAction *> viewActions = createPopupMenu()->actions();
307 viewMenu->insertActions(NULL, viewActions);
309 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
310 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
311 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
313 m_timelineContextMenu = new QMenu(this);
314 m_timelineContextClipMenu = new QMenu(this);
315 m_timelineContextTransitionMenu = new QMenu(this);
318 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
319 QStringList effects = transitions.effectNames();
322 for (int ix = 0; ix < transitions.count(); ix++) {
323 effectInfo = transitions.effectIdInfo(ix);
324 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
326 foreach(const QStringList &value, effectsList) {
327 action = new QAction(value.at(0), this);
328 action->setData(value);
329 transitionsMenu->addAction(action);
331 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
333 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
334 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
335 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
337 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
338 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
339 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
340 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
341 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
342 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
343 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
345 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
346 m_timelineContextClipMenu->addMenu(markersMenu);
347 m_timelineContextClipMenu->addMenu(transitionsMenu);
348 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
349 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
350 //TODO: re-enable custom effects menu when it is implemented
351 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
353 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
354 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
356 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
358 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
359 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
360 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
361 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
362 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
363 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
365 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
366 slotConnectMonitors();
368 // Open or create a file. Command line argument passed in Url has
369 // precedence, then "openlastproject", then just a plain empty file.
370 // If opening Url fails, openlastproject will _not_ be used.
371 if (!Url.isEmpty()) {
374 if (KdenliveSettings::openlastproject()) {
378 if (m_timelineArea->count() == 0) {
382 #ifndef NO_JOGSHUTTLE
383 activateShuttleDevice();
384 #endif /* NO_JOGSHUTTLE */
385 m_projectListDock->raise();
388 void MainWindow::queryQuit()
391 if (m_projectMonitor) m_projectMonitor->stop();
392 if (m_clipMonitor) m_clipMonitor->stop();
393 delete m_effectStack;
394 delete m_activeTimeline;
395 delete m_projectMonitor;
396 delete m_clipMonitor;
397 delete m_activeDocument;
398 delete m_shortcutRemoveFocus;
399 Mlt::Factory::close();
405 bool MainWindow::queryClose()
407 if (m_renderWidget) {
408 int waitingJobs = m_renderWidget->waitingJobsCount();
409 if (waitingJobs > 0) {
410 switch (KMessageBox::warningYesNoCancel(this, i18n("You have %1 rendering jobs waiting in the queue.\nWhat do you want to do with these jobs?", waitingJobs), QString(), KGuiItem(i18n("Start them now")), KGuiItem(i18n("Delete them")))) {
411 case KMessageBox::Yes :
412 // create script with waiting jobs and start it
413 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
415 case KMessageBox::No :
416 // Don't do anything, jobs will be deleted
424 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
425 if (m_activeDocument && m_activeDocument->isModified()) {
426 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
427 case KMessageBox::Yes :
428 // save document here. If saving fails, return false;
430 case KMessageBox::No :
431 // User does not want to save the changes, clear recovery files
432 m_activeDocument->m_autosave->resize(0);
442 void MainWindow::loadPlugins()
444 foreach(QObject *plugin, QPluginLoader::staticInstances())
445 populateMenus(plugin);
447 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
449 filters << "libkdenlive*";
450 foreach(const QString &folder, directories) {
451 kDebug() << "// PARSING FIOLER: " << folder;
452 QDir pluginsDir(folder);
453 foreach(const QString &fileName, pluginsDir.entryList(filters, QDir::Files)) {
454 kDebug() << "// FOUND PLUGIN: " << fileName << "= " << pluginsDir.absoluteFilePath(fileName);
455 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
456 QObject *plugin = loader.instance();
458 populateMenus(plugin);
459 m_pluginFileNames += fileName;
460 } else kDebug() << "// ERROR LOADING PLUGIN: " << fileName << ", " << loader.errorString();
466 void MainWindow::populateMenus(QObject *plugin)
468 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
469 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
471 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
475 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
476 QMenu *menu, const char *member,
477 QActionGroup *actionGroup)
479 kDebug() << "// ADD to MENU" << texts;
480 foreach(const QString &text, texts) {
481 QAction *action = new QAction(text, plugin);
482 action->setData(text);
483 connect(action, SIGNAL(triggered()), this, member);
484 menu->addAction(action);
487 action->setCheckable(true);
488 actionGroup->addAction(action);
493 void MainWindow::aboutPlugins()
495 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
500 void MainWindow::generateClip()
502 QAction *action = qobject_cast<QAction *>(sender());
503 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
505 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(), QStringList(), QStringList(), 25, 720, 576);
506 if (!clipUrl.isEmpty()) {
507 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
511 void MainWindow::saveProperties(KConfigGroup &config)
513 // save properties here,used by session management
515 KMainWindow::saveProperties(config);
519 void MainWindow::readProperties(const KConfigGroup &config)
521 // read properties here,used by session management
522 KMainWindow::readProperties(config);
523 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
524 openFile(KUrl(Lastproject));
527 void MainWindow::slotReloadEffects()
529 kDebug() << "START RELOAD; COUNR: " << m_customEffectsMenu->actions().count();
530 m_customEffectsMenu->clear();
531 kDebug() << "START RELOAD; CLR: " << m_customEffectsMenu->actions().count();
532 initEffects::parseCustomEffectsFile();
533 const QStringList effects = customEffects.effectNames();
534 kDebug() << "NEW EFFS: " << effects;
536 if (effects.isEmpty()) m_customEffectsMenu->setEnabled(false);
537 else m_customEffectsMenu->setEnabled(true);
539 foreach(const QString &name, effects) {
540 action = new QAction(name, this);
541 action->setData(name);
542 m_customEffectsMenu->addAction(action);
544 m_effectList->reloadEffectList();
547 #ifndef NO_JOGSHUTTLE
548 void MainWindow::activateShuttleDevice()
552 if (KdenliveSettings::enableshuttle() == false) return;
553 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
554 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
555 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
556 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
557 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
558 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
559 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
562 void MainWindow::slotShuttleButton(int code)
566 slotShuttleAction(KdenliveSettings::shuttle1());
569 slotShuttleAction(KdenliveSettings::shuttle2());
572 slotShuttleAction(KdenliveSettings::shuttle3());
575 slotShuttleAction(KdenliveSettings::shuttle4());
578 slotShuttleAction(KdenliveSettings::shuttle5());
583 void MainWindow::slotShuttleAction(int code)
589 m_monitorManager->slotPlay();
592 m_monitorManager->slotPlay();
596 #endif /* NO_JOGSHUTTLE */
598 void MainWindow::configureNotifications()
600 KNotifyConfigWidget::configure(this);
603 void MainWindow::slotFullScreen()
605 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
608 void MainWindow::slotAddEffect(const QDomElement effect, GenTime pos, int track)
610 if (!m_activeDocument) return;
611 if (effect.isNull()) {
612 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
615 QDomElement effectToAdd = effect.cloneNode().toElement();
616 m_activeTimeline->projectView()->slotAddEffect(effectToAdd, pos, track);
619 void MainWindow::slotRaiseMonitor(bool clipMonitor)
621 if (clipMonitor) m_clipMonitorDock->raise();
622 else m_projectMonitorDock->raise();
625 void MainWindow::slotUpdateClip(const QString &id)
627 if (!m_activeDocument) return;
628 m_activeTimeline->projectView()->slotUpdateClip(id);
631 void MainWindow::slotConnectMonitors()
634 m_projectList->setRenderer(m_projectMonitor->render);
635 connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
636 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
637 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, bool)));
638 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
639 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)));
641 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
643 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
645 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
646 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
648 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
649 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
652 void MainWindow::slotAdjustClipMonitor()
654 m_clipMonitorDock->updateGeometry();
655 m_clipMonitorDock->adjustSize();
656 m_clipMonitor->resetSize();
659 void MainWindow::slotAdjustProjectMonitor()
661 m_projectMonitorDock->updateGeometry();
662 m_projectMonitorDock->adjustSize();
663 m_projectMonitor->resetSize();
666 void MainWindow::setupActions()
669 KActionCollection* collection = actionCollection();
670 m_timecodeFormat = new KComboBox(this);
671 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
672 m_timecodeFormat->addItem(i18n("Frames"));
673 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
674 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
676 m_statusProgressBar = new QProgressBar(this);
677 m_statusProgressBar->setMinimum(0);
678 m_statusProgressBar->setMaximum(100);
679 m_statusProgressBar->setMaximumWidth(150);
680 m_statusProgressBar->setVisible(false);
682 QWidget *w = new QWidget;
684 QHBoxLayout *layout = new QHBoxLayout;
685 w->setLayout(layout);
686 layout->setContentsMargins(5, 0, 5, 0);
687 QToolBar *toolbar = new QToolBar("statusToolBar", this);
690 m_toolGroup = new QActionGroup(this);
692 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;}";
694 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
695 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
696 toolbar->addAction(m_buttonSelectTool);
697 m_buttonSelectTool->setCheckable(true);
698 m_buttonSelectTool->setChecked(true);
700 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
701 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
702 toolbar->addAction(m_buttonRazorTool);
703 m_buttonRazorTool->setCheckable(true);
704 m_buttonRazorTool->setChecked(false);
706 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
707 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
708 toolbar->addAction(m_buttonSpacerTool);
709 m_buttonSpacerTool->setCheckable(true);
710 m_buttonSpacerTool->setChecked(false);
712 m_toolGroup->addAction(m_buttonSelectTool);
713 m_toolGroup->addAction(m_buttonRazorTool);
714 m_toolGroup->addAction(m_buttonSpacerTool);
715 m_toolGroup->setExclusive(true);
716 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
718 QWidget * actionWidget;
719 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
720 actionWidget->setMaximumWidth(24);
721 actionWidget->setMinimumHeight(18);
723 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
724 actionWidget->setMaximumWidth(24);
725 actionWidget->setMinimumHeight(18);
727 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
728 actionWidget->setMaximumWidth(24);
729 actionWidget->setMinimumHeight(18);
731 toolbar->setStyleSheet(style1);
732 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
734 toolbar->addSeparator();
735 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
736 toolbar->addAction(m_buttonFitZoom);
737 m_buttonFitZoom->setCheckable(false);
738 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
740 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
741 actionWidget->setMaximumWidth(24);
742 actionWidget->setMinimumHeight(18);
744 m_zoomSlider = new QSlider(Qt::Horizontal, this);
745 m_zoomSlider->setMaximum(13);
746 m_zoomSlider->setPageStep(1);
748 m_zoomSlider->setMaximumWidth(150);
749 m_zoomSlider->setMinimumWidth(100);
752 const int contentHeight = QFontMetrics(w->font()).height() + 14;
754 const int contentHeight = QFontMetrics(w->font()).height() + 8;
757 QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
758 style.append("QSlider::handle:horizontal { background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
760 m_zoomSlider->setStyleSheet(style);
762 //m_zoomSlider->height() + 5;
763 statusBar()->setMinimumHeight(contentHeight);
766 toolbar->addWidget(m_zoomSlider);
768 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
769 toolbar->addAction(m_buttonVideoThumbs);
770 m_buttonVideoThumbs->setCheckable(true);
771 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
772 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
774 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
775 toolbar->addAction(m_buttonAudioThumbs);
776 m_buttonAudioThumbs->setCheckable(true);
777 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
778 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
780 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
781 toolbar->addAction(m_buttonShowMarkers);
782 m_buttonShowMarkers->setCheckable(true);
783 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
784 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
786 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
787 toolbar->addAction(m_buttonSnap);
788 m_buttonSnap->setCheckable(true);
789 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
790 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
791 layout->addWidget(toolbar);
794 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
795 actionWidget->setMaximumWidth(24);
796 actionWidget->setMinimumHeight(18);
798 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
799 actionWidget->setMaximumWidth(24);
800 actionWidget->setMinimumHeight(18);
802 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
803 actionWidget->setMaximumWidth(24);
804 actionWidget->setMinimumHeight(18);
806 actionWidget = toolbar->widgetForAction(m_buttonSnap);
807 actionWidget->setMaximumWidth(24);
808 actionWidget->setMinimumHeight(18);
810 m_messageLabel = new StatusBarMessageLabel(this);
811 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
813 statusBar()->addWidget(m_messageLabel, 10);
814 statusBar()->addWidget(m_statusProgressBar, 0);
815 statusBar()->addPermanentWidget(w);
816 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
817 statusBar()->addPermanentWidget(m_timecodeFormat);
818 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
820 collection->addAction("select_tool", m_buttonSelectTool);
821 collection->addAction("razor_tool", m_buttonRazorTool);
822 collection->addAction("spacer_tool", m_buttonSpacerTool);
824 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
825 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
826 collection->addAction("show_markers", m_buttonShowMarkers);
827 collection->addAction("snap", m_buttonSnap);
828 collection->addAction("zoom_fit", m_buttonFitZoom);
830 KAction* zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
831 collection->addAction("zoom_in", zoomIn);
832 connect(zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
833 zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
835 KAction* zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
836 collection->addAction("zoom_out", zoomOut);
837 connect(zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
838 zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
840 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
841 collection->addAction("project_find", m_projectSearch);
842 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
843 m_projectSearch->setShortcut(Qt::Key_Slash);
845 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
846 collection->addAction("project_find_next", m_projectSearchNext);
847 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
848 m_projectSearchNext->setShortcut(Qt::Key_F3);
849 m_projectSearchNext->setEnabled(false);
851 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
852 collection->addAction("manage_profiles", profilesAction);
853 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
855 KNS::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
857 KNS::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
859 KNS::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
861 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
862 collection->addAction("run_wizard", wizAction);
863 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
865 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
866 collection->addAction("project_settings", projectAction);
867 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
869 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
870 collection->addAction("project_render", projectRender);
871 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
872 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
874 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
875 KShortcut playShortcut;
876 playShortcut.setPrimary(Qt::Key_Space);
877 playShortcut.setAlternate(Qt::Key_K);
878 monitorPlay->setShortcut(playShortcut);
879 collection->addAction("monitor_play", monitorPlay);
880 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
882 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
883 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
884 collection->addAction("monitor_play_zone", m_playZone);
885 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
887 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
888 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
889 collection->addAction("monitor_loop_zone", m_loopZone);
890 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
892 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
893 collection->addAction("dvd_wizard", dvdWizard);
894 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
896 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clip"), this);
897 collection->addAction("transcode_clip", transcodeClip);
898 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
900 KAction *markIn = collection->addAction("mark_in");
901 markIn->setText(i18n("Set In Point"));
902 markIn->setShortcut(Qt::Key_I);
903 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
905 KAction *markOut = collection->addAction("mark_out");
906 markOut->setText(i18n("Set Out Point"));
907 markOut->setShortcut(Qt::Key_O);
908 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
910 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
911 monitorSeekBackward->setShortcut(Qt::Key_J);
912 collection->addAction("monitor_seek_backward", monitorSeekBackward);
913 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
915 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
916 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
917 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
918 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
920 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
921 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
922 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
923 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
925 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
926 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
927 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
928 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
930 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
931 monitorSeekForward->setShortcut(Qt::Key_L);
932 collection->addAction("monitor_seek_forward", monitorSeekForward);
933 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
935 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
936 clipStart->setShortcut(Qt::Key_Home);
937 collection->addAction("seek_clip_start", clipStart);
938 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
940 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
941 clipEnd->setShortcut(Qt::Key_End);
942 collection->addAction("seek_clip_end", clipEnd);
943 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
945 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
946 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
947 collection->addAction("seek_start", projectStart);
948 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
950 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
951 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
952 collection->addAction("seek_end", projectEnd);
953 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
955 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
956 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
957 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
958 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
960 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
961 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
962 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
963 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
965 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
966 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
967 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
968 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
970 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
971 deleteTimelineClip->setShortcut(Qt::Key_Delete);
972 collection->addAction("delete_timeline_clip", deleteTimelineClip);
973 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
975 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
976 collection->addAction("change_clip_speed", editTimelineClipSpeed);
977 editTimelineClipSpeed->setData("change_speed");
978 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
980 KAction *stickTransition = collection->addAction("auto_transition");
981 stickTransition->setData(QString("auto"));
982 stickTransition->setCheckable(true);
983 stickTransition->setEnabled(false);
984 stickTransition->setText(i18n("Automatic Transition"));
985 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
987 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
988 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
989 collection->addAction("group_clip", groupClip);
990 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
992 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
993 collection->addAction("ungroup_clip", ungroupClip);
994 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
995 ungroupClip->setData("ungroup_clip");
996 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
998 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
999 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1000 collection->addAction("cut_timeline_clip", cutTimelineClip);
1001 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1003 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1004 collection->addAction("add_clip_marker", addClipMarker);
1005 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1007 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1008 collection->addAction("delete_clip_marker", deleteClipMarker);
1009 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1011 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1012 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
1013 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1015 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1016 collection->addAction("edit_clip_marker", editClipMarker);
1017 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1019 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1020 collection->addAction("split_audio", splitAudio);
1021 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1023 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1024 collection->addAction("clip_audio_only", audioOnly);
1025 audioOnly->setData("clip_audio_only");
1026 audioOnly->setCheckable(true);
1028 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1029 collection->addAction("clip_video_only", videoOnly);
1030 videoOnly->setData("clip_video_only");
1031 videoOnly->setCheckable(true);
1033 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1034 collection->addAction("clip_audio_and_video", audioAndVideo);
1035 audioAndVideo->setData("clip_audio_and_video");
1036 audioAndVideo->setCheckable(true);
1038 m_clipTypeGroup = new QActionGroup(this);
1039 m_clipTypeGroup->addAction(audioOnly);
1040 m_clipTypeGroup->addAction(videoOnly);
1041 m_clipTypeGroup->addAction(audioAndVideo);
1042 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1043 m_clipTypeGroup->setEnabled(false);
1045 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1046 collection->addAction("insert_space", insertSpace);
1047 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1049 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1050 collection->addAction("delete_space", removeSpace);
1051 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1053 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1054 collection->addAction("insert_track", insertTrack);
1055 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1057 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1058 collection->addAction("delete_track", deleteTrack);
1059 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1061 KAction *changeTrack = new KAction(KIcon(), i18n("Change Track"), this);
1062 collection->addAction("change_track", changeTrack);
1063 connect(changeTrack, SIGNAL(triggered()), this, SLOT(slotChangeTrack()));
1065 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1066 collection->addAction("add_guide", addGuide);
1067 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1069 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1070 collection->addAction("delete_guide", delGuide);
1071 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1073 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1074 collection->addAction("edit_guide", editGuide);
1075 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1077 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1078 collection->addAction("delete_all_guides", delAllGuides);
1079 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1081 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1082 collection->addAction("paste_effects", pasteEffects);
1083 pasteEffects->setData("paste_effects");
1084 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1086 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1087 collection->addAction("show_timeline", showTimeline);
1088 showTimeline->setCheckable(true);
1089 showTimeline->setChecked(true);
1090 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1092 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1093 collection->addAction("maximize_current", maxCurrent);
1094 maxCurrent->setCheckable(true);
1095 maxCurrent->setChecked(false);
1096 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1099 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1101 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1103 KStandardAction::open(this, SLOT(openFile()), collection);
1105 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1107 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1109 KStandardAction::openNew(this, SLOT(newFile()), collection);
1111 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1113 KStandardAction::configureNotifications(this , SLOT(configureNotifications()), collection);
1115 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1117 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1119 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1120 undo->setEnabled(false);
1121 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1123 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1124 redo->setEnabled(false);
1125 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1127 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1130 //TODO: Add status tooltip to actions ?
1131 connect(collection, SIGNAL(actionHovered(QAction*)),
1132 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1135 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1136 collection->addAction("add_clip", addClip);
1137 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1139 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1140 collection->addAction("add_color_clip", addColorClip);
1141 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1143 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1144 collection->addAction("add_slide_clip", addSlideClip);
1145 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1147 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1148 collection->addAction("add_text_clip", addTitleClip);
1149 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1151 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1152 collection->addAction("add_text_template_clip", addTitleTemplateClip);
1153 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1155 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1156 collection->addAction("add_folder", addFolderButton);
1157 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1159 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1160 collection->addAction("clip_properties", clipProperties);
1161 clipProperties->setData("clip_properties");
1162 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1163 clipProperties->setEnabled(false);
1165 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1166 collection->addAction("edit_clip", openClip);
1167 openClip->setData("edit_clip");
1168 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1169 openClip->setEnabled(false);
1171 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1172 collection->addAction("delete_clip", deleteClip);
1173 deleteClip->setData("delete_clip");
1174 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1175 deleteClip->setEnabled(false);
1177 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1178 collection->addAction("reload_clip", reloadClip);
1179 reloadClip->setData("reload_clip");
1180 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1181 reloadClip->setEnabled(false);
1183 QMenu *addClips = new QMenu();
1184 addClips->addAction(addClip);
1185 addClips->addAction(addColorClip);
1186 addClips->addAction(addSlideClip);
1187 addClips->addAction(addTitleClip);
1188 addClips->addAction(addTitleTemplateClip);
1189 addClips->addAction(addFolderButton);
1191 addClips->addAction(reloadClip);
1192 addClips->addAction(clipProperties);
1193 addClips->addAction(openClip);
1194 addClips->addAction(deleteClip);
1195 m_projectList->setupMenu(addClips, addClip);
1197 //connect(collection, SIGNAL( clearStatusText() ),
1198 //statusBar(), SLOT( clear() ) );
1201 void MainWindow::slotDisplayActionMessage(QAction *a)
1203 statusBar()->showMessage(a->data().toString(), 3000);
1206 void MainWindow::saveOptions()
1208 KdenliveSettings::self()->writeConfig();
1209 KSharedConfigPtr config = KGlobal::config();
1210 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1211 KConfigGroup treecolumns(config, "Project Tree");
1212 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1216 void MainWindow::readOptions()
1218 KSharedConfigPtr config = KGlobal::config();
1219 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1220 KConfigGroup initialGroup(config, "version");
1221 bool upgrade = false;
1222 if (initialGroup.exists()) {
1223 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1227 if (initialGroup.readEntry("version") == "0.7") {
1228 //Add new settings from 0.7.1
1229 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1230 QString path = QDir::homePath() + "/kdenlive";
1231 if (KStandardDirs::makeDir(path) == false) {
1232 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1233 } else KdenliveSettings::setDefaultprojectfolder(path);
1239 if (!initialGroup.exists() || upgrade) {
1240 // this is our first run, show Wizard
1241 Wizard *w = new Wizard(upgrade, this);
1242 if (w->exec() == QDialog::Accepted && w->isOk()) {
1243 w->adjustSettings();
1244 initialGroup.writeEntry("version", version);
1250 KConfigGroup treecolumns(config, "Project Tree");
1251 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1252 if (!state.isEmpty())
1253 m_projectList->setHeaderInfo(state);
1256 void MainWindow::slotRunWizard()
1258 Wizard *w = new Wizard(false, this);
1259 if (w->exec() == QDialog::Accepted && w->isOk()) {
1260 w->adjustSettings();
1265 void MainWindow::newFile(bool showProjectSettings)
1267 if (!m_timelineArea->isEnabled()) return;
1268 QString profileName;
1270 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1271 if (!showProjectSettings && m_timelineArea->count() == 0) {
1272 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1273 profileName = KdenliveSettings::default_profile();
1274 projectFolder = KdenliveSettings::defaultprojectfolder();
1276 ProjectSettings *w = new ProjectSettings(projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, this);
1277 if (w->exec() != QDialog::Accepted) return;
1278 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1279 KdenliveSettings::setVideothumbnails(w->enableVideoThumbs());
1280 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1281 KdenliveSettings::setAudiothumbnails(w->enableAudioThumbs());
1282 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1283 profileName = w->selectedProfile();
1284 projectFolder = w->selectedFolder();
1285 projectTracks = w->tracks();
1288 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1289 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1291 TrackView *trackView = new TrackView(doc, &ok, this);
1292 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1295 m_timelineArea->setEnabled(false);
1296 m_projectList->setEnabled(false);
1297 m_monitorManager->slotBlockMonitors();
1301 if (m_timelineArea->count() == 1) {
1302 connectDocumentInfo(doc);
1303 connectDocument(trackView, doc);
1304 } else m_timelineArea->setTabBarHidden(false);
1305 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1308 void MainWindow::activateDocument()
1310 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1311 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1312 KdenliveDoc *currentDoc = currentTab->document();
1313 connectDocumentInfo(currentDoc);
1314 connectDocument(currentTab, currentDoc);
1317 void MainWindow::closeCurrentDocument()
1319 QWidget *w = m_timelineArea->currentWidget();
1321 // closing current document
1322 int ix = m_timelineArea->currentIndex() + 1;
1323 if (ix == m_timelineArea->count()) ix = 0;
1324 m_timelineArea->setCurrentIndex(ix);
1325 TrackView *tabToClose = (TrackView *) w;
1326 KdenliveDoc *docToClose = tabToClose->document();
1327 if (docToClose && docToClose->isModified()) {
1328 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
1329 case KMessageBox::Yes :
1330 // save document here. If saving fails, return false;
1331 if (saveFile() == false) return;
1333 case KMessageBox::Cancel :
1340 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1341 if (m_timelineArea->count() == 1) {
1342 m_timelineArea->setTabBarHidden(true);
1343 m_closeAction->setEnabled(false);
1345 if (docToClose == m_activeDocument) {
1346 delete m_activeDocument;
1347 m_activeDocument = NULL;
1348 m_effectStack->clear();
1349 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1350 } else delete docToClose;
1351 if (w == m_activeTimeline) {
1352 delete m_activeTimeline;
1353 m_activeTimeline = NULL;
1357 bool MainWindow::saveFileAs(const QString &outputFileName)
1359 QString currentSceneList;
1360 if (KdenliveSettings::dropbframes()) {
1361 KdenliveSettings::setDropbframes(false);
1362 m_activeDocument->clipManager()->updatePreviewSettings();
1363 currentSceneList = m_projectMonitor->sceneList();
1364 KdenliveSettings::setDropbframes(true);
1365 m_activeDocument->clipManager()->updatePreviewSettings();
1366 } else currentSceneList = m_projectMonitor->sceneList();
1368 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1371 // Save timeline thumbnails
1372 m_activeTimeline->projectView()->saveThumbnails();
1373 m_activeDocument->setUrl(KUrl(outputFileName));
1374 if (m_activeDocument->m_autosave == NULL) {
1375 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1376 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1377 setCaption(m_activeDocument->description());
1378 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1379 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1380 m_activeDocument->setModified(false);
1381 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1385 bool MainWindow::saveFileAs()
1387 // Check that the Kdenlive mime type is correctly installed
1388 QString mimetype = "application/x-kdenlive";
1389 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1390 if (!mime) mimetype = "*.kdenlive";
1392 QString outputFile = KFileDialog::getSaveFileName(KUrl(), mimetype);
1393 if (outputFile.isEmpty()) return false;
1394 if (QFile::exists(outputFile)) {
1395 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it?")) == KMessageBox::No) return false;
1397 return saveFileAs(outputFile);
1400 bool MainWindow::saveFile()
1402 if (!m_activeDocument) return true;
1403 if (m_activeDocument->url().isEmpty()) {
1404 return saveFileAs();
1406 bool result = saveFileAs(m_activeDocument->url().path());
1407 m_activeDocument->m_autosave->resize(0);
1412 void MainWindow::openFile()
1414 // Check that the Kdenlive mime type is correctly installed
1415 QString mimetype = "application/x-kdenlive";
1416 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1417 if (!mime) mimetype = "*.kdenlive";
1419 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), mimetype);
1420 if (url.isEmpty()) return;
1421 m_fileOpenRecent->addUrl(url);
1425 void MainWindow::openLastFile()
1427 KSharedConfigPtr config = KGlobal::config();
1428 KUrl::List urls = m_fileOpenRecent->urls();
1429 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1430 if (urls.isEmpty()) newFile(false);
1431 else openFile(urls.last());
1434 void MainWindow::openFile(const KUrl &url)
1436 // Check if the document is already opened
1437 const int ct = m_timelineArea->count();
1438 bool isOpened = false;
1440 for (i = 0; i < ct; i++) {
1441 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1442 KdenliveDoc *doc = tab->document();
1443 if (doc->url() == url) {
1449 m_timelineArea->setCurrentIndex(i);
1453 // Check for backup file
1454 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1455 if (!staleFiles.isEmpty()) {
1456 if (KMessageBox::questionYesNo(this,
1457 i18n("Auto-saved files exist. Do you want to recover them now?"),
1458 i18n("File Recovery"),
1459 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1460 recoverFiles(staleFiles);
1463 // remove the stale files
1464 foreach(KAutoSaveFile *stale, staleFiles) {
1465 stale->open(QIODevice::ReadWrite);
1470 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1471 doOpenFile(url, NULL);
1474 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1476 if (!m_timelineArea->isEnabled()) return;
1477 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, this);
1478 if (stale == NULL) {
1479 stale = new KAutoSaveFile(url, doc);
1480 doc->m_autosave = stale;
1482 doc->m_autosave = stale;
1483 doc->setUrl(stale->managedFile());
1484 doc->setModified(true);
1485 stale->setParent(doc);
1487 connectDocumentInfo(doc);
1489 TrackView *trackView = new TrackView(doc, &ok, this);
1490 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1492 m_timelineArea->setEnabled(false);
1493 m_projectList->setEnabled(false);
1494 m_monitorManager->slotBlockMonitors();
1498 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1499 trackView->setDuration(trackView->duration());
1500 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1502 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1503 slotGotProgressInfo(QString(), -1);
1504 m_clipMonitor->refreshMonitor(true);
1505 m_projectMonitor->adjustRulerSize(trackView->duration());
1506 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1509 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1511 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1512 foreach(KAutoSaveFile *stale, staleFiles) {
1513 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1514 // show an error message; we could not steal the lockfile
1515 // maybe another application got to the file before us?
1519 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1520 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
1521 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1522 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1527 void MainWindow::parseProfiles(const QString &mltPath)
1529 // kDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
1531 //KdenliveSettings::setDefaulttmpfolder();
1532 if (!mltPath.isEmpty()) {
1533 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1534 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
1537 if (KdenliveSettings::mltpath().isEmpty()) {
1538 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1540 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
1541 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
1542 if (!QFile::exists(meltPath))
1543 meltPath = KStandardDirs::findExe("melt");
1544 KdenliveSettings::setRendererpath(meltPath);
1546 QStringList profilesFilter;
1547 profilesFilter << "*";
1548 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1550 if (profilesList.isEmpty()) {
1551 // Cannot find MLT path, try finding melt
1552 QString profilePath = KdenliveSettings::rendererpath();
1553 if (!profilePath.isEmpty()) {
1554 profilePath = profilePath.section('/', 0, -3);
1555 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1556 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1559 if (profilesList.isEmpty()) {
1560 // Cannot find the MLT profiles, ask for location
1561 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1562 getUrl->fileDialog()->setMode(KFile::Directory);
1563 if (getUrl->exec() == QDialog::Rejected) {
1566 KUrl mltPath = getUrl->selectedUrl();
1568 if (mltPath.isEmpty()) ::exit(0);
1569 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
1570 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1574 if (KdenliveSettings::rendererpath().isEmpty()) {
1575 // Cannot find the MLT melt renderer, ask for location
1576 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of Mlt)"), this);
1577 if (getUrl->exec() == QDialog::Rejected) {
1580 KUrl rendererPath = getUrl->selectedUrl();
1582 if (rendererPath.isEmpty()) ::exit(0);
1583 KdenliveSettings::setRendererpath(rendererPath.path());
1586 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1588 // Parse MLT profiles to build a list of available video formats
1589 if (profilesList.isEmpty()) parseProfiles();
1593 void MainWindow::slotEditProfiles()
1595 ProfilesDialog *w = new ProfilesDialog;
1596 if (w->exec() == QDialog::Accepted) {
1597 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1598 if (d) d->checkProfile();
1603 void MainWindow::slotDetectAudioDriver()
1605 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
1606 leading to no audio output, see bug #934 */
1608 //decide which audio driver is really best, in some cases SDL is wrong
1609 if (KdenliveSettings::audiodrivername().isEmpty()) {
1611 KProcess readProcess;
1612 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
1613 if (!KStandardDirs::findExe("pactl").isEmpty()) {
1614 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
1615 readProcess.setProgram("pactl", QStringList() << "stat");
1616 readProcess.execute(2000); // Kill it after 2 seconds
1618 QString result = QString(readProcess.readAllStandardOutput());
1619 kDebug() << "// / / / / / READING PACTL: ";
1621 if (!result.isEmpty()) {
1623 kDebug() << "// / / / / PULSEAUDIO DETECTED";
1627 KdenliveSettings::setAutoaudiodrivername(driver);
1631 void MainWindow::slotEditProjectSettings()
1633 QPoint p = m_activeDocument->getTracksCount();
1634 ProjectSettings *w = new ProjectSettings(p.x(), p.y(), m_activeDocument->projectFolder().path(), true, this);
1636 if (w->exec() == QDialog::Accepted) {
1637 QString profile = w->selectedProfile();
1638 m_activeDocument->setProjectFolder(w->selectedFolder());
1639 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path(KUrl::AddTrailingSlash));
1640 if (m_activeDocument->profilePath() != profile) {
1641 // Profile was changed
1642 double dar = m_activeDocument->dar();
1644 // Deselect current effect / transition
1645 m_effectStack->slotClipItemSelected(NULL, 0);
1646 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1647 m_clipMonitor->slotSetXml(NULL, 0);
1648 m_activeDocument->setProfilePath(profile);
1649 KdenliveSettings::setCurrent_profile(profile);
1650 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1651 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1653 m_activeDocument->clipManager()->clearUnusedProducers();
1654 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1656 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeTimeline->tracksNumber());
1657 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
1658 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1659 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1660 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1661 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
1662 m_activeTimeline->updateProjectFps();
1664 // We need to desactivate & reactivate monitors to get a refresh
1665 //m_monitorManager->switchMonitors();
1671 void MainWindow::slotRenderProject()
1673 if (!m_renderWidget) {
1674 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
1675 m_renderWidget = new RenderWidget(projectfolder, this);
1676 connect(m_renderWidget, SIGNAL(selectedRenderProfile(const QString &, const QString &, const QString&)), this, SLOT(slotSetDocumentRenderProfile(const QString &, const QString &, const QString&)));
1677 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
1678 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1679 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1680 if (m_activeDocument) {
1681 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1682 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1683 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
1684 m_renderWidget->setRenderProfile(m_activeDocument->getDocumentProperty("renderdestination"), m_activeDocument->getDocumentProperty("renderprofile"), m_activeDocument->getDocumentProperty("renderurl"));
1687 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1688 if (currentTab) m_renderWidget->setTimeline(currentTab);
1689 m_renderWidget->setDocument(m_activeDocument);*/
1690 m_renderWidget->show();
1691 m_renderWidget->showNormal();
1694 void MainWindow::setRenderingProgress(const QString &url, int progress)
1696 if (m_renderWidget) m_renderWidget->setRenderJob(url, progress);
1699 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
1701 if (m_renderWidget) m_renderWidget->setRenderStatus(url, status, error);
1704 void MainWindow::slotUpdateMousePosition(int pos)
1706 if (m_activeDocument)
1707 switch (m_timecodeFormat->currentIndex()) {
1709 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1712 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1716 void MainWindow::slotUpdateDocumentState(bool modified)
1718 if (!m_activeDocument) return;
1719 setCaption(m_activeDocument->description(), modified);
1720 m_saveAction->setEnabled(modified);
1722 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1723 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1725 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1726 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1730 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
1732 if (m_activeDocument) {
1733 if (m_activeDocument == doc) return;
1734 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1736 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1739 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
1741 //m_projectMonitor->stop();
1742 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1743 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1744 if (m_activeDocument) {
1745 if (m_activeDocument == doc) return;
1746 if (m_activeTimeline) {
1747 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1748 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1749 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1750 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1751 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
1753 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1754 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1755 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1756 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1757 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1758 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1759 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1760 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1761 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1762 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
1763 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1764 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1765 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1766 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1767 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1768 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1769 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1770 disconnect(m_activeTimeline, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1771 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1772 disconnect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1773 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1774 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1775 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1776 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1777 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1778 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1779 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
1780 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1781 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1782 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
1783 m_effectStack->clear();
1785 //m_activeDocument->setRenderer(NULL);
1786 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1787 disconnect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
1788 m_clipMonitor->stop();
1790 KdenliveSettings::setCurrent_profile(doc->profilePath());
1791 KdenliveSettings::setProject_fps(doc->fps());
1792 m_monitorManager->resetProfiles(doc->timecode());
1793 m_projectList->setDocument(doc);
1794 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), trackView->tracksNumber());
1795 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
1796 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1797 connect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
1798 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1799 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
1802 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1803 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1804 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1805 connect(trackView, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1806 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1807 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1808 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1809 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1810 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
1812 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1813 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1814 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1815 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1816 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1818 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1819 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1820 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1823 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1824 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1825 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
1826 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1827 m_zoomSlider->setValue(doc->zoom().x());
1828 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1829 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1830 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1831 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1833 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1836 connect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1837 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1838 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1839 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1840 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1841 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1842 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1843 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1845 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1846 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1847 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
1849 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup);
1850 m_activeTimeline = trackView;
1851 if (m_renderWidget) {
1852 m_renderWidget->setProfile(doc->mltProfile());
1853 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
1854 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
1855 m_renderWidget->setRenderProfile(doc->getDocumentProperty("renderdestination"), doc->getDocumentProperty("renderprofile"), doc->getDocumentProperty("renderurl"));
1857 //doc->setRenderer(m_projectMonitor->render);
1858 m_commandStack->setActiveStack(doc->commandStack());
1859 KdenliveSettings::setProject_display_ratio(doc->dar());
1860 //doc->clipManager()->checkAudioThumbs();
1862 //m_overView->setScene(trackView->projectScene());
1863 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1864 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1866 setCaption(doc->description(), doc->isModified());
1867 m_saveAction->setEnabled(doc->isModified());
1868 m_activeDocument = doc;
1869 m_activeTimeline->updateProjectFps();
1870 m_projectList->updateAllClips();
1871 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
1873 // set tool to select tool
1874 m_buttonSelectTool->setChecked(true);
1877 void MainWindow::slotZoneMoved(int start, int end)
1879 m_activeDocument->setZone(start, end);
1880 m_projectMonitor->slotZoneMoved(start, end);
1883 void MainWindow::slotGuidesUpdated()
1885 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1888 void MainWindow::slotPreferences(int page, int option)
1890 //An instance of your dialog could be already created and could be
1891 // cached, in which case you want to display the cached dialog
1892 // instead of creating another one
1893 if (KConfigDialog::showDialog("settings")) {
1894 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1895 if (page != -1) d->showPage(page, option);
1899 // KConfigDialog didn't find an instance of this dialog, so lets
1901 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1902 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1903 //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
1904 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1905 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1907 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
1909 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1911 if (page != -1) dialog->showPage(page, option);
1914 void MainWindow::slotUpdatePreviewSettings()
1916 if (m_activeDocument) {
1917 m_clipMonitor->slotSetXml(NULL, 0);
1918 m_activeDocument->updatePreviewSettings();
1922 void MainWindow::updateConfiguration()
1924 //TODO: we should apply settings to all projects, not only the current one
1925 if (m_activeTimeline) {
1926 m_activeTimeline->refresh();
1927 m_activeTimeline->projectView()->checkAutoScroll();
1928 m_activeTimeline->projectView()->checkTrackHeight();
1929 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1931 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1932 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1934 // Update list of transcoding profiles
1936 #ifndef NO_JOGSHUTTLE
1937 activateShuttleDevice();
1938 #endif /* NO_JOGSHUTTLE */
1943 void MainWindow::slotSwitchVideoThumbs()
1945 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1946 if (m_activeTimeline) {
1947 m_activeTimeline->projectView()->slotUpdateAllThumbs();
1949 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1952 void MainWindow::slotSwitchAudioThumbs()
1954 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
1955 if (m_activeTimeline) {
1956 m_activeTimeline->refresh();
1957 m_activeTimeline->projectView()->checkAutoScroll();
1958 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1960 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1963 void MainWindow::slotSwitchMarkersComments()
1965 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1966 if (m_activeTimeline) {
1967 m_activeTimeline->refresh();
1969 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1972 void MainWindow::slotSwitchSnap()
1974 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
1975 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1979 void MainWindow::slotDeleteTimelineClip()
1981 if (QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) m_projectList->slotRemoveClip();
1982 else if (m_activeTimeline) {
1983 m_activeTimeline->projectView()->deleteSelectedClips();
1987 void MainWindow::slotAddClipMarker()
1989 DocClipBase *clip = NULL;
1991 if (m_projectMonitor->isActive()) {
1992 if (m_activeTimeline) {
1993 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1995 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
1996 clip = item->baseClip();
2000 clip = m_clipMonitor->activeClip();
2001 pos = m_clipMonitor->position();
2004 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2007 QString id = clip->getId();
2008 CommentedTime marker(pos, i18n("Marker"));
2009 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2010 if (d.exec() == QDialog::Accepted) {
2011 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2013 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2016 void MainWindow::slotDeleteClipMarker()
2018 DocClipBase *clip = NULL;
2020 if (m_projectMonitor->isActive()) {
2021 if (m_activeTimeline) {
2022 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2024 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2025 clip = item->baseClip();
2029 clip = m_clipMonitor->activeClip();
2030 pos = m_clipMonitor->position();
2033 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2037 QString id = clip->getId();
2038 QString comment = clip->markerComment(pos);
2039 if (comment.isEmpty()) {
2040 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2043 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2044 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2048 void MainWindow::slotDeleteAllClipMarkers()
2050 DocClipBase *clip = NULL;
2051 if (m_projectMonitor->isActive()) {
2052 if (m_activeTimeline) {
2053 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2055 clip = item->baseClip();
2059 clip = m_clipMonitor->activeClip();
2062 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2065 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2066 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2069 void MainWindow::slotEditClipMarker()
2071 DocClipBase *clip = NULL;
2073 if (m_projectMonitor->isActive()) {
2074 if (m_activeTimeline) {
2075 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2077 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2078 clip = item->baseClip();
2082 clip = m_clipMonitor->activeClip();
2083 pos = m_clipMonitor->position();
2086 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2090 QString id = clip->getId();
2091 QString oldcomment = clip->markerComment(pos);
2092 if (oldcomment.isEmpty()) {
2093 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2097 CommentedTime marker(pos, oldcomment);
2098 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2099 if (d.exec() == QDialog::Accepted) {
2100 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2101 if (d.newMarker().time() != pos) {
2102 // remove old marker
2103 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2105 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2109 void MainWindow::slotAddGuide()
2111 if (m_activeTimeline)
2112 m_activeTimeline->projectView()->slotAddGuide();
2115 void MainWindow::slotInsertSpace()
2117 if (m_activeTimeline)
2118 m_activeTimeline->projectView()->slotInsertSpace();
2121 void MainWindow::slotRemoveSpace()
2123 if (m_activeTimeline)
2124 m_activeTimeline->projectView()->slotRemoveSpace();
2127 void MainWindow::slotInsertTrack(int ix)
2129 m_projectMonitor->activateMonitor();
2130 if (m_activeTimeline)
2131 m_activeTimeline->projectView()->slotInsertTrack(ix);
2134 void MainWindow::slotDeleteTrack(int ix)
2136 m_projectMonitor->activateMonitor();
2137 if (m_activeTimeline)
2138 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2141 void MainWindow::slotChangeTrack(int ix)
2143 m_projectMonitor->activateMonitor();
2144 if (m_activeTimeline)
2145 m_activeTimeline->projectView()->slotChangeTrack(ix);
2148 void MainWindow::slotEditGuide()
2150 if (m_activeTimeline)
2151 m_activeTimeline->projectView()->slotEditGuide();
2154 void MainWindow::slotDeleteGuide()
2156 if (m_activeTimeline)
2157 m_activeTimeline->projectView()->slotDeleteGuide();
2160 void MainWindow::slotDeleteAllGuides()
2162 if (m_activeTimeline)
2163 m_activeTimeline->projectView()->slotDeleteAllGuides();
2166 void MainWindow::slotCutTimelineClip()
2168 if (m_activeTimeline) {
2169 m_activeTimeline->projectView()->cutSelectedClips();
2173 void MainWindow::slotGroupClips()
2175 if (m_activeTimeline) {
2176 m_activeTimeline->projectView()->groupClips();
2180 void MainWindow::slotUnGroupClips()
2182 if (m_activeTimeline) {
2183 m_activeTimeline->projectView()->groupClips(false);
2187 void MainWindow::slotAddProjectClip(KUrl url)
2189 if (m_activeDocument)
2190 m_activeDocument->slotAddClipFile(url, QString());
2193 void MainWindow::slotAddTransition(QAction *result)
2195 if (!result) return;
2196 QStringList info = result->data().toStringList();
2197 if (info.isEmpty()) return;
2198 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2199 if (m_activeTimeline && !transition.isNull()) {
2200 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2204 void MainWindow::slotAddVideoEffect(QAction *result)
2206 if (!result) return;
2207 QStringList info = result->data().toStringList();
2208 if (info.isEmpty()) return;
2209 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2210 slotAddEffect(effect);
2213 void MainWindow::slotAddAudioEffect(QAction *result)
2215 if (!result) return;
2216 QStringList info = result->data().toStringList();
2217 if (info.isEmpty()) return;
2218 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2219 slotAddEffect(effect);
2222 void MainWindow::slotAddCustomEffect(QAction *result)
2224 if (!result) return;
2225 QStringList info = result->data().toStringList();
2226 if (info.isEmpty()) return;
2227 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2228 slotAddEffect(effect);
2231 void MainWindow::slotZoomIn()
2233 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2236 void MainWindow::slotZoomOut()
2238 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2241 void MainWindow::slotFitZoom()
2243 if (m_activeTimeline) {
2244 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2248 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2250 m_statusProgressBar->setValue(progress);
2251 if (progress >= 0) {
2252 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2253 m_statusProgressBar->setVisible(true);
2255 m_messageLabel->setMessage(QString(), DefaultMessage);
2256 m_statusProgressBar->setVisible(false);
2260 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2262 if (clip->clipType() == TEXT) {
2263 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
2264 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
2265 // template text clip
2267 // Get the list of existing templates
2269 filter << "*.kdenlivetitle";
2270 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
2272 QDialog *dia = new QDialog(this);
2273 Ui::TemplateClip_UI dia_ui;
2274 dia_ui.setupUi(dia);
2276 const QString templatePath = clip->getProperty("resource");
2277 for (int i = 0; i < templateFiles.size(); ++i) {
2278 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
2279 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
2281 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
2282 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
2283 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
2284 //warning: setting base directory doesn't work??
2285 KUrl startDir(titlepath);
2286 dia_ui.template_list->fileDialog()->setUrl(startDir);
2287 dia_ui.description->setText(clip->getProperty("description"));
2288 if (dia->exec() == QDialog::Accepted) {
2289 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
2290 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
2292 QMap <QString, QString> newprops;
2294 if (KUrl(textTemplate).path() != templatePath) {
2295 // The template was changed
2296 newprops.insert("resource", textTemplate);
2299 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
2300 newprops.insert("description", dia_ui.description->toPlainText());
2303 QString newtemplate = newprops.value("xmltemplate");
2304 if (newtemplate.isEmpty()) newtemplate = templatePath;
2306 // template modified we need to update xmldata
2307 QString description = newprops.value("description");
2308 if (description.isEmpty()) description = clip->getProperty("description");
2309 else newprops.insert("templatetext", description);
2310 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
2312 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2313 m_activeDocument->commandStack()->push(command);
2317 QString path = clip->getProperty("resource");
2318 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
2320 doc.setContent(clip->getProperty("xmldata"));
2321 dia_ui->setXml(doc);
2322 if (dia_ui->exec() == QDialog::Accepted) {
2323 QMap <QString, QString> newprops;
2324 newprops.insert("xmldata", dia_ui->xml().toString());
2325 newprops.insert("out", QString::number(dia_ui->duration()));
2326 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2327 m_activeDocument->commandStack()->push(command);
2328 m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
2329 m_activeDocument->setModified(true);
2333 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2336 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2337 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2338 if (dia.exec() == QDialog::Accepted) {
2339 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true);
2340 m_activeDocument->commandStack()->push(command);
2342 //m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
2343 if (dia.needsTimelineRefresh()) {
2344 // update clip occurences in timeline
2345 m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
2350 void MainWindow::customEvent(QEvent* e)
2352 if (e->type() == QEvent::User) {
2353 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
2356 void MainWindow::slotActivateEffectStackView()
2358 m_effectStack->raiseWindow(m_effectStackDock);
2361 void MainWindow::slotActivateTransitionView(Transition *t)
2363 if (t) m_transitionConfig->raiseWindow(m_transitionConfigDock);
2366 void MainWindow::slotSnapRewind()
2368 if (m_projectMonitor->isActive()) {
2369 if (m_activeTimeline)
2370 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2371 } else m_clipMonitor->slotSeekToPreviousSnap();
2374 void MainWindow::slotSnapForward()
2376 if (m_projectMonitor->isActive()) {
2377 if (m_activeTimeline)
2378 m_activeTimeline->projectView()->slotSeekToNextSnap();
2379 } else m_clipMonitor->slotSeekToNextSnap();
2382 void MainWindow::slotClipStart()
2384 if (m_projectMonitor->isActive()) {
2385 if (m_activeTimeline)
2386 m_activeTimeline->projectView()->clipStart();
2390 void MainWindow::slotClipEnd()
2392 if (m_projectMonitor->isActive()) {
2393 if (m_activeTimeline)
2394 m_activeTimeline->projectView()->clipEnd();
2398 void MainWindow::slotChangeTool(QAction * action)
2400 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
2401 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
2402 else if (action == m_buttonSpacerTool) slotSetTool(SPACERTOOL);
2405 void MainWindow::slotSetTool(PROJECTTOOL tool)
2407 if (m_activeDocument && m_activeTimeline) {
2408 //m_activeDocument->setTool(tool);
2409 m_activeTimeline->projectView()->setTool(tool);
2413 void MainWindow::slotCopy()
2415 if (!m_activeDocument || !m_activeTimeline) return;
2416 m_activeTimeline->projectView()->copyClip();
2419 void MainWindow::slotPaste()
2421 if (!m_activeDocument || !m_activeTimeline) return;
2422 m_activeTimeline->projectView()->pasteClip();
2425 void MainWindow::slotPasteEffects()
2427 if (!m_activeDocument || !m_activeTimeline) return;
2428 m_activeTimeline->projectView()->pasteClipEffects();
2431 void MainWindow::slotFind()
2433 if (!m_activeDocument || !m_activeTimeline) return;
2434 m_projectSearch->setEnabled(false);
2435 m_findActivated = true;
2436 m_findString.clear();
2437 m_activeTimeline->projectView()->initSearchStrings();
2438 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2439 m_findTimer.start(5000);
2440 qApp->installEventFilter(this);
2443 void MainWindow::slotFindNext()
2445 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
2446 statusBar()->showMessage(i18n("Found: %1", m_findString));
2448 statusBar()->showMessage(i18n("Reached end of project"));
2450 m_findTimer.start(4000);
2453 void MainWindow::findAhead()
2455 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
2456 m_projectSearchNext->setEnabled(true);
2457 statusBar()->showMessage(i18n("Found: %1", m_findString));
2459 m_projectSearchNext->setEnabled(false);
2460 statusBar()->showMessage(i18n("Not found: %1", m_findString));
2464 void MainWindow::findTimeout()
2466 m_projectSearchNext->setEnabled(false);
2467 m_findActivated = false;
2468 m_findString.clear();
2469 statusBar()->showMessage(i18n("Find stopped"), 3000);
2470 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
2471 m_projectSearch->setEnabled(true);
2472 removeEventFilter(this);
2475 void MainWindow::keyPressEvent(QKeyEvent *ke)
2477 if (m_findActivated) {
2478 if (ke->key() == Qt::Key_Backspace) {
2479 m_findString = m_findString.left(m_findString.length() - 1);
2481 if (!m_findString.isEmpty()) {
2487 m_findTimer.start(4000);
2490 } else if (ke->key() == Qt::Key_Escape) {
2494 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
2495 m_findString += ke->text();
2499 m_findTimer.start(4000);
2503 } else KXmlGuiWindow::keyPressEvent(ke);
2507 /** Gets called when the window gets hidden */
2508 void MainWindow::hideEvent(QHideEvent */*event*/)
2510 // kDebug() << "I was hidden";
2511 // issue http://www.kdenlive.org/mantis/view.php?id=231
2512 if (isMinimized()) {
2513 // kDebug() << "I am minimized";
2514 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
2518 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
2520 if (m_findActivated) {
2521 if (event->type() == QEvent::ShortcutOverride) {
2522 QKeyEvent* ke = (QKeyEvent*) event;
2523 if (ke->text().trimmed().isEmpty()) return false;
2526 } else return false;
2528 // pass the event on to the parent class
2529 return QMainWindow::eventFilter(obj, event);
2534 void MainWindow::slotSaveZone(Render *render, QPoint zone)
2536 KDialog *dialog = new KDialog(this);
2537 dialog->setCaption("Save clip zone");
2538 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
2540 QWidget *widget = new QWidget(dialog);
2541 dialog->setMainWidget(widget);
2543 QVBoxLayout *vbox = new QVBoxLayout(widget);
2544 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
2545 QString path = m_activeDocument->projectFolder().path();
2547 path.append("untitled.mlt");
2548 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
2549 url->setFilter("video/mlt-playlist");
2550 QLabel *label2 = new QLabel(i18n("Description:"), this);
2551 KLineEdit *edit = new KLineEdit(this);
2552 vbox->addWidget(label1);
2553 vbox->addWidget(url);
2554 vbox->addWidget(label2);
2555 vbox->addWidget(edit);
2556 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
2560 void MainWindow::slotSetInPoint()
2562 if (m_clipMonitor->isActive()) {
2563 m_clipMonitor->slotSetZoneStart();
2564 } else m_activeTimeline->projectView()->setInPoint();
2567 void MainWindow::slotSetOutPoint()
2569 if (m_clipMonitor->isActive()) {
2570 m_clipMonitor->slotSetZoneEnd();
2571 } else m_activeTimeline->projectView()->setOutPoint();
2574 void MainWindow::slotGetNewLumaStuff()
2576 //KNS::Entry::List download();
2577 KNS::Entry::List entries = KNS::Engine::download();
2578 // list of changed entries
2579 kDebug() << "// PARSING KNS";
2580 foreach(KNS::Entry* entry, entries) {
2581 // care only about installed ones
2582 if (entry->status() == KNS::Entry::Installed) {
2583 foreach(const QString &file, entry->installedFiles()) {
2584 kDebug() << "// CURRENTLY INSTALLED: " << file;
2588 qDeleteAll(entries);
2589 initEffects::refreshLumas();
2590 m_activeTimeline->projectView()->reloadTransitionLumas();
2593 void MainWindow::slotGetNewRenderStuff()
2595 //KNS::Entry::List download();
2597 KNS::Engine engine(0);
2598 if (engine.init("kdenlive_render.knsrc")) {
2599 KNS::Entry::List entries = engine.downloadDialogModal(this);
2601 if (entries.size() > 0) {
2602 foreach(KNS::Entry* entry, entries) {
2603 // care only about installed ones
2604 if (entry->status() == KNS::Entry::Installed) {
2605 foreach(const QString &file, entry->installedFiles()) {
2606 kDebug() << "// CURRENTLY INSTALLED: " << file;
2611 if (m_renderWidget) m_renderWidget->reloadProfiles();
2615 void MainWindow::slotGetNewMltProfileStuff()
2617 //KNS::Entry::List download();
2619 KNS::Engine engine(0);
2620 if (engine.init("kdenlive_mltprofiles.knsrc")) {
2621 KNS::Entry::List entries = engine.downloadDialogModal(this);
2623 if (entries.size() > 0) {
2624 foreach(KNS::Entry* entry, entries) {
2625 // care only about installed ones
2626 if (entry->status() == KNS::Entry::Installed) {
2627 foreach(const QString &file, entry->installedFiles()) {
2628 kDebug() << "// CURRENTLY INSTALLED: " << file;
2633 // update the list of profiles in settings dialog
2634 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2635 if (d) d->checkProfile();
2640 void MainWindow::slotAutoTransition()
2642 if (m_activeTimeline) m_activeTimeline->projectView()->autoTransition();
2645 void MainWindow::slotSplitAudio()
2647 if (m_activeTimeline) m_activeTimeline->projectView()->splitAudio();
2650 void MainWindow::slotUpdateClipType(QAction *action)
2652 if (m_activeTimeline) {
2653 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
2654 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
2655 else m_activeTimeline->projectView()->setAudioAndVideo();
2659 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
2661 DvdWizard *w = new DvdWizard(url, profile, this);
2665 void MainWindow::slotShowTimeline(bool show)
2667 if (show == false) {
2668 m_timelineState = saveState();
2669 centralWidget()->setHidden(true);
2671 centralWidget()->setHidden(false);
2672 restoreState(m_timelineState);
2676 void MainWindow::slotMaximizeCurrent(bool /*show*/)
2678 //TODO: is there a way to maximize current widget?
2681 m_timelineState = saveState();
2682 QWidget *par = focusWidget()->parentWidget();
2683 while (par->parentWidget() && par->parentWidget() != this) {
2684 par = par->parentWidget();
2686 kDebug() << "CURRENT WIDGET: " << par->objectName();
2689 //centralWidget()->setHidden(false);
2690 //restoreState(m_timelineState);
2694 void MainWindow::loadTranscoders()
2696 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
2699 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
2700 KConfigGroup transConfig(config, "Transcoding");
2702 QMap< QString, QString > profiles = transConfig.entryMap();
2703 QMapIterator<QString, QString> i(profiles);
2704 while (i.hasNext()) {
2706 QAction *a = transMenu->addAction(i.key());
2707 a->setData(i.value());
2708 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
2712 void MainWindow::slotTranscode(KUrl::List urls)
2715 if (urls.isEmpty()) {
2716 urls.append(m_projectList->currentClipUrl());
2717 QAction *action = qobject_cast<QAction *>(sender());
2718 params = action->data().toString();
2720 if (urls.isEmpty()) return;
2721 ClipTranscode *d = new ClipTranscode(urls, params);
2722 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
2724 //QProcess::startDetached("ffmpeg", parameters);
2727 void MainWindow::slotTranscodeClip()
2729 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
2730 if (urls.isEmpty()) return;
2731 slotTranscode(urls);
2734 void MainWindow::slotSetDocumentRenderProfile(const QString &dest, const QString &name, const QString &file)
2736 if (m_activeDocument == NULL) return;
2737 m_activeDocument->setDocumentProperty("renderdestination", dest);
2738 m_activeDocument->setDocumentProperty("renderprofile", name);
2739 m_activeDocument->setDocumentProperty("renderurl", file);
2740 m_activeDocument->setModified(true);
2744 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
2746 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
2748 QString playlistPath;
2751 QString scriptsFolder = m_activeDocument->projectFolder().path() + "/scripts/";
2752 QString path = m_renderWidget->getFreeScriptName();
2753 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
2754 if (!ok || scriptPath.isEmpty()) return;
2755 scriptPath.prepend(scriptsFolder);
2756 QFile f(scriptPath);
2758 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
2761 playlistPath = scriptPath + ".mlt";
2762 m_projectMonitor->saveSceneList(playlistPath);
2764 KTemporaryFile temp;
2765 temp.setAutoRemove(false);
2766 temp.setSuffix(".mlt");
2768 playlistPath = temp.fileName();
2769 m_projectMonitor->saveSceneList(playlistPath);
2772 if (!chapterFile.isEmpty()) {
2775 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
2777 in = m_activeTimeline->inPoint();
2778 out = m_activeTimeline->outPoint();
2781 QDomElement chapters = doc.createElement("chapters");
2782 chapters.setAttribute("fps", m_activeDocument->fps());
2783 doc.appendChild(chapters);
2785 QDomElement guidesxml = m_activeDocument->guidesXml();
2786 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
2787 for (int i = 0; i < nodes.count(); i++) {
2788 QDomElement e = nodes.item(i).toElement();
2790 QString comment = e.attribute("comment");
2791 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
2792 if (time >= in && time < out) {
2793 if (zoneOnly) time = time - in;
2794 QDomElement chapter = doc.createElement("chapter");
2795 chapters.appendChild(chapter);
2796 chapter.setAttribute("title", comment);
2797 chapter.setAttribute("time", time);
2801 if (chapters.childNodes().count() > 0) {
2802 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
2803 // Always insert a guide in pos 0
2804 QDomElement chapter = doc.createElement("chapter");
2805 chapters.insertBefore(chapter, QDomNode());
2806 chapter.setAttribute("title", i18n("Start"));
2807 chapter.setAttribute("time", "0");
2809 // save chapters file
2810 QFile file(chapterFile);
2811 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
2812 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
2814 file.write(doc.toString().toUtf8());
2815 if (file.error() != QFile::NoError) {
2816 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
2823 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath);
2826 void MainWindow::slotUpdateTimecodeFormat(int ix)
2828 KdenliveSettings::setFrametimecode(ix == 1);
2829 m_clipMonitor->updateTimecodeFormat();
2830 m_projectMonitor->updateTimecodeFormat();
2833 void MainWindow::slotRemoveFocus()
2835 statusBar()->setFocus();
2836 statusBar()->clearFocus();
2842 #include "mainwindow.moc"