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>
86 #include <QTextStream>
90 #include <QInputDialog>
91 #include <QDesktopWidget>
95 static const char version[] = VERSION;
97 static const int ID_TIMELINE_POS = 0;
104 EffectsList MainWindow::videoEffects;
105 EffectsList MainWindow::audioEffects;
106 EffectsList MainWindow::customEffects;
107 EffectsList MainWindow::transitions;
109 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent) :
110 KXmlGuiWindow(parent),
111 m_activeDocument(NULL),
112 m_activeTimeline(NULL),
113 m_renderWidget(NULL),
114 #ifndef NO_JOGSHUTTLE
116 #endif /* NO_JOGSHUTTLE */
117 m_findActivated(false)
120 // Create DBus interface
121 new MainWindowAdaptor(this);
122 QDBusConnection dbus = QDBusConnection::sessionBus();
123 dbus.registerObject("/MainWindow", this);
125 setlocale(LC_NUMERIC, "POSIX");
126 setFont(KGlobalSettings::toolBarFont());
127 parseProfiles(MltPath);
128 m_commandStack = new QUndoGroup;
129 m_timelineArea = new KTabWidget(this);
130 m_timelineArea->setTabReorderingEnabled(true);
131 m_timelineArea->setTabBarHidden(true);
133 QToolButton *closeTabButton = new QToolButton;
134 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
135 closeTabButton->setIcon(KIcon("tab-close"));
136 closeTabButton->adjustSize();
137 closeTabButton->setToolTip(i18n("Close the current tab"));
138 m_timelineArea->setCornerWidget(closeTabButton);
139 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
141 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
142 m_findTimer.setSingleShot(true);
144 // FIXME: the next call returns a newly allocated object, which leaks
145 initEffects::parseEffectFiles();
146 //initEffects::parseCustomEffectsFile();
148 m_monitorManager = new MonitorManager();
150 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
151 m_projectListDock->setObjectName("project_tree");
152 m_projectList = new ProjectList(this);
153 m_projectListDock->setWidget(m_projectList);
154 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
156 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
157 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
159 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
160 m_effectListDock->setObjectName("effect_list");
161 m_effectList = new EffectsListView();
163 //m_effectList = new KListWidget(this);
164 m_effectListDock->setWidget(m_effectList);
165 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
167 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
168 m_effectStackDock->setObjectName("effect_stack");
169 m_effectStack = new EffectStackView(this);
170 m_effectStackDock->setWidget(m_effectStack);
171 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
173 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
174 m_transitionConfigDock->setObjectName("transition");
175 m_transitionConfig = new TransitionSettings(this);
176 m_transitionConfigDock->setWidget(m_transitionConfig);
177 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
179 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
180 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
182 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
183 m_fileRevert->setEnabled(false);
185 //slotDetectAudioDriver();
187 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
188 m_clipMonitorDock->setObjectName("clip_monitor");
189 m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), this);
190 m_clipMonitorDock->setWidget(m_clipMonitor);
191 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
192 //m_clipMonitor->stop();
194 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
195 m_projectMonitorDock->setObjectName("project_monitor");
196 m_projectMonitor = new Monitor("project", m_monitorManager, QString(), this);
197 m_projectMonitorDock->setWidget(m_projectMonitor);
198 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
201 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
202 m_recMonitorDock->setObjectName("record_monitor");
203 m_recMonitor = new RecMonitor("record", this);
204 m_recMonitorDock->setWidget(m_recMonitor);
205 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
207 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
208 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
211 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
212 m_undoViewDock->setObjectName("undo_history");
213 m_undoView = new QUndoView(this);
214 m_undoView->setCleanIcon(KIcon("edit-clear"));
215 m_undoView->setEmptyLabel(i18n("Clean"));
216 m_undoViewDock->setWidget(m_undoView);
217 m_undoView->setGroup(m_commandStack);
218 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
220 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
221 //overviewDock->setObjectName("project_overview");
222 //m_overView = new CustomTrackView(NULL, NULL, this);
223 //overviewDock->setWidget(m_overView);
224 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
227 //tabifyDockWidget(projectListDock, effectListDock);
228 tabifyDockWidget(m_projectListDock, m_effectStackDock);
229 tabifyDockWidget(m_projectListDock, m_transitionConfigDock);
230 //tabifyDockWidget(projectListDock, undoViewDock);
233 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
235 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
237 setCentralWidget(m_timelineArea);
242 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
243 guiFactory()->addClient(sp);*/
247 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
249 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone);
250 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
251 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)), static_cast<QMenu*>(factory()->container("transcoders", this)));
254 // build themes menus
255 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
256 action = new QAction(i18n("Default"), this);
257 themesMenu->addAction(action);
258 fprintf(stderr, "THEMES: %s\n", KStandardDirs::installPath("data").toUtf8().data());
259 KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
260 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
261 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it) {
263 action = new QAction(fi.fileName(), this);
264 action->setData(*it);
265 themesMenu->addAction(action);
267 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
269 // build effects menus
270 QMenu *videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
272 QStringList effectInfo;
273 QMap<QString, QStringList> effectsList;
274 for (int ix = 0; ix < videoEffects.count(); ix++) {
275 effectInfo = videoEffects.effectIdInfo(ix);
276 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
279 foreach(const QStringList &value, effectsList) {
280 action = new QAction(value.at(0), this);
281 action->setData(value);
282 videoEffectsMenu->addAction(action);
285 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
289 for (int ix = 0; ix < audioEffects.count(); ix++) {
290 effectInfo = audioEffects.effectIdInfo(ix);
291 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
294 foreach(const QStringList &value, effectsList) {
295 action = new QAction(value.at(0), this);
296 action->setData(value);
297 audioEffectsMenu->addAction(action);
300 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
302 if (customEffects.isEmpty()) m_customEffectsMenu->setEnabled(false);
303 else m_customEffectsMenu->setEnabled(true);
306 for (int ix = 0; ix < customEffects.count(); ix++) {
307 effectInfo = customEffects.effectIdInfo(ix);
308 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
311 foreach(const QStringList &value, effectsList) {
312 action = new QAction(value.at(0), this);
313 action->setData(value);
314 m_customEffectsMenu->addAction(action);
317 QMenu *newEffect = new QMenu(this);
318 newEffect->addMenu(videoEffectsMenu);
319 newEffect->addMenu(audioEffectsMenu);
320 newEffect->addMenu(m_customEffectsMenu);
321 m_effectStack->setMenu(newEffect);
324 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
325 const QList<QAction *> viewActions = createPopupMenu()->actions();
326 viewMenu->insertActions(NULL, viewActions);
328 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
329 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
330 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
332 m_timelineContextMenu = new QMenu(this);
333 m_timelineContextClipMenu = new QMenu(this);
334 m_timelineContextTransitionMenu = new QMenu(this);
337 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
338 QStringList effects = transitions.effectNames();
341 for (int ix = 0; ix < transitions.count(); ix++) {
342 effectInfo = transitions.effectIdInfo(ix);
343 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
345 foreach(const QStringList &value, effectsList) {
346 action = new QAction(value.at(0), this);
347 action->setData(value);
348 transitionsMenu->addAction(action);
350 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
352 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
353 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
354 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
356 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
357 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
358 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
359 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
360 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
361 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
362 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
364 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
365 m_timelineContextClipMenu->addMenu(markersMenu);
366 m_timelineContextClipMenu->addMenu(transitionsMenu);
367 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
368 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
369 //TODO: re-enable custom effects menu when it is implemented
370 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
372 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
373 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
375 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
377 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
378 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
379 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
380 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
381 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
382 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
384 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
385 slotConnectMonitors();
387 // Open or create a file. Command line argument passed in Url has
388 // precedence, then "openlastproject", then just a plain empty file.
389 // If opening Url fails, openlastproject will _not_ be used.
390 if (!Url.isEmpty()) {
391 // delay loading so that the window shows up
393 QTimer::singleShot(500, this, SLOT(openFile()));
394 } else if (KdenliveSettings::openlastproject()) {
395 QTimer::singleShot(500, this, SLOT(openLastFile()));
396 } else { //if (m_timelineArea->count() == 0) {
400 #ifndef NO_JOGSHUTTLE
401 activateShuttleDevice();
402 #endif /* NO_JOGSHUTTLE */
403 m_projectListDock->raise();
406 void MainWindow::queryQuit()
409 if (m_projectMonitor) m_projectMonitor->stop();
410 if (m_clipMonitor) m_clipMonitor->stop();
411 delete m_effectStack;
412 delete m_activeTimeline;
414 // This sometimes causes crash on exit on OS X for some reason.
415 delete m_projectMonitor;
416 delete m_clipMonitor;
418 delete m_activeDocument;
419 delete m_shortcutRemoveFocus;
420 Mlt::Factory::close();
426 bool MainWindow::queryClose()
428 if (m_renderWidget) {
429 int waitingJobs = m_renderWidget->waitingJobsCount();
430 if (waitingJobs > 0) {
431 switch (KMessageBox::warningYesNoCancel(this, i18np("You have 1 rendering job waiting in the queue.\nWhat do you want to do with this job?", "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")))) {
432 case KMessageBox::Yes :
433 // create script with waiting jobs and start it
434 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
436 case KMessageBox::No :
437 // Don't do anything, jobs will be deleted
445 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
446 if (m_activeDocument && m_activeDocument->isModified()) {
447 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
448 case KMessageBox::Yes :
449 // save document here. If saving fails, return false;
451 case KMessageBox::No :
452 // User does not want to save the changes, clear recovery files
453 m_activeDocument->m_autosave->resize(0);
463 void MainWindow::loadPlugins()
465 foreach(QObject *plugin, QPluginLoader::staticInstances())
466 populateMenus(plugin);
468 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
470 filters << "libkdenlive*";
471 foreach(const QString &folder, directories) {
472 kDebug() << "// PARSING FIOLER: " << folder;
473 QDir pluginsDir(folder);
474 foreach(const QString &fileName, pluginsDir.entryList(filters, QDir::Files)) {
475 kDebug() << "// FOUND PLUGIN: " << fileName << "= " << pluginsDir.absoluteFilePath(fileName);
476 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
477 QObject *plugin = loader.instance();
479 populateMenus(plugin);
480 m_pluginFileNames += fileName;
481 } else kDebug() << "// ERROR LOADING PLUGIN: " << fileName << ", " << loader.errorString();
487 void MainWindow::populateMenus(QObject *plugin)
489 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
490 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
492 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
496 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
497 QMenu *menu, const char *member,
498 QActionGroup *actionGroup)
500 kDebug() << "// ADD to MENU" << texts;
501 foreach(const QString &text, texts) {
502 QAction *action = new QAction(text, plugin);
503 action->setData(text);
504 connect(action, SIGNAL(triggered()), this, member);
505 menu->addAction(action);
508 action->setCheckable(true);
509 actionGroup->addAction(action);
514 void MainWindow::aboutPlugins()
516 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
521 void MainWindow::generateClip()
523 QAction *action = qobject_cast<QAction *>(sender());
524 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
526 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(), QStringList(), QStringList(), 25, 720, 576);
527 if (!clipUrl.isEmpty()) {
528 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
532 void MainWindow::saveProperties(KConfigGroup &config)
534 // save properties here,used by session management
536 KMainWindow::saveProperties(config);
540 void MainWindow::readProperties(const KConfigGroup &config)
542 // read properties here,used by session management
543 KMainWindow::readProperties(config);
544 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
545 openFile(KUrl(Lastproject));
548 void MainWindow::slotReloadEffects()
550 kDebug() << "START RELOAD; COUNR: " << m_customEffectsMenu->actions().count();
551 m_customEffectsMenu->clear();
552 kDebug() << "START RELOAD; CLR: " << m_customEffectsMenu->actions().count();
553 initEffects::parseCustomEffectsFile();
554 const QStringList effects = customEffects.effectNames();
555 kDebug() << "NEW EFFS: " << effects;
557 if (effects.isEmpty()) m_customEffectsMenu->setEnabled(false);
558 else m_customEffectsMenu->setEnabled(true);
560 foreach(const QString &name, effects) {
561 action = new QAction(name, this);
562 action->setData(name);
563 m_customEffectsMenu->addAction(action);
565 m_effectList->reloadEffectList();
568 #ifndef NO_JOGSHUTTLE
569 void MainWindow::activateShuttleDevice()
573 if (KdenliveSettings::enableshuttle() == false) return;
574 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
575 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
576 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
577 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
578 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
579 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
580 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
583 void MainWindow::slotShuttleButton(int code)
587 slotShuttleAction(KdenliveSettings::shuttle1());
590 slotShuttleAction(KdenliveSettings::shuttle2());
593 slotShuttleAction(KdenliveSettings::shuttle3());
596 slotShuttleAction(KdenliveSettings::shuttle4());
599 slotShuttleAction(KdenliveSettings::shuttle5());
604 void MainWindow::slotShuttleAction(int code)
610 m_monitorManager->slotPlay();
613 m_monitorManager->slotPlay();
617 #endif /* NO_JOGSHUTTLE */
619 void MainWindow::configureNotifications()
621 KNotifyConfigWidget::configure(this);
624 void MainWindow::slotFullScreen()
626 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
629 void MainWindow::slotAddEffect(const QDomElement effect, GenTime pos, int track)
631 if (!m_activeDocument) return;
632 if (effect.isNull()) {
633 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
636 QDomElement effectToAdd = effect.cloneNode().toElement();
637 m_activeTimeline->projectView()->slotAddEffect(effectToAdd, pos, track);
640 void MainWindow::slotRaiseMonitor(bool clipMonitor)
642 if (clipMonitor) m_clipMonitorDock->raise();
643 else m_projectMonitorDock->raise();
646 void MainWindow::slotUpdateClip(const QString &id)
648 if (!m_activeDocument) return;
649 m_activeTimeline->projectView()->slotUpdateClip(id);
652 void MainWindow::slotConnectMonitors()
655 m_projectList->setRenderer(m_projectMonitor->render);
656 //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
657 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
658 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, bool)));
659 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
660 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)));
662 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
664 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
666 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
667 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
669 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
670 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
673 void MainWindow::slotAdjustClipMonitor()
675 m_clipMonitorDock->updateGeometry();
676 m_clipMonitorDock->adjustSize();
677 m_clipMonitor->resetSize();
680 void MainWindow::slotAdjustProjectMonitor()
682 m_projectMonitorDock->updateGeometry();
683 m_projectMonitorDock->adjustSize();
684 m_projectMonitor->resetSize();
687 void MainWindow::setupActions()
690 KActionCollection* collection = actionCollection();
691 m_timecodeFormat = new KComboBox(this);
692 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
693 m_timecodeFormat->addItem(i18n("Frames"));
694 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
695 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
697 m_statusProgressBar = new QProgressBar(this);
698 m_statusProgressBar->setMinimum(0);
699 m_statusProgressBar->setMaximum(100);
700 m_statusProgressBar->setMaximumWidth(150);
701 m_statusProgressBar->setVisible(false);
703 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
704 toolbar->setMovable(false);
705 m_toolGroup = new QActionGroup(this);
706 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
707 QString style1 = "QToolBar { border: 0px } QToolButton { 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;}";
709 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
710 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
711 toolbar->addAction(m_buttonSelectTool);
712 m_buttonSelectTool->setCheckable(true);
713 m_buttonSelectTool->setChecked(true);
715 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
716 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
717 toolbar->addAction(m_buttonRazorTool);
718 m_buttonRazorTool->setCheckable(true);
719 m_buttonRazorTool->setChecked(false);
721 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
722 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
723 toolbar->addAction(m_buttonSpacerTool);
724 m_buttonSpacerTool->setCheckable(true);
725 m_buttonSpacerTool->setChecked(false);
727 m_toolGroup->addAction(m_buttonSelectTool);
728 m_toolGroup->addAction(m_buttonRazorTool);
729 m_toolGroup->addAction(m_buttonSpacerTool);
730 m_toolGroup->setExclusive(true);
731 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
733 QWidget * actionWidget;
734 int max = toolbar->iconSizeDefault() + 2;
735 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
736 actionWidget->setMaximumWidth(max);
737 actionWidget->setMaximumHeight(max - 4);
739 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
740 actionWidget->setMaximumWidth(max);
741 actionWidget->setMaximumHeight(max - 4);
743 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
744 actionWidget->setMaximumWidth(max);
745 actionWidget->setMaximumHeight(max - 4);
747 toolbar->setStyleSheet(style1);
748 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
750 toolbar->addSeparator();
751 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
752 toolbar->addAction(m_buttonFitZoom);
753 m_buttonFitZoom->setCheckable(false);
754 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
756 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
757 actionWidget->setMaximumWidth(max);
758 actionWidget->setMaximumHeight(max - 4);
760 m_zoomSlider = new QSlider(Qt::Horizontal, this);
761 m_zoomSlider->setMaximum(13);
762 m_zoomSlider->setPageStep(1);
764 m_zoomSlider->setMaximumWidth(150);
765 m_zoomSlider->setMinimumWidth(100);
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()));
792 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
793 actionWidget->setMaximumWidth(max);
794 actionWidget->setMaximumHeight(max - 4);
796 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
797 actionWidget->setMaximumWidth(max);
798 actionWidget->setMaximumHeight(max - 4);
800 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
801 actionWidget->setMaximumWidth(max);
802 actionWidget->setMaximumHeight(max - 4);
804 actionWidget = toolbar->widgetForAction(m_buttonSnap);
805 actionWidget->setMaximumWidth(max);
806 actionWidget->setMaximumHeight(max - 4);
808 m_messageLabel = new StatusBarMessageLabel(this);
809 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
811 statusBar()->addWidget(m_messageLabel, 10);
812 statusBar()->addWidget(m_statusProgressBar, 0);
813 statusBar()->addPermanentWidget(toolbar);
814 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
815 statusBar()->addPermanentWidget(m_timecodeFormat);
816 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
818 collection->addAction("select_tool", m_buttonSelectTool);
819 collection->addAction("razor_tool", m_buttonRazorTool);
820 collection->addAction("spacer_tool", m_buttonSpacerTool);
822 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
823 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
824 collection->addAction("show_markers", m_buttonShowMarkers);
825 collection->addAction("snap", m_buttonSnap);
826 collection->addAction("zoom_fit", m_buttonFitZoom);
828 KAction* zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
829 collection->addAction("zoom_in", zoomIn);
830 connect(zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
831 zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
833 KAction* zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
834 collection->addAction("zoom_out", zoomOut);
835 connect(zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
836 zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
838 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
839 collection->addAction("project_find", m_projectSearch);
840 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
841 m_projectSearch->setShortcut(Qt::Key_Slash);
843 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
844 collection->addAction("project_find_next", m_projectSearchNext);
845 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
846 m_projectSearchNext->setShortcut(Qt::Key_F3);
847 m_projectSearchNext->setEnabled(false);
849 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
850 collection->addAction("manage_profiles", profilesAction);
851 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
853 KNS::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
855 KNS::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
857 KNS::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
859 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
860 collection->addAction("run_wizard", wizAction);
861 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
863 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
864 collection->addAction("project_settings", projectAction);
865 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
867 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
868 collection->addAction("project_render", projectRender);
869 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
870 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
872 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
873 collection->addAction("project_clean", projectClean);
874 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
876 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
877 KShortcut playShortcut;
878 playShortcut.setPrimary(Qt::Key_Space);
879 playShortcut.setAlternate(Qt::Key_K);
880 monitorPlay->setShortcut(playShortcut);
881 collection->addAction("monitor_play", monitorPlay);
882 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
884 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
885 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
886 collection->addAction("monitor_play_zone", m_playZone);
887 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
889 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
890 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
891 collection->addAction("monitor_loop_zone", m_loopZone);
892 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
894 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
895 collection->addAction("dvd_wizard", dvdWizard);
896 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
898 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
899 collection->addAction("transcode_clip", transcodeClip);
900 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
902 KAction *markIn = collection->addAction("mark_in");
903 markIn->setText(i18n("Set In Point"));
904 markIn->setShortcut(Qt::Key_I);
905 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
907 KAction *markOut = collection->addAction("mark_out");
908 markOut->setText(i18n("Set Out Point"));
909 markOut->setShortcut(Qt::Key_O);
910 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
912 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
913 monitorSeekBackward->setShortcut(Qt::Key_J);
914 collection->addAction("monitor_seek_backward", monitorSeekBackward);
915 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
917 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
918 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
919 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
920 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
922 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
923 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
924 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
925 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
927 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
928 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
929 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
930 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
932 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
933 monitorSeekForward->setShortcut(Qt::Key_L);
934 collection->addAction("monitor_seek_forward", monitorSeekForward);
935 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
937 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
938 clipStart->setShortcut(Qt::Key_Home);
939 collection->addAction("seek_clip_start", clipStart);
940 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
942 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
943 clipEnd->setShortcut(Qt::Key_End);
944 collection->addAction("seek_clip_end", clipEnd);
945 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
947 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
948 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
949 collection->addAction("seek_start", projectStart);
950 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
952 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
953 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
954 collection->addAction("seek_end", projectEnd);
955 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
957 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
958 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
959 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
960 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
962 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
963 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
964 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
965 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
967 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
968 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
969 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
970 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
972 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
973 deleteTimelineClip->setShortcut(Qt::Key_Delete);
974 collection->addAction("delete_timeline_clip", deleteTimelineClip);
975 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
977 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
978 collection->addAction("change_clip_speed", editTimelineClipSpeed);
979 editTimelineClipSpeed->setData("change_speed");
980 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
982 KAction *stickTransition = collection->addAction("auto_transition");
983 stickTransition->setData(QString("auto"));
984 stickTransition->setCheckable(true);
985 stickTransition->setEnabled(false);
986 stickTransition->setText(i18n("Automatic Transition"));
987 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
989 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
990 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
991 collection->addAction("group_clip", groupClip);
992 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
994 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
995 collection->addAction("ungroup_clip", ungroupClip);
996 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
997 ungroupClip->setData("ungroup_clip");
998 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1000 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1001 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1002 collection->addAction("cut_timeline_clip", cutTimelineClip);
1003 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1005 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1006 collection->addAction("add_clip_marker", addClipMarker);
1007 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1009 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1010 collection->addAction("delete_clip_marker", deleteClipMarker);
1011 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1013 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1014 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
1015 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1017 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1018 collection->addAction("edit_clip_marker", editClipMarker);
1019 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1021 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1022 collection->addAction("split_audio", splitAudio);
1023 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1025 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1026 collection->addAction("clip_audio_only", audioOnly);
1027 audioOnly->setData("clip_audio_only");
1028 audioOnly->setCheckable(true);
1030 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1031 collection->addAction("clip_video_only", videoOnly);
1032 videoOnly->setData("clip_video_only");
1033 videoOnly->setCheckable(true);
1035 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1036 collection->addAction("clip_audio_and_video", audioAndVideo);
1037 audioAndVideo->setData("clip_audio_and_video");
1038 audioAndVideo->setCheckable(true);
1040 m_clipTypeGroup = new QActionGroup(this);
1041 m_clipTypeGroup->addAction(audioOnly);
1042 m_clipTypeGroup->addAction(videoOnly);
1043 m_clipTypeGroup->addAction(audioAndVideo);
1044 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1045 m_clipTypeGroup->setEnabled(false);
1047 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1048 collection->addAction("insert_space", insertSpace);
1049 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1051 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1052 collection->addAction("delete_space", removeSpace);
1053 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1055 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1056 collection->addAction("insert_track", insertTrack);
1057 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1059 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1060 collection->addAction("delete_track", deleteTrack);
1061 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1063 KAction *changeTrack = new KAction(KIcon(), i18n("Change Track"), this);
1064 collection->addAction("change_track", changeTrack);
1065 connect(changeTrack, SIGNAL(triggered()), this, SLOT(slotChangeTrack()));
1067 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1068 collection->addAction("add_guide", addGuide);
1069 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1071 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1072 collection->addAction("delete_guide", delGuide);
1073 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1075 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1076 collection->addAction("edit_guide", editGuide);
1077 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1079 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1080 collection->addAction("delete_all_guides", delAllGuides);
1081 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1083 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1084 collection->addAction("paste_effects", pasteEffects);
1085 pasteEffects->setData("paste_effects");
1086 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1088 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1089 collection->addAction("show_timeline", showTimeline);
1090 showTimeline->setCheckable(true);
1091 showTimeline->setChecked(true);
1092 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1094 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1095 collection->addAction("maximize_current", maxCurrent);
1096 maxCurrent->setCheckable(true);
1097 maxCurrent->setChecked(false);
1098 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1101 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1103 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1105 KStandardAction::open(this, SLOT(openFile()), collection);
1107 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1109 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1111 KStandardAction::openNew(this, SLOT(newFile()), collection);
1113 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1115 KStandardAction::configureNotifications(this , SLOT(configureNotifications()), collection);
1117 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1119 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1121 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1122 undo->setEnabled(false);
1123 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1125 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1126 redo->setEnabled(false);
1127 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1129 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1132 //TODO: Add status tooltip to actions ?
1133 connect(collection, SIGNAL(actionHovered(QAction*)),
1134 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1137 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1138 collection->addAction("add_clip", addClip);
1139 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1141 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1142 collection->addAction("add_color_clip", addColorClip);
1143 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1145 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1146 collection->addAction("add_slide_clip", addSlideClip);
1147 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1149 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1150 collection->addAction("add_text_clip", addTitleClip);
1151 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1153 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1154 collection->addAction("add_text_template_clip", addTitleTemplateClip);
1155 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1157 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1158 collection->addAction("add_folder", addFolderButton);
1159 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1161 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1162 collection->addAction("clip_properties", clipProperties);
1163 clipProperties->setData("clip_properties");
1164 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1165 clipProperties->setEnabled(false);
1167 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1168 collection->addAction("edit_clip", openClip);
1169 openClip->setData("edit_clip");
1170 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1171 openClip->setEnabled(false);
1173 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1174 collection->addAction("delete_clip", deleteClip);
1175 deleteClip->setData("delete_clip");
1176 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1177 deleteClip->setEnabled(false);
1179 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1180 collection->addAction("reload_clip", reloadClip);
1181 reloadClip->setData("reload_clip");
1182 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1183 reloadClip->setEnabled(false);
1185 QMenu *addClips = new QMenu();
1186 addClips->addAction(addClip);
1187 addClips->addAction(addColorClip);
1188 addClips->addAction(addSlideClip);
1189 addClips->addAction(addTitleClip);
1190 addClips->addAction(addTitleTemplateClip);
1191 addClips->addAction(addFolderButton);
1193 addClips->addAction(reloadClip);
1194 addClips->addAction(clipProperties);
1195 addClips->addAction(openClip);
1196 addClips->addAction(deleteClip);
1197 m_projectList->setupMenu(addClips, addClip);
1199 //connect(collection, SIGNAL( clearStatusText() ),
1200 //statusBar(), SLOT( clear() ) );
1203 void MainWindow::slotDisplayActionMessage(QAction *a)
1205 statusBar()->showMessage(a->data().toString(), 3000);
1208 void MainWindow::saveOptions()
1210 KdenliveSettings::self()->writeConfig();
1211 KSharedConfigPtr config = KGlobal::config();
1212 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1213 KConfigGroup treecolumns(config, "Project Tree");
1214 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1218 void MainWindow::readOptions()
1220 KSharedConfigPtr config = KGlobal::config();
1221 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1222 KConfigGroup initialGroup(config, "version");
1223 bool upgrade = false;
1224 if (initialGroup.exists()) {
1225 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1229 if (initialGroup.readEntry("version") == "0.7") {
1230 //Add new settings from 0.7.1
1231 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1232 QString path = QDir::homePath() + "/kdenlive";
1233 if (KStandardDirs::makeDir(path) == false) {
1234 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1235 } else KdenliveSettings::setDefaultprojectfolder(path);
1241 if (!initialGroup.exists() || upgrade) {
1242 // this is our first run, show Wizard
1243 Wizard *w = new Wizard(upgrade, this);
1244 if (w->exec() == QDialog::Accepted && w->isOk()) {
1245 w->adjustSettings();
1246 initialGroup.writeEntry("version", version);
1252 KConfigGroup treecolumns(config, "Project Tree");
1253 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1254 if (!state.isEmpty())
1255 m_projectList->setHeaderInfo(state);
1258 void MainWindow::slotRunWizard()
1260 Wizard *w = new Wizard(false, this);
1261 if (w->exec() == QDialog::Accepted && w->isOk()) {
1262 w->adjustSettings();
1267 void MainWindow::newFile(bool showProjectSettings)
1269 if (!m_timelineArea->isEnabled()) return;
1270 m_fileRevert->setEnabled(false);
1271 QString profileName;
1273 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1274 if (!showProjectSettings && m_timelineArea->count() == 0) {
1275 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1276 profileName = KdenliveSettings::default_profile();
1277 projectFolder = KdenliveSettings::defaultprojectfolder();
1279 ProjectSettings *w = new ProjectSettings(NULL, projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1280 if (w->exec() != QDialog::Accepted) return;
1281 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1282 KdenliveSettings::setVideothumbnails(w->enableVideoThumbs());
1283 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1284 KdenliveSettings::setAudiothumbnails(w->enableAudioThumbs());
1285 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1286 profileName = w->selectedProfile();
1287 projectFolder = w->selectedFolder();
1288 projectTracks = w->tracks();
1291 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1292 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1294 TrackView *trackView = new TrackView(doc, &ok, this);
1295 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1298 m_timelineArea->setEnabled(false);
1299 m_projectList->setEnabled(false);
1300 m_monitorManager->slotBlockMonitors();
1304 if (m_timelineArea->count() == 1) {
1305 connectDocumentInfo(doc);
1306 connectDocument(trackView, doc);
1307 } else m_timelineArea->setTabBarHidden(false);
1308 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1311 void MainWindow::activateDocument()
1313 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1314 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1315 KdenliveDoc *currentDoc = currentTab->document();
1316 connectDocumentInfo(currentDoc);
1317 connectDocument(currentTab, currentDoc);
1320 void MainWindow::closeCurrentDocument(bool saveChanges)
1322 QWidget *w = m_timelineArea->currentWidget();
1324 // closing current document
1325 int ix = m_timelineArea->currentIndex() + 1;
1326 if (ix == m_timelineArea->count()) ix = 0;
1327 m_timelineArea->setCurrentIndex(ix);
1328 TrackView *tabToClose = (TrackView *) w;
1329 KdenliveDoc *docToClose = tabToClose->document();
1330 if (docToClose && docToClose->isModified() && saveChanges) {
1331 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
1332 case KMessageBox::Yes :
1333 // save document here. If saving fails, return false;
1334 if (saveFile() == false) return;
1336 case KMessageBox::Cancel :
1343 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1344 if (m_timelineArea->count() == 1) {
1345 m_timelineArea->setTabBarHidden(true);
1346 m_closeAction->setEnabled(false);
1348 if (docToClose == m_activeDocument) {
1349 delete m_activeDocument;
1350 m_activeDocument = NULL;
1351 m_effectStack->clear();
1352 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1353 } else delete docToClose;
1354 if (w == m_activeTimeline) {
1355 delete m_activeTimeline;
1356 m_activeTimeline = NULL;
1360 bool MainWindow::saveFileAs(const QString &outputFileName)
1362 QString currentSceneList;
1363 if (KdenliveSettings::dropbframes()) {
1364 KdenliveSettings::setDropbframes(false);
1365 m_activeDocument->clipManager()->updatePreviewSettings();
1366 currentSceneList = m_projectMonitor->sceneList();
1367 KdenliveSettings::setDropbframes(true);
1368 m_activeDocument->clipManager()->updatePreviewSettings();
1369 } else currentSceneList = m_projectMonitor->sceneList();
1371 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1374 // Save timeline thumbnails
1375 m_activeTimeline->projectView()->saveThumbnails();
1376 m_activeDocument->setUrl(KUrl(outputFileName));
1377 if (m_activeDocument->m_autosave == NULL) {
1378 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1379 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1380 setCaption(m_activeDocument->description());
1381 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1382 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1383 m_activeDocument->setModified(false);
1384 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1385 m_fileRevert->setEnabled(true);
1389 bool MainWindow::saveFileAs()
1391 // Check that the Kdenlive mime type is correctly installed
1392 QString mimetype = "application/x-kdenlive";
1393 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1394 if (!mime) mimetype = "*.kdenlive";
1396 QString outputFile = KFileDialog::getSaveFileName(KUrl(), mimetype);
1397 if (outputFile.isEmpty()) return false;
1398 if (QFile::exists(outputFile)) {
1399 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it?")) == KMessageBox::No) return false;
1401 return saveFileAs(outputFile);
1404 bool MainWindow::saveFile()
1406 if (!m_activeDocument) return true;
1407 if (m_activeDocument->url().isEmpty()) {
1408 return saveFileAs();
1410 bool result = saveFileAs(m_activeDocument->url().path());
1411 m_activeDocument->m_autosave->resize(0);
1416 void MainWindow::openFile()
1418 if (!m_startUrl.isEmpty()) {
1419 openFile(m_startUrl);
1420 m_startUrl = KUrl();
1423 // Check that the Kdenlive mime type is correctly installed
1424 QString mimetype = "application/x-kdenlive";
1425 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1426 if (!mime) mimetype = "*.kdenlive";
1428 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), mimetype);
1429 if (url.isEmpty()) return;
1430 m_fileOpenRecent->addUrl(url);
1434 void MainWindow::openLastFile()
1436 KSharedConfigPtr config = KGlobal::config();
1437 KUrl::List urls = m_fileOpenRecent->urls();
1438 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1439 if (urls.isEmpty()) newFile(false);
1440 else openFile(urls.last());
1443 void MainWindow::openFile(const KUrl &url)
1445 // Check if the document is already opened
1446 const int ct = m_timelineArea->count();
1447 bool isOpened = false;
1449 for (i = 0; i < ct; i++) {
1450 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1451 KdenliveDoc *doc = tab->document();
1452 if (doc->url() == url) {
1458 m_timelineArea->setCurrentIndex(i);
1462 // Check for backup file
1463 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1464 if (!staleFiles.isEmpty()) {
1465 if (KMessageBox::questionYesNo(this,
1466 i18n("Auto-saved files exist. Do you want to recover them now?"),
1467 i18n("File Recovery"),
1468 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1469 recoverFiles(staleFiles);
1472 // remove the stale files
1473 foreach(KAutoSaveFile *stale, staleFiles) {
1474 stale->open(QIODevice::ReadWrite);
1479 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1480 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
1481 qApp->processEvents();
1482 doOpenFile(url, NULL);
1485 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1487 if (!m_timelineArea->isEnabled()) return;
1488 m_fileRevert->setEnabled(true);
1489 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, this);
1490 if (stale == NULL) {
1491 stale = new KAutoSaveFile(url, doc);
1492 doc->m_autosave = stale;
1494 doc->m_autosave = stale;
1495 doc->setUrl(stale->managedFile());
1496 doc->setModified(true);
1497 stale->setParent(doc);
1499 connectDocumentInfo(doc);
1501 TrackView *trackView = new TrackView(doc, &ok, this);
1502 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1504 m_timelineArea->setEnabled(false);
1505 m_projectList->setEnabled(false);
1506 m_monitorManager->slotBlockMonitors();
1510 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1511 trackView->setDuration(trackView->duration());
1512 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1514 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1515 slotGotProgressInfo(QString(), -1);
1516 m_clipMonitor->refreshMonitor(true);
1517 m_projectMonitor->adjustRulerSize(trackView->duration());
1518 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1521 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1523 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1524 foreach(KAutoSaveFile *stale, staleFiles) {
1525 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1526 // show an error message; we could not steal the lockfile
1527 // maybe another application got to the file before us?
1531 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1532 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
1533 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1534 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1539 void MainWindow::parseProfiles(const QString &mltPath)
1541 // kDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
1543 //KdenliveSettings::setDefaulttmpfolder();
1544 if (!mltPath.isEmpty()) {
1545 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1546 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
1549 if (KdenliveSettings::mltpath().isEmpty()) {
1550 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1552 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
1553 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
1554 if (!QFile::exists(meltPath))
1555 meltPath = KStandardDirs::findExe("melt");
1556 KdenliveSettings::setRendererpath(meltPath);
1558 QStringList profilesFilter;
1559 profilesFilter << "*";
1560 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1562 if (profilesList.isEmpty()) {
1563 // Cannot find MLT path, try finding melt
1564 QString profilePath = KdenliveSettings::rendererpath();
1565 if (!profilePath.isEmpty()) {
1566 profilePath = profilePath.section('/', 0, -3);
1567 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1568 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1571 if (profilesList.isEmpty()) {
1572 // Cannot find the MLT profiles, ask for location
1573 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1574 getUrl->fileDialog()->setMode(KFile::Directory);
1575 if (getUrl->exec() == QDialog::Rejected) {
1578 KUrl mltPath = getUrl->selectedUrl();
1580 if (mltPath.isEmpty()) ::exit(0);
1581 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
1582 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1586 if (KdenliveSettings::rendererpath().isEmpty()) {
1587 // Cannot find the MLT melt renderer, ask for location
1588 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of Mlt)"), this);
1589 if (getUrl->exec() == QDialog::Rejected) {
1592 KUrl rendererPath = getUrl->selectedUrl();
1594 if (rendererPath.isEmpty()) ::exit(0);
1595 KdenliveSettings::setRendererpath(rendererPath.path());
1598 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1600 // Parse MLT profiles to build a list of available video formats
1601 if (profilesList.isEmpty()) parseProfiles();
1605 void MainWindow::slotEditProfiles()
1607 ProfilesDialog *w = new ProfilesDialog;
1608 if (w->exec() == QDialog::Accepted) {
1609 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1610 if (d) d->checkProfile();
1615 void MainWindow::slotDetectAudioDriver()
1617 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
1618 leading to no audio output, see bug #934 */
1620 //decide which audio driver is really best, in some cases SDL is wrong
1621 if (KdenliveSettings::audiodrivername().isEmpty()) {
1623 KProcess readProcess;
1624 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
1625 if (!KStandardDirs::findExe("pactl").isEmpty()) {
1626 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
1627 readProcess.setProgram("pactl", QStringList() << "stat");
1628 readProcess.execute(2000); // Kill it after 2 seconds
1630 QString result = QString(readProcess.readAllStandardOutput());
1631 kDebug() << "// / / / / / READING PACTL: ";
1633 if (!result.isEmpty()) {
1635 kDebug() << "// / / / / PULSEAUDIO DETECTED";
1639 KdenliveSettings::setAutoaudiodrivername(driver);
1643 void MainWindow::slotEditProjectSettings()
1645 QPoint p = m_activeDocument->getTracksCount();
1646 ProjectSettings *w = new ProjectSettings(m_activeDocument->clipManager(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
1648 if (w->exec() == QDialog::Accepted) {
1649 if (w->deleteUnused()) {
1650 // we are going to trash the unused clips
1651 m_projectList->trashUnusedClips();
1653 QString profile = w->selectedProfile();
1654 m_activeDocument->setProjectFolder(w->selectedFolder());
1655 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path(KUrl::AddTrailingSlash));
1656 if (m_activeDocument->profilePath() != profile) {
1657 // Profile was changed
1658 double dar = m_activeDocument->dar();
1660 // Deselect current effect / transition
1661 m_effectStack->slotClipItemSelected(NULL, 0);
1662 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1663 m_clipMonitor->slotSetXml(NULL, 0);
1664 bool updateFps = m_activeDocument->setProfilePath(profile);
1665 KdenliveSettings::setCurrent_profile(profile);
1666 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1667 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1669 m_activeDocument->clipManager()->clearUnusedProducers();
1670 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1672 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
1673 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
1674 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1675 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1676 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1677 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
1678 if (updateFps) m_activeTimeline->updateProjectFps();
1679 m_activeDocument->setModified(true);
1680 m_commandStack->activeStack()->clear();
1681 // We need to desactivate & reactivate monitors to get a refresh
1682 //m_monitorManager->switchMonitors();
1689 void MainWindow::slotRenderProject()
1691 if (!m_renderWidget) {
1692 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
1693 m_renderWidget = new RenderWidget(projectfolder, this);
1694 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
1695 connect(m_renderWidget, SIGNAL(selectedRenderProfile(const QString &, const QString &, const QString&)), this, SLOT(slotSetDocumentRenderProfile(const QString &, const QString &, const QString&)));
1696 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
1697 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1698 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1699 if (m_activeDocument) {
1700 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1701 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1702 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
1703 m_renderWidget->setRenderProfile(m_activeDocument->getDocumentProperty("renderdestination"), m_activeDocument->getDocumentProperty("renderprofile"), m_activeDocument->getDocumentProperty("renderurl"));
1706 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1707 if (currentTab) m_renderWidget->setTimeline(currentTab);
1708 m_renderWidget->setDocument(m_activeDocument);*/
1709 m_renderWidget->show();
1710 m_renderWidget->showNormal();
1713 void MainWindow::setRenderingProgress(const QString &url, int progress)
1715 if (m_renderWidget) m_renderWidget->setRenderJob(url, progress);
1718 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
1720 if (m_renderWidget) m_renderWidget->setRenderStatus(url, status, error);
1723 void MainWindow::slotCleanProject()
1725 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
1726 m_projectList->cleanup();
1729 void MainWindow::slotUpdateMousePosition(int pos)
1731 if (m_activeDocument)
1732 switch (m_timecodeFormat->currentIndex()) {
1734 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1737 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1741 void MainWindow::slotUpdateDocumentState(bool modified)
1743 if (!m_activeDocument) return;
1744 setCaption(m_activeDocument->description(), modified);
1745 m_saveAction->setEnabled(modified);
1747 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1748 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1750 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1751 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1755 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
1757 if (m_activeDocument) {
1758 if (m_activeDocument == doc) return;
1759 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1761 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1764 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
1766 //m_projectMonitor->stop();
1767 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1768 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1769 if (m_activeDocument) {
1770 if (m_activeDocument == doc) return;
1771 if (m_activeTimeline) {
1772 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1773 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1774 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1775 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1776 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
1778 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1779 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1780 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1781 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1782 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1783 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1784 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1785 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1786 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1787 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
1788 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1789 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1790 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1791 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1792 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1793 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1794 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1795 disconnect(m_activeTimeline, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1796 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1797 disconnect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1798 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1799 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1800 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1801 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1802 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1803 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1804 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
1805 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1806 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1807 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
1808 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
1809 m_effectStack->clear();
1811 //m_activeDocument->setRenderer(NULL);
1812 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1813 disconnect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
1814 m_clipMonitor->stop();
1816 KdenliveSettings::setCurrent_profile(doc->profilePath());
1817 KdenliveSettings::setProject_fps(doc->fps());
1818 m_monitorManager->resetProfiles(doc->timecode());
1819 m_projectList->setDocument(doc);
1820 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
1821 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
1822 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1823 connect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
1824 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1825 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
1828 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1829 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1830 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1831 connect(trackView, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1832 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
1833 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1834 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1835 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1836 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1837 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
1839 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1840 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1841 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1842 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1843 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1845 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1846 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1847 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1850 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1851 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
1853 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1854 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
1855 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1856 m_zoomSlider->setValue(doc->zoom().x());
1857 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1858 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1859 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1860 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
1861 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1863 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1866 connect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1867 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1868 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1869 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1870 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1871 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1872 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1873 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1875 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1876 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1877 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
1878 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
1881 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup);
1882 m_activeTimeline = trackView;
1883 if (m_renderWidget) {
1884 m_renderWidget->setProfile(doc->mltProfile());
1885 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
1886 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
1887 m_renderWidget->setRenderProfile(doc->getDocumentProperty("renderdestination"), doc->getDocumentProperty("renderprofile"), doc->getDocumentProperty("renderurl"));
1889 //doc->setRenderer(m_projectMonitor->render);
1890 m_commandStack->setActiveStack(doc->commandStack());
1891 KdenliveSettings::setProject_display_ratio(doc->dar());
1892 //doc->clipManager()->checkAudioThumbs();
1894 //m_overView->setScene(trackView->projectScene());
1895 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1896 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1898 setCaption(doc->description(), doc->isModified());
1899 m_saveAction->setEnabled(doc->isModified());
1900 m_activeDocument = doc;
1901 m_activeTimeline->updateProjectFps();
1902 m_activeDocument->checkProjectClips();
1903 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
1905 // set tool to select tool
1906 m_buttonSelectTool->setChecked(true);
1909 void MainWindow::slotZoneMoved(int start, int end)
1911 m_activeDocument->setZone(start, end);
1912 m_projectMonitor->slotZoneMoved(start, end);
1915 void MainWindow::slotGuidesUpdated()
1917 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1920 void MainWindow::slotPreferences(int page, int option)
1922 //An instance of your dialog could be already created and could be
1923 // cached, in which case you want to display the cached dialog
1924 // instead of creating another one
1925 if (KConfigDialog::showDialog("settings")) {
1926 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1927 if (page != -1) d->showPage(page, option);
1931 // KConfigDialog didn't find an instance of this dialog, so lets
1933 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1934 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1935 //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
1936 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1937 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1939 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
1941 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1943 if (page != -1) dialog->showPage(page, option);
1946 void MainWindow::slotUpdatePreviewSettings()
1948 if (m_activeDocument) {
1949 m_clipMonitor->slotSetXml(NULL, 0);
1950 m_activeDocument->updatePreviewSettings();
1954 void MainWindow::updateConfiguration()
1956 //TODO: we should apply settings to all projects, not only the current one
1957 if (m_activeTimeline) {
1958 m_activeTimeline->refresh();
1959 m_activeTimeline->projectView()->checkAutoScroll();
1960 m_activeTimeline->projectView()->checkTrackHeight();
1961 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1963 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1964 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1966 // Update list of transcoding profiles
1968 #ifndef NO_JOGSHUTTLE
1969 activateShuttleDevice();
1970 #endif /* NO_JOGSHUTTLE */
1975 void MainWindow::slotSwitchVideoThumbs()
1977 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1978 if (m_activeTimeline) {
1979 m_activeTimeline->projectView()->slotUpdateAllThumbs();
1981 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1984 void MainWindow::slotSwitchAudioThumbs()
1986 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
1987 if (m_activeTimeline) {
1988 m_activeTimeline->refresh();
1989 m_activeTimeline->projectView()->checkAutoScroll();
1990 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1992 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1995 void MainWindow::slotSwitchMarkersComments()
1997 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1998 if (m_activeTimeline) {
1999 m_activeTimeline->refresh();
2001 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2004 void MainWindow::slotSwitchSnap()
2006 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2007 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2011 void MainWindow::slotDeleteTimelineClip()
2013 if (QApplication::focusWidget() && QApplication::focusWidget()->parentWidget() && QApplication::focusWidget()->parentWidget()->parentWidget() && QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) m_projectList->slotRemoveClip();
2014 else if (m_activeTimeline) {
2015 m_activeTimeline->projectView()->deleteSelectedClips();
2019 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2021 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2022 m_clipMonitor->updateMarkers(clip);
2025 void MainWindow::slotAddClipMarker()
2027 DocClipBase *clip = NULL;
2029 if (m_projectMonitor->isActive()) {
2030 if (m_activeTimeline) {
2031 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2033 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2034 clip = item->baseClip();
2038 clip = m_clipMonitor->activeClip();
2039 pos = m_clipMonitor->position();
2042 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2045 QString id = clip->getId();
2046 CommentedTime marker(pos, i18n("Marker"));
2047 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2048 if (d.exec() == QDialog::Accepted) {
2049 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2053 void MainWindow::slotDeleteClipMarker()
2055 DocClipBase *clip = NULL;
2057 if (m_projectMonitor->isActive()) {
2058 if (m_activeTimeline) {
2059 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2061 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2062 clip = item->baseClip();
2066 clip = m_clipMonitor->activeClip();
2067 pos = m_clipMonitor->position();
2070 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2074 QString id = clip->getId();
2075 QString comment = clip->markerComment(pos);
2076 if (comment.isEmpty()) {
2077 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2080 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2083 void MainWindow::slotDeleteAllClipMarkers()
2085 DocClipBase *clip = NULL;
2086 if (m_projectMonitor->isActive()) {
2087 if (m_activeTimeline) {
2088 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2090 clip = item->baseClip();
2094 clip = m_clipMonitor->activeClip();
2097 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2100 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2103 void MainWindow::slotEditClipMarker()
2105 DocClipBase *clip = NULL;
2107 if (m_projectMonitor->isActive()) {
2108 if (m_activeTimeline) {
2109 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2111 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2112 clip = item->baseClip();
2116 clip = m_clipMonitor->activeClip();
2117 pos = m_clipMonitor->position();
2120 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2124 QString id = clip->getId();
2125 QString oldcomment = clip->markerComment(pos);
2126 if (oldcomment.isEmpty()) {
2127 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2131 CommentedTime marker(pos, oldcomment);
2132 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2133 if (d.exec() == QDialog::Accepted) {
2134 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2135 if (d.newMarker().time() != pos) {
2136 // remove old marker
2137 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2142 void MainWindow::slotAddGuide()
2144 if (m_activeTimeline)
2145 m_activeTimeline->projectView()->slotAddGuide();
2148 void MainWindow::slotInsertSpace()
2150 if (m_activeTimeline)
2151 m_activeTimeline->projectView()->slotInsertSpace();
2154 void MainWindow::slotRemoveSpace()
2156 if (m_activeTimeline)
2157 m_activeTimeline->projectView()->slotRemoveSpace();
2160 void MainWindow::slotInsertTrack(int ix)
2162 m_projectMonitor->activateMonitor();
2163 if (m_activeTimeline)
2164 m_activeTimeline->projectView()->slotInsertTrack(ix);
2167 void MainWindow::slotDeleteTrack(int ix)
2169 m_projectMonitor->activateMonitor();
2170 if (m_activeTimeline)
2171 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2174 void MainWindow::slotChangeTrack(int ix)
2176 m_projectMonitor->activateMonitor();
2177 if (m_activeTimeline)
2178 m_activeTimeline->projectView()->slotChangeTrack(ix);
2181 void MainWindow::slotEditGuide()
2183 if (m_activeTimeline)
2184 m_activeTimeline->projectView()->slotEditGuide();
2187 void MainWindow::slotDeleteGuide()
2189 if (m_activeTimeline)
2190 m_activeTimeline->projectView()->slotDeleteGuide();
2193 void MainWindow::slotDeleteAllGuides()
2195 if (m_activeTimeline)
2196 m_activeTimeline->projectView()->slotDeleteAllGuides();
2199 void MainWindow::slotCutTimelineClip()
2201 if (m_activeTimeline) {
2202 m_activeTimeline->projectView()->cutSelectedClips();
2206 void MainWindow::slotGroupClips()
2208 if (m_activeTimeline) {
2209 m_activeTimeline->projectView()->groupClips();
2213 void MainWindow::slotUnGroupClips()
2215 if (m_activeTimeline) {
2216 m_activeTimeline->projectView()->groupClips(false);
2220 void MainWindow::slotAddProjectClip(KUrl url)
2222 if (m_activeDocument)
2223 m_activeDocument->slotAddClipFile(url, QString());
2226 void MainWindow::slotAddTransition(QAction *result)
2228 if (!result) return;
2229 QStringList info = result->data().toStringList();
2230 if (info.isEmpty()) return;
2231 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2232 if (m_activeTimeline && !transition.isNull()) {
2233 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2237 void MainWindow::slotAddVideoEffect(QAction *result)
2239 if (!result) return;
2240 QStringList info = result->data().toStringList();
2241 if (info.isEmpty()) return;
2242 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2243 slotAddEffect(effect);
2246 void MainWindow::slotAddAudioEffect(QAction *result)
2248 if (!result) return;
2249 QStringList info = result->data().toStringList();
2250 if (info.isEmpty()) return;
2251 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2252 slotAddEffect(effect);
2255 void MainWindow::slotAddCustomEffect(QAction *result)
2257 if (!result) return;
2258 QStringList info = result->data().toStringList();
2259 if (info.isEmpty()) return;
2260 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2261 slotAddEffect(effect);
2264 void MainWindow::slotZoomIn()
2266 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2269 void MainWindow::slotZoomOut()
2271 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2274 void MainWindow::slotFitZoom()
2276 if (m_activeTimeline) {
2277 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2281 void MainWindow::slotSetZoom(int value)
2283 m_zoomSlider->setValue(value);
2286 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2288 m_statusProgressBar->setValue(progress);
2289 if (progress >= 0) {
2290 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2291 m_statusProgressBar->setVisible(true);
2293 m_messageLabel->setMessage(QString(), DefaultMessage);
2294 m_statusProgressBar->setVisible(false);
2298 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2300 if (clip->clipType() == TEXT) {
2301 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
2302 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
2303 // template text clip
2305 // Get the list of existing templates
2307 filter << "*.kdenlivetitle";
2308 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
2310 QDialog *dia = new QDialog(this);
2311 Ui::TemplateClip_UI dia_ui;
2312 dia_ui.setupUi(dia);
2314 const QString templatePath = clip->getProperty("resource");
2315 for (int i = 0; i < templateFiles.size(); ++i) {
2316 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
2317 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
2319 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
2320 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
2321 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
2322 //warning: setting base directory doesn't work??
2323 KUrl startDir(titlepath);
2324 dia_ui.template_list->fileDialog()->setUrl(startDir);
2325 dia_ui.description->setText(clip->getProperty("description"));
2326 if (dia->exec() == QDialog::Accepted) {
2327 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
2328 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
2330 QMap <QString, QString> newprops;
2332 if (KUrl(textTemplate).path() != templatePath) {
2333 // The template was changed
2334 newprops.insert("resource", textTemplate);
2337 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
2338 newprops.insert("description", dia_ui.description->toPlainText());
2341 QString newtemplate = newprops.value("xmltemplate");
2342 if (newtemplate.isEmpty()) newtemplate = templatePath;
2344 // template modified we need to update xmldata
2345 QString description = newprops.value("description");
2346 if (description.isEmpty()) description = clip->getProperty("description");
2347 else newprops.insert("templatetext", description);
2348 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
2350 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2351 m_activeDocument->commandStack()->push(command);
2355 QString path = clip->getProperty("resource");
2356 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
2358 doc.setContent(clip->getProperty("xmldata"));
2359 dia_ui->setXml(doc);
2360 if (dia_ui->exec() == QDialog::Accepted) {
2361 QMap <QString, QString> newprops;
2362 newprops.insert("xmldata", dia_ui->xml().toString());
2363 if (dia_ui->duration() != clip->duration().frames(m_activeDocument->fps()) - 1) {
2364 // duration changed, we need to update duration
2365 newprops.insert("out", QString::number(dia_ui->duration()));
2367 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2368 m_activeDocument->commandStack()->push(command);
2369 m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
2370 m_activeDocument->setModified(true);
2374 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2377 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2378 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2379 if (dia.exec() == QDialog::Accepted) {
2380 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true);
2381 m_activeDocument->commandStack()->push(command);
2383 if (dia.needsTimelineRefresh()) {
2384 // update clip occurences in timeline
2385 m_activeTimeline->projectView()->slotUpdateClip(clip->getId(), dia.needsTimelineReload());
2390 void MainWindow::customEvent(QEvent* e)
2392 if (e->type() == QEvent::User) {
2393 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
2396 void MainWindow::slotActivateEffectStackView()
2398 m_effectStack->raiseWindow(m_effectStackDock);
2401 void MainWindow::slotActivateTransitionView(Transition *t)
2403 if (t) m_transitionConfig->raiseWindow(m_transitionConfigDock);
2406 void MainWindow::slotSnapRewind()
2408 if (m_projectMonitor->isActive()) {
2409 if (m_activeTimeline)
2410 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2411 } else m_clipMonitor->slotSeekToPreviousSnap();
2414 void MainWindow::slotSnapForward()
2416 if (m_projectMonitor->isActive()) {
2417 if (m_activeTimeline)
2418 m_activeTimeline->projectView()->slotSeekToNextSnap();
2419 } else m_clipMonitor->slotSeekToNextSnap();
2422 void MainWindow::slotClipStart()
2424 if (m_projectMonitor->isActive()) {
2425 if (m_activeTimeline)
2426 m_activeTimeline->projectView()->clipStart();
2430 void MainWindow::slotClipEnd()
2432 if (m_projectMonitor->isActive()) {
2433 if (m_activeTimeline)
2434 m_activeTimeline->projectView()->clipEnd();
2438 void MainWindow::slotChangeTool(QAction * action)
2440 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
2441 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
2442 else if (action == m_buttonSpacerTool) slotSetTool(SPACERTOOL);
2445 void MainWindow::slotSetTool(PROJECTTOOL tool)
2447 if (m_activeDocument && m_activeTimeline) {
2448 //m_activeDocument->setTool(tool);
2452 message = i18n("Ctrl + click to use spacer on current track only");
2455 message = i18n("Click on a clip to cut it");
2458 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
2461 m_messageLabel->setMessage(message, InformationMessage);
2462 m_activeTimeline->projectView()->setTool(tool);
2466 void MainWindow::slotCopy()
2468 if (!m_activeDocument || !m_activeTimeline) return;
2469 m_activeTimeline->projectView()->copyClip();
2472 void MainWindow::slotPaste()
2474 if (!m_activeDocument || !m_activeTimeline) return;
2475 m_activeTimeline->projectView()->pasteClip();
2478 void MainWindow::slotPasteEffects()
2480 if (!m_activeDocument || !m_activeTimeline) return;
2481 m_activeTimeline->projectView()->pasteClipEffects();
2484 void MainWindow::slotFind()
2486 if (!m_activeDocument || !m_activeTimeline) return;
2487 m_projectSearch->setEnabled(false);
2488 m_findActivated = true;
2489 m_findString.clear();
2490 m_activeTimeline->projectView()->initSearchStrings();
2491 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2492 m_findTimer.start(5000);
2493 qApp->installEventFilter(this);
2496 void MainWindow::slotFindNext()
2498 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
2499 statusBar()->showMessage(i18n("Found: %1", m_findString));
2501 statusBar()->showMessage(i18n("Reached end of project"));
2503 m_findTimer.start(4000);
2506 void MainWindow::findAhead()
2508 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
2509 m_projectSearchNext->setEnabled(true);
2510 statusBar()->showMessage(i18n("Found: %1", m_findString));
2512 m_projectSearchNext->setEnabled(false);
2513 statusBar()->showMessage(i18n("Not found: %1", m_findString));
2517 void MainWindow::findTimeout()
2519 m_projectSearchNext->setEnabled(false);
2520 m_findActivated = false;
2521 m_findString.clear();
2522 statusBar()->showMessage(i18n("Find stopped"), 3000);
2523 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
2524 m_projectSearch->setEnabled(true);
2525 removeEventFilter(this);
2528 void MainWindow::keyPressEvent(QKeyEvent *ke)
2530 if (m_findActivated) {
2531 if (ke->key() == Qt::Key_Backspace) {
2532 m_findString = m_findString.left(m_findString.length() - 1);
2534 if (!m_findString.isEmpty()) {
2540 m_findTimer.start(4000);
2543 } else if (ke->key() == Qt::Key_Escape) {
2547 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
2548 m_findString += ke->text();
2552 m_findTimer.start(4000);
2556 } else KXmlGuiWindow::keyPressEvent(ke);
2560 /** Gets called when the window gets hidden */
2561 void MainWindow::hideEvent(QHideEvent */*event*/)
2563 // kDebug() << "I was hidden";
2564 // issue http://www.kdenlive.org/mantis/view.php?id=231
2565 if (isMinimized()) {
2566 // kDebug() << "I am minimized";
2567 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
2571 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
2573 if (m_findActivated) {
2574 if (event->type() == QEvent::ShortcutOverride) {
2575 QKeyEvent* ke = (QKeyEvent*) event;
2576 if (ke->text().trimmed().isEmpty()) return false;
2579 } else return false;
2581 // pass the event on to the parent class
2582 return QMainWindow::eventFilter(obj, event);
2587 void MainWindow::slotSaveZone(Render *render, QPoint zone)
2589 KDialog *dialog = new KDialog(this);
2590 dialog->setCaption("Save clip zone");
2591 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
2593 QWidget *widget = new QWidget(dialog);
2594 dialog->setMainWidget(widget);
2596 QVBoxLayout *vbox = new QVBoxLayout(widget);
2597 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
2598 QString path = m_activeDocument->projectFolder().path();
2600 path.append("untitled.mlt");
2601 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
2602 url->setFilter("video/mlt-playlist");
2603 QLabel *label2 = new QLabel(i18n("Description:"), this);
2604 KLineEdit *edit = new KLineEdit(this);
2605 vbox->addWidget(label1);
2606 vbox->addWidget(url);
2607 vbox->addWidget(label2);
2608 vbox->addWidget(edit);
2609 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
2613 void MainWindow::slotSetInPoint()
2615 if (m_clipMonitor->isActive()) {
2616 m_clipMonitor->slotSetZoneStart();
2617 } else m_activeTimeline->projectView()->setInPoint();
2620 void MainWindow::slotSetOutPoint()
2622 if (m_clipMonitor->isActive()) {
2623 m_clipMonitor->slotSetZoneEnd();
2624 } else m_activeTimeline->projectView()->setOutPoint();
2627 void MainWindow::slotGetNewLumaStuff()
2629 //KNS::Entry::List download();
2630 KNS::Entry::List entries = KNS::Engine::download();
2631 // list of changed entries
2632 kDebug() << "// PARSING KNS";
2633 foreach(KNS::Entry* entry, entries) {
2634 // care only about installed ones
2635 if (entry->status() == KNS::Entry::Installed) {
2636 foreach(const QString &file, entry->installedFiles()) {
2637 kDebug() << "// CURRENTLY INSTALLED: " << file;
2641 qDeleteAll(entries);
2642 initEffects::refreshLumas();
2643 m_activeTimeline->projectView()->reloadTransitionLumas();
2646 void MainWindow::slotGetNewRenderStuff()
2648 //KNS::Entry::List download();
2650 KNS::Engine engine(0);
2651 if (engine.init("kdenlive_render.knsrc")) {
2652 KNS::Entry::List entries = engine.downloadDialogModal(this);
2654 if (entries.size() > 0) {
2655 foreach(KNS::Entry* entry, entries) {
2656 // care only about installed ones
2657 if (entry->status() == KNS::Entry::Installed) {
2658 foreach(const QString &file, entry->installedFiles()) {
2659 kDebug() << "// CURRENTLY INSTALLED: " << file;
2664 if (m_renderWidget) m_renderWidget->reloadProfiles();
2668 void MainWindow::slotGetNewMltProfileStuff()
2670 //KNS::Entry::List download();
2672 KNS::Engine engine(0);
2673 if (engine.init("kdenlive_mltprofiles.knsrc")) {
2674 KNS::Entry::List entries = engine.downloadDialogModal(this);
2676 if (entries.size() > 0) {
2677 foreach(KNS::Entry* entry, entries) {
2678 // care only about installed ones
2679 if (entry->status() == KNS::Entry::Installed) {
2680 foreach(const QString &file, entry->installedFiles()) {
2681 kDebug() << "// CURRENTLY INSTALLED: " << file;
2686 // update the list of profiles in settings dialog
2687 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2688 if (d) d->checkProfile();
2693 void MainWindow::slotAutoTransition()
2695 if (m_activeTimeline) m_activeTimeline->projectView()->autoTransition();
2698 void MainWindow::slotSplitAudio()
2700 if (m_activeTimeline) m_activeTimeline->projectView()->splitAudio();
2703 void MainWindow::slotUpdateClipType(QAction *action)
2705 if (m_activeTimeline) {
2706 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
2707 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
2708 else m_activeTimeline->projectView()->setAudioAndVideo();
2712 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
2714 // We must stop the monitors since we create a new on in the dvd wizard
2715 m_clipMonitor->stop();
2716 m_projectMonitor->stop();
2717 DvdWizard w(url, profile, this);
2719 m_projectMonitor->start();
2722 void MainWindow::slotShowTimeline(bool show)
2724 if (show == false) {
2725 m_timelineState = saveState();
2726 centralWidget()->setHidden(true);
2728 centralWidget()->setHidden(false);
2729 restoreState(m_timelineState);
2733 void MainWindow::slotMaximizeCurrent(bool /*show*/)
2735 //TODO: is there a way to maximize current widget?
2738 m_timelineState = saveState();
2739 QWidget *par = focusWidget()->parentWidget();
2740 while (par->parentWidget() && par->parentWidget() != this) {
2741 par = par->parentWidget();
2743 kDebug() << "CURRENT WIDGET: " << par->objectName();
2746 //centralWidget()->setHidden(false);
2747 //restoreState(m_timelineState);
2751 void MainWindow::loadTranscoders()
2753 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
2756 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
2757 KConfigGroup transConfig(config, "Transcoding");
2759 QMap< QString, QString > profiles = transConfig.entryMap();
2760 QMapIterator<QString, QString> i(profiles);
2761 while (i.hasNext()) {
2763 QAction *a = transMenu->addAction(i.key());
2764 a->setData(i.value());
2765 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
2769 void MainWindow::slotTranscode(KUrl::List urls)
2772 if (urls.isEmpty()) {
2773 urls.append(m_projectList->currentClipUrl());
2774 QAction *action = qobject_cast<QAction *>(sender());
2775 params = action->data().toString();
2777 if (urls.isEmpty()) return;
2778 ClipTranscode *d = new ClipTranscode(urls, params);
2779 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
2781 //QProcess::startDetached("ffmpeg", parameters);
2784 void MainWindow::slotTranscodeClip()
2786 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
2787 if (urls.isEmpty()) return;
2788 slotTranscode(urls);
2791 void MainWindow::slotSetDocumentRenderProfile(const QString &dest, const QString &name, const QString &file)
2793 if (m_activeDocument == NULL) return;
2794 m_activeDocument->setDocumentProperty("renderdestination", dest);
2795 m_activeDocument->setDocumentProperty("renderprofile", name);
2796 m_activeDocument->setDocumentProperty("renderurl", file);
2797 m_activeDocument->setModified(true);
2801 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
2803 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
2805 QString playlistPath;
2808 QString scriptsFolder = m_activeDocument->projectFolder().path() + "/scripts/";
2809 QString path = m_renderWidget->getFreeScriptName();
2810 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
2811 if (!ok || scriptPath.isEmpty()) return;
2812 scriptPath.prepend(scriptsFolder);
2813 QFile f(scriptPath);
2815 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
2818 playlistPath = scriptPath + ".mlt";
2819 m_projectMonitor->saveSceneList(playlistPath);
2821 KTemporaryFile temp;
2822 temp.setAutoRemove(false);
2823 temp.setSuffix(".mlt");
2825 playlistPath = temp.fileName();
2826 m_projectMonitor->saveSceneList(playlistPath);
2829 if (!chapterFile.isEmpty()) {
2832 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
2834 in = m_activeTimeline->inPoint();
2835 out = m_activeTimeline->outPoint();
2838 QDomElement chapters = doc.createElement("chapters");
2839 chapters.setAttribute("fps", m_activeDocument->fps());
2840 doc.appendChild(chapters);
2842 QDomElement guidesxml = m_activeDocument->guidesXml();
2843 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
2844 for (int i = 0; i < nodes.count(); i++) {
2845 QDomElement e = nodes.item(i).toElement();
2847 QString comment = e.attribute("comment");
2848 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
2849 if (time >= in && time < out) {
2850 if (zoneOnly) time = time - in;
2851 QDomElement chapter = doc.createElement("chapter");
2852 chapters.appendChild(chapter);
2853 chapter.setAttribute("title", comment);
2854 chapter.setAttribute("time", time);
2858 if (chapters.childNodes().count() > 0) {
2859 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
2860 // Always insert a guide in pos 0
2861 QDomElement chapter = doc.createElement("chapter");
2862 chapters.insertBefore(chapter, QDomNode());
2863 chapter.setAttribute("title", i18n("Start"));
2864 chapter.setAttribute("time", "0");
2866 // save chapters file
2867 QFile file(chapterFile);
2868 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
2869 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
2871 file.write(doc.toString().toUtf8());
2872 if (file.error() != QFile::NoError) {
2873 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
2880 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath);
2883 void MainWindow::slotUpdateTimecodeFormat(int ix)
2885 KdenliveSettings::setFrametimecode(ix == 1);
2886 m_clipMonitor->updateTimecodeFormat();
2887 m_projectMonitor->updateTimecodeFormat();
2890 void MainWindow::slotRemoveFocus()
2892 statusBar()->setFocus();
2893 statusBar()->clearFocus();
2896 void MainWindow::slotRevert()
2898 if (KMessageBox::warningContinueCancel(this, i18n("This will delete all changes made since you last saved your project. Are you sure you want to continue?"), i18n("Revert to last saved version")) == KMessageBox::Cancel) return;
2899 KUrl url = m_activeDocument->url();
2900 closeCurrentDocument(false);
2901 doOpenFile(url, NULL);
2905 void MainWindow::slotShutdown()
2907 if (m_activeDocument) m_activeDocument->setModified(false);
2909 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
2910 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
2911 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
2912 smserver.call("logout", 1, 2, 2);
2916 void MainWindow::slotUpdateTrackInfo()
2918 if (m_activeDocument)
2919 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2922 void MainWindow::slotChangePalette(QAction *action)
2924 // Load the theme file
2925 QString theme = action->data().toString();
2927 // Make palette for all widgets.
2929 if (theme.isEmpty())
2930 plt = QApplication::desktop()->palette();
2932 KConfig confFile(theme, KConfig::SimpleConfig);
2933 plt = kapp->palette();
2935 const QColor fg(confFile.entryMap().value("TextRegularColor"));
2936 const QColor bg(confFile.entryMap().value("BaseColor"));
2938 bg.getHsv(&h, &s, &v);
2939 v += (v < 128) ? + 50 : -50;
2940 v &= 255; //ensures 0 <= v < 256
2941 const QColor highlight = QColor::fromHsv(h, s, v);
2943 fg.getHsv(&h, &s, &v);
2944 v += (v < 128) ? + 150 : -150;
2945 v &= 255; //ensures 0 <= v < 256
2946 const QColor alternate = QColor::fromHsv(h, s, v);
2948 plt.setColor(QPalette::Active, QPalette::Base, bg);
2949 plt.setColor(QPalette::Active, QPalette::AlternateBase, alternate);
2950 plt.setColor(QPalette::Active, QPalette::Background, bg.dark(115));
2951 plt.setColor(QPalette::Active, QPalette::Foreground, fg);
2952 plt.setColor(QPalette::Active, QPalette::Highlight, highlight);
2953 plt.setColor(QPalette::Active, QPalette::HighlightedText, confFile.entryMap().value("TextSelectedColor"));
2954 plt.setColor(QPalette::Active, QPalette::Dark, Qt::darkGray);
2955 plt.setColor(QPalette::Active, QPalette::Button, bg);
2956 plt.setColor(QPalette::Active, QPalette::ButtonText, fg);
2957 plt.setColor(QPalette::Active, QPalette::Text, fg);
2958 plt.setColor(QPalette::Active, QPalette::Link, confFile.entryMap().value("TextSpecialRegularColor"));
2959 plt.setColor(QPalette::Active, QPalette::LinkVisited, confFile.entryMap().value("TextSpecialSelectedColor"));
2961 plt.setColor(QPalette::Inactive, QPalette::Base, bg);
2962 plt.setColor(QPalette::Inactive, QPalette::AlternateBase, alternate);
2963 plt.setColor(QPalette::Inactive, QPalette::Background, bg.dark(115));
2964 plt.setColor(QPalette::Inactive, QPalette::Foreground, fg);
2965 plt.setColor(QPalette::Inactive, QPalette::Highlight, highlight);
2966 plt.setColor(QPalette::Inactive, QPalette::HighlightedText, confFile.entryMap().value("TextSelectedColor"));
2967 plt.setColor(QPalette::Inactive, QPalette::Dark, Qt::darkGray);
2968 plt.setColor(QPalette::Inactive, QPalette::Button, bg);
2969 plt.setColor(QPalette::Inactive, QPalette::ButtonText, fg);
2970 plt.setColor(QPalette::Inactive, QPalette::Text, fg);
2971 plt.setColor(QPalette::Inactive, QPalette::Link, confFile.entryMap().value("TextSpecialRegularColor"));
2972 plt.setColor(QPalette::Inactive, QPalette::LinkVisited, confFile.entryMap().value("TextSpecialSelectedColor"));
2974 plt.setColor(QPalette::Disabled, QPalette::Base, bg);
2975 plt.setColor(QPalette::Disabled, QPalette::AlternateBase, alternate);
2976 plt.setColor(QPalette::Disabled, QPalette::Background, bg.dark(115));
2977 plt.setColor(QPalette::Disabled, QPalette::Foreground, fg);
2978 plt.setColor(QPalette::Disabled, QPalette::Highlight, highlight);
2979 plt.setColor(QPalette::Disabled, QPalette::HighlightedText, confFile.entryMap().value("TextSelectedColor"));
2980 plt.setColor(QPalette::Disabled, QPalette::Dark, Qt::darkGray);
2981 plt.setColor(QPalette::Disabled, QPalette::Button, bg);
2982 plt.setColor(QPalette::Disabled, QPalette::ButtonText, fg);
2983 plt.setColor(QPalette::Disabled, QPalette::Text, fg);
2984 plt.setColor(QPalette::Disabled, QPalette::Link, confFile.entryMap().value("TextSpecialRegularColor"));
2985 plt.setColor(QPalette::Disabled, QPalette::LinkVisited, confFile.entryMap().value("TextSpecialSelectedColor"));
2988 cg.setColor(QColorGroup::Light, ThemeEngine::instance()->textRegColor());
2989 cg.setColor(QColorGroup::Midlight, ThemeEngine::instance()->textRegColor());
2990 cg.setColor(QColorGroup::Mid, ThemeEngine::instance()->textRegColor());
2991 cg.setColor(QColorGroup::Shadow, ThemeEngine::instance()->textRegColor());
2995 kapp->setPalette(plt);
2999 #include "mainwindow.moc"