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 #if KDE_IS_VERSION(4,3,80)
83 #include <knewstuff3/downloaddialog.h>
84 #include <knewstuff3/knewstuffaction.h>
86 #include <knewstuff2/engine.h>
87 #include <knewstuff2/ui/knewstuffaction.h>
89 #endif /* KDE_IS_VERSION(4,3,80) */
91 #include <KColorScheme>
93 #include <QTextStream>
97 #include <QInputDialog>
98 #include <QDesktopWidget>
103 static const char version[] = VERSION;
105 static const int ID_TIMELINE_POS = 0;
112 EffectsList MainWindow::videoEffects;
113 EffectsList MainWindow::audioEffects;
114 EffectsList MainWindow::customEffects;
115 EffectsList MainWindow::transitions;
117 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent) :
118 KXmlGuiWindow(parent),
119 m_activeDocument(NULL),
120 m_activeTimeline(NULL),
121 m_renderWidget(NULL),
122 #ifndef NO_JOGSHUTTLE
124 #endif /* NO_JOGSHUTTLE */
125 m_findActivated(false)
128 // Create DBus interface
129 new MainWindowAdaptor(this);
130 QDBusConnection dbus = QDBusConnection::sessionBus();
131 dbus.registerObject("/MainWindow", this);
133 setlocale(LC_NUMERIC, "POSIX");
134 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
135 setFont(KGlobalSettings::toolBarFont());
136 parseProfiles(MltPath);
137 m_commandStack = new QUndoGroup;
138 m_timelineArea = new KTabWidget(this);
139 m_timelineArea->setTabReorderingEnabled(true);
140 m_timelineArea->setTabBarHidden(true);
142 QToolButton *closeTabButton = new QToolButton;
143 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
144 closeTabButton->setIcon(KIcon("tab-close"));
145 closeTabButton->adjustSize();
146 closeTabButton->setToolTip(i18n("Close the current tab"));
147 m_timelineArea->setCornerWidget(closeTabButton);
148 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
150 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
151 m_findTimer.setSingleShot(true);
153 // FIXME: the next call returns a newly allocated object, which leaks
154 initEffects::parseEffectFiles();
155 //initEffects::parseCustomEffectsFile();
157 m_monitorManager = new MonitorManager();
159 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
160 m_projectListDock->setObjectName("project_tree");
161 m_projectList = new ProjectList(this);
162 m_projectListDock->setWidget(m_projectList);
163 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
165 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
166 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
168 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
169 m_effectListDock->setObjectName("effect_list");
170 m_effectList = new EffectsListView();
172 //m_effectList = new KListWidget(this);
173 m_effectListDock->setWidget(m_effectList);
174 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
176 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
177 m_effectStackDock->setObjectName("effect_stack");
178 m_effectStack = new EffectStackView(this);
179 m_effectStackDock->setWidget(m_effectStack);
180 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
182 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
183 m_transitionConfigDock->setObjectName("transition");
184 m_transitionConfig = new TransitionSettings(this);
185 m_transitionConfigDock->setWidget(m_transitionConfig);
186 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
188 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
189 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
191 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
192 m_fileRevert->setEnabled(false);
194 //slotDetectAudioDriver();
196 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
197 m_clipMonitorDock->setObjectName("clip_monitor");
198 m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), this);
199 m_clipMonitorDock->setWidget(m_clipMonitor);
200 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
201 //m_clipMonitor->stop();
203 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
204 m_projectMonitorDock->setObjectName("project_monitor");
205 m_projectMonitor = new Monitor("project", m_monitorManager, QString(), this);
206 m_projectMonitorDock->setWidget(m_projectMonitor);
207 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
210 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
211 m_recMonitorDock->setObjectName("record_monitor");
212 m_recMonitor = new RecMonitor("record", this);
213 m_recMonitorDock->setWidget(m_recMonitor);
214 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
216 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
217 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
220 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
221 m_undoViewDock->setObjectName("undo_history");
222 m_undoView = new QUndoView(this);
223 m_undoView->setCleanIcon(KIcon("edit-clear"));
224 m_undoView->setEmptyLabel(i18n("Clean"));
225 m_undoViewDock->setWidget(m_undoView);
226 m_undoView->setGroup(m_commandStack);
227 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
229 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
230 //overviewDock->setObjectName("project_overview");
231 //m_overView = new CustomTrackView(NULL, NULL, this);
232 //overviewDock->setWidget(m_overView);
233 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
236 //tabifyDockWidget(projectListDock, effectListDock);
237 tabifyDockWidget(m_projectListDock, m_effectStackDock);
238 tabifyDockWidget(m_projectListDock, m_transitionConfigDock);
239 //tabifyDockWidget(projectListDock, undoViewDock);
242 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
244 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
246 setCentralWidget(m_timelineArea);
249 // Find QDockWidget tab bars and show / hide widget title bars on right click
250 QList <QTabBar *> tabs = findChildren<QTabBar *>();
251 for (int i = 0; i < tabs.count(); i++) {
252 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
253 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
256 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
257 guiFactory()->addClient(sp);*/
261 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
263 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone);
264 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
266 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
267 clipInTimeline->setIcon(KIcon("go-jump"));
268 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)),
269 static_cast<QMenu*>(factory()->container("transcoders", this)),
273 // build themes menus
274 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
275 QActionGroup *themegroup = new QActionGroup(this);
276 themegroup->setExclusive(true);
277 action = new QAction(i18n("Default"), this);
278 action->setCheckable(true);
279 themegroup->addAction(action);
280 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
283 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
285 for (int i = 0; i < schemeFiles.size(); ++i) {
287 const QString filename = schemeFiles.at(i);
288 const QFileInfo info(filename);
291 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
292 QIcon icon = createSchemePreviewIcon(config);
293 KConfigGroup group(config, "General");
294 const QString name = group.readEntry("Name", info.baseName());
295 action = new QAction(name, this);
296 action->setData(filename);
297 action->setIcon(icon);
298 action->setCheckable(true);
299 themegroup->addAction(action);
300 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
308 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
309 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
310 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
313 action = new QAction(fi.fileName(), this);
314 action->setData(*it);
315 action->setCheckable(true);
316 themegroup->addAction(action);
317 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
319 themesMenu->addActions(themegroup->actions());
320 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
322 // build effects menus
323 QMenu *videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
325 QStringList effectInfo;
326 QMap<QString, QStringList> effectsList;
327 for (int ix = 0; ix < videoEffects.count(); ix++) {
328 effectInfo = videoEffects.effectIdInfo(ix);
329 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
332 foreach(const QStringList &value, effectsList) {
333 action = new QAction(value.at(0), this);
334 action->setData(value);
335 videoEffectsMenu->addAction(action);
338 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
342 for (int ix = 0; ix < audioEffects.count(); ix++) {
343 effectInfo = audioEffects.effectIdInfo(ix);
344 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
347 foreach(const QStringList &value, effectsList) {
348 action = new QAction(value.at(0), this);
349 action->setData(value);
350 audioEffectsMenu->addAction(action);
353 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
355 if (customEffects.isEmpty()) m_customEffectsMenu->setEnabled(false);
356 else m_customEffectsMenu->setEnabled(true);
359 for (int ix = 0; ix < customEffects.count(); ix++) {
360 effectInfo = customEffects.effectIdInfo(ix);
361 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
364 foreach(const QStringList &value, effectsList) {
365 action = new QAction(value.at(0), this);
366 action->setData(value);
367 m_customEffectsMenu->addAction(action);
370 QMenu *newEffect = new QMenu(this);
371 newEffect->addMenu(videoEffectsMenu);
372 newEffect->addMenu(audioEffectsMenu);
373 newEffect->addMenu(m_customEffectsMenu);
374 m_effectStack->setMenu(newEffect);
377 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
378 const QList<QAction *> viewActions = createPopupMenu()->actions();
379 viewMenu->insertActions(NULL, viewActions);
381 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
382 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
383 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
385 m_timelineContextMenu = new QMenu(this);
386 m_timelineContextClipMenu = new QMenu(this);
387 m_timelineContextTransitionMenu = new QMenu(this);
390 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
391 QStringList effects = transitions.effectNames();
394 for (int ix = 0; ix < transitions.count(); ix++) {
395 effectInfo = transitions.effectIdInfo(ix);
396 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
398 foreach(const QStringList &value, effectsList) {
399 action = new QAction(value.at(0), this);
400 action->setData(value);
401 transitionsMenu->addAction(action);
403 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
405 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
406 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
407 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
409 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
410 m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
411 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
412 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
413 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
414 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
415 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
416 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
417 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
419 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
420 m_timelineContextClipMenu->addMenu(markersMenu);
421 m_timelineContextClipMenu->addMenu(transitionsMenu);
422 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
423 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
424 //TODO: re-enable custom effects menu when it is implemented
425 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
427 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
428 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
429 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
431 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
433 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
434 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
435 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
436 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
437 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
438 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
440 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
441 slotConnectMonitors();
443 // Disable drop B frames, see Kdenlive issue #1330, see also kdenlivesettingsdialog.cpp
444 KdenliveSettings::setDropbframes(false);
446 // Open or create a file. Command line argument passed in Url has
447 // precedence, then "openlastproject", then just a plain empty file.
448 // If opening Url fails, openlastproject will _not_ be used.
449 if (!Url.isEmpty()) {
450 // delay loading so that the window shows up
452 QTimer::singleShot(500, this, SLOT(openFile()));
453 } else if (KdenliveSettings::openlastproject()) {
454 QTimer::singleShot(500, this, SLOT(openLastFile()));
455 } else { //if (m_timelineArea->count() == 0) {
459 #ifndef NO_JOGSHUTTLE
460 activateShuttleDevice();
461 #endif /* NO_JOGSHUTTLE */
462 m_projectListDock->raise();
465 void MainWindow::queryQuit()
468 if (m_projectMonitor) m_projectMonitor->stop();
469 if (m_clipMonitor) m_clipMonitor->stop();
470 delete m_effectStack;
471 delete m_activeTimeline;
473 // This sometimes causes crash on exit on OS X for some reason.
474 delete m_projectMonitor;
475 delete m_clipMonitor;
477 delete m_activeDocument;
478 delete m_shortcutRemoveFocus;
479 Mlt::Factory::close();
485 bool MainWindow::queryClose()
487 if (m_renderWidget) {
488 int waitingJobs = m_renderWidget->waitingJobsCount();
489 if (waitingJobs > 0) {
490 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")))) {
491 case KMessageBox::Yes :
492 // create script with waiting jobs and start it
493 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
495 case KMessageBox::No :
496 // Don't do anything, jobs will be deleted
504 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
505 if (m_activeDocument && m_activeDocument->isModified()) {
506 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
507 case KMessageBox::Yes :
508 // save document here. If saving fails, return false;
510 case KMessageBox::No :
511 // User does not want to save the changes, clear recovery files
512 m_activeDocument->m_autosave->resize(0);
522 void MainWindow::loadPlugins()
524 foreach(QObject *plugin, QPluginLoader::staticInstances())
525 populateMenus(plugin);
527 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
529 filters << "libkdenlive*";
530 foreach(const QString &folder, directories) {
531 kDebug() << "// PARSING FIOLER: " << folder;
532 QDir pluginsDir(folder);
533 foreach(const QString &fileName, pluginsDir.entryList(filters, QDir::Files)) {
534 kDebug() << "// FOUND PLUGIN: " << fileName << "= " << pluginsDir.absoluteFilePath(fileName);
535 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
536 QObject *plugin = loader.instance();
538 populateMenus(plugin);
539 m_pluginFileNames += fileName;
540 } else kDebug() << "// ERROR LOADING PLUGIN: " << fileName << ", " << loader.errorString();
546 void MainWindow::populateMenus(QObject *plugin)
548 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
549 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
551 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
555 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
556 QMenu *menu, const char *member,
557 QActionGroup *actionGroup)
559 kDebug() << "// ADD to MENU" << texts;
560 foreach(const QString &text, texts) {
561 QAction *action = new QAction(text, plugin);
562 action->setData(text);
563 connect(action, SIGNAL(triggered()), this, member);
564 menu->addAction(action);
567 action->setCheckable(true);
568 actionGroup->addAction(action);
573 void MainWindow::aboutPlugins()
575 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
580 void MainWindow::generateClip()
582 QAction *action = qobject_cast<QAction *>(sender());
583 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
585 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(), QStringList(), QStringList(), 25, 720, 576);
586 if (!clipUrl.isEmpty()) {
587 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
591 void MainWindow::saveProperties(KConfigGroup &config)
593 // save properties here,used by session management
595 KMainWindow::saveProperties(config);
599 void MainWindow::readProperties(const KConfigGroup &config)
601 // read properties here,used by session management
602 KMainWindow::readProperties(config);
603 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
604 openFile(KUrl(Lastproject));
607 void MainWindow::slotReloadEffects()
609 m_customEffectsMenu->clear();
610 initEffects::parseCustomEffectsFile();
612 QStringList effectInfo;
613 QMap<QString, QStringList> effectsList;
615 for (int ix = 0; ix < customEffects.count(); ix++) {
616 effectInfo = customEffects.effectIdInfo(ix);
617 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
619 if (effectsList.isEmpty()) {
620 m_customEffectsMenu->setEnabled(false);
622 } else m_customEffectsMenu->setEnabled(true);
624 foreach(const QStringList &value, effectsList) {
625 action = new QAction(value.at(0), this);
626 action->setData(value);
627 m_customEffectsMenu->addAction(action);
629 m_effectList->reloadEffectList();
632 #ifndef NO_JOGSHUTTLE
633 void MainWindow::activateShuttleDevice()
637 if (KdenliveSettings::enableshuttle() == false) return;
638 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
639 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
640 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
641 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
642 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
643 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
644 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
647 void MainWindow::slotShuttleButton(int code)
651 slotShuttleAction(KdenliveSettings::shuttle1());
654 slotShuttleAction(KdenliveSettings::shuttle2());
657 slotShuttleAction(KdenliveSettings::shuttle3());
660 slotShuttleAction(KdenliveSettings::shuttle4());
663 slotShuttleAction(KdenliveSettings::shuttle5());
668 void MainWindow::slotShuttleAction(int code)
674 m_monitorManager->slotPlay();
677 m_monitorManager->slotPlay();
681 #endif /* NO_JOGSHUTTLE */
683 void MainWindow::configureNotifications()
685 KNotifyConfigWidget::configure(this);
688 void MainWindow::slotFullScreen()
690 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
693 void MainWindow::slotAddEffect(const QDomElement effect, GenTime pos, int track)
695 if (!m_activeDocument) return;
696 if (effect.isNull()) {
697 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
700 QDomElement effectToAdd = effect.cloneNode().toElement();
701 m_activeTimeline->projectView()->slotAddEffect(effectToAdd, pos, track);
704 void MainWindow::slotRaiseMonitor(bool clipMonitor)
706 if (clipMonitor) m_clipMonitorDock->raise();
707 else m_projectMonitorDock->raise();
710 void MainWindow::slotUpdateClip(const QString &id)
712 if (!m_activeDocument) return;
713 m_activeTimeline->projectView()->slotUpdateClip(id);
716 void MainWindow::slotConnectMonitors()
719 m_projectList->setRenderer(m_projectMonitor->render);
720 //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
721 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
722 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
723 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
724 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, int, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, int, bool)));
725 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
726 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)));
728 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
730 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
732 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
733 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
735 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
736 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
739 void MainWindow::slotAdjustClipMonitor()
741 m_clipMonitorDock->updateGeometry();
742 m_clipMonitorDock->adjustSize();
743 m_clipMonitor->resetSize();
746 void MainWindow::slotAdjustProjectMonitor()
748 m_projectMonitorDock->updateGeometry();
749 m_projectMonitorDock->adjustSize();
750 m_projectMonitor->resetSize();
753 void MainWindow::setupActions()
756 KActionCollection* collection = actionCollection();
757 m_timecodeFormat = new KComboBox(this);
758 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
759 m_timecodeFormat->addItem(i18n("Frames"));
760 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
761 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
763 m_statusProgressBar = new QProgressBar(this);
764 m_statusProgressBar->setMinimum(0);
765 m_statusProgressBar->setMaximum(100);
766 m_statusProgressBar->setMaximumWidth(150);
767 m_statusProgressBar->setVisible(false);
769 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
770 toolbar->setMovable(false);
771 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
772 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;}";
774 //create edit mode buttons
775 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
776 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
777 toolbar->addAction(m_normalEditTool);
778 m_normalEditTool->setCheckable(true);
779 m_normalEditTool->setChecked(true);
781 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
782 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
783 toolbar->addAction(m_overwriteEditTool);
784 m_overwriteEditTool->setCheckable(true);
785 m_overwriteEditTool->setChecked(false);
787 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
788 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
789 toolbar->addAction(m_insertEditTool);
790 m_insertEditTool->setCheckable(true);
791 m_insertEditTool->setChecked(false);
792 // not implemented yet
793 m_insertEditTool->setEnabled(false);
795 QActionGroup *editGroup = new QActionGroup(this);
796 editGroup->addAction(m_normalEditTool);
797 editGroup->addAction(m_overwriteEditTool);
798 editGroup->addAction(m_insertEditTool);
799 editGroup->setExclusive(true);
800 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
801 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
803 toolbar->addSeparator();
805 // create tools buttons
806 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
807 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
808 toolbar->addAction(m_buttonSelectTool);
809 m_buttonSelectTool->setCheckable(true);
810 m_buttonSelectTool->setChecked(true);
812 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
813 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
814 toolbar->addAction(m_buttonRazorTool);
815 m_buttonRazorTool->setCheckable(true);
816 m_buttonRazorTool->setChecked(false);
818 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
819 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
820 toolbar->addAction(m_buttonSpacerTool);
821 m_buttonSpacerTool->setCheckable(true);
822 m_buttonSpacerTool->setChecked(false);
824 QActionGroup *toolGroup = new QActionGroup(this);
825 toolGroup->addAction(m_buttonSelectTool);
826 toolGroup->addAction(m_buttonRazorTool);
827 toolGroup->addAction(m_buttonSpacerTool);
828 toolGroup->setExclusive(true);
829 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
831 QWidget * actionWidget;
832 int max = toolbar->iconSizeDefault() + 2;
833 actionWidget = toolbar->widgetForAction(m_normalEditTool);
834 actionWidget->setMaximumWidth(max);
835 actionWidget->setMaximumHeight(max - 4);
837 actionWidget = toolbar->widgetForAction(m_insertEditTool);
838 actionWidget->setMaximumWidth(max);
839 actionWidget->setMaximumHeight(max - 4);
841 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
842 actionWidget->setMaximumWidth(max);
843 actionWidget->setMaximumHeight(max - 4);
845 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
846 actionWidget->setMaximumWidth(max);
847 actionWidget->setMaximumHeight(max - 4);
849 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
850 actionWidget->setMaximumWidth(max);
851 actionWidget->setMaximumHeight(max - 4);
853 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
854 actionWidget->setMaximumWidth(max);
855 actionWidget->setMaximumHeight(max - 4);
857 toolbar->setStyleSheet(style1);
858 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
860 toolbar->addSeparator();
861 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
862 toolbar->addAction(m_buttonFitZoom);
863 m_buttonFitZoom->setCheckable(false);
864 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
866 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
867 actionWidget->setMaximumWidth(max);
868 actionWidget->setMaximumHeight(max - 4);
870 m_zoomSlider = new QSlider(Qt::Horizontal, this);
871 m_zoomSlider->setMaximum(13);
872 m_zoomSlider->setPageStep(1);
874 m_zoomSlider->setMaximumWidth(150);
875 m_zoomSlider->setMinimumWidth(100);
876 toolbar->addWidget(m_zoomSlider);
878 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
879 toolbar->addAction(m_buttonVideoThumbs);
880 m_buttonVideoThumbs->setCheckable(true);
881 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
882 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
884 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
885 toolbar->addAction(m_buttonAudioThumbs);
886 m_buttonAudioThumbs->setCheckable(true);
887 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
888 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
890 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
891 toolbar->addAction(m_buttonShowMarkers);
892 m_buttonShowMarkers->setCheckable(true);
893 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
894 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
896 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
897 toolbar->addAction(m_buttonSnap);
898 m_buttonSnap->setCheckable(true);
899 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
900 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
902 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
903 actionWidget->setMaximumWidth(max);
904 actionWidget->setMaximumHeight(max - 4);
906 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
907 actionWidget->setMaximumWidth(max);
908 actionWidget->setMaximumHeight(max - 4);
910 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
911 actionWidget->setMaximumWidth(max);
912 actionWidget->setMaximumHeight(max - 4);
914 actionWidget = toolbar->widgetForAction(m_buttonSnap);
915 actionWidget->setMaximumWidth(max);
916 actionWidget->setMaximumHeight(max - 4);
918 m_messageLabel = new StatusBarMessageLabel(this);
919 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
921 statusBar()->addWidget(m_messageLabel, 10);
922 statusBar()->addWidget(m_statusProgressBar, 0);
923 statusBar()->addPermanentWidget(toolbar);
924 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
925 statusBar()->addPermanentWidget(m_timecodeFormat);
926 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
928 collection->addAction("normal_mode", m_normalEditTool);
929 collection->addAction("overwrite_mode", m_overwriteEditTool);
930 collection->addAction("insert_mode", m_insertEditTool);
931 collection->addAction("select_tool", m_buttonSelectTool);
932 collection->addAction("razor_tool", m_buttonRazorTool);
933 collection->addAction("spacer_tool", m_buttonSpacerTool);
935 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
936 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
937 collection->addAction("show_markers", m_buttonShowMarkers);
938 collection->addAction("snap", m_buttonSnap);
939 collection->addAction("zoom_fit", m_buttonFitZoom);
941 KAction* zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
942 collection->addAction("zoom_in", zoomIn);
943 connect(zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
944 zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
946 KAction* zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
947 collection->addAction("zoom_out", zoomOut);
948 connect(zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
949 zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
951 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
952 collection->addAction("project_find", m_projectSearch);
953 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
954 m_projectSearch->setShortcut(Qt::Key_Slash);
956 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
957 collection->addAction("project_find_next", m_projectSearchNext);
958 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
959 m_projectSearchNext->setShortcut(Qt::Key_F3);
960 m_projectSearchNext->setEnabled(false);
962 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
963 collection->addAction("manage_profiles", profilesAction);
964 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
966 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
968 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
970 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
972 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
974 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
975 collection->addAction("run_wizard", wizAction);
976 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
978 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
979 collection->addAction("project_settings", projectAction);
980 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
982 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
983 collection->addAction("project_render", projectRender);
984 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
985 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
987 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
988 collection->addAction("project_clean", projectClean);
989 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
991 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
992 KShortcut playShortcut;
993 playShortcut.setPrimary(Qt::Key_Space);
994 playShortcut.setAlternate(Qt::Key_K);
995 monitorPlay->setShortcut(playShortcut);
996 collection->addAction("monitor_play", monitorPlay);
997 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
999 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1000 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1001 collection->addAction("monitor_play_zone", m_playZone);
1002 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1004 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1005 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1006 collection->addAction("monitor_loop_zone", m_loopZone);
1007 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1009 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1010 collection->addAction("dvd_wizard", dvdWizard);
1011 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1013 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1014 collection->addAction("transcode_clip", transcodeClip);
1015 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1017 KAction *markIn = collection->addAction("mark_in");
1018 markIn->setText(i18n("Set Zone In"));
1019 markIn->setShortcut(Qt::Key_I);
1020 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1022 KAction *markOut = collection->addAction("mark_out");
1023 markOut->setText(i18n("Set Zone Out"));
1024 markOut->setShortcut(Qt::Key_O);
1025 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1027 KAction *switchMon = collection->addAction("switch_monitor");
1028 switchMon->setText(i18n("Switch monitor"));
1029 switchMon->setShortcut(Qt::Key_T);
1030 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1032 KAction *insertTree = collection->addAction("insert_project_tree");
1033 insertTree->setText(i18n("Insert zone in project tree"));
1034 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1035 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1037 KAction *insertTimeline = collection->addAction("insert_timeline");
1038 insertTimeline->setText(i18n("Insert zone in timeline"));
1039 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1040 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1042 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1043 collection->addAction("resize_timeline_clip_start", resizeStart);
1044 resizeStart->setShortcut(Qt::Key_1);
1045 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1047 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1048 collection->addAction("resize_timeline_clip_end", resizeEnd);
1049 resizeEnd->setShortcut(Qt::Key_2);
1050 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1052 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1053 monitorSeekBackward->setShortcut(Qt::Key_J);
1054 collection->addAction("monitor_seek_backward", monitorSeekBackward);
1055 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1057 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1058 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1059 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1060 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1062 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1063 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1064 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1065 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1067 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1068 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1069 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1070 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1072 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1073 monitorSeekForward->setShortcut(Qt::Key_L);
1074 collection->addAction("monitor_seek_forward", monitorSeekForward);
1075 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1077 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1078 clipStart->setShortcut(Qt::Key_Home);
1079 collection->addAction("seek_clip_start", clipStart);
1080 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1082 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1083 clipEnd->setShortcut(Qt::Key_End);
1084 collection->addAction("seek_clip_end", clipEnd);
1085 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1087 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1088 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1089 collection->addAction("seek_zone_start", zoneStart);
1090 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1092 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1093 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1094 collection->addAction("seek_zone_end", zoneEnd);
1095 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1097 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1098 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1099 collection->addAction("seek_start", projectStart);
1100 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1102 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1103 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1104 collection->addAction("seek_end", projectEnd);
1105 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1107 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1108 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1109 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1110 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1112 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1113 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1114 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1115 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1117 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1118 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1119 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1120 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1122 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1123 deleteTimelineClip->setShortcut(Qt::Key_Delete);
1124 collection->addAction("delete_timeline_clip", deleteTimelineClip);
1125 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
1127 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1128 collection->addAction("change_clip_speed", editTimelineClipSpeed);
1129 editTimelineClipSpeed->setData("change_speed");
1130 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1132 KAction *stickTransition = collection->addAction("auto_transition");
1133 stickTransition->setData(QString("auto"));
1134 stickTransition->setCheckable(true);
1135 stickTransition->setEnabled(false);
1136 stickTransition->setText(i18n("Automatic Transition"));
1137 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1139 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1140 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1141 collection->addAction("group_clip", groupClip);
1142 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1144 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1145 collection->addAction("ungroup_clip", ungroupClip);
1146 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1147 ungroupClip->setData("ungroup_clip");
1148 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1150 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1151 collection->addAction("edit_item_duration", editItemDuration);
1152 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1154 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1155 collection->addAction("clip_in_project_tree", clipInProjectTree);
1156 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1158 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1159 insertOvertwrite->setShortcut(Qt::Key_V);
1160 collection->addAction("overwrite_to_in_point", insertOvertwrite);
1161 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1163 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1164 selectTimelineClip->setShortcut(Qt::Key_Plus);
1165 collection->addAction("select_timeline_clip", selectTimelineClip);
1166 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1168 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1169 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1170 collection->addAction("deselect_timeline_clip", deselectTimelineClip);
1171 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1173 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1174 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1175 collection->addAction("select_add_timeline_clip", selectAddTimelineClip);
1176 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1178 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1179 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1180 collection->addAction("select_timeline_transition", selectTimelineTransition);
1181 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1183 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1184 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1185 collection->addAction("deselect_timeline_transition", deselectTimelineTransition);
1186 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1188 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1189 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1190 collection->addAction("select_add_timeline_transition", selectAddTimelineTransition);
1191 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1193 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1194 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1195 collection->addAction("cut_timeline_clip", cutTimelineClip);
1196 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1198 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1199 collection->addAction("add_clip_marker", addClipMarker);
1200 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1202 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1203 collection->addAction("delete_clip_marker", deleteClipMarker);
1204 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1206 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1207 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
1208 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1210 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1211 collection->addAction("edit_clip_marker", editClipMarker);
1212 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1214 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1215 collection->addAction("split_audio", splitAudio);
1216 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1218 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1219 collection->addAction("clip_audio_only", audioOnly);
1220 audioOnly->setData("clip_audio_only");
1221 audioOnly->setCheckable(true);
1223 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1224 collection->addAction("clip_video_only", videoOnly);
1225 videoOnly->setData("clip_video_only");
1226 videoOnly->setCheckable(true);
1228 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1229 collection->addAction("clip_audio_and_video", audioAndVideo);
1230 audioAndVideo->setData("clip_audio_and_video");
1231 audioAndVideo->setCheckable(true);
1233 m_clipTypeGroup = new QActionGroup(this);
1234 m_clipTypeGroup->addAction(audioOnly);
1235 m_clipTypeGroup->addAction(videoOnly);
1236 m_clipTypeGroup->addAction(audioAndVideo);
1237 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1238 m_clipTypeGroup->setEnabled(false);
1240 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1241 collection->addAction("insert_space", insertSpace);
1242 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1244 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1245 collection->addAction("delete_space", removeSpace);
1246 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1248 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1249 collection->addAction("insert_track", insertTrack);
1250 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1252 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1253 collection->addAction("delete_track", deleteTrack);
1254 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1256 KAction *changeTrack = new KAction(KIcon(), i18n("Change Track"), this);
1257 collection->addAction("change_track", changeTrack);
1258 connect(changeTrack, SIGNAL(triggered()), this, SLOT(slotChangeTrack()));
1260 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1261 collection->addAction("add_guide", addGuide);
1262 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1264 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1265 collection->addAction("delete_guide", delGuide);
1266 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1268 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1269 collection->addAction("edit_guide", editGuide);
1270 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1272 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1273 collection->addAction("delete_all_guides", delAllGuides);
1274 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1276 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1277 collection->addAction("paste_effects", pasteEffects);
1278 pasteEffects->setData("paste_effects");
1279 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1281 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1282 collection->addAction("show_timeline", showTimeline);
1283 showTimeline->setCheckable(true);
1284 showTimeline->setChecked(true);
1285 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1287 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1288 collection->addAction("show_titlebars", showTitleBar);
1289 showTitleBar->setCheckable(true);
1290 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1291 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1292 slotShowTitleBars(KdenliveSettings::showtitlebars());
1294 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1295 collection->addAction("maximize_current", maxCurrent);
1296 maxCurrent->setCheckable(true);
1297 maxCurrent->setChecked(false);
1298 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1301 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1303 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1305 KStandardAction::open(this, SLOT(openFile()), collection);
1307 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1309 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1311 KStandardAction::openNew(this, SLOT(newFile()), collection);
1313 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1315 KStandardAction::configureNotifications(this , SLOT(configureNotifications()), collection);
1317 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1319 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1321 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1322 undo->setEnabled(false);
1323 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1325 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1326 redo->setEnabled(false);
1327 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1329 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1332 //TODO: Add status tooltip to actions ?
1333 connect(collection, SIGNAL(actionHovered(QAction*)),
1334 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1337 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1338 collection->addAction("add_clip", addClip);
1339 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1341 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1342 collection->addAction("add_color_clip", addColorClip);
1343 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1345 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1346 collection->addAction("add_slide_clip", addSlideClip);
1347 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1349 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1350 collection->addAction("add_text_clip", addTitleClip);
1351 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1353 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1354 collection->addAction("add_text_template_clip", addTitleTemplateClip);
1355 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1357 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1358 collection->addAction("add_folder", addFolderButton);
1359 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1361 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1362 collection->addAction("clip_properties", clipProperties);
1363 clipProperties->setData("clip_properties");
1364 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1365 clipProperties->setEnabled(false);
1367 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1368 collection->addAction("edit_clip", openClip);
1369 openClip->setData("edit_clip");
1370 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1371 openClip->setEnabled(false);
1373 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1374 collection->addAction("delete_clip", deleteClip);
1375 deleteClip->setData("delete_clip");
1376 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1377 deleteClip->setEnabled(false);
1379 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1380 collection->addAction("reload_clip", reloadClip);
1381 reloadClip->setData("reload_clip");
1382 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1383 reloadClip->setEnabled(false);
1385 QMenu *addClips = new QMenu();
1386 addClips->addAction(addClip);
1387 addClips->addAction(addColorClip);
1388 addClips->addAction(addSlideClip);
1389 addClips->addAction(addTitleClip);
1390 addClips->addAction(addTitleTemplateClip);
1391 addClips->addAction(addFolderButton);
1393 addClips->addAction(reloadClip);
1394 addClips->addAction(clipProperties);
1395 addClips->addAction(openClip);
1396 addClips->addAction(deleteClip);
1397 m_projectList->setupMenu(addClips, addClip);
1399 //connect(collection, SIGNAL( clearStatusText() ),
1400 //statusBar(), SLOT( clear() ) );
1403 void MainWindow::slotDisplayActionMessage(QAction *a)
1405 statusBar()->showMessage(a->data().toString(), 3000);
1408 void MainWindow::saveOptions()
1410 KdenliveSettings::self()->writeConfig();
1411 KSharedConfigPtr config = KGlobal::config();
1412 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1413 KConfigGroup treecolumns(config, "Project Tree");
1414 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1418 void MainWindow::readOptions()
1420 KSharedConfigPtr config = KGlobal::config();
1421 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1422 KConfigGroup initialGroup(config, "version");
1423 bool upgrade = false;
1424 if (initialGroup.exists()) {
1425 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1429 if (initialGroup.readEntry("version") == "0.7") {
1430 //Add new settings from 0.7.1
1431 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1432 QString path = QDir::homePath() + "/kdenlive";
1433 if (KStandardDirs::makeDir(path) == false) {
1434 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1435 } else KdenliveSettings::setDefaultprojectfolder(path);
1441 if (!initialGroup.exists() || upgrade) {
1442 // this is our first run, show Wizard
1443 Wizard *w = new Wizard(upgrade, this);
1444 if (w->exec() == QDialog::Accepted && w->isOk()) {
1445 w->adjustSettings();
1446 initialGroup.writeEntry("version", version);
1452 KConfigGroup treecolumns(config, "Project Tree");
1453 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1454 if (!state.isEmpty())
1455 m_projectList->setHeaderInfo(state);
1458 void MainWindow::slotRunWizard()
1460 Wizard *w = new Wizard(false, this);
1461 if (w->exec() == QDialog::Accepted && w->isOk()) {
1462 w->adjustSettings();
1467 void MainWindow::newFile(bool showProjectSettings, bool force)
1469 if (!m_timelineArea->isEnabled() && !force) return;
1470 m_fileRevert->setEnabled(false);
1471 QString profileName;
1473 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1474 if (!showProjectSettings) {
1475 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1476 profileName = KdenliveSettings::default_profile();
1477 projectFolder = KdenliveSettings::defaultprojectfolder();
1479 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1480 if (w->exec() != QDialog::Accepted) return;
1481 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1482 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
1483 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
1484 profileName = w->selectedProfile();
1485 projectFolder = w->selectedFolder();
1486 projectTracks = w->tracks();
1489 m_timelineArea->setEnabled(true);
1490 m_projectList->setEnabled(true);
1491 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1492 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1494 TrackView *trackView = new TrackView(doc, &ok, this);
1495 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1498 //m_timelineArea->setEnabled(false);
1499 //m_projectList->setEnabled(false);
1503 if (m_timelineArea->count() == 1) {
1504 connectDocumentInfo(doc);
1505 connectDocument(trackView, doc);
1506 } else m_timelineArea->setTabBarHidden(false);
1507 m_monitorManager->activateMonitor("clip");
1508 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1511 void MainWindow::activateDocument()
1513 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1514 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1515 KdenliveDoc *currentDoc = currentTab->document();
1516 connectDocumentInfo(currentDoc);
1517 connectDocument(currentTab, currentDoc);
1520 void MainWindow::closeCurrentDocument(bool saveChanges)
1522 QWidget *w = m_timelineArea->currentWidget();
1524 // closing current document
1525 int ix = m_timelineArea->currentIndex() + 1;
1526 if (ix == m_timelineArea->count()) ix = 0;
1527 m_timelineArea->setCurrentIndex(ix);
1528 TrackView *tabToClose = (TrackView *) w;
1529 KdenliveDoc *docToClose = tabToClose->document();
1530 if (docToClose && docToClose->isModified() && saveChanges) {
1531 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
1532 case KMessageBox::Yes :
1533 // save document here. If saving fails, return false;
1534 if (saveFile() == false) return;
1536 case KMessageBox::Cancel :
1543 m_clipMonitor->slotSetXml(NULL);
1544 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1545 if (m_timelineArea->count() == 1) {
1546 m_timelineArea->setTabBarHidden(true);
1547 m_closeAction->setEnabled(false);
1549 if (docToClose == m_activeDocument) {
1550 delete m_activeDocument;
1551 m_activeDocument = NULL;
1552 m_effectStack->clear();
1553 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1554 } else delete docToClose;
1555 if (w == m_activeTimeline) {
1556 delete m_activeTimeline;
1557 m_activeTimeline = NULL;
1561 bool MainWindow::saveFileAs(const QString &outputFileName)
1563 QString currentSceneList;
1564 m_monitorManager->stopActiveMonitor();
1565 if (KdenliveSettings::dropbframes()) {
1566 KdenliveSettings::setDropbframes(false);
1567 m_activeDocument->clipManager()->updatePreviewSettings();
1568 currentSceneList = m_projectMonitor->sceneList();
1569 KdenliveSettings::setDropbframes(true);
1570 m_activeDocument->clipManager()->updatePreviewSettings();
1571 } else currentSceneList = m_projectMonitor->sceneList();
1573 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1576 // Save timeline thumbnails
1577 m_activeTimeline->projectView()->saveThumbnails();
1578 m_activeDocument->setUrl(KUrl(outputFileName));
1579 if (m_activeDocument->m_autosave == NULL) {
1580 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1581 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1582 setCaption(m_activeDocument->description());
1583 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1584 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1585 m_activeDocument->setModified(false);
1586 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1587 m_fileRevert->setEnabled(true);
1591 bool MainWindow::saveFileAs()
1593 // Check that the Kdenlive mime type is correctly installed
1594 QString mimetype = "application/x-kdenlive";
1595 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1596 if (!mime) mimetype = "*.kdenlive";
1598 QString outputFile = KFileDialog::getSaveFileName(KUrl(), mimetype);
1599 if (outputFile.isEmpty()) return false;
1600 if (QFile::exists(outputFile)) {
1601 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it?")) == KMessageBox::No) return false;
1603 return saveFileAs(outputFile);
1606 bool MainWindow::saveFile()
1608 if (!m_activeDocument) return true;
1609 if (m_activeDocument->url().isEmpty()) {
1610 return saveFileAs();
1612 bool result = saveFileAs(m_activeDocument->url().path());
1613 m_activeDocument->m_autosave->resize(0);
1618 void MainWindow::openFile()
1620 if (!m_startUrl.isEmpty()) {
1621 openFile(m_startUrl);
1622 m_startUrl = KUrl();
1625 // Check that the Kdenlive mime type is correctly installed
1626 QString mimetype = "application/x-kdenlive";
1627 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1628 if (!mime) mimetype = "*.kdenlive";
1630 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), mimetype);
1631 if (url.isEmpty()) return;
1632 m_fileOpenRecent->addUrl(url);
1636 void MainWindow::openLastFile()
1638 KSharedConfigPtr config = KGlobal::config();
1639 KUrl::List urls = m_fileOpenRecent->urls();
1640 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1641 if (urls.isEmpty()) newFile(false);
1642 else openFile(urls.last());
1645 void MainWindow::openFile(const KUrl &url)
1647 // Check if the document is already opened
1648 const int ct = m_timelineArea->count();
1649 bool isOpened = false;
1651 for (i = 0; i < ct; i++) {
1652 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1653 KdenliveDoc *doc = tab->document();
1654 if (doc->url() == url) {
1660 m_timelineArea->setCurrentIndex(i);
1664 // Check for backup file
1665 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1666 if (!staleFiles.isEmpty()) {
1667 if (KMessageBox::questionYesNo(this,
1668 i18n("Auto-saved files exist. Do you want to recover them now?"),
1669 i18n("File Recovery"),
1670 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1671 recoverFiles(staleFiles);
1674 // remove the stale files
1675 foreach(KAutoSaveFile *stale, staleFiles) {
1676 stale->open(QIODevice::ReadWrite);
1681 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1682 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
1683 m_messageLabel->repaint();
1684 doOpenFile(url, NULL);
1687 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1689 if (!m_timelineArea->isEnabled()) return;
1690 m_fileRevert->setEnabled(true);
1691 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, this);
1692 if (stale == NULL) {
1693 stale = new KAutoSaveFile(url, doc);
1694 doc->m_autosave = stale;
1696 doc->m_autosave = stale;
1697 doc->setUrl(stale->managedFile());
1698 doc->setModified(true);
1699 stale->setParent(doc);
1701 connectDocumentInfo(doc);
1703 TrackView *trackView = new TrackView(doc, &ok, this);
1704 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1706 m_timelineArea->setEnabled(false);
1707 m_projectList->setEnabled(false);
1708 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
1709 slotGotProgressInfo(QString(), -1);
1710 newFile(false, true);
1713 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1714 trackView->setDuration(trackView->duration());
1715 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1717 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1718 slotGotProgressInfo(QString(), -1);
1719 m_projectMonitor->adjustRulerSize(trackView->duration());
1720 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1721 m_clipMonitor->refreshMonitor(true);
1724 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1726 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1727 foreach(KAutoSaveFile *stale, staleFiles) {
1728 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1729 // show an error message; we could not steal the lockfile
1730 // maybe another application got to the file before us?
1734 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1735 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
1736 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1737 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1742 void MainWindow::parseProfiles(const QString &mltPath)
1744 // kDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
1746 //KdenliveSettings::setDefaulttmpfolder();
1747 if (!mltPath.isEmpty()) {
1748 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1749 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
1752 if (KdenliveSettings::mltpath().isEmpty()) {
1753 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1755 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
1756 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
1757 if (!QFile::exists(meltPath))
1758 meltPath = KStandardDirs::findExe("melt");
1759 KdenliveSettings::setRendererpath(meltPath);
1761 QStringList profilesFilter;
1762 profilesFilter << "*";
1763 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1765 if (profilesList.isEmpty()) {
1766 // Cannot find MLT path, try finding melt
1767 QString profilePath = KdenliveSettings::rendererpath();
1768 if (!profilePath.isEmpty()) {
1769 profilePath = profilePath.section('/', 0, -3);
1770 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1771 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1774 if (profilesList.isEmpty()) {
1775 // Cannot find the MLT profiles, ask for location
1776 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1777 getUrl->fileDialog()->setMode(KFile::Directory);
1778 if (getUrl->exec() == QDialog::Rejected) {
1781 KUrl mltPath = getUrl->selectedUrl();
1783 if (mltPath.isEmpty()) ::exit(0);
1784 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
1785 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1789 if (KdenliveSettings::rendererpath().isEmpty()) {
1790 // Cannot find the MLT melt renderer, ask for location
1791 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of Mlt)"), this);
1792 if (getUrl->exec() == QDialog::Rejected) {
1795 KUrl rendererPath = getUrl->selectedUrl();
1797 if (rendererPath.isEmpty()) ::exit(0);
1798 KdenliveSettings::setRendererpath(rendererPath.path());
1801 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1803 // Parse MLT profiles to build a list of available video formats
1804 if (profilesList.isEmpty()) parseProfiles();
1808 void MainWindow::slotEditProfiles()
1810 ProfilesDialog *w = new ProfilesDialog;
1811 if (w->exec() == QDialog::Accepted) {
1812 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1813 if (d) d->checkProfile();
1818 void MainWindow::slotDetectAudioDriver()
1820 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
1821 leading to no audio output, see bug #934 */
1823 //decide which audio driver is really best, in some cases SDL is wrong
1824 if (KdenliveSettings::audiodrivername().isEmpty()) {
1826 KProcess readProcess;
1827 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
1828 if (!KStandardDirs::findExe("pactl").isEmpty()) {
1829 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
1830 readProcess.setProgram("pactl", QStringList() << "stat");
1831 readProcess.execute(2000); // Kill it after 2 seconds
1833 QString result = QString(readProcess.readAllStandardOutput());
1834 kDebug() << "// / / / / / READING PACTL: ";
1836 if (!result.isEmpty()) {
1838 kDebug() << "// / / / / PULSEAUDIO DETECTED";
1842 KdenliveSettings::setAutoaudiodrivername(driver);
1846 void MainWindow::slotEditProjectSettings()
1848 QPoint p = m_activeDocument->getTracksCount();
1849 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
1851 if (w->exec() == QDialog::Accepted) {
1852 QString profile = w->selectedProfile();
1853 m_activeDocument->setProjectFolder(w->selectedFolder());
1854 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path(KUrl::AddTrailingSlash));
1855 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
1856 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
1857 if (m_activeDocument->profilePath() != profile) {
1858 // Profile was changed
1859 double dar = m_activeDocument->dar();
1861 // Deselect current effect / transition
1862 m_effectStack->slotClipItemSelected(NULL, 0);
1863 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1864 m_clipMonitor->slotSetXml(NULL);
1865 bool updateFps = m_activeDocument->setProfilePath(profile);
1866 KdenliveSettings::setCurrent_profile(profile);
1867 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1868 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1870 m_activeDocument->clipManager()->clearUnusedProducers();
1871 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1873 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
1874 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
1875 m_projectList->updateProjectFormat(m_activeDocument->timecode());
1876 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1877 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1878 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1879 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
1880 if (updateFps) m_activeTimeline->updateProjectFps();
1881 m_activeDocument->setModified(true);
1882 m_commandStack->activeStack()->clear();
1883 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
1884 slotUpdateMousePosition(0);
1885 // We need to desactivate & reactivate monitors to get a refresh
1886 //m_monitorManager->switchMonitors();
1893 void MainWindow::slotRenderProject()
1895 if (!m_renderWidget) {
1896 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
1897 m_renderWidget = new RenderWidget(projectfolder, this);
1898 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
1899 connect(m_renderWidget, SIGNAL(selectedRenderProfile(const QString &, const QString &, const QString &, const QString&)), this, SLOT(slotSetDocumentRenderProfile(const QString &, const QString &, const QString &, const QString&)));
1900 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
1901 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1902 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1903 if (m_activeDocument) {
1904 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1905 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1906 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
1907 m_renderWidget->setRenderProfile(m_activeDocument->getDocumentProperty("renderdestination"), m_activeDocument->getDocumentProperty("rendercategory"), m_activeDocument->getDocumentProperty("renderprofile"), m_activeDocument->getDocumentProperty("renderurl"));
1910 slotCheckRenderStatus();
1911 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1912 if (currentTab) m_renderWidget->setTimeline(currentTab);
1913 m_renderWidget->setDocument(m_activeDocument);*/
1914 m_renderWidget->show();
1915 m_renderWidget->showNormal();
1918 void MainWindow::slotCheckRenderStatus()
1920 // Make sure there are no missing clips
1921 if (m_renderWidget) m_renderWidget->missingClips(m_projectList->hasMissingClips());
1924 void MainWindow::setRenderingProgress(const QString &url, int progress)
1926 if (m_renderWidget) m_renderWidget->setRenderJob(url, progress);
1929 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
1931 if (m_renderWidget) m_renderWidget->setRenderStatus(url, status, error);
1934 void MainWindow::slotCleanProject()
1936 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
1937 m_projectList->cleanup();
1940 void MainWindow::slotUpdateMousePosition(int pos)
1942 if (m_activeDocument)
1943 switch (m_timecodeFormat->currentIndex()) {
1945 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1948 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1952 void MainWindow::slotUpdateDocumentState(bool modified)
1954 if (!m_activeDocument) return;
1955 setCaption(m_activeDocument->description(), modified);
1956 m_saveAction->setEnabled(modified);
1958 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1959 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1961 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1962 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1966 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
1968 if (m_activeDocument) {
1969 if (m_activeDocument == doc) return;
1970 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1972 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1975 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
1977 //m_projectMonitor->stop();
1978 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1979 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1980 if (m_activeDocument) {
1981 if (m_activeDocument == doc) return;
1982 if (m_activeTimeline) {
1983 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1984 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1985 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1986 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1987 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
1989 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1990 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1991 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1992 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1993 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1994 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1995 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1996 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1997 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1998 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
1999 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2000 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2001 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
2002 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2003 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2004 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2005 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2006 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2007 disconnect(m_activeTimeline, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
2008 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2009 disconnect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
2010 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
2011 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
2012 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
2013 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2014 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2015 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2016 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2017 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2018 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2019 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2020 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2021 disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2022 disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2023 m_effectStack->clear();
2025 //m_activeDocument->setRenderer(NULL);
2026 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
2027 disconnect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2028 m_clipMonitor->stop();
2030 KdenliveSettings::setCurrent_profile(doc->profilePath());
2031 KdenliveSettings::setProject_fps(doc->fps());
2032 m_monitorManager->resetProfiles(doc->timecode());
2033 m_projectList->setDocument(doc);
2034 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2035 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2036 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint)));
2037 connect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2038 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), trackView->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2040 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2041 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2043 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
2046 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2047 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2048 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2049 connect(trackView, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
2050 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2051 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2052 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2053 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2054 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
2055 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2056 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
2058 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2059 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2060 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
2061 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2062 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2064 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
2065 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2066 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2069 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2070 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2072 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2073 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2074 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2075 m_zoomSlider->setValue(doc->zoom().x());
2076 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
2077 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2078 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2079 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2080 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2082 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2083 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2086 connect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
2087 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
2088 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
2089 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
2090 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2091 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2092 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2093 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2094 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2096 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2097 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2098 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2099 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2100 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2103 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2104 m_activeTimeline = trackView;
2105 if (m_renderWidget) {
2106 slotCheckRenderStatus();
2107 m_renderWidget->setProfile(doc->mltProfile());
2108 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2109 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2110 m_renderWidget->setRenderProfile(doc->getDocumentProperty("renderdestination"), doc->getDocumentProperty("rendercategory"), doc->getDocumentProperty("renderprofile"), doc->getDocumentProperty("renderurl"));
2112 //doc->setRenderer(m_projectMonitor->render);
2113 m_commandStack->setActiveStack(doc->commandStack());
2114 KdenliveSettings::setProject_display_ratio(doc->dar());
2115 //doc->clipManager()->checkAudioThumbs();
2117 //m_overView->setScene(trackView->projectScene());
2118 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2119 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2121 setCaption(doc->description(), doc->isModified());
2122 m_saveAction->setEnabled(doc->isModified());
2123 m_normalEditTool->setChecked(true);
2124 m_activeDocument = doc;
2125 m_activeTimeline->updateProjectFps();
2126 m_activeDocument->checkProjectClips();
2127 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
2128 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2129 slotUpdateMousePosition(0);
2130 // set tool to select tool
2131 m_buttonSelectTool->setChecked(true);
2134 void MainWindow::slotZoneMoved(int start, int end)
2136 m_activeDocument->setZone(start, end);
2137 m_projectMonitor->slotZoneMoved(start, end);
2140 void MainWindow::slotGuidesUpdated()
2142 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2145 void MainWindow::slotPreferences(int page, int option)
2147 //An instance of your dialog could be already created and could be
2148 // cached, in which case you want to display the cached dialog
2149 // instead of creating another one
2150 if (KConfigDialog::showDialog("settings")) {
2151 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2152 if (page != -1) d->showPage(page, option);
2156 // KConfigDialog didn't find an instance of this dialog, so lets
2158 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
2159 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2160 //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
2161 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2162 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2164 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
2166 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2168 if (page != -1) dialog->showPage(page, option);
2171 void MainWindow::slotUpdatePreviewSettings()
2173 if (m_activeDocument) {
2174 m_clipMonitor->slotSetXml(NULL);
2175 m_activeDocument->updatePreviewSettings();
2179 void MainWindow::updateConfiguration()
2181 //TODO: we should apply settings to all projects, not only the current one
2182 if (m_activeTimeline) {
2183 m_activeTimeline->refresh();
2184 m_activeTimeline->projectView()->checkAutoScroll();
2185 m_activeTimeline->projectView()->checkTrackHeight();
2186 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
2188 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2189 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2191 // Update list of transcoding profiles
2193 #ifndef NO_JOGSHUTTLE
2194 activateShuttleDevice();
2195 #endif /* NO_JOGSHUTTLE */
2200 void MainWindow::slotSwitchVideoThumbs()
2202 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2203 if (m_activeTimeline) {
2204 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2206 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2209 void MainWindow::slotSwitchAudioThumbs()
2211 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2212 if (m_activeTimeline) {
2213 m_activeTimeline->refresh();
2214 m_activeTimeline->projectView()->checkAutoScroll();
2215 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
2217 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2220 void MainWindow::slotSwitchMarkersComments()
2222 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2223 if (m_activeTimeline) {
2224 m_activeTimeline->refresh();
2226 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2229 void MainWindow::slotSwitchSnap()
2231 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2232 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2236 void MainWindow::slotDeleteTimelineClip()
2238 if (QApplication::focusWidget() && QApplication::focusWidget()->parentWidget() && QApplication::focusWidget()->parentWidget()->parentWidget() && QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) m_projectList->slotRemoveClip();
2239 else if (m_activeTimeline) {
2240 m_activeTimeline->projectView()->deleteSelectedClips();
2244 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2246 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2247 m_clipMonitor->updateMarkers(clip);
2250 void MainWindow::slotAddClipMarker()
2252 DocClipBase *clip = NULL;
2254 if (m_projectMonitor->isActive()) {
2255 if (m_activeTimeline) {
2256 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2258 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2259 clip = item->baseClip();
2263 clip = m_clipMonitor->activeClip();
2264 pos = m_clipMonitor->position();
2267 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2270 QString id = clip->getId();
2271 CommentedTime marker(pos, i18n("Marker"));
2272 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2273 if (d.exec() == QDialog::Accepted) {
2274 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2278 void MainWindow::slotDeleteClipMarker()
2280 DocClipBase *clip = NULL;
2282 if (m_projectMonitor->isActive()) {
2283 if (m_activeTimeline) {
2284 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2286 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2287 clip = item->baseClip();
2291 clip = m_clipMonitor->activeClip();
2292 pos = m_clipMonitor->position();
2295 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2299 QString id = clip->getId();
2300 QString comment = clip->markerComment(pos);
2301 if (comment.isEmpty()) {
2302 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2305 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2308 void MainWindow::slotDeleteAllClipMarkers()
2310 DocClipBase *clip = NULL;
2311 if (m_projectMonitor->isActive()) {
2312 if (m_activeTimeline) {
2313 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2315 clip = item->baseClip();
2319 clip = m_clipMonitor->activeClip();
2322 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2325 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2328 void MainWindow::slotEditClipMarker()
2330 DocClipBase *clip = NULL;
2332 if (m_projectMonitor->isActive()) {
2333 if (m_activeTimeline) {
2334 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2336 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2337 clip = item->baseClip();
2341 clip = m_clipMonitor->activeClip();
2342 pos = m_clipMonitor->position();
2345 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2349 QString id = clip->getId();
2350 QString oldcomment = clip->markerComment(pos);
2351 if (oldcomment.isEmpty()) {
2352 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2356 CommentedTime marker(pos, oldcomment);
2357 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2358 if (d.exec() == QDialog::Accepted) {
2359 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2360 if (d.newMarker().time() != pos) {
2361 // remove old marker
2362 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2367 void MainWindow::slotAddGuide()
2369 if (m_activeTimeline)
2370 m_activeTimeline->projectView()->slotAddGuide();
2373 void MainWindow::slotInsertSpace()
2375 if (m_activeTimeline)
2376 m_activeTimeline->projectView()->slotInsertSpace();
2379 void MainWindow::slotRemoveSpace()
2381 if (m_activeTimeline)
2382 m_activeTimeline->projectView()->slotRemoveSpace();
2385 void MainWindow::slotInsertTrack(int ix)
2387 m_projectMonitor->activateMonitor();
2388 if (m_activeTimeline)
2389 m_activeTimeline->projectView()->slotInsertTrack(ix);
2390 if (m_activeDocument)
2391 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2394 void MainWindow::slotDeleteTrack(int ix)
2396 m_projectMonitor->activateMonitor();
2397 if (m_activeTimeline)
2398 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2399 if (m_activeDocument)
2400 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2403 void MainWindow::slotChangeTrack(int ix)
2405 m_projectMonitor->activateMonitor();
2406 if (m_activeTimeline)
2407 m_activeTimeline->projectView()->slotChangeTrack(ix);
2410 void MainWindow::slotEditGuide()
2412 if (m_activeTimeline)
2413 m_activeTimeline->projectView()->slotEditGuide();
2416 void MainWindow::slotDeleteGuide()
2418 if (m_activeTimeline)
2419 m_activeTimeline->projectView()->slotDeleteGuide();
2422 void MainWindow::slotDeleteAllGuides()
2424 if (m_activeTimeline)
2425 m_activeTimeline->projectView()->slotDeleteAllGuides();
2428 void MainWindow::slotCutTimelineClip()
2430 if (m_activeTimeline) {
2431 m_activeTimeline->projectView()->cutSelectedClips();
2435 void MainWindow::slotInsertClipOverwrite()
2437 if (m_activeTimeline) {
2438 QStringList data = m_clipMonitor->getZoneInfo();
2439 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2443 void MainWindow::slotSelectTimelineClip()
2445 if (m_activeTimeline) {
2446 m_activeTimeline->projectView()->selectClip(true);
2450 void MainWindow::slotSelectTimelineTransition()
2452 if (m_activeTimeline) {
2453 m_activeTimeline->projectView()->selectTransition(true);
2457 void MainWindow::slotDeselectTimelineClip()
2459 if (m_activeTimeline) {
2460 m_activeTimeline->projectView()->selectClip(false, true);
2464 void MainWindow::slotDeselectTimelineTransition()
2466 if (m_activeTimeline) {
2467 m_activeTimeline->projectView()->selectTransition(false, true);
2471 void MainWindow::slotSelectAddTimelineClip()
2473 if (m_activeTimeline) {
2474 m_activeTimeline->projectView()->selectClip(true, true);
2478 void MainWindow::slotSelectAddTimelineTransition()
2480 if (m_activeTimeline) {
2481 m_activeTimeline->projectView()->selectTransition(true, true);
2485 void MainWindow::slotGroupClips()
2487 if (m_activeTimeline) {
2488 m_activeTimeline->projectView()->groupClips();
2492 void MainWindow::slotUnGroupClips()
2494 if (m_activeTimeline) {
2495 m_activeTimeline->projectView()->groupClips(false);
2499 void MainWindow::slotEditItemDuration()
2501 if (m_activeTimeline) {
2502 m_activeTimeline->projectView()->editItemDuration();
2506 void MainWindow::slotAddProjectClip(KUrl url)
2508 if (m_activeDocument)
2509 m_activeDocument->slotAddClipFile(url, QString());
2512 void MainWindow::slotAddTransition(QAction *result)
2514 if (!result) return;
2515 QStringList info = result->data().toStringList();
2516 if (info.isEmpty()) return;
2517 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2518 if (m_activeTimeline && !transition.isNull()) {
2519 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2523 void MainWindow::slotAddVideoEffect(QAction *result)
2525 if (!result) return;
2526 QStringList info = result->data().toStringList();
2527 if (info.isEmpty()) return;
2528 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2529 slotAddEffect(effect);
2532 void MainWindow::slotAddAudioEffect(QAction *result)
2534 if (!result) return;
2535 QStringList info = result->data().toStringList();
2536 if (info.isEmpty()) return;
2537 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2538 slotAddEffect(effect);
2541 void MainWindow::slotAddCustomEffect(QAction *result)
2543 if (!result) return;
2544 QStringList info = result->data().toStringList();
2545 if (info.isEmpty()) return;
2546 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2547 slotAddEffect(effect);
2550 void MainWindow::slotZoomIn()
2552 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2555 void MainWindow::slotZoomOut()
2557 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2560 void MainWindow::slotFitZoom()
2562 if (m_activeTimeline) {
2563 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2567 void MainWindow::slotSetZoom(int value)
2569 m_zoomSlider->setValue(value);
2572 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2574 m_statusProgressBar->setValue(progress);
2575 if (progress >= 0) {
2576 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2577 m_statusProgressBar->setVisible(true);
2578 } else if (progress == -2) {
2579 if (!message.isEmpty()) m_messageLabel->setMessage(message, ErrorMessage);
2580 m_statusProgressBar->setVisible(false);
2582 m_messageLabel->setMessage(QString(), DefaultMessage);
2583 m_statusProgressBar->setVisible(false);
2587 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2589 if (clip->clipType() == TEXT) {
2590 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
2591 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
2592 // template text clip
2594 // Get the list of existing templates
2596 filter << "*.kdenlivetitle";
2597 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
2599 QDialog *dia = new QDialog(this);
2600 Ui::TemplateClip_UI dia_ui;
2601 dia_ui.setupUi(dia);
2603 const QString templatePath = clip->getProperty("resource");
2604 for (int i = 0; i < templateFiles.size(); ++i) {
2605 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
2606 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
2608 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
2609 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
2610 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
2611 //warning: setting base directory doesn't work??
2612 KUrl startDir(titlepath);
2613 dia_ui.template_list->fileDialog()->setUrl(startDir);
2614 dia_ui.description->setText(clip->getProperty("description"));
2615 if (dia->exec() == QDialog::Accepted) {
2616 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
2617 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
2619 QMap <QString, QString> newprops;
2621 if (KUrl(textTemplate).path() != templatePath) {
2622 // The template was changed
2623 newprops.insert("resource", textTemplate);
2626 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
2627 newprops.insert("description", dia_ui.description->toPlainText());
2630 QString newtemplate = newprops.value("xmltemplate");
2631 if (newtemplate.isEmpty()) newtemplate = templatePath;
2633 // template modified we need to update xmldata
2634 QString description = newprops.value("description");
2635 if (description.isEmpty()) description = clip->getProperty("description");
2636 else newprops.insert("templatetext", description);
2637 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
2638 if (!newprops.isEmpty()) {
2639 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2640 m_activeDocument->commandStack()->push(command);
2646 QString path = clip->getProperty("resource");
2647 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
2649 doc.setContent(clip->getProperty("xmldata"));
2650 dia_ui->setXml(doc);
2651 if (dia_ui->exec() == QDialog::Accepted) {
2652 QMap <QString, QString> newprops;
2653 newprops.insert("xmldata", dia_ui->xml().toString());
2654 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
2655 // duration changed, we need to update duration
2656 newprops.insert("out", QString::number(dia_ui->outPoint()));
2658 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2659 m_activeDocument->commandStack()->push(command);
2660 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
2661 m_activeDocument->setModified(true);
2665 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2668 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2669 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2670 if (dia.exec() == QDialog::Accepted) {
2671 QMap <QString, QString> newprops = dia.properties();
2672 if (newprops.isEmpty()) return;
2673 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2674 m_activeDocument->commandStack()->push(command);
2676 if (dia.needsTimelineRefresh()) {
2677 // update clip occurences in timeline
2678 m_activeTimeline->projectView()->slotUpdateClip(clip->getId(), dia.needsTimelineReload());
2684 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
2686 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
2687 if (dia.exec() == QDialog::Accepted) {
2688 QUndoCommand *command = new QUndoCommand();
2689 command->setText(i18n("Edit clips"));
2690 for (int i = 0; i < cliplist.count(); i++) {
2691 DocClipBase *clip = cliplist.at(i);
2692 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true, command);
2694 m_activeDocument->commandStack()->push(command);
2695 for (int i = 0; i < cliplist.count(); i++) {
2696 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
2701 void MainWindow::customEvent(QEvent* e)
2703 if (e->type() == QEvent::User) {
2704 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
2707 void MainWindow::slotActivateEffectStackView()
2709 m_effectStack->raiseWindow(m_effectStackDock);
2712 void MainWindow::slotActivateTransitionView(Transition *t)
2714 if (t) m_transitionConfig->raiseWindow(m_transitionConfigDock);
2717 void MainWindow::slotSnapRewind()
2719 if (m_projectMonitor->isActive()) {
2720 if (m_activeTimeline)
2721 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2722 } else m_clipMonitor->slotSeekToPreviousSnap();
2725 void MainWindow::slotSnapForward()
2727 if (m_projectMonitor->isActive()) {
2728 if (m_activeTimeline)
2729 m_activeTimeline->projectView()->slotSeekToNextSnap();
2730 } else m_clipMonitor->slotSeekToNextSnap();
2733 void MainWindow::slotClipStart()
2735 if (m_projectMonitor->isActive()) {
2736 if (m_activeTimeline)
2737 m_activeTimeline->projectView()->clipStart();
2741 void MainWindow::slotClipEnd()
2743 if (m_projectMonitor->isActive()) {
2744 if (m_activeTimeline)
2745 m_activeTimeline->projectView()->clipEnd();
2749 void MainWindow::slotZoneStart()
2751 if (m_projectMonitor->isActive()) m_projectMonitor->slotZoneStart();
2752 else m_clipMonitor->slotZoneStart();
2755 void MainWindow::slotZoneEnd()
2757 if (m_projectMonitor->isActive()) m_projectMonitor->slotZoneEnd();
2758 else m_clipMonitor->slotZoneEnd();
2761 void MainWindow::slotChangeTool(QAction * action)
2763 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
2764 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
2765 else if (action == m_buttonSpacerTool) slotSetTool(SPACERTOOL);
2768 void MainWindow::slotChangeEdit(QAction * action)
2770 if (!m_activeTimeline) return;
2771 if (action == m_overwriteEditTool) m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
2772 else if (action == m_insertEditTool) m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
2773 else m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
2776 void MainWindow::slotSetTool(PROJECTTOOL tool)
2778 if (m_activeDocument && m_activeTimeline) {
2779 //m_activeDocument->setTool(tool);
2783 message = i18n("Ctrl + click to use spacer on current track only");
2786 message = i18n("Click on a clip to cut it");
2789 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
2792 m_messageLabel->setMessage(message, InformationMessage);
2793 m_activeTimeline->projectView()->setTool(tool);
2797 void MainWindow::slotCopy()
2799 if (!m_activeDocument || !m_activeTimeline) return;
2800 m_activeTimeline->projectView()->copyClip();
2803 void MainWindow::slotPaste()
2805 if (!m_activeDocument || !m_activeTimeline) return;
2806 m_activeTimeline->projectView()->pasteClip();
2809 void MainWindow::slotPasteEffects()
2811 if (!m_activeDocument || !m_activeTimeline) return;
2812 m_activeTimeline->projectView()->pasteClipEffects();
2815 void MainWindow::slotFind()
2817 if (!m_activeDocument || !m_activeTimeline) return;
2818 m_projectSearch->setEnabled(false);
2819 m_findActivated = true;
2820 m_findString.clear();
2821 m_activeTimeline->projectView()->initSearchStrings();
2822 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2823 m_findTimer.start(5000);
2824 qApp->installEventFilter(this);
2827 void MainWindow::slotFindNext()
2829 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
2830 statusBar()->showMessage(i18n("Found: %1", m_findString));
2832 statusBar()->showMessage(i18n("Reached end of project"));
2834 m_findTimer.start(4000);
2837 void MainWindow::findAhead()
2839 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
2840 m_projectSearchNext->setEnabled(true);
2841 statusBar()->showMessage(i18n("Found: %1", m_findString));
2843 m_projectSearchNext->setEnabled(false);
2844 statusBar()->showMessage(i18n("Not found: %1", m_findString));
2848 void MainWindow::findTimeout()
2850 m_projectSearchNext->setEnabled(false);
2851 m_findActivated = false;
2852 m_findString.clear();
2853 statusBar()->showMessage(i18n("Find stopped"), 3000);
2854 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
2855 m_projectSearch->setEnabled(true);
2856 removeEventFilter(this);
2859 void MainWindow::slotClipInTimeline(const QString &clipId)
2861 if (m_activeTimeline && m_activeDocument) {
2862 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
2864 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
2865 inTimelineMenu->clear();
2867 QList <QAction *> actionList;
2869 for (int i = 0; i < matching.count(); ++i) {
2870 QString track = QString::number(matching.at(i).track);
2871 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
2873 QAction *a = new QAction(track + ": " + start, this);
2874 a->setData(QStringList() << track << start);
2875 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
2876 while (j < actionList.count()) {
2877 if (actionList.at(j)->text() > a->text()) break;
2880 actionList.insert(j, a);
2883 inTimelineMenu->addActions(actionList);
2885 if (matching.empty())
2886 inTimelineMenu->setEnabled(false);
2888 inTimelineMenu->setEnabled(true);
2892 void MainWindow::slotClipInProjectTree()
2894 if (m_activeTimeline) {
2895 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
2896 if (clipIds.isEmpty()) return;
2897 m_projectListDock->raise();
2898 for (int i = 0; i < clipIds.count(); i++) {
2899 m_projectList->selectItemById(clipIds.at(i));
2901 if (m_projectMonitor->isActive())
2902 slotSwitchMonitors();
2906 void MainWindow::slotSelectClipInTimeline()
2908 if (m_activeTimeline) {
2909 QAction *action = qobject_cast<QAction *>(sender());
2910 QStringList data = action->data().toStringList();
2911 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
2915 void MainWindow::keyPressEvent(QKeyEvent *ke)
2917 if (m_findActivated) {
2918 if (ke->key() == Qt::Key_Backspace) {
2919 m_findString = m_findString.left(m_findString.length() - 1);
2921 if (!m_findString.isEmpty()) {
2927 m_findTimer.start(4000);
2930 } else if (ke->key() == Qt::Key_Escape) {
2934 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
2935 m_findString += ke->text();
2939 m_findTimer.start(4000);
2943 } else KXmlGuiWindow::keyPressEvent(ke);
2947 /** Gets called when the window gets hidden */
2948 void MainWindow::hideEvent(QHideEvent */*event*/)
2950 // kDebug() << "I was hidden";
2951 // issue http://www.kdenlive.org/mantis/view.php?id=231
2952 if (isMinimized()) {
2953 // kDebug() << "I am minimized";
2954 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
2958 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
2960 if (m_findActivated) {
2961 if (event->type() == QEvent::ShortcutOverride) {
2962 QKeyEvent* ke = (QKeyEvent*) event;
2963 if (ke->text().trimmed().isEmpty()) return false;
2966 } else return false;
2968 // pass the event on to the parent class
2969 return QMainWindow::eventFilter(obj, event);
2974 void MainWindow::slotSaveZone(Render *render, QPoint zone)
2976 KDialog *dialog = new KDialog(this);
2977 dialog->setCaption("Save clip zone");
2978 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
2980 QWidget *widget = new QWidget(dialog);
2981 dialog->setMainWidget(widget);
2983 QVBoxLayout *vbox = new QVBoxLayout(widget);
2984 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
2985 QString path = m_activeDocument->projectFolder().path();
2987 path.append("untitled.mlt");
2988 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
2989 url->setFilter("video/mlt-playlist");
2990 QLabel *label2 = new QLabel(i18n("Description:"), this);
2991 KLineEdit *edit = new KLineEdit(this);
2992 vbox->addWidget(label1);
2993 vbox->addWidget(url);
2994 vbox->addWidget(label2);
2995 vbox->addWidget(edit);
2996 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
3000 void MainWindow::slotSetInPoint()
3002 if (m_clipMonitor->isActive()) {
3003 m_clipMonitor->slotSetZoneStart();
3004 } else m_projectMonitor->slotSetZoneStart();
3005 //else m_activeTimeline->projectView()->setInPoint();
3008 void MainWindow::slotSetOutPoint()
3010 if (m_clipMonitor->isActive()) {
3011 m_clipMonitor->slotSetZoneEnd();
3012 } else m_projectMonitor->slotSetZoneEnd();
3013 // else m_activeTimeline->projectView()->setOutPoint();
3016 void MainWindow::slotResizeItemStart()
3018 if (m_activeTimeline) m_activeTimeline->projectView()->setInPoint();
3021 void MainWindow::slotResizeItemEnd()
3023 if (m_activeTimeline) m_activeTimeline->projectView()->setOutPoint();
3026 int MainWindow::getNewStuff(const QString &configFile)
3028 KNS3::Entry::List entries;
3029 #if KDE_IS_VERSION(4,3,80)
3030 KNS3::DownloadDialog dialog(configFile);
3032 entries = dialog.changedEntries();
3033 foreach(const KNS3::Entry &entry, entries) {
3034 if (entry.status() == KNS3::Entry::Installed)
3035 kDebug() << "// Installed files: " << entry.installedFiles();
3038 KNS::Engine engine(0);
3039 if (engine.init(configFile))
3040 entries = engine.downloadDialogModal(this);
3041 foreach(KNS::Entry *entry, entries) {
3042 if (entry->status() == KNS::Entry::Installed)
3043 kDebug() << "// Installed files: " << entry->installedFiles();
3045 #endif /* KDE_IS_VERSION(4,3,80) */
3046 return entries.size();
3049 void MainWindow::slotGetNewTitleStuff()
3051 if (getNewStuff("kdenlive_titles.knsrc") > 0) {
3052 TitleWidget::refreshTitleTemplates();
3056 void MainWindow::slotGetNewLumaStuff()
3058 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3059 initEffects::refreshLumas();
3060 m_activeTimeline->projectView()->reloadTransitionLumas();
3064 void MainWindow::slotGetNewRenderStuff()
3066 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0) {
3068 m_renderWidget->reloadProfiles();
3072 void MainWindow::slotGetNewMltProfileStuff()
3074 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3075 // update the list of profiles in settings dialog
3076 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3082 void MainWindow::slotAutoTransition()
3084 if (m_activeTimeline) m_activeTimeline->projectView()->autoTransition();
3087 void MainWindow::slotSplitAudio()
3089 if (m_activeTimeline) m_activeTimeline->projectView()->splitAudio();
3092 void MainWindow::slotUpdateClipType(QAction *action)
3094 if (m_activeTimeline) {
3095 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3096 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3097 else m_activeTimeline->projectView()->setAudioAndVideo();
3101 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3103 // We must stop the monitors since we create a new on in the dvd wizard
3104 m_clipMonitor->stop();
3105 m_projectMonitor->stop();
3106 DvdWizard w(url, profile, this);
3108 m_projectMonitor->start();
3111 void MainWindow::slotShowTimeline(bool show)
3113 if (show == false) {
3114 m_timelineState = saveState();
3115 centralWidget()->setHidden(true);
3117 centralWidget()->setHidden(false);
3118 restoreState(m_timelineState);
3122 void MainWindow::slotMaximizeCurrent(bool /*show*/)
3124 //TODO: is there a way to maximize current widget?
3127 m_timelineState = saveState();
3128 QWidget *par = focusWidget()->parentWidget();
3129 while (par->parentWidget() && par->parentWidget() != this) {
3130 par = par->parentWidget();
3132 kDebug() << "CURRENT WIDGET: " << par->objectName();
3135 //centralWidget()->setHidden(false);
3136 //restoreState(m_timelineState);
3140 void MainWindow::loadTranscoders()
3142 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3145 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3146 KConfigGroup transConfig(config, "Transcoding");
3148 QMap< QString, QString > profiles = transConfig.entryMap();
3149 QMapIterator<QString, QString> i(profiles);
3150 while (i.hasNext()) {
3152 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3153 QAction *a = transMenu->addAction(i.key());
3155 if (data.count() > 1) {
3156 a->setToolTip(data.at(1));
3158 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3162 void MainWindow::slotTranscode(KUrl::List urls)
3167 if (urls.isEmpty()) {
3168 QAction *action = qobject_cast<QAction *>(sender());
3169 QStringList data = action->data().toStringList();
3170 params = data.at(0);
3171 if (data.count() > 1) desc = data.at(1);
3172 if (data.count() > 2) condition = data.at(2);
3173 urls << m_projectList->getConditionalUrls(condition);
3174 urls.removeAll(KUrl());
3176 if (urls.isEmpty()) {
3177 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3180 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3181 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3183 //QProcess::startDetached("ffmpeg", parameters);
3186 void MainWindow::slotTranscodeClip()
3188 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3189 if (urls.isEmpty()) return;
3190 slotTranscode(urls);
3193 void MainWindow::slotSetDocumentRenderProfile(const QString &dest, const QString &group, const QString &name, const QString &file)
3195 if (m_activeDocument == NULL) return;
3196 m_activeDocument->setDocumentProperty("renderdestination", dest);
3197 m_activeDocument->setDocumentProperty("rendercategory", group);
3198 m_activeDocument->setDocumentProperty("renderprofile", name);
3199 m_activeDocument->setDocumentProperty("renderurl", file);
3200 m_activeDocument->setModified(true);
3204 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3206 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3208 QString playlistPath;
3211 QString scriptsFolder = m_activeDocument->projectFolder().path() + "/scripts/";
3212 QString path = m_renderWidget->getFreeScriptName();
3213 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3214 if (!ok || scriptPath.isEmpty()) return;
3215 scriptPath.prepend(scriptsFolder);
3216 QFile f(scriptPath);
3218 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3221 playlistPath = scriptPath + ".mlt";
3222 m_projectMonitor->saveSceneList(playlistPath);
3224 KTemporaryFile temp;
3225 temp.setAutoRemove(false);
3226 temp.setSuffix(".mlt");
3228 playlistPath = temp.fileName();
3229 m_projectMonitor->saveSceneList(playlistPath);
3232 if (!chapterFile.isEmpty()) {
3235 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3237 in = m_activeTimeline->inPoint();
3238 out = m_activeTimeline->outPoint();
3241 QDomElement chapters = doc.createElement("chapters");
3242 chapters.setAttribute("fps", m_activeDocument->fps());
3243 doc.appendChild(chapters);
3245 QDomElement guidesxml = m_activeDocument->guidesXml();
3246 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3247 for (int i = 0; i < nodes.count(); i++) {
3248 QDomElement e = nodes.item(i).toElement();
3250 QString comment = e.attribute("comment");
3251 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3252 if (time >= in && time < out) {
3253 if (zoneOnly) time = time - in;
3254 QDomElement chapter = doc.createElement("chapter");
3255 chapters.appendChild(chapter);
3256 chapter.setAttribute("title", comment);
3257 chapter.setAttribute("time", time);
3261 if (chapters.childNodes().count() > 0) {
3262 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3263 // Always insert a guide in pos 0
3264 QDomElement chapter = doc.createElement("chapter");
3265 chapters.insertBefore(chapter, QDomNode());
3266 chapter.setAttribute("title", i18n("Start"));
3267 chapter.setAttribute("time", "0");
3269 // save chapters file
3270 QFile file(chapterFile);
3271 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3272 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3274 file.write(doc.toString().toUtf8());
3275 if (file.error() != QFile::NoError) {
3276 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3283 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath);
3286 void MainWindow::slotUpdateTimecodeFormat(int ix)
3288 KdenliveSettings::setFrametimecode(ix == 1);
3289 m_clipMonitor->updateTimecodeFormat();
3290 m_projectMonitor->updateTimecodeFormat();
3291 m_activeTimeline->projectView()->clearSelection();
3294 void MainWindow::slotRemoveFocus()
3296 statusBar()->setFocus();
3297 statusBar()->clearFocus();
3300 void MainWindow::slotRevert()
3302 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;
3303 KUrl url = m_activeDocument->url();
3304 closeCurrentDocument(false);
3305 doOpenFile(url, NULL);
3309 void MainWindow::slotShutdown()
3311 if (m_activeDocument) m_activeDocument->setModified(false);
3313 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
3314 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
3315 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
3316 smserver.call("logout", 1, 2, 2);
3317 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
3318 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
3319 smserver.call("Shutdown");
3323 void MainWindow::slotUpdateTrackInfo()
3325 if (m_activeDocument)
3326 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
3329 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
3331 // Load the theme file
3333 if (action == NULL) theme = themename;
3334 else theme = action->data().toString();
3335 KdenliveSettings::setColortheme(theme);
3336 // Make palette for all widgets.
3338 if (theme.isEmpty())
3339 plt = QApplication::desktop()->palette();
3341 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
3342 plt = KGlobalSettings::createApplicationPalette(config);
3345 kapp->setPalette(plt);
3346 const QObjectList children = statusBar()->children();
3348 foreach(QObject *child, children) {
3349 if (child->isWidgetType())
3350 ((QWidget*)child)->setPalette(plt);
3351 const QObjectList subchildren = child->children();
3352 foreach(QObject *subchild, subchildren) {
3353 if (subchild->isWidgetType())
3354 ((QWidget*)subchild)->setPalette(plt);
3360 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
3362 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
3363 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
3364 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
3365 const QSize bitsSize(24, 2);
3366 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
3367 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
3369 QPixmap pixmap(23, 16);
3370 pixmap.fill(Qt::black); // ### use some color other than black for borders?
3372 KConfigGroup group(config, "WM");
3373 QPainter p(&pixmap);
3374 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
3375 p.fillRect(1, 1, 7, 7, windowScheme.background());
3376 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
3378 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
3379 p.fillRect(8, 1, 7, 7, buttonScheme.background());
3380 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
3382 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
3383 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
3385 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
3386 p.fillRect(1, 8, 7, 7, viewScheme.background());
3387 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
3389 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
3390 p.fillRect(8, 8, 7, 7, selectionScheme.background());
3391 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
3393 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
3394 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
3400 void MainWindow::slotSwitchMonitors()
3402 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
3403 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
3404 else m_projectList->focusTree();
3407 void MainWindow::slotInsertZoneToTree()
3409 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
3410 QStringList info = m_clipMonitor->getZoneInfo();
3411 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
3414 void MainWindow::slotInsertZoneToTimeline()
3416 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
3417 QStringList info = m_clipMonitor->getZoneInfo();
3418 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
3422 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
3424 for (int i = 0; i < ids.size(); ++i) {
3425 m_activeTimeline->slotDeleteClip(ids.at(i));
3427 m_activeDocument->clipManager()->slotDeleteClips(ids);
3428 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
3432 void MainWindow::slotShowTitleBars(bool show)
3435 m_effectStackDock->setTitleBarWidget(0);
3436 m_clipMonitorDock->setTitleBarWidget(0);
3437 m_projectMonitorDock->setTitleBarWidget(0);
3439 m_recMonitorDock->setTitleBarWidget(0);
3441 m_effectListDock->setTitleBarWidget(0);
3442 m_transitionConfigDock->setTitleBarWidget(0);
3443 m_projectListDock->setTitleBarWidget(0);
3444 m_undoViewDock->setTitleBarWidget(0);
3446 if (!m_effectStackDock->isFloating()) m_effectStackDock->setTitleBarWidget(new QWidget(this));
3447 if (!m_clipMonitorDock->isFloating()) m_clipMonitorDock->setTitleBarWidget(new QWidget(this));
3448 if (!m_projectMonitorDock->isFloating()) m_projectMonitorDock->setTitleBarWidget(new QWidget(this));
3450 if (!m_recMonitorDock->isFloating()) m_recMonitorDock->setTitleBarWidget(new QWidget(this));
3452 if (!m_effectListDock->isFloating()) m_effectListDock->setTitleBarWidget(new QWidget(this));
3453 if (!m_transitionConfigDock->isFloating()) m_transitionConfigDock->setTitleBarWidget(new QWidget(this));
3454 if (!m_projectListDock->isFloating()) m_projectListDock->setTitleBarWidget(new QWidget(this));
3455 if (!m_undoViewDock->isFloating()) m_undoViewDock->setTitleBarWidget(new QWidget(this));
3457 KdenliveSettings::setShowtitlebars(show);
3460 void MainWindow::slotSwitchTitles()
3462 slotShowTitleBars(!KdenliveSettings::showtitlebars());
3465 #include "mainwindow.moc"