1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
21 #include "mainwindow.h"
22 #include "mainwindowadaptor.h"
23 #include "kdenlivesettings.h"
24 #include "kdenlivesettingsdialog.h"
25 #include "initeffects.h"
26 #include "profilesdialog.h"
27 #include "projectsettings.h"
29 #include "clipmanager.h"
30 #include "projectlist.h"
32 #include "recmonitor.h"
33 #include "monitormanager.h"
34 #include "kdenlivedoc.h"
35 #include "trackview.h"
36 #include "customtrackview.h"
37 #include "effectslistview.h"
38 #include "effectstackview.h"
39 #include "transitionsettings.h"
40 #include "renderwidget.h"
43 #include "jogshuttle.h"
44 #endif /* NO_JOGSHUTTLE */
45 #include "clipproperties.h"
47 #include "editclipcommand.h"
48 #include "titlewidget.h"
49 #include "markerdialog.h"
51 #include "interfaces.h"
52 #include "kdenlive-config.h"
53 #include "cliptranscode.h"
54 #include "ui_templateclip_ui.h"
56 #include <KApplication>
60 #include <KActionCollection>
61 #include <KStandardAction>
62 #include <KFileDialog>
63 #include <KMessageBox>
65 #include <KIO/NetAccess>
68 #include <KConfigDialog>
69 #include <KXMLGUIFactory>
71 #include <kstandarddirs.h>
72 #include <KUrlRequesterDialog>
73 #include <KTemporaryFile>
75 #include <KActionMenu>
78 #include <ktogglefullscreenaction.h>
80 #include <KNotification>
81 #include <KNotifyConfigWidget>
82 #include <knewstuff2/engine.h>
83 #include <knewstuff2/ui/knewstuffaction.h>
85 #include <KColorScheme>
87 #include <QTextStream>
91 #include <QInputDialog>
92 #include <QDesktopWidget>
97 static const char version[] = VERSION;
99 static const int ID_TIMELINE_POS = 0;
106 EffectsList MainWindow::videoEffects;
107 EffectsList MainWindow::audioEffects;
108 EffectsList MainWindow::customEffects;
109 EffectsList MainWindow::transitions;
111 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent) :
112 KXmlGuiWindow(parent),
113 m_activeDocument(NULL),
114 m_activeTimeline(NULL),
115 m_renderWidget(NULL),
116 #ifndef NO_JOGSHUTTLE
118 #endif /* NO_JOGSHUTTLE */
119 m_findActivated(false)
122 // Create DBus interface
123 new MainWindowAdaptor(this);
124 QDBusConnection dbus = QDBusConnection::sessionBus();
125 dbus.registerObject("/MainWindow", this);
127 setlocale(LC_NUMERIC, "POSIX");
128 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
129 setFont(KGlobalSettings::toolBarFont());
130 parseProfiles(MltPath);
131 m_commandStack = new QUndoGroup;
132 m_timelineArea = new KTabWidget(this);
133 m_timelineArea->setTabReorderingEnabled(true);
134 m_timelineArea->setTabBarHidden(true);
136 QToolButton *closeTabButton = new QToolButton;
137 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
138 closeTabButton->setIcon(KIcon("tab-close"));
139 closeTabButton->adjustSize();
140 closeTabButton->setToolTip(i18n("Close the current tab"));
141 m_timelineArea->setCornerWidget(closeTabButton);
142 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
144 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
145 m_findTimer.setSingleShot(true);
147 // FIXME: the next call returns a newly allocated object, which leaks
148 initEffects::parseEffectFiles();
149 //initEffects::parseCustomEffectsFile();
151 m_monitorManager = new MonitorManager();
153 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
154 m_projectListDock->setObjectName("project_tree");
155 m_projectList = new ProjectList(this);
156 m_projectListDock->setWidget(m_projectList);
157 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
159 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
160 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
162 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
163 m_effectListDock->setObjectName("effect_list");
164 m_effectList = new EffectsListView();
166 //m_effectList = new KListWidget(this);
167 m_effectListDock->setWidget(m_effectList);
168 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
170 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
171 m_effectStackDock->setObjectName("effect_stack");
172 m_effectStack = new EffectStackView(this);
173 m_effectStackDock->setWidget(m_effectStack);
174 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
176 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
177 m_transitionConfigDock->setObjectName("transition");
178 m_transitionConfig = new TransitionSettings(this);
179 m_transitionConfigDock->setWidget(m_transitionConfig);
180 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
182 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
183 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
185 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
186 m_fileRevert->setEnabled(false);
188 //slotDetectAudioDriver();
190 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
191 m_clipMonitorDock->setObjectName("clip_monitor");
192 m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), this);
193 m_clipMonitorDock->setWidget(m_clipMonitor);
194 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
195 //m_clipMonitor->stop();
197 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
198 m_projectMonitorDock->setObjectName("project_monitor");
199 m_projectMonitor = new Monitor("project", m_monitorManager, QString(), this);
200 m_projectMonitorDock->setWidget(m_projectMonitor);
201 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
204 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
205 m_recMonitorDock->setObjectName("record_monitor");
206 m_recMonitor = new RecMonitor("record", this);
207 m_recMonitorDock->setWidget(m_recMonitor);
208 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
210 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
211 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
214 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
215 m_undoViewDock->setObjectName("undo_history");
216 m_undoView = new QUndoView(this);
217 m_undoView->setCleanIcon(KIcon("edit-clear"));
218 m_undoView->setEmptyLabel(i18n("Clean"));
219 m_undoViewDock->setWidget(m_undoView);
220 m_undoView->setGroup(m_commandStack);
221 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
223 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
224 //overviewDock->setObjectName("project_overview");
225 //m_overView = new CustomTrackView(NULL, NULL, this);
226 //overviewDock->setWidget(m_overView);
227 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
230 //tabifyDockWidget(projectListDock, effectListDock);
231 tabifyDockWidget(m_projectListDock, m_effectStackDock);
232 tabifyDockWidget(m_projectListDock, m_transitionConfigDock);
233 //tabifyDockWidget(projectListDock, undoViewDock);
236 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
238 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
240 setCentralWidget(m_timelineArea);
245 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
246 guiFactory()->addClient(sp);*/
250 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
252 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone);
253 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
254 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)), static_cast<QMenu*>(factory()->container("transcoders", this)));
257 // build themes menus
258 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
259 QActionGroup *themegroup = new QActionGroup(this);
260 themegroup->setExclusive(true);
261 action = new QAction(i18n("Default"), this);
262 action->setCheckable(true);
263 themegroup->addAction(action);
264 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
267 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
269 for (int i = 0; i < schemeFiles.size(); ++i) {
271 const QString filename = schemeFiles.at(i);
272 const QFileInfo info(filename);
275 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
276 QIcon icon = createSchemePreviewIcon(config);
277 KConfigGroup group(config, "General");
278 const QString name = group.readEntry("Name", info.baseName());
279 action = new QAction(name, this);
280 action->setData(filename);
281 action->setIcon(icon);
282 action->setCheckable(true);
283 themegroup->addAction(action);
284 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
292 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
293 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
294 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
297 action = new QAction(fi.fileName(), this);
298 action->setData(*it);
299 action->setCheckable(true);
300 themegroup->addAction(action);
301 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
303 themesMenu->addActions(themegroup->actions());
304 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
306 // build effects menus
307 QMenu *videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
309 QStringList effectInfo;
310 QMap<QString, QStringList> effectsList;
311 for (int ix = 0; ix < videoEffects.count(); ix++) {
312 effectInfo = videoEffects.effectIdInfo(ix);
313 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
316 foreach(const QStringList &value, effectsList) {
317 action = new QAction(value.at(0), this);
318 action->setData(value);
319 videoEffectsMenu->addAction(action);
322 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
326 for (int ix = 0; ix < audioEffects.count(); ix++) {
327 effectInfo = audioEffects.effectIdInfo(ix);
328 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
331 foreach(const QStringList &value, effectsList) {
332 action = new QAction(value.at(0), this);
333 action->setData(value);
334 audioEffectsMenu->addAction(action);
337 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
339 if (customEffects.isEmpty()) m_customEffectsMenu->setEnabled(false);
340 else m_customEffectsMenu->setEnabled(true);
343 for (int ix = 0; ix < customEffects.count(); ix++) {
344 effectInfo = customEffects.effectIdInfo(ix);
345 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
348 foreach(const QStringList &value, effectsList) {
349 action = new QAction(value.at(0), this);
350 action->setData(value);
351 m_customEffectsMenu->addAction(action);
354 QMenu *newEffect = new QMenu(this);
355 newEffect->addMenu(videoEffectsMenu);
356 newEffect->addMenu(audioEffectsMenu);
357 newEffect->addMenu(m_customEffectsMenu);
358 m_effectStack->setMenu(newEffect);
361 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
362 const QList<QAction *> viewActions = createPopupMenu()->actions();
363 viewMenu->insertActions(NULL, viewActions);
365 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
366 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
367 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
369 m_timelineContextMenu = new QMenu(this);
370 m_timelineContextClipMenu = new QMenu(this);
371 m_timelineContextTransitionMenu = new QMenu(this);
374 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
375 QStringList effects = transitions.effectNames();
378 for (int ix = 0; ix < transitions.count(); ix++) {
379 effectInfo = transitions.effectIdInfo(ix);
380 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
382 foreach(const QStringList &value, effectsList) {
383 action = new QAction(value.at(0), this);
384 action->setData(value);
385 transitionsMenu->addAction(action);
387 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
389 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
390 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
391 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
393 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
394 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
395 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
396 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
397 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
398 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
399 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
401 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
402 m_timelineContextClipMenu->addMenu(markersMenu);
403 m_timelineContextClipMenu->addMenu(transitionsMenu);
404 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
405 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
406 //TODO: re-enable custom effects menu when it is implemented
407 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
409 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
410 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
412 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
414 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
415 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
416 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
417 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
418 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
419 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
421 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
422 slotConnectMonitors();
424 // Open or create a file. Command line argument passed in Url has
425 // precedence, then "openlastproject", then just a plain empty file.
426 // If opening Url fails, openlastproject will _not_ be used.
427 if (!Url.isEmpty()) {
428 // delay loading so that the window shows up
430 QTimer::singleShot(500, this, SLOT(openFile()));
431 } else if (KdenliveSettings::openlastproject()) {
432 QTimer::singleShot(500, this, SLOT(openLastFile()));
433 } else { //if (m_timelineArea->count() == 0) {
437 #ifndef NO_JOGSHUTTLE
438 activateShuttleDevice();
439 #endif /* NO_JOGSHUTTLE */
440 m_projectListDock->raise();
443 void MainWindow::queryQuit()
446 if (m_projectMonitor) m_projectMonitor->stop();
447 if (m_clipMonitor) m_clipMonitor->stop();
448 delete m_effectStack;
449 delete m_activeTimeline;
451 // This sometimes causes crash on exit on OS X for some reason.
452 delete m_projectMonitor;
453 delete m_clipMonitor;
455 delete m_activeDocument;
456 delete m_shortcutRemoveFocus;
457 Mlt::Factory::close();
463 bool MainWindow::queryClose()
465 if (m_renderWidget) {
466 int waitingJobs = m_renderWidget->waitingJobsCount();
467 if (waitingJobs > 0) {
468 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")))) {
469 case KMessageBox::Yes :
470 // create script with waiting jobs and start it
471 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
473 case KMessageBox::No :
474 // Don't do anything, jobs will be deleted
482 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
483 if (m_activeDocument && m_activeDocument->isModified()) {
484 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
485 case KMessageBox::Yes :
486 // save document here. If saving fails, return false;
488 case KMessageBox::No :
489 // User does not want to save the changes, clear recovery files
490 m_activeDocument->m_autosave->resize(0);
500 void MainWindow::loadPlugins()
502 foreach(QObject *plugin, QPluginLoader::staticInstances())
503 populateMenus(plugin);
505 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
507 filters << "libkdenlive*";
508 foreach(const QString &folder, directories) {
509 kDebug() << "// PARSING FIOLER: " << folder;
510 QDir pluginsDir(folder);
511 foreach(const QString &fileName, pluginsDir.entryList(filters, QDir::Files)) {
512 kDebug() << "// FOUND PLUGIN: " << fileName << "= " << pluginsDir.absoluteFilePath(fileName);
513 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
514 QObject *plugin = loader.instance();
516 populateMenus(plugin);
517 m_pluginFileNames += fileName;
518 } else kDebug() << "// ERROR LOADING PLUGIN: " << fileName << ", " << loader.errorString();
524 void MainWindow::populateMenus(QObject *plugin)
526 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
527 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
529 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
533 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
534 QMenu *menu, const char *member,
535 QActionGroup *actionGroup)
537 kDebug() << "// ADD to MENU" << texts;
538 foreach(const QString &text, texts) {
539 QAction *action = new QAction(text, plugin);
540 action->setData(text);
541 connect(action, SIGNAL(triggered()), this, member);
542 menu->addAction(action);
545 action->setCheckable(true);
546 actionGroup->addAction(action);
551 void MainWindow::aboutPlugins()
553 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
558 void MainWindow::generateClip()
560 QAction *action = qobject_cast<QAction *>(sender());
561 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
563 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(), QStringList(), QStringList(), 25, 720, 576);
564 if (!clipUrl.isEmpty()) {
565 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
569 void MainWindow::saveProperties(KConfigGroup &config)
571 // save properties here,used by session management
573 KMainWindow::saveProperties(config);
577 void MainWindow::readProperties(const KConfigGroup &config)
579 // read properties here,used by session management
580 KMainWindow::readProperties(config);
581 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
582 openFile(KUrl(Lastproject));
585 void MainWindow::slotReloadEffects()
587 kDebug() << "START RELOAD; COUNR: " << m_customEffectsMenu->actions().count();
588 m_customEffectsMenu->clear();
589 kDebug() << "START RELOAD; CLR: " << m_customEffectsMenu->actions().count();
590 initEffects::parseCustomEffectsFile();
591 const QStringList effects = customEffects.effectNames();
592 kDebug() << "NEW EFFS: " << effects;
594 if (effects.isEmpty()) m_customEffectsMenu->setEnabled(false);
595 else m_customEffectsMenu->setEnabled(true);
597 foreach(const QString &name, effects) {
598 action = new QAction(name, this);
599 action->setData(name);
600 m_customEffectsMenu->addAction(action);
602 m_effectList->reloadEffectList();
605 #ifndef NO_JOGSHUTTLE
606 void MainWindow::activateShuttleDevice()
610 if (KdenliveSettings::enableshuttle() == false) return;
611 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
612 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
613 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
614 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
615 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
616 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
617 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
620 void MainWindow::slotShuttleButton(int code)
624 slotShuttleAction(KdenliveSettings::shuttle1());
627 slotShuttleAction(KdenliveSettings::shuttle2());
630 slotShuttleAction(KdenliveSettings::shuttle3());
633 slotShuttleAction(KdenliveSettings::shuttle4());
636 slotShuttleAction(KdenliveSettings::shuttle5());
641 void MainWindow::slotShuttleAction(int code)
647 m_monitorManager->slotPlay();
650 m_monitorManager->slotPlay();
654 #endif /* NO_JOGSHUTTLE */
656 void MainWindow::configureNotifications()
658 KNotifyConfigWidget::configure(this);
661 void MainWindow::slotFullScreen()
663 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
666 void MainWindow::slotAddEffect(const QDomElement effect, GenTime pos, int track)
668 if (!m_activeDocument) return;
669 if (effect.isNull()) {
670 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
673 QDomElement effectToAdd = effect.cloneNode().toElement();
674 m_activeTimeline->projectView()->slotAddEffect(effectToAdd, pos, track);
677 void MainWindow::slotRaiseMonitor(bool clipMonitor)
679 if (clipMonitor) m_clipMonitorDock->raise();
680 else m_projectMonitorDock->raise();
683 void MainWindow::slotUpdateClip(const QString &id)
685 if (!m_activeDocument) return;
686 m_activeTimeline->projectView()->slotUpdateClip(id);
689 void MainWindow::slotConnectMonitors()
692 m_projectList->setRenderer(m_projectMonitor->render);
693 //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
694 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
695 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, bool)));
696 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
697 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)));
699 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
701 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
703 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
704 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
706 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
707 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
710 void MainWindow::slotAdjustClipMonitor()
712 m_clipMonitorDock->updateGeometry();
713 m_clipMonitorDock->adjustSize();
714 m_clipMonitor->resetSize();
717 void MainWindow::slotAdjustProjectMonitor()
719 m_projectMonitorDock->updateGeometry();
720 m_projectMonitorDock->adjustSize();
721 m_projectMonitor->resetSize();
724 void MainWindow::setupActions()
727 KActionCollection* collection = actionCollection();
728 m_timecodeFormat = new KComboBox(this);
729 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
730 m_timecodeFormat->addItem(i18n("Frames"));
731 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
732 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
734 m_statusProgressBar = new QProgressBar(this);
735 m_statusProgressBar->setMinimum(0);
736 m_statusProgressBar->setMaximum(100);
737 m_statusProgressBar->setMaximumWidth(150);
738 m_statusProgressBar->setVisible(false);
740 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
741 toolbar->setMovable(false);
742 m_toolGroup = new QActionGroup(this);
743 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
744 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;}";
746 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
747 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
748 toolbar->addAction(m_buttonSelectTool);
749 m_buttonSelectTool->setCheckable(true);
750 m_buttonSelectTool->setChecked(true);
752 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
753 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
754 toolbar->addAction(m_buttonRazorTool);
755 m_buttonRazorTool->setCheckable(true);
756 m_buttonRazorTool->setChecked(false);
758 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
759 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
760 toolbar->addAction(m_buttonSpacerTool);
761 m_buttonSpacerTool->setCheckable(true);
762 m_buttonSpacerTool->setChecked(false);
764 m_toolGroup->addAction(m_buttonSelectTool);
765 m_toolGroup->addAction(m_buttonRazorTool);
766 m_toolGroup->addAction(m_buttonSpacerTool);
767 m_toolGroup->setExclusive(true);
768 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
770 QWidget * actionWidget;
771 int max = toolbar->iconSizeDefault() + 2;
772 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
773 actionWidget->setMaximumWidth(max);
774 actionWidget->setMaximumHeight(max - 4);
776 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
777 actionWidget->setMaximumWidth(max);
778 actionWidget->setMaximumHeight(max - 4);
780 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
781 actionWidget->setMaximumWidth(max);
782 actionWidget->setMaximumHeight(max - 4);
784 toolbar->setStyleSheet(style1);
785 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
787 toolbar->addSeparator();
788 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
789 toolbar->addAction(m_buttonFitZoom);
790 m_buttonFitZoom->setCheckable(false);
791 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
793 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
794 actionWidget->setMaximumWidth(max);
795 actionWidget->setMaximumHeight(max - 4);
797 m_zoomSlider = new QSlider(Qt::Horizontal, this);
798 m_zoomSlider->setMaximum(13);
799 m_zoomSlider->setPageStep(1);
801 m_zoomSlider->setMaximumWidth(150);
802 m_zoomSlider->setMinimumWidth(100);
803 toolbar->addWidget(m_zoomSlider);
805 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
806 toolbar->addAction(m_buttonVideoThumbs);
807 m_buttonVideoThumbs->setCheckable(true);
808 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
809 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
811 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
812 toolbar->addAction(m_buttonAudioThumbs);
813 m_buttonAudioThumbs->setCheckable(true);
814 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
815 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
817 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
818 toolbar->addAction(m_buttonShowMarkers);
819 m_buttonShowMarkers->setCheckable(true);
820 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
821 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
823 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
824 toolbar->addAction(m_buttonSnap);
825 m_buttonSnap->setCheckable(true);
826 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
827 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
829 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
830 actionWidget->setMaximumWidth(max);
831 actionWidget->setMaximumHeight(max - 4);
833 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
834 actionWidget->setMaximumWidth(max);
835 actionWidget->setMaximumHeight(max - 4);
837 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
838 actionWidget->setMaximumWidth(max);
839 actionWidget->setMaximumHeight(max - 4);
841 actionWidget = toolbar->widgetForAction(m_buttonSnap);
842 actionWidget->setMaximumWidth(max);
843 actionWidget->setMaximumHeight(max - 4);
845 m_messageLabel = new StatusBarMessageLabel(this);
846 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
848 statusBar()->addWidget(m_messageLabel, 10);
849 statusBar()->addWidget(m_statusProgressBar, 0);
850 statusBar()->addPermanentWidget(toolbar);
851 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
852 statusBar()->addPermanentWidget(m_timecodeFormat);
853 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
855 collection->addAction("select_tool", m_buttonSelectTool);
856 collection->addAction("razor_tool", m_buttonRazorTool);
857 collection->addAction("spacer_tool", m_buttonSpacerTool);
859 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
860 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
861 collection->addAction("show_markers", m_buttonShowMarkers);
862 collection->addAction("snap", m_buttonSnap);
863 collection->addAction("zoom_fit", m_buttonFitZoom);
865 KAction* zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
866 collection->addAction("zoom_in", zoomIn);
867 connect(zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
868 zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
870 KAction* zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
871 collection->addAction("zoom_out", zoomOut);
872 connect(zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
873 zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
875 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
876 collection->addAction("project_find", m_projectSearch);
877 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
878 m_projectSearch->setShortcut(Qt::Key_Slash);
880 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
881 collection->addAction("project_find_next", m_projectSearchNext);
882 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
883 m_projectSearchNext->setShortcut(Qt::Key_F3);
884 m_projectSearchNext->setEnabled(false);
886 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
887 collection->addAction("manage_profiles", profilesAction);
888 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
890 KNS::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
892 KNS::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
894 KNS::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
896 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
897 collection->addAction("run_wizard", wizAction);
898 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
900 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
901 collection->addAction("project_settings", projectAction);
902 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
904 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
905 collection->addAction("project_render", projectRender);
906 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
907 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
909 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
910 collection->addAction("project_clean", projectClean);
911 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
913 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
914 KShortcut playShortcut;
915 playShortcut.setPrimary(Qt::Key_Space);
916 playShortcut.setAlternate(Qt::Key_K);
917 monitorPlay->setShortcut(playShortcut);
918 collection->addAction("monitor_play", monitorPlay);
919 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
921 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
922 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
923 collection->addAction("monitor_play_zone", m_playZone);
924 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
926 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
927 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
928 collection->addAction("monitor_loop_zone", m_loopZone);
929 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
931 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
932 collection->addAction("dvd_wizard", dvdWizard);
933 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
935 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
936 collection->addAction("transcode_clip", transcodeClip);
937 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
939 KAction *markIn = collection->addAction("mark_in");
940 markIn->setText(i18n("Set Zone In"));
941 markIn->setShortcut(Qt::Key_I);
942 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
944 KAction *markOut = collection->addAction("mark_out");
945 markOut->setText(i18n("Set Zone Out"));
946 markOut->setShortcut(Qt::Key_O);
947 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
949 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
950 monitorSeekBackward->setShortcut(Qt::Key_J);
951 collection->addAction("monitor_seek_backward", monitorSeekBackward);
952 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
954 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
955 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
956 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
957 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
959 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
960 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
961 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
962 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
964 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
965 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
966 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
967 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
969 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
970 monitorSeekForward->setShortcut(Qt::Key_L);
971 collection->addAction("monitor_seek_forward", monitorSeekForward);
972 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
974 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
975 clipStart->setShortcut(Qt::Key_Home);
976 collection->addAction("seek_clip_start", clipStart);
977 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
979 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
980 clipEnd->setShortcut(Qt::Key_End);
981 collection->addAction("seek_clip_end", clipEnd);
982 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
984 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
985 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
986 collection->addAction("seek_zone_start", zoneStart);
987 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
989 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
990 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
991 collection->addAction("seek_zone_end", zoneEnd);
992 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
994 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
995 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
996 collection->addAction("seek_start", projectStart);
997 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
999 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1000 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1001 collection->addAction("seek_end", projectEnd);
1002 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1004 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1005 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1006 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1007 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1009 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1010 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1011 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1012 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1014 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1015 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1016 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1017 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1019 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1020 deleteTimelineClip->setShortcut(Qt::Key_Delete);
1021 collection->addAction("delete_timeline_clip", deleteTimelineClip);
1022 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
1024 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1025 collection->addAction("change_clip_speed", editTimelineClipSpeed);
1026 editTimelineClipSpeed->setData("change_speed");
1027 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1029 KAction *stickTransition = collection->addAction("auto_transition");
1030 stickTransition->setData(QString("auto"));
1031 stickTransition->setCheckable(true);
1032 stickTransition->setEnabled(false);
1033 stickTransition->setText(i18n("Automatic Transition"));
1034 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1036 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1037 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1038 collection->addAction("group_clip", groupClip);
1039 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1041 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1042 collection->addAction("ungroup_clip", ungroupClip);
1043 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1044 ungroupClip->setData("ungroup_clip");
1045 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1047 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1048 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1049 collection->addAction("cut_timeline_clip", cutTimelineClip);
1050 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1052 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1053 collection->addAction("add_clip_marker", addClipMarker);
1054 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1056 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1057 collection->addAction("delete_clip_marker", deleteClipMarker);
1058 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1060 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1061 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
1062 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1064 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1065 collection->addAction("edit_clip_marker", editClipMarker);
1066 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1068 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1069 collection->addAction("split_audio", splitAudio);
1070 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1072 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1073 collection->addAction("clip_audio_only", audioOnly);
1074 audioOnly->setData("clip_audio_only");
1075 audioOnly->setCheckable(true);
1077 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1078 collection->addAction("clip_video_only", videoOnly);
1079 videoOnly->setData("clip_video_only");
1080 videoOnly->setCheckable(true);
1082 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1083 collection->addAction("clip_audio_and_video", audioAndVideo);
1084 audioAndVideo->setData("clip_audio_and_video");
1085 audioAndVideo->setCheckable(true);
1087 m_clipTypeGroup = new QActionGroup(this);
1088 m_clipTypeGroup->addAction(audioOnly);
1089 m_clipTypeGroup->addAction(videoOnly);
1090 m_clipTypeGroup->addAction(audioAndVideo);
1091 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1092 m_clipTypeGroup->setEnabled(false);
1094 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1095 collection->addAction("insert_space", insertSpace);
1096 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1098 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1099 collection->addAction("delete_space", removeSpace);
1100 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1102 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1103 collection->addAction("insert_track", insertTrack);
1104 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1106 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1107 collection->addAction("delete_track", deleteTrack);
1108 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1110 KAction *changeTrack = new KAction(KIcon(), i18n("Change Track"), this);
1111 collection->addAction("change_track", changeTrack);
1112 connect(changeTrack, SIGNAL(triggered()), this, SLOT(slotChangeTrack()));
1114 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1115 collection->addAction("add_guide", addGuide);
1116 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1118 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1119 collection->addAction("delete_guide", delGuide);
1120 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1122 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1123 collection->addAction("edit_guide", editGuide);
1124 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1126 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1127 collection->addAction("delete_all_guides", delAllGuides);
1128 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1130 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1131 collection->addAction("paste_effects", pasteEffects);
1132 pasteEffects->setData("paste_effects");
1133 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1135 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1136 collection->addAction("show_timeline", showTimeline);
1137 showTimeline->setCheckable(true);
1138 showTimeline->setChecked(true);
1139 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1141 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1142 collection->addAction("maximize_current", maxCurrent);
1143 maxCurrent->setCheckable(true);
1144 maxCurrent->setChecked(false);
1145 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1148 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1150 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1152 KStandardAction::open(this, SLOT(openFile()), collection);
1154 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1156 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1158 KStandardAction::openNew(this, SLOT(newFile()), collection);
1160 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1162 KStandardAction::configureNotifications(this , SLOT(configureNotifications()), collection);
1164 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1166 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1168 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1169 undo->setEnabled(false);
1170 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1172 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1173 redo->setEnabled(false);
1174 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1176 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1179 //TODO: Add status tooltip to actions ?
1180 connect(collection, SIGNAL(actionHovered(QAction*)),
1181 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1184 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1185 collection->addAction("add_clip", addClip);
1186 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1188 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1189 collection->addAction("add_color_clip", addColorClip);
1190 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1192 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1193 collection->addAction("add_slide_clip", addSlideClip);
1194 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1196 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1197 collection->addAction("add_text_clip", addTitleClip);
1198 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1200 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1201 collection->addAction("add_text_template_clip", addTitleTemplateClip);
1202 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1204 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1205 collection->addAction("add_folder", addFolderButton);
1206 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1208 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1209 collection->addAction("clip_properties", clipProperties);
1210 clipProperties->setData("clip_properties");
1211 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1212 clipProperties->setEnabled(false);
1214 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1215 collection->addAction("edit_clip", openClip);
1216 openClip->setData("edit_clip");
1217 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1218 openClip->setEnabled(false);
1220 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1221 collection->addAction("delete_clip", deleteClip);
1222 deleteClip->setData("delete_clip");
1223 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1224 deleteClip->setEnabled(false);
1226 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1227 collection->addAction("reload_clip", reloadClip);
1228 reloadClip->setData("reload_clip");
1229 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1230 reloadClip->setEnabled(false);
1232 QMenu *addClips = new QMenu();
1233 addClips->addAction(addClip);
1234 addClips->addAction(addColorClip);
1235 addClips->addAction(addSlideClip);
1236 addClips->addAction(addTitleClip);
1237 addClips->addAction(addTitleTemplateClip);
1238 addClips->addAction(addFolderButton);
1240 addClips->addAction(reloadClip);
1241 addClips->addAction(clipProperties);
1242 addClips->addAction(openClip);
1243 addClips->addAction(deleteClip);
1244 m_projectList->setupMenu(addClips, addClip);
1246 //connect(collection, SIGNAL( clearStatusText() ),
1247 //statusBar(), SLOT( clear() ) );
1250 void MainWindow::slotDisplayActionMessage(QAction *a)
1252 statusBar()->showMessage(a->data().toString(), 3000);
1255 void MainWindow::saveOptions()
1257 KdenliveSettings::self()->writeConfig();
1258 KSharedConfigPtr config = KGlobal::config();
1259 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1260 KConfigGroup treecolumns(config, "Project Tree");
1261 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1265 void MainWindow::readOptions()
1267 KSharedConfigPtr config = KGlobal::config();
1268 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1269 KConfigGroup initialGroup(config, "version");
1270 bool upgrade = false;
1271 if (initialGroup.exists()) {
1272 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1276 if (initialGroup.readEntry("version") == "0.7") {
1277 //Add new settings from 0.7.1
1278 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1279 QString path = QDir::homePath() + "/kdenlive";
1280 if (KStandardDirs::makeDir(path) == false) {
1281 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1282 } else KdenliveSettings::setDefaultprojectfolder(path);
1288 if (!initialGroup.exists() || upgrade) {
1289 // this is our first run, show Wizard
1290 Wizard *w = new Wizard(upgrade, this);
1291 if (w->exec() == QDialog::Accepted && w->isOk()) {
1292 w->adjustSettings();
1293 initialGroup.writeEntry("version", version);
1299 KConfigGroup treecolumns(config, "Project Tree");
1300 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1301 if (!state.isEmpty())
1302 m_projectList->setHeaderInfo(state);
1305 void MainWindow::slotRunWizard()
1307 Wizard *w = new Wizard(false, this);
1308 if (w->exec() == QDialog::Accepted && w->isOk()) {
1309 w->adjustSettings();
1314 void MainWindow::newFile(bool showProjectSettings)
1316 if (!m_timelineArea->isEnabled()) return;
1317 m_fileRevert->setEnabled(false);
1318 QString profileName;
1320 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1321 if (!showProjectSettings && m_timelineArea->count() == 0) {
1322 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1323 profileName = KdenliveSettings::default_profile();
1324 projectFolder = KdenliveSettings::defaultprojectfolder();
1326 ProjectSettings *w = new ProjectSettings(NULL, projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1327 if (w->exec() != QDialog::Accepted) return;
1328 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1329 KdenliveSettings::setVideothumbnails(w->enableVideoThumbs());
1330 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1331 KdenliveSettings::setAudiothumbnails(w->enableAudioThumbs());
1332 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1333 profileName = w->selectedProfile();
1334 projectFolder = w->selectedFolder();
1335 projectTracks = w->tracks();
1338 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1339 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1341 TrackView *trackView = new TrackView(doc, &ok, this);
1342 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1345 m_timelineArea->setEnabled(false);
1346 m_projectList->setEnabled(false);
1347 m_monitorManager->slotBlockMonitors();
1351 if (m_timelineArea->count() == 1) {
1352 connectDocumentInfo(doc);
1353 connectDocument(trackView, doc);
1354 } else m_timelineArea->setTabBarHidden(false);
1355 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1358 void MainWindow::activateDocument()
1360 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1361 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1362 KdenliveDoc *currentDoc = currentTab->document();
1363 connectDocumentInfo(currentDoc);
1364 connectDocument(currentTab, currentDoc);
1367 void MainWindow::closeCurrentDocument(bool saveChanges)
1369 QWidget *w = m_timelineArea->currentWidget();
1371 // closing current document
1372 int ix = m_timelineArea->currentIndex() + 1;
1373 if (ix == m_timelineArea->count()) ix = 0;
1374 m_timelineArea->setCurrentIndex(ix);
1375 TrackView *tabToClose = (TrackView *) w;
1376 KdenliveDoc *docToClose = tabToClose->document();
1377 if (docToClose && docToClose->isModified() && saveChanges) {
1378 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
1379 case KMessageBox::Yes :
1380 // save document here. If saving fails, return false;
1381 if (saveFile() == false) return;
1383 case KMessageBox::Cancel :
1390 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1391 if (m_timelineArea->count() == 1) {
1392 m_timelineArea->setTabBarHidden(true);
1393 m_closeAction->setEnabled(false);
1395 if (docToClose == m_activeDocument) {
1396 delete m_activeDocument;
1397 m_activeDocument = NULL;
1398 m_effectStack->clear();
1399 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1400 } else delete docToClose;
1401 if (w == m_activeTimeline) {
1402 delete m_activeTimeline;
1403 m_activeTimeline = NULL;
1407 bool MainWindow::saveFileAs(const QString &outputFileName)
1409 QString currentSceneList;
1410 if (KdenliveSettings::dropbframes()) {
1411 KdenliveSettings::setDropbframes(false);
1412 m_activeDocument->clipManager()->updatePreviewSettings();
1413 currentSceneList = m_projectMonitor->sceneList();
1414 KdenliveSettings::setDropbframes(true);
1415 m_activeDocument->clipManager()->updatePreviewSettings();
1416 } else currentSceneList = m_projectMonitor->sceneList();
1418 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1421 // Save timeline thumbnails
1422 m_activeTimeline->projectView()->saveThumbnails();
1423 m_activeDocument->setUrl(KUrl(outputFileName));
1424 if (m_activeDocument->m_autosave == NULL) {
1425 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1426 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1427 setCaption(m_activeDocument->description());
1428 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1429 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1430 m_activeDocument->setModified(false);
1431 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1432 m_fileRevert->setEnabled(true);
1436 bool MainWindow::saveFileAs()
1438 // Check that the Kdenlive mime type is correctly installed
1439 QString mimetype = "application/x-kdenlive";
1440 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1441 if (!mime) mimetype = "*.kdenlive";
1443 QString outputFile = KFileDialog::getSaveFileName(KUrl(), mimetype);
1444 if (outputFile.isEmpty()) return false;
1445 if (QFile::exists(outputFile)) {
1446 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it?")) == KMessageBox::No) return false;
1448 return saveFileAs(outputFile);
1451 bool MainWindow::saveFile()
1453 if (!m_activeDocument) return true;
1454 if (m_activeDocument->url().isEmpty()) {
1455 return saveFileAs();
1457 bool result = saveFileAs(m_activeDocument->url().path());
1458 m_activeDocument->m_autosave->resize(0);
1463 void MainWindow::openFile()
1465 if (!m_startUrl.isEmpty()) {
1466 openFile(m_startUrl);
1467 m_startUrl = KUrl();
1470 // Check that the Kdenlive mime type is correctly installed
1471 QString mimetype = "application/x-kdenlive";
1472 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1473 if (!mime) mimetype = "*.kdenlive";
1475 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), mimetype);
1476 if (url.isEmpty()) return;
1477 m_fileOpenRecent->addUrl(url);
1481 void MainWindow::openLastFile()
1483 KSharedConfigPtr config = KGlobal::config();
1484 KUrl::List urls = m_fileOpenRecent->urls();
1485 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1486 if (urls.isEmpty()) newFile(false);
1487 else openFile(urls.last());
1490 void MainWindow::openFile(const KUrl &url)
1492 // Check if the document is already opened
1493 const int ct = m_timelineArea->count();
1494 bool isOpened = false;
1496 for (i = 0; i < ct; i++) {
1497 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1498 KdenliveDoc *doc = tab->document();
1499 if (doc->url() == url) {
1505 m_timelineArea->setCurrentIndex(i);
1509 // Check for backup file
1510 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1511 if (!staleFiles.isEmpty()) {
1512 if (KMessageBox::questionYesNo(this,
1513 i18n("Auto-saved files exist. Do you want to recover them now?"),
1514 i18n("File Recovery"),
1515 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1516 recoverFiles(staleFiles);
1519 // remove the stale files
1520 foreach(KAutoSaveFile *stale, staleFiles) {
1521 stale->open(QIODevice::ReadWrite);
1526 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1527 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
1528 qApp->processEvents();
1529 doOpenFile(url, NULL);
1532 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1534 if (!m_timelineArea->isEnabled()) return;
1535 m_fileRevert->setEnabled(true);
1536 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, this);
1537 if (stale == NULL) {
1538 stale = new KAutoSaveFile(url, doc);
1539 doc->m_autosave = stale;
1541 doc->m_autosave = stale;
1542 doc->setUrl(stale->managedFile());
1543 doc->setModified(true);
1544 stale->setParent(doc);
1546 connectDocumentInfo(doc);
1548 TrackView *trackView = new TrackView(doc, &ok, this);
1549 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1551 m_timelineArea->setEnabled(false);
1552 m_projectList->setEnabled(false);
1553 m_monitorManager->slotBlockMonitors();
1557 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1558 trackView->setDuration(trackView->duration());
1559 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1561 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1562 slotGotProgressInfo(QString(), -1);
1563 m_clipMonitor->refreshMonitor(true);
1564 m_projectMonitor->adjustRulerSize(trackView->duration());
1565 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1568 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1570 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1571 foreach(KAutoSaveFile *stale, staleFiles) {
1572 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1573 // show an error message; we could not steal the lockfile
1574 // maybe another application got to the file before us?
1578 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1579 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
1580 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1581 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1586 void MainWindow::parseProfiles(const QString &mltPath)
1588 // kDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
1590 //KdenliveSettings::setDefaulttmpfolder();
1591 if (!mltPath.isEmpty()) {
1592 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1593 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
1596 if (KdenliveSettings::mltpath().isEmpty()) {
1597 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1599 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
1600 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
1601 if (!QFile::exists(meltPath))
1602 meltPath = KStandardDirs::findExe("melt");
1603 KdenliveSettings::setRendererpath(meltPath);
1605 QStringList profilesFilter;
1606 profilesFilter << "*";
1607 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1609 if (profilesList.isEmpty()) {
1610 // Cannot find MLT path, try finding melt
1611 QString profilePath = KdenliveSettings::rendererpath();
1612 if (!profilePath.isEmpty()) {
1613 profilePath = profilePath.section('/', 0, -3);
1614 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1615 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1618 if (profilesList.isEmpty()) {
1619 // Cannot find the MLT profiles, ask for location
1620 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1621 getUrl->fileDialog()->setMode(KFile::Directory);
1622 if (getUrl->exec() == QDialog::Rejected) {
1625 KUrl mltPath = getUrl->selectedUrl();
1627 if (mltPath.isEmpty()) ::exit(0);
1628 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
1629 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1633 if (KdenliveSettings::rendererpath().isEmpty()) {
1634 // Cannot find the MLT melt renderer, ask for location
1635 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of Mlt)"), this);
1636 if (getUrl->exec() == QDialog::Rejected) {
1639 KUrl rendererPath = getUrl->selectedUrl();
1641 if (rendererPath.isEmpty()) ::exit(0);
1642 KdenliveSettings::setRendererpath(rendererPath.path());
1645 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1647 // Parse MLT profiles to build a list of available video formats
1648 if (profilesList.isEmpty()) parseProfiles();
1652 void MainWindow::slotEditProfiles()
1654 ProfilesDialog *w = new ProfilesDialog;
1655 if (w->exec() == QDialog::Accepted) {
1656 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1657 if (d) d->checkProfile();
1662 void MainWindow::slotDetectAudioDriver()
1664 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
1665 leading to no audio output, see bug #934 */
1667 //decide which audio driver is really best, in some cases SDL is wrong
1668 if (KdenliveSettings::audiodrivername().isEmpty()) {
1670 KProcess readProcess;
1671 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
1672 if (!KStandardDirs::findExe("pactl").isEmpty()) {
1673 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
1674 readProcess.setProgram("pactl", QStringList() << "stat");
1675 readProcess.execute(2000); // Kill it after 2 seconds
1677 QString result = QString(readProcess.readAllStandardOutput());
1678 kDebug() << "// / / / / / READING PACTL: ";
1680 if (!result.isEmpty()) {
1682 kDebug() << "// / / / / PULSEAUDIO DETECTED";
1686 KdenliveSettings::setAutoaudiodrivername(driver);
1690 void MainWindow::slotEditProjectSettings()
1692 QPoint p = m_activeDocument->getTracksCount();
1693 ProjectSettings *w = new ProjectSettings(m_projectList, p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
1695 if (w->exec() == QDialog::Accepted) {
1696 QString profile = w->selectedProfile();
1697 m_activeDocument->setProjectFolder(w->selectedFolder());
1698 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path(KUrl::AddTrailingSlash));
1699 if (m_activeDocument->profilePath() != profile) {
1700 // Profile was changed
1701 double dar = m_activeDocument->dar();
1703 // Deselect current effect / transition
1704 m_effectStack->slotClipItemSelected(NULL, 0);
1705 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1706 m_clipMonitor->slotSetXml(NULL, 0);
1707 bool updateFps = m_activeDocument->setProfilePath(profile);
1708 KdenliveSettings::setCurrent_profile(profile);
1709 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1710 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1712 m_activeDocument->clipManager()->clearUnusedProducers();
1713 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1715 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
1716 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
1717 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1718 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1719 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1720 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
1721 if (updateFps) m_activeTimeline->updateProjectFps();
1722 m_activeDocument->setModified(true);
1723 m_commandStack->activeStack()->clear();
1724 // We need to desactivate & reactivate monitors to get a refresh
1725 //m_monitorManager->switchMonitors();
1732 void MainWindow::slotRenderProject()
1734 if (!m_renderWidget) {
1735 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
1736 m_renderWidget = new RenderWidget(projectfolder, this);
1737 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
1738 connect(m_renderWidget, SIGNAL(selectedRenderProfile(const QString &, const QString &, const QString&)), this, SLOT(slotSetDocumentRenderProfile(const QString &, const QString &, const QString&)));
1739 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
1740 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1741 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1742 if (m_activeDocument) {
1743 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1744 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1745 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
1746 m_renderWidget->setRenderProfile(m_activeDocument->getDocumentProperty("renderdestination"), m_activeDocument->getDocumentProperty("renderprofile"), m_activeDocument->getDocumentProperty("renderurl"));
1749 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1750 if (currentTab) m_renderWidget->setTimeline(currentTab);
1751 m_renderWidget->setDocument(m_activeDocument);*/
1752 m_renderWidget->show();
1753 m_renderWidget->showNormal();
1756 void MainWindow::setRenderingProgress(const QString &url, int progress)
1758 if (m_renderWidget) m_renderWidget->setRenderJob(url, progress);
1761 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
1763 if (m_renderWidget) m_renderWidget->setRenderStatus(url, status, error);
1766 void MainWindow::slotCleanProject()
1768 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
1769 m_projectList->cleanup();
1772 void MainWindow::slotUpdateMousePosition(int pos)
1774 if (m_activeDocument)
1775 switch (m_timecodeFormat->currentIndex()) {
1777 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1780 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1784 void MainWindow::slotUpdateDocumentState(bool modified)
1786 if (!m_activeDocument) return;
1787 setCaption(m_activeDocument->description(), modified);
1788 m_saveAction->setEnabled(modified);
1790 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1791 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1793 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1794 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1798 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
1800 if (m_activeDocument) {
1801 if (m_activeDocument == doc) return;
1802 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1804 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1807 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
1809 //m_projectMonitor->stop();
1810 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1811 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1812 if (m_activeDocument) {
1813 if (m_activeDocument == doc) return;
1814 if (m_activeTimeline) {
1815 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1816 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1817 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1818 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1819 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
1821 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1822 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1823 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1824 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1825 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1826 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1827 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1828 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1829 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1830 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
1831 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1832 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1833 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1834 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1835 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1836 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1837 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1838 disconnect(m_activeTimeline, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1839 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1840 disconnect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1841 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1842 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1843 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1844 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1845 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1846 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1847 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
1848 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1849 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1850 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
1851 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
1852 m_effectStack->clear();
1854 //m_activeDocument->setRenderer(NULL);
1855 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1856 disconnect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
1857 m_clipMonitor->stop();
1859 KdenliveSettings::setCurrent_profile(doc->profilePath());
1860 KdenliveSettings::setProject_fps(doc->fps());
1861 m_monitorManager->resetProfiles(doc->timecode());
1862 m_projectList->setDocument(doc);
1863 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
1864 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
1865 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1866 connect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
1867 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1868 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
1871 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1872 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1873 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1874 connect(trackView, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1875 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
1876 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1877 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1878 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1879 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1880 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
1882 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1883 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1884 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1885 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1886 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1888 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1889 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1890 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1893 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1894 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
1896 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1897 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
1898 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1899 m_zoomSlider->setValue(doc->zoom().x());
1900 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1901 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1902 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1903 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
1904 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1906 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1909 connect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1910 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1911 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1912 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1913 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1914 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1915 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1916 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1918 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1919 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1920 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
1921 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
1924 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup);
1925 m_activeTimeline = trackView;
1926 if (m_renderWidget) {
1927 m_renderWidget->setProfile(doc->mltProfile());
1928 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
1929 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
1930 m_renderWidget->setRenderProfile(doc->getDocumentProperty("renderdestination"), doc->getDocumentProperty("renderprofile"), doc->getDocumentProperty("renderurl"));
1932 //doc->setRenderer(m_projectMonitor->render);
1933 m_commandStack->setActiveStack(doc->commandStack());
1934 KdenliveSettings::setProject_display_ratio(doc->dar());
1935 //doc->clipManager()->checkAudioThumbs();
1937 //m_overView->setScene(trackView->projectScene());
1938 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1939 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1941 setCaption(doc->description(), doc->isModified());
1942 m_saveAction->setEnabled(doc->isModified());
1943 m_activeDocument = doc;
1944 m_activeTimeline->updateProjectFps();
1945 m_activeDocument->checkProjectClips();
1946 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
1948 // set tool to select tool
1949 m_buttonSelectTool->setChecked(true);
1952 void MainWindow::slotZoneMoved(int start, int end)
1954 m_activeDocument->setZone(start, end);
1955 m_projectMonitor->slotZoneMoved(start, end);
1958 void MainWindow::slotGuidesUpdated()
1960 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1963 void MainWindow::slotPreferences(int page, int option)
1965 //An instance of your dialog could be already created and could be
1966 // cached, in which case you want to display the cached dialog
1967 // instead of creating another one
1968 if (KConfigDialog::showDialog("settings")) {
1969 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1970 if (page != -1) d->showPage(page, option);
1974 // KConfigDialog didn't find an instance of this dialog, so lets
1976 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1977 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1978 //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
1979 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1980 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1982 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
1984 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1986 if (page != -1) dialog->showPage(page, option);
1989 void MainWindow::slotUpdatePreviewSettings()
1991 if (m_activeDocument) {
1992 m_clipMonitor->slotSetXml(NULL, 0);
1993 m_activeDocument->updatePreviewSettings();
1997 void MainWindow::updateConfiguration()
1999 //TODO: we should apply settings to all projects, not only the current one
2000 if (m_activeTimeline) {
2001 m_activeTimeline->refresh();
2002 m_activeTimeline->projectView()->checkAutoScroll();
2003 m_activeTimeline->projectView()->checkTrackHeight();
2004 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
2006 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2007 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2009 // Update list of transcoding profiles
2011 #ifndef NO_JOGSHUTTLE
2012 activateShuttleDevice();
2013 #endif /* NO_JOGSHUTTLE */
2018 void MainWindow::slotSwitchVideoThumbs()
2020 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2021 if (m_activeTimeline) {
2022 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2024 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2027 void MainWindow::slotSwitchAudioThumbs()
2029 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2030 if (m_activeTimeline) {
2031 m_activeTimeline->refresh();
2032 m_activeTimeline->projectView()->checkAutoScroll();
2033 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
2035 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2038 void MainWindow::slotSwitchMarkersComments()
2040 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2041 if (m_activeTimeline) {
2042 m_activeTimeline->refresh();
2044 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2047 void MainWindow::slotSwitchSnap()
2049 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2050 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2054 void MainWindow::slotDeleteTimelineClip()
2056 if (QApplication::focusWidget() && QApplication::focusWidget()->parentWidget() && QApplication::focusWidget()->parentWidget()->parentWidget() && QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) m_projectList->slotRemoveClip();
2057 else if (m_activeTimeline) {
2058 m_activeTimeline->projectView()->deleteSelectedClips();
2062 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2064 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2065 m_clipMonitor->updateMarkers(clip);
2068 void MainWindow::slotAddClipMarker()
2070 DocClipBase *clip = NULL;
2072 if (m_projectMonitor->isActive()) {
2073 if (m_activeTimeline) {
2074 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2076 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2077 clip = item->baseClip();
2081 clip = m_clipMonitor->activeClip();
2082 pos = m_clipMonitor->position();
2085 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2088 QString id = clip->getId();
2089 CommentedTime marker(pos, i18n("Marker"));
2090 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2091 if (d.exec() == QDialog::Accepted) {
2092 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2096 void MainWindow::slotDeleteClipMarker()
2098 DocClipBase *clip = NULL;
2100 if (m_projectMonitor->isActive()) {
2101 if (m_activeTimeline) {
2102 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2104 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2105 clip = item->baseClip();
2109 clip = m_clipMonitor->activeClip();
2110 pos = m_clipMonitor->position();
2113 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2117 QString id = clip->getId();
2118 QString comment = clip->markerComment(pos);
2119 if (comment.isEmpty()) {
2120 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2123 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2126 void MainWindow::slotDeleteAllClipMarkers()
2128 DocClipBase *clip = NULL;
2129 if (m_projectMonitor->isActive()) {
2130 if (m_activeTimeline) {
2131 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2133 clip = item->baseClip();
2137 clip = m_clipMonitor->activeClip();
2140 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2143 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2146 void MainWindow::slotEditClipMarker()
2148 DocClipBase *clip = NULL;
2150 if (m_projectMonitor->isActive()) {
2151 if (m_activeTimeline) {
2152 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2154 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2155 clip = item->baseClip();
2159 clip = m_clipMonitor->activeClip();
2160 pos = m_clipMonitor->position();
2163 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2167 QString id = clip->getId();
2168 QString oldcomment = clip->markerComment(pos);
2169 if (oldcomment.isEmpty()) {
2170 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2174 CommentedTime marker(pos, oldcomment);
2175 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2176 if (d.exec() == QDialog::Accepted) {
2177 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2178 if (d.newMarker().time() != pos) {
2179 // remove old marker
2180 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2185 void MainWindow::slotAddGuide()
2187 if (m_activeTimeline)
2188 m_activeTimeline->projectView()->slotAddGuide();
2191 void MainWindow::slotInsertSpace()
2193 if (m_activeTimeline)
2194 m_activeTimeline->projectView()->slotInsertSpace();
2197 void MainWindow::slotRemoveSpace()
2199 if (m_activeTimeline)
2200 m_activeTimeline->projectView()->slotRemoveSpace();
2203 void MainWindow::slotInsertTrack(int ix)
2205 m_projectMonitor->activateMonitor();
2206 if (m_activeTimeline)
2207 m_activeTimeline->projectView()->slotInsertTrack(ix);
2210 void MainWindow::slotDeleteTrack(int ix)
2212 m_projectMonitor->activateMonitor();
2213 if (m_activeTimeline)
2214 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2217 void MainWindow::slotChangeTrack(int ix)
2219 m_projectMonitor->activateMonitor();
2220 if (m_activeTimeline)
2221 m_activeTimeline->projectView()->slotChangeTrack(ix);
2224 void MainWindow::slotEditGuide()
2226 if (m_activeTimeline)
2227 m_activeTimeline->projectView()->slotEditGuide();
2230 void MainWindow::slotDeleteGuide()
2232 if (m_activeTimeline)
2233 m_activeTimeline->projectView()->slotDeleteGuide();
2236 void MainWindow::slotDeleteAllGuides()
2238 if (m_activeTimeline)
2239 m_activeTimeline->projectView()->slotDeleteAllGuides();
2242 void MainWindow::slotCutTimelineClip()
2244 if (m_activeTimeline) {
2245 m_activeTimeline->projectView()->cutSelectedClips();
2249 void MainWindow::slotGroupClips()
2251 if (m_activeTimeline) {
2252 m_activeTimeline->projectView()->groupClips();
2256 void MainWindow::slotUnGroupClips()
2258 if (m_activeTimeline) {
2259 m_activeTimeline->projectView()->groupClips(false);
2263 void MainWindow::slotAddProjectClip(KUrl url)
2265 if (m_activeDocument)
2266 m_activeDocument->slotAddClipFile(url, QString());
2269 void MainWindow::slotAddTransition(QAction *result)
2271 if (!result) return;
2272 QStringList info = result->data().toStringList();
2273 if (info.isEmpty()) return;
2274 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2275 if (m_activeTimeline && !transition.isNull()) {
2276 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2280 void MainWindow::slotAddVideoEffect(QAction *result)
2282 if (!result) return;
2283 QStringList info = result->data().toStringList();
2284 if (info.isEmpty()) return;
2285 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2286 slotAddEffect(effect);
2289 void MainWindow::slotAddAudioEffect(QAction *result)
2291 if (!result) return;
2292 QStringList info = result->data().toStringList();
2293 if (info.isEmpty()) return;
2294 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2295 slotAddEffect(effect);
2298 void MainWindow::slotAddCustomEffect(QAction *result)
2300 if (!result) return;
2301 QStringList info = result->data().toStringList();
2302 if (info.isEmpty()) return;
2303 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2304 slotAddEffect(effect);
2307 void MainWindow::slotZoomIn()
2309 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2312 void MainWindow::slotZoomOut()
2314 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2317 void MainWindow::slotFitZoom()
2319 if (m_activeTimeline) {
2320 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2324 void MainWindow::slotSetZoom(int value)
2326 m_zoomSlider->setValue(value);
2329 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2331 m_statusProgressBar->setValue(progress);
2332 if (progress >= 0) {
2333 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2334 m_statusProgressBar->setVisible(true);
2336 m_messageLabel->setMessage(QString(), DefaultMessage);
2337 m_statusProgressBar->setVisible(false);
2341 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2343 if (clip->clipType() == TEXT) {
2344 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
2345 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
2346 // template text clip
2348 // Get the list of existing templates
2350 filter << "*.kdenlivetitle";
2351 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
2353 QDialog *dia = new QDialog(this);
2354 Ui::TemplateClip_UI dia_ui;
2355 dia_ui.setupUi(dia);
2357 const QString templatePath = clip->getProperty("resource");
2358 for (int i = 0; i < templateFiles.size(); ++i) {
2359 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
2360 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
2362 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
2363 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
2364 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
2365 //warning: setting base directory doesn't work??
2366 KUrl startDir(titlepath);
2367 dia_ui.template_list->fileDialog()->setUrl(startDir);
2368 dia_ui.description->setText(clip->getProperty("description"));
2369 if (dia->exec() == QDialog::Accepted) {
2370 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
2371 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
2373 QMap <QString, QString> newprops;
2375 if (KUrl(textTemplate).path() != templatePath) {
2376 // The template was changed
2377 newprops.insert("resource", textTemplate);
2380 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
2381 newprops.insert("description", dia_ui.description->toPlainText());
2384 QString newtemplate = newprops.value("xmltemplate");
2385 if (newtemplate.isEmpty()) newtemplate = templatePath;
2387 // template modified we need to update xmldata
2388 QString description = newprops.value("description");
2389 if (description.isEmpty()) description = clip->getProperty("description");
2390 else newprops.insert("templatetext", description);
2391 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
2393 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2394 m_activeDocument->commandStack()->push(command);
2398 QString path = clip->getProperty("resource");
2399 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
2401 doc.setContent(clip->getProperty("xmldata"));
2402 dia_ui->setXml(doc);
2403 if (dia_ui->exec() == QDialog::Accepted) {
2404 QMap <QString, QString> newprops;
2405 newprops.insert("xmldata", dia_ui->xml().toString());
2406 if (dia_ui->duration() != clip->duration().frames(m_activeDocument->fps()) - 1) {
2407 // duration changed, we need to update duration
2408 newprops.insert("out", QString::number(dia_ui->duration()));
2410 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2411 m_activeDocument->commandStack()->push(command);
2412 m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
2413 m_activeDocument->setModified(true);
2417 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2420 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2421 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2422 if (dia.exec() == QDialog::Accepted) {
2423 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true);
2424 m_activeDocument->commandStack()->push(command);
2426 if (dia.needsTimelineRefresh()) {
2427 // update clip occurences in timeline
2428 m_activeTimeline->projectView()->slotUpdateClip(clip->getId(), dia.needsTimelineReload());
2433 void MainWindow::customEvent(QEvent* e)
2435 if (e->type() == QEvent::User) {
2436 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
2439 void MainWindow::slotActivateEffectStackView()
2441 m_effectStack->raiseWindow(m_effectStackDock);
2444 void MainWindow::slotActivateTransitionView(Transition *t)
2446 if (t) m_transitionConfig->raiseWindow(m_transitionConfigDock);
2449 void MainWindow::slotSnapRewind()
2451 if (m_projectMonitor->isActive()) {
2452 if (m_activeTimeline)
2453 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2454 } else m_clipMonitor->slotSeekToPreviousSnap();
2457 void MainWindow::slotSnapForward()
2459 if (m_projectMonitor->isActive()) {
2460 if (m_activeTimeline)
2461 m_activeTimeline->projectView()->slotSeekToNextSnap();
2462 } else m_clipMonitor->slotSeekToNextSnap();
2465 void MainWindow::slotClipStart()
2467 if (m_projectMonitor->isActive()) {
2468 if (m_activeTimeline)
2469 m_activeTimeline->projectView()->clipStart();
2473 void MainWindow::slotClipEnd()
2475 if (m_projectMonitor->isActive()) {
2476 if (m_activeTimeline)
2477 m_activeTimeline->projectView()->clipEnd();
2481 void MainWindow::slotZoneStart()
2483 if (m_projectMonitor->isActive()) m_projectMonitor->slotZoneStart();
2484 else m_clipMonitor->slotZoneStart();
2487 void MainWindow::slotZoneEnd()
2489 if (m_projectMonitor->isActive()) m_projectMonitor->slotZoneEnd();
2490 else m_clipMonitor->slotZoneEnd();
2493 void MainWindow::slotChangeTool(QAction * action)
2495 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
2496 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
2497 else if (action == m_buttonSpacerTool) slotSetTool(SPACERTOOL);
2500 void MainWindow::slotSetTool(PROJECTTOOL tool)
2502 if (m_activeDocument && m_activeTimeline) {
2503 //m_activeDocument->setTool(tool);
2507 message = i18n("Ctrl + click to use spacer on current track only");
2510 message = i18n("Click on a clip to cut it");
2513 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
2516 m_messageLabel->setMessage(message, InformationMessage);
2517 m_activeTimeline->projectView()->setTool(tool);
2521 void MainWindow::slotCopy()
2523 if (!m_activeDocument || !m_activeTimeline) return;
2524 m_activeTimeline->projectView()->copyClip();
2527 void MainWindow::slotPaste()
2529 if (!m_activeDocument || !m_activeTimeline) return;
2530 m_activeTimeline->projectView()->pasteClip();
2533 void MainWindow::slotPasteEffects()
2535 if (!m_activeDocument || !m_activeTimeline) return;
2536 m_activeTimeline->projectView()->pasteClipEffects();
2539 void MainWindow::slotFind()
2541 if (!m_activeDocument || !m_activeTimeline) return;
2542 m_projectSearch->setEnabled(false);
2543 m_findActivated = true;
2544 m_findString.clear();
2545 m_activeTimeline->projectView()->initSearchStrings();
2546 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2547 m_findTimer.start(5000);
2548 qApp->installEventFilter(this);
2551 void MainWindow::slotFindNext()
2553 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
2554 statusBar()->showMessage(i18n("Found: %1", m_findString));
2556 statusBar()->showMessage(i18n("Reached end of project"));
2558 m_findTimer.start(4000);
2561 void MainWindow::findAhead()
2563 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
2564 m_projectSearchNext->setEnabled(true);
2565 statusBar()->showMessage(i18n("Found: %1", m_findString));
2567 m_projectSearchNext->setEnabled(false);
2568 statusBar()->showMessage(i18n("Not found: %1", m_findString));
2572 void MainWindow::findTimeout()
2574 m_projectSearchNext->setEnabled(false);
2575 m_findActivated = false;
2576 m_findString.clear();
2577 statusBar()->showMessage(i18n("Find stopped"), 3000);
2578 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
2579 m_projectSearch->setEnabled(true);
2580 removeEventFilter(this);
2583 void MainWindow::keyPressEvent(QKeyEvent *ke)
2585 if (m_findActivated) {
2586 if (ke->key() == Qt::Key_Backspace) {
2587 m_findString = m_findString.left(m_findString.length() - 1);
2589 if (!m_findString.isEmpty()) {
2595 m_findTimer.start(4000);
2598 } else if (ke->key() == Qt::Key_Escape) {
2602 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
2603 m_findString += ke->text();
2607 m_findTimer.start(4000);
2611 } else KXmlGuiWindow::keyPressEvent(ke);
2615 /** Gets called when the window gets hidden */
2616 void MainWindow::hideEvent(QHideEvent */*event*/)
2618 // kDebug() << "I was hidden";
2619 // issue http://www.kdenlive.org/mantis/view.php?id=231
2620 if (isMinimized()) {
2621 // kDebug() << "I am minimized";
2622 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
2626 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
2628 if (m_findActivated) {
2629 if (event->type() == QEvent::ShortcutOverride) {
2630 QKeyEvent* ke = (QKeyEvent*) event;
2631 if (ke->text().trimmed().isEmpty()) return false;
2634 } else return false;
2636 // pass the event on to the parent class
2637 return QMainWindow::eventFilter(obj, event);
2642 void MainWindow::slotSaveZone(Render *render, QPoint zone)
2644 KDialog *dialog = new KDialog(this);
2645 dialog->setCaption("Save clip zone");
2646 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
2648 QWidget *widget = new QWidget(dialog);
2649 dialog->setMainWidget(widget);
2651 QVBoxLayout *vbox = new QVBoxLayout(widget);
2652 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
2653 QString path = m_activeDocument->projectFolder().path();
2655 path.append("untitled.mlt");
2656 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
2657 url->setFilter("video/mlt-playlist");
2658 QLabel *label2 = new QLabel(i18n("Description:"), this);
2659 KLineEdit *edit = new KLineEdit(this);
2660 vbox->addWidget(label1);
2661 vbox->addWidget(url);
2662 vbox->addWidget(label2);
2663 vbox->addWidget(edit);
2664 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
2668 void MainWindow::slotSetInPoint()
2670 if (m_clipMonitor->isActive()) {
2671 m_clipMonitor->slotSetZoneStart();
2672 } else m_projectMonitor->slotSetZoneStart();
2673 //else m_activeTimeline->projectView()->setInPoint();
2676 void MainWindow::slotSetOutPoint()
2678 if (m_clipMonitor->isActive()) {
2679 m_clipMonitor->slotSetZoneEnd();
2680 } else m_projectMonitor->slotSetZoneEnd();
2681 // else m_activeTimeline->projectView()->setOutPoint();
2684 void MainWindow::slotGetNewLumaStuff()
2686 //KNS::Entry::List download();
2687 KNS::Entry::List entries = KNS::Engine::download();
2688 // list of changed entries
2689 kDebug() << "// PARSING KNS";
2690 foreach(KNS::Entry* entry, entries) {
2691 // care only about installed ones
2692 if (entry->status() == KNS::Entry::Installed) {
2693 foreach(const QString &file, entry->installedFiles()) {
2694 kDebug() << "// CURRENTLY INSTALLED: " << file;
2698 qDeleteAll(entries);
2699 initEffects::refreshLumas();
2700 m_activeTimeline->projectView()->reloadTransitionLumas();
2703 void MainWindow::slotGetNewRenderStuff()
2705 //KNS::Entry::List download();
2707 KNS::Engine engine(0);
2708 if (engine.init("kdenlive_render.knsrc")) {
2709 KNS::Entry::List entries = engine.downloadDialogModal(this);
2711 if (entries.size() > 0) {
2712 foreach(KNS::Entry* entry, entries) {
2713 // care only about installed ones
2714 if (entry->status() == KNS::Entry::Installed) {
2715 foreach(const QString &file, entry->installedFiles()) {
2716 kDebug() << "// CURRENTLY INSTALLED: " << file;
2721 if (m_renderWidget) m_renderWidget->reloadProfiles();
2725 void MainWindow::slotGetNewMltProfileStuff()
2727 //KNS::Entry::List download();
2729 KNS::Engine engine(0);
2730 if (engine.init("kdenlive_mltprofiles.knsrc")) {
2731 KNS::Entry::List entries = engine.downloadDialogModal(this);
2733 if (entries.size() > 0) {
2734 foreach(KNS::Entry* entry, entries) {
2735 // care only about installed ones
2736 if (entry->status() == KNS::Entry::Installed) {
2737 foreach(const QString &file, entry->installedFiles()) {
2738 kDebug() << "// CURRENTLY INSTALLED: " << file;
2743 // update the list of profiles in settings dialog
2744 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2745 if (d) d->checkProfile();
2750 void MainWindow::slotAutoTransition()
2752 if (m_activeTimeline) m_activeTimeline->projectView()->autoTransition();
2755 void MainWindow::slotSplitAudio()
2757 if (m_activeTimeline) m_activeTimeline->projectView()->splitAudio();
2760 void MainWindow::slotUpdateClipType(QAction *action)
2762 if (m_activeTimeline) {
2763 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
2764 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
2765 else m_activeTimeline->projectView()->setAudioAndVideo();
2769 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
2771 // We must stop the monitors since we create a new on in the dvd wizard
2772 m_clipMonitor->stop();
2773 m_projectMonitor->stop();
2774 DvdWizard w(url, profile, this);
2776 m_projectMonitor->start();
2779 void MainWindow::slotShowTimeline(bool show)
2781 if (show == false) {
2782 m_timelineState = saveState();
2783 centralWidget()->setHidden(true);
2785 centralWidget()->setHidden(false);
2786 restoreState(m_timelineState);
2790 void MainWindow::slotMaximizeCurrent(bool /*show*/)
2792 //TODO: is there a way to maximize current widget?
2795 m_timelineState = saveState();
2796 QWidget *par = focusWidget()->parentWidget();
2797 while (par->parentWidget() && par->parentWidget() != this) {
2798 par = par->parentWidget();
2800 kDebug() << "CURRENT WIDGET: " << par->objectName();
2803 //centralWidget()->setHidden(false);
2804 //restoreState(m_timelineState);
2808 void MainWindow::loadTranscoders()
2810 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
2813 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
2814 KConfigGroup transConfig(config, "Transcoding");
2816 QMap< QString, QString > profiles = transConfig.entryMap();
2817 QMapIterator<QString, QString> i(profiles);
2818 while (i.hasNext()) {
2820 QAction *a = transMenu->addAction(i.key());
2821 a->setData(i.value());
2822 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
2826 void MainWindow::slotTranscode(KUrl::List urls)
2829 if (urls.isEmpty()) {
2830 urls.append(m_projectList->currentClipUrl());
2831 QAction *action = qobject_cast<QAction *>(sender());
2832 params = action->data().toString();
2834 if (urls.isEmpty()) return;
2835 ClipTranscode *d = new ClipTranscode(urls, params);
2836 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
2838 //QProcess::startDetached("ffmpeg", parameters);
2841 void MainWindow::slotTranscodeClip()
2843 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
2844 if (urls.isEmpty()) return;
2845 slotTranscode(urls);
2848 void MainWindow::slotSetDocumentRenderProfile(const QString &dest, const QString &name, const QString &file)
2850 if (m_activeDocument == NULL) return;
2851 m_activeDocument->setDocumentProperty("renderdestination", dest);
2852 m_activeDocument->setDocumentProperty("renderprofile", name);
2853 m_activeDocument->setDocumentProperty("renderurl", file);
2854 m_activeDocument->setModified(true);
2858 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
2860 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
2862 QString playlistPath;
2865 QString scriptsFolder = m_activeDocument->projectFolder().path() + "/scripts/";
2866 QString path = m_renderWidget->getFreeScriptName();
2867 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
2868 if (!ok || scriptPath.isEmpty()) return;
2869 scriptPath.prepend(scriptsFolder);
2870 QFile f(scriptPath);
2872 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
2875 playlistPath = scriptPath + ".mlt";
2876 m_projectMonitor->saveSceneList(playlistPath);
2878 KTemporaryFile temp;
2879 temp.setAutoRemove(false);
2880 temp.setSuffix(".mlt");
2882 playlistPath = temp.fileName();
2883 m_projectMonitor->saveSceneList(playlistPath);
2886 if (!chapterFile.isEmpty()) {
2889 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
2891 in = m_activeTimeline->inPoint();
2892 out = m_activeTimeline->outPoint();
2895 QDomElement chapters = doc.createElement("chapters");
2896 chapters.setAttribute("fps", m_activeDocument->fps());
2897 doc.appendChild(chapters);
2899 QDomElement guidesxml = m_activeDocument->guidesXml();
2900 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
2901 for (int i = 0; i < nodes.count(); i++) {
2902 QDomElement e = nodes.item(i).toElement();
2904 QString comment = e.attribute("comment");
2905 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
2906 if (time >= in && time < out) {
2907 if (zoneOnly) time = time - in;
2908 QDomElement chapter = doc.createElement("chapter");
2909 chapters.appendChild(chapter);
2910 chapter.setAttribute("title", comment);
2911 chapter.setAttribute("time", time);
2915 if (chapters.childNodes().count() > 0) {
2916 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
2917 // Always insert a guide in pos 0
2918 QDomElement chapter = doc.createElement("chapter");
2919 chapters.insertBefore(chapter, QDomNode());
2920 chapter.setAttribute("title", i18n("Start"));
2921 chapter.setAttribute("time", "0");
2923 // save chapters file
2924 QFile file(chapterFile);
2925 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
2926 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
2928 file.write(doc.toString().toUtf8());
2929 if (file.error() != QFile::NoError) {
2930 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
2937 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath);
2940 void MainWindow::slotUpdateTimecodeFormat(int ix)
2942 KdenliveSettings::setFrametimecode(ix == 1);
2943 m_clipMonitor->updateTimecodeFormat();
2944 m_projectMonitor->updateTimecodeFormat();
2947 void MainWindow::slotRemoveFocus()
2949 statusBar()->setFocus();
2950 statusBar()->clearFocus();
2953 void MainWindow::slotRevert()
2955 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;
2956 KUrl url = m_activeDocument->url();
2957 closeCurrentDocument(false);
2958 doOpenFile(url, NULL);
2962 void MainWindow::slotShutdown()
2964 if (m_activeDocument) m_activeDocument->setModified(false);
2966 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
2967 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
2968 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
2969 smserver.call("logout", 1, 2, 2);
2973 void MainWindow::slotUpdateTrackInfo()
2975 if (m_activeDocument)
2976 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2979 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
2981 // Load the theme file
2983 if (action == NULL) theme = themename;
2984 else theme = action->data().toString();
2985 KdenliveSettings::setColortheme(theme);
2986 // Make palette for all widgets.
2988 if (theme.isEmpty())
2989 plt = QApplication::desktop()->palette();
2991 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
2992 plt = KGlobalSettings::createApplicationPalette(config);
2995 kapp->setPalette(plt);
2996 const QObjectList children = statusBar()->children();
2998 foreach(QObject *child, children) {
2999 if (child->isWidgetType())
3000 ((QWidget*)child)->setPalette(plt);
3001 const QObjectList subchildren = child->children();
3002 foreach(QObject *subchild, subchildren) {
3003 if (subchild->isWidgetType())
3004 ((QWidget*)subchild)->setPalette(plt);
3010 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
3012 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
3013 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
3014 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
3015 const QSize bitsSize(24, 2);
3016 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
3017 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
3019 QPixmap pixmap(23, 16);
3020 pixmap.fill(Qt::black); // ### use some color other than black for borders?
3022 KConfigGroup group(config, "WM");
3023 QPainter p(&pixmap);
3024 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
3025 p.fillRect(1, 1, 7, 7, windowScheme.background());
3026 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
3028 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
3029 p.fillRect(8, 1, 7, 7, buttonScheme.background());
3030 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
3032 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
3033 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
3035 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
3036 p.fillRect(1, 8, 7, 7, viewScheme.background());
3037 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
3039 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
3040 p.fillRect(8, 8, 7, 7, selectionScheme.background());
3041 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
3043 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
3044 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
3051 #include "mainwindow.moc"