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"
55 #include "vectorscope.h"
57 #include <KApplication>
61 #include <KActionCollection>
62 #include <KActionCategory>
63 #include <KStandardAction>
64 #include <KShortcutsDialog>
65 #include <KFileDialog>
66 #include <KMessageBox>
68 #include <KIO/NetAccess>
71 #include <KConfigDialog>
72 #include <KXMLGUIFactory>
74 #include <kstandarddirs.h>
75 #include <KUrlRequesterDialog>
76 #include <KTemporaryFile>
78 #include <KActionMenu>
81 #include <ktogglefullscreenaction.h>
83 #include <KNotification>
84 #include <KNotifyConfigWidget>
85 #if KDE_IS_VERSION(4,3,80)
86 #include <knewstuff3/downloaddialog.h>
87 #include <knewstuff3/knewstuffaction.h>
89 #include <knewstuff2/engine.h>
90 #include <knewstuff2/ui/knewstuffaction.h>
92 #endif /* KDE_IS_VERSION(4,3,80) */
94 #include <KColorScheme>
96 #include <QTextStream>
100 #include <QInputDialog>
101 #include <QDesktopWidget>
106 static const char version[] = VERSION;
108 static const int ID_TIMELINE_POS = 0;
115 EffectsList MainWindow::videoEffects;
116 EffectsList MainWindow::audioEffects;
117 EffectsList MainWindow::customEffects;
118 EffectsList MainWindow::transitions;
120 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent) :
121 KXmlGuiWindow(parent),
122 m_activeDocument(NULL),
123 m_activeTimeline(NULL),
124 m_renderWidget(NULL),
125 #ifndef NO_JOGSHUTTLE
127 #endif /* NO_JOGSHUTTLE */
128 m_findActivated(false)
131 // Create DBus interface
132 new MainWindowAdaptor(this);
133 QDBusConnection dbus = QDBusConnection::sessionBus();
134 dbus.registerObject("/MainWindow", this);
136 setlocale(LC_NUMERIC, "POSIX");
137 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
138 setFont(KGlobalSettings::toolBarFont());
139 parseProfiles(MltPath);
140 m_commandStack = new QUndoGroup;
141 m_timelineArea = new KTabWidget(this);
142 m_timelineArea->setTabReorderingEnabled(true);
143 m_timelineArea->setTabBarHidden(true);
144 m_timelineArea->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
145 m_timelineArea->setMinimumHeight(200);
147 QToolButton *closeTabButton = new QToolButton;
148 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
149 closeTabButton->setIcon(KIcon("tab-close"));
150 closeTabButton->adjustSize();
151 closeTabButton->setToolTip(i18n("Close the current tab"));
152 m_timelineArea->setCornerWidget(closeTabButton);
153 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
155 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
156 m_findTimer.setSingleShot(true);
158 // FIXME: the next call returns a newly allocated object, which leaks
159 initEffects::parseEffectFiles();
160 //initEffects::parseCustomEffectsFile();
162 m_monitorManager = new MonitorManager();
164 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
165 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
170 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
171 m_projectListDock->setObjectName("project_tree");
172 m_projectList = new ProjectList(this);
173 m_projectListDock->setWidget(m_projectList);
174 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
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 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
189 m_clipMonitorDock->setObjectName("clip_monitor");
190 m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), this);
191 m_clipMonitorDock->setWidget(m_clipMonitor);
192 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
194 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
195 m_projectMonitorDock->setObjectName("project_monitor");
196 m_projectMonitor = new Monitor("project", m_monitorManager, QString(), this);
197 m_projectMonitorDock->setWidget(m_projectMonitor);
198 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
201 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
202 m_recMonitorDock->setObjectName("record_monitor");
203 m_recMonitor = new RecMonitor("record", this);
204 m_recMonitorDock->setWidget(m_recMonitor);
205 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
206 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
207 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
210 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
211 m_effectListDock->setObjectName("effect_list");
212 m_effectList = new EffectsListView();
213 m_effectListDock->setWidget(m_effectList);
214 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
216 m_vectorscope = new Vectorscope(m_projectMonitor->render, m_clipMonitor->render, this);
217 m_vectorscopeDock = new QDockWidget(i18n("Vectorscope"), this);
218 m_vectorscopeDock->setObjectName("vectorscope");
219 m_vectorscopeDock->setWidget(m_vectorscope);
220 addDockWidget(Qt::TopDockWidgetArea, m_vectorscopeDock);
223 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
224 m_undoViewDock->setObjectName("undo_history");
225 m_undoView = new QUndoView(this);
226 m_undoView->setCleanIcon(KIcon("edit-clear"));
227 m_undoView->setEmptyLabel(i18n("Clean"));
228 m_undoViewDock->setWidget(m_undoView);
229 m_undoView->setGroup(m_commandStack);
230 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
232 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
233 //overviewDock->setObjectName("project_overview");
234 //m_overView = new CustomTrackView(NULL, NULL, this);
235 //overviewDock->setWidget(m_overView);
236 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
241 /// Tabify Widgets ///
242 tabifyDockWidget(m_projectListDock, m_effectStackDock);
243 tabifyDockWidget(m_projectListDock, m_transitionConfigDock);
246 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
248 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
251 tabifyDockWidget(m_vectorscopeDock, m_undoViewDock);
252 tabifyDockWidget(m_vectorscopeDock, m_effectListDock);
255 setCentralWidget(m_timelineArea);
258 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
259 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
261 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
262 m_fileRevert->setEnabled(false);
268 // Find QDockWidget tab bars and show / hide widget title bars on right click
269 QList <QTabBar *> tabs = findChildren<QTabBar *>();
270 for (int i = 0; i < tabs.count(); i++) {
271 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
272 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
275 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
276 guiFactory()->addClient(sp);*/
280 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
282 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone);
283 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
285 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
286 clipInTimeline->setIcon(KIcon("go-jump"));
287 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)),
288 static_cast<QMenu*>(factory()->container("transcoders", this)),
292 // build themes menus
293 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
294 QActionGroup *themegroup = new QActionGroup(this);
295 themegroup->setExclusive(true);
296 action = new KAction(i18n("Default"), this);
297 action->setCheckable(true);
298 themegroup->addAction(action);
299 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
301 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
303 for (int i = 0; i < schemeFiles.size(); ++i) {
305 const QString filename = schemeFiles.at(i);
306 const QFileInfo info(filename);
309 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
310 QIcon icon = createSchemePreviewIcon(config);
311 KConfigGroup group(config, "General");
312 const QString name = group.readEntry("Name", info.baseName());
313 action = new KAction(name, this);
314 action->setData(filename);
315 action->setIcon(icon);
316 action->setCheckable(true);
317 themegroup->addAction(action);
318 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
321 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
322 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
323 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
326 action = new QAction(fi.fileName(), this);
327 action->setData(*it);
328 action->setCheckable(true);
329 themegroup->addAction(action);
330 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
332 themesMenu->addActions(themegroup->actions());
333 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
335 // Setup and fill effects and transitions menus.
336 m_videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
337 for (int i = 0; i < videoEffects.count(); ++i)
338 m_videoEffectsMenu->addAction(m_videoEffects[i]);
339 m_audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
340 for (int i = 0; i < audioEffects.count(); ++i)
341 m_audioEffectsMenu->addAction(m_audioEffects[i]);
342 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
343 if (customEffects.isEmpty())
344 m_customEffectsMenu->setEnabled(false);
346 m_customEffectsMenu->setEnabled(true);
347 for (int i = 0; i < customEffects.count(); ++i)
348 m_customEffectsMenu->addAction(m_customEffects[i]);
349 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
350 for (int i = 0; i < transitions.count(); ++i)
351 m_transitionsMenu->addAction(m_transitions[i]);
353 connect(m_videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
354 connect(m_audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
355 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
356 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
358 QMenu *newEffect = new QMenu(this);
359 newEffect->addMenu(m_videoEffectsMenu);
360 newEffect->addMenu(m_audioEffectsMenu);
361 newEffect->addMenu(m_customEffectsMenu);
362 m_effectStack->setMenu(newEffect);
364 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
365 const QList<QAction *> viewActions = createPopupMenu()->actions();
366 viewMenu->insertActions(NULL, viewActions);
368 m_timelineContextMenu = new QMenu(this);
369 m_timelineContextClipMenu = new QMenu(this);
370 m_timelineContextTransitionMenu = new QMenu(this);
372 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
373 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
374 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
376 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
377 //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
378 m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
379 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
380 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
381 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
382 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
383 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
384 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
385 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
387 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
388 m_timelineContextClipMenu->addMenu(markersMenu);
389 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
390 m_timelineContextClipMenu->addMenu(m_videoEffectsMenu);
391 m_timelineContextClipMenu->addMenu(m_audioEffectsMenu);
392 //TODO: re-enable custom effects menu when it is implemented
393 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
395 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
396 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
397 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
399 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
401 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
402 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
403 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
404 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
405 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), m_vectorscope, SLOT(slotActiveMonitorChanged(bool)));
406 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
407 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
409 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
410 slotConnectMonitors();
412 // Disable drop B frames, see Kdenlive issue #1330, see also kdenlivesettingsdialog.cpp
413 KdenliveSettings::setDropbframes(false);
415 // Open or create a file. Command line argument passed in Url has
416 // precedence, then "openlastproject", then just a plain empty file.
417 // If opening Url fails, openlastproject will _not_ be used.
418 if (!Url.isEmpty()) {
419 // delay loading so that the window shows up
421 QTimer::singleShot(500, this, SLOT(openFile()));
422 } else if (KdenliveSettings::openlastproject()) {
423 QTimer::singleShot(500, this, SLOT(openLastFile()));
424 } else { //if (m_timelineArea->count() == 0) {
428 #ifndef NO_JOGSHUTTLE
429 activateShuttleDevice();
430 #endif /* NO_JOGSHUTTLE */
431 m_projectListDock->raise();
434 void MainWindow::queryQuit()
437 if (m_projectMonitor) m_projectMonitor->stop();
438 if (m_clipMonitor) m_clipMonitor->stop();
439 delete m_effectStack;
440 delete m_activeTimeline;
442 // This sometimes causes crash on exit on OS X for some reason.
443 delete m_projectMonitor;
444 delete m_clipMonitor;
446 delete m_activeDocument;
447 delete m_shortcutRemoveFocus;
448 Mlt::Factory::close();
454 bool MainWindow::queryClose()
456 if (m_renderWidget) {
457 int waitingJobs = m_renderWidget->waitingJobsCount();
458 if (waitingJobs > 0) {
459 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")))) {
460 case KMessageBox::Yes :
461 // create script with waiting jobs and start it
462 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
464 case KMessageBox::No :
465 // Don't do anything, jobs will be deleted
473 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
474 // warn the user to save if document is modified and we have clips in our project list
475 if (m_activeDocument && m_activeDocument->isModified() &&
476 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
477 !m_projectList->documentClipList().isEmpty())) {
478 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
479 case KMessageBox::Yes :
480 // save document here. If saving fails, return false;
482 case KMessageBox::No :
483 // User does not want to save the changes, clear recovery files
484 m_activeDocument->m_autosave->resize(0);
493 void MainWindow::loadPlugins()
495 foreach(QObject *plugin, QPluginLoader::staticInstances()) {
496 populateMenus(plugin);
499 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
501 filters << "libkdenlive*";
502 foreach(const QString &folder, directories) {
503 kDebug() << "Parsing plugin folder: " << folder;
504 QDir pluginsDir(folder);
505 foreach(const QString &fileName,
506 pluginsDir.entryList(filters, QDir::Files)) {
508 * Avoid loading the same plugin twice when there is more than one
511 if (!m_pluginFileNames.contains(fileName)) {
512 kDebug() << "Found plugin: " << fileName;
513 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
514 QObject *plugin = loader.instance();
516 populateMenus(plugin);
517 m_pluginFileNames += fileName;
519 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
525 void MainWindow::populateMenus(QObject *plugin)
527 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
528 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
530 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
534 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
535 QMenu *menu, const char *member,
536 QActionGroup *actionGroup)
538 kDebug() << "// ADD to MENU" << texts;
539 foreach(const QString &text, texts) {
540 QAction *action = new QAction(text, plugin);
541 action->setData(text);
542 connect(action, SIGNAL(triggered()), this, member);
543 menu->addAction(action);
546 action->setCheckable(true);
547 actionGroup->addAction(action);
552 void MainWindow::aboutPlugins()
554 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
559 void MainWindow::generateClip()
561 QAction *action = qobject_cast<QAction *>(sender());
562 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
564 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
565 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
566 if (!clipUrl.isEmpty()) {
567 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
571 void MainWindow::saveProperties(KConfigGroup &config)
573 // save properties here,used by session management
575 KMainWindow::saveProperties(config);
579 void MainWindow::readProperties(const KConfigGroup &config)
581 // read properties here,used by session management
582 KMainWindow::readProperties(config);
583 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
584 openFile(KUrl(Lastproject));
587 void MainWindow::slotReloadEffects()
589 m_customEffectsMenu->clear();
590 initEffects::parseCustomEffectsFile();
592 QStringList effectInfo;
593 QMap<QString, QStringList> effectsList;
594 for (int ix = 0; ix < customEffects.count(); ix++) {
595 effectInfo = customEffects.effectIdInfo(ix);
596 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
598 if (effectsList.isEmpty())
599 m_customEffectsMenu->setEnabled(false);
601 m_customEffectsMenu->setEnabled(true);
603 foreach(const QStringList &value, effectsList) {
604 action = new QAction(value.at(0), this);
605 action->setData(value);
606 m_customEffectsMenu->addAction(action);
608 m_effectList->reloadEffectList();
611 #ifndef NO_JOGSHUTTLE
612 void MainWindow::activateShuttleDevice()
616 if (KdenliveSettings::enableshuttle() == false) return;
617 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
618 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
619 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
620 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
621 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
622 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
623 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
626 void MainWindow::slotShuttleButton(int code)
630 slotShuttleAction(KdenliveSettings::shuttle1());
633 slotShuttleAction(KdenliveSettings::shuttle2());
636 slotShuttleAction(KdenliveSettings::shuttle3());
639 slotShuttleAction(KdenliveSettings::shuttle4());
642 slotShuttleAction(KdenliveSettings::shuttle5());
647 void MainWindow::slotShuttleAction(int code)
653 m_monitorManager->slotPlay();
656 m_monitorManager->slotPlay();
660 #endif /* NO_JOGSHUTTLE */
662 void MainWindow::configureNotifications()
664 KNotifyConfigWidget::configure(this);
667 void MainWindow::slotFullScreen()
669 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
672 void MainWindow::slotAddEffect(const QDomElement effect, GenTime pos, int track)
674 if (!m_activeDocument) return;
675 if (effect.isNull()) {
676 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
679 QDomElement effectToAdd = effect.cloneNode().toElement();
680 m_activeTimeline->projectView()->slotAddEffect(effectToAdd, pos, track);
683 void MainWindow::slotRaiseMonitor(bool clipMonitor)
685 if (clipMonitor) m_clipMonitorDock->raise();
686 else m_projectMonitorDock->raise();
689 void MainWindow::slotUpdateClip(const QString &id)
691 if (!m_activeDocument) return;
692 m_activeTimeline->projectView()->slotUpdateClip(id);
695 void MainWindow::slotConnectMonitors()
697 m_projectList->setRenderer(m_projectMonitor->render);
698 //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
699 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
700 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
701 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
702 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, int, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, int, bool)));
703 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
704 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)));
706 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
708 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
710 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
711 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
713 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
714 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
717 void MainWindow::slotAdjustClipMonitor()
719 m_clipMonitorDock->updateGeometry();
720 m_clipMonitorDock->adjustSize();
721 m_clipMonitor->resetSize();
724 void MainWindow::slotAdjustProjectMonitor()
726 m_projectMonitorDock->updateGeometry();
727 m_projectMonitorDock->adjustSize();
728 m_projectMonitor->resetSize();
731 void MainWindow::setupActions()
734 KActionCollection* collection = actionCollection();
735 m_timecodeFormat = new KComboBox(this);
736 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
737 m_timecodeFormat->addItem(i18n("Frames"));
738 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
739 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
741 m_statusProgressBar = new QProgressBar(this);
742 m_statusProgressBar->setMinimum(0);
743 m_statusProgressBar->setMaximum(100);
744 m_statusProgressBar->setMaximumWidth(150);
745 m_statusProgressBar->setVisible(false);
747 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
748 toolbar->setMovable(false);
749 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
750 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;}";
751 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
753 //create edit mode buttons
754 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
755 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
756 toolbar->addAction(m_normalEditTool);
757 m_normalEditTool->setCheckable(true);
758 m_normalEditTool->setChecked(true);
760 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
761 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
762 toolbar->addAction(m_overwriteEditTool);
763 m_overwriteEditTool->setCheckable(true);
764 m_overwriteEditTool->setChecked(false);
766 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
767 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
768 toolbar->addAction(m_insertEditTool);
769 m_insertEditTool->setCheckable(true);
770 m_insertEditTool->setChecked(false);
771 // not implemented yet
772 m_insertEditTool->setEnabled(false);
774 QActionGroup *editGroup = new QActionGroup(this);
775 editGroup->addAction(m_normalEditTool);
776 editGroup->addAction(m_overwriteEditTool);
777 editGroup->addAction(m_insertEditTool);
778 editGroup->setExclusive(true);
779 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
780 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
782 toolbar->addSeparator();
784 // create tools buttons
785 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
786 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
787 toolbar->addAction(m_buttonSelectTool);
788 m_buttonSelectTool->setCheckable(true);
789 m_buttonSelectTool->setChecked(true);
791 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
792 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
793 toolbar->addAction(m_buttonRazorTool);
794 m_buttonRazorTool->setCheckable(true);
795 m_buttonRazorTool->setChecked(false);
797 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
798 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
799 toolbar->addAction(m_buttonSpacerTool);
800 m_buttonSpacerTool->setCheckable(true);
801 m_buttonSpacerTool->setChecked(false);
803 QActionGroup *toolGroup = new QActionGroup(this);
804 toolGroup->addAction(m_buttonSelectTool);
805 toolGroup->addAction(m_buttonRazorTool);
806 toolGroup->addAction(m_buttonSpacerTool);
807 toolGroup->setExclusive(true);
808 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
810 QWidget * actionWidget;
811 int max = toolbar->iconSizeDefault() + 2;
812 actionWidget = toolbar->widgetForAction(m_normalEditTool);
813 actionWidget->setMaximumWidth(max);
814 actionWidget->setMaximumHeight(max - 4);
816 actionWidget = toolbar->widgetForAction(m_insertEditTool);
817 actionWidget->setMaximumWidth(max);
818 actionWidget->setMaximumHeight(max - 4);
820 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
821 actionWidget->setMaximumWidth(max);
822 actionWidget->setMaximumHeight(max - 4);
824 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
825 actionWidget->setMaximumWidth(max);
826 actionWidget->setMaximumHeight(max - 4);
828 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
829 actionWidget->setMaximumWidth(max);
830 actionWidget->setMaximumHeight(max - 4);
832 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
833 actionWidget->setMaximumWidth(max);
834 actionWidget->setMaximumHeight(max - 4);
836 toolbar->setStyleSheet(style1);
837 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
839 toolbar->addSeparator();
840 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
841 toolbar->addAction(m_buttonFitZoom);
842 m_buttonFitZoom->setCheckable(false);
844 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
845 toolbar->addAction(m_zoomOut);
846 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
848 m_zoomSlider = new QSlider(Qt::Horizontal, this);
849 m_zoomSlider->setMaximum(13);
850 m_zoomSlider->setPageStep(1);
851 m_zoomSlider->setInvertedAppearance(true);
853 m_zoomSlider->setMaximumWidth(150);
854 m_zoomSlider->setMinimumWidth(100);
855 toolbar->addWidget(m_zoomSlider);
857 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
858 toolbar->addAction(m_zoomIn);
859 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
861 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
862 actionWidget->setMaximumWidth(max);
863 actionWidget->setMaximumHeight(max - 4);
864 actionWidget->setStyleSheet(styleBorderless);
866 actionWidget = toolbar->widgetForAction(m_zoomIn);
867 actionWidget->setMaximumWidth(max);
868 actionWidget->setMaximumHeight(max - 4);
869 actionWidget->setStyleSheet(styleBorderless);
871 actionWidget = toolbar->widgetForAction(m_zoomOut);
872 actionWidget->setMaximumWidth(max);
873 actionWidget->setMaximumHeight(max - 4);
874 actionWidget->setStyleSheet(styleBorderless);
876 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
877 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
878 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
879 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
880 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
882 toolbar->addSeparator();
884 //create automatic audio split button
885 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
886 toolbar->addAction(m_buttonAutomaticSplitAudio);
887 m_buttonAutomaticSplitAudio->setCheckable(true);
888 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
889 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
891 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
892 toolbar->addAction(m_buttonVideoThumbs);
893 m_buttonVideoThumbs->setCheckable(true);
894 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
895 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
897 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
898 toolbar->addAction(m_buttonAudioThumbs);
899 m_buttonAudioThumbs->setCheckable(true);
900 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
901 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
903 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
904 toolbar->addAction(m_buttonShowMarkers);
905 m_buttonShowMarkers->setCheckable(true);
906 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
907 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
909 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
910 toolbar->addAction(m_buttonSnap);
911 m_buttonSnap->setCheckable(true);
912 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
913 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
915 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
916 actionWidget->setMaximumWidth(max);
917 actionWidget->setMaximumHeight(max - 4);
919 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
920 actionWidget->setMaximumWidth(max);
921 actionWidget->setMaximumHeight(max - 4);
923 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
924 actionWidget->setMaximumWidth(max);
925 actionWidget->setMaximumHeight(max - 4);
927 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
928 actionWidget->setMaximumWidth(max);
929 actionWidget->setMaximumHeight(max - 4);
931 actionWidget = toolbar->widgetForAction(m_buttonSnap);
932 actionWidget->setMaximumWidth(max);
933 actionWidget->setMaximumHeight(max - 4);
935 m_messageLabel = new StatusBarMessageLabel(this);
936 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
938 statusBar()->addWidget(m_messageLabel, 10);
939 statusBar()->addWidget(m_statusProgressBar, 0);
940 statusBar()->addPermanentWidget(toolbar);
941 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
942 statusBar()->addPermanentWidget(m_timecodeFormat);
943 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
945 collection->addAction("normal_mode", m_normalEditTool);
946 collection->addAction("overwrite_mode", m_overwriteEditTool);
947 collection->addAction("insert_mode", m_insertEditTool);
948 collection->addAction("select_tool", m_buttonSelectTool);
949 collection->addAction("razor_tool", m_buttonRazorTool);
950 collection->addAction("spacer_tool", m_buttonSpacerTool);
952 collection->addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
953 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
954 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
955 collection->addAction("show_markers", m_buttonShowMarkers);
956 collection->addAction("snap", m_buttonSnap);
957 collection->addAction("zoom_fit", m_buttonFitZoom);
958 collection->addAction("zoom_in", m_zoomIn);
959 collection->addAction("zoom_out", m_zoomOut);
961 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
962 collection->addAction("project_find", m_projectSearch);
963 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
964 m_projectSearch->setShortcut(Qt::Key_Slash);
966 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
967 collection->addAction("project_find_next", m_projectSearchNext);
968 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
969 m_projectSearchNext->setShortcut(Qt::Key_F3);
970 m_projectSearchNext->setEnabled(false);
972 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
973 collection->addAction("manage_profiles", profilesAction);
974 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
976 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
977 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
978 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
979 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
981 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
982 collection->addAction("run_wizard", wizAction);
983 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
985 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
986 collection->addAction("project_settings", projectAction);
987 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
989 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
990 collection->addAction("project_render", projectRender);
991 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
992 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
994 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
995 collection->addAction("project_clean", projectClean);
996 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
998 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
999 KShortcut playShortcut;
1000 playShortcut.setPrimary(Qt::Key_Space);
1001 playShortcut.setAlternate(Qt::Key_K);
1002 monitorPlay->setShortcut(playShortcut);
1003 collection->addAction("monitor_play", monitorPlay);
1004 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1006 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1007 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1008 collection->addAction("monitor_play_zone", m_playZone);
1009 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1011 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1012 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1013 collection->addAction("monitor_loop_zone", m_loopZone);
1014 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1016 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1017 collection->addAction("dvd_wizard", dvdWizard);
1018 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1020 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1021 collection->addAction("transcode_clip", transcodeClip);
1022 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1024 KAction *markIn = collection->addAction("mark_in");
1025 markIn->setText(i18n("Set Zone In"));
1026 markIn->setShortcut(Qt::Key_I);
1027 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1029 KAction *markOut = collection->addAction("mark_out");
1030 markOut->setText(i18n("Set Zone Out"));
1031 markOut->setShortcut(Qt::Key_O);
1032 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1034 KAction *switchMon = collection->addAction("switch_monitor");
1035 switchMon->setText(i18n("Switch monitor"));
1036 switchMon->setShortcut(Qt::Key_T);
1037 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1039 KAction *insertTree = collection->addAction("insert_project_tree");
1040 insertTree->setText(i18n("Insert zone in project tree"));
1041 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1042 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1044 KAction *insertTimeline = collection->addAction("insert_timeline");
1045 insertTimeline->setText(i18n("Insert zone in timeline"));
1046 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1047 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1049 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1050 collection->addAction("resize_timeline_clip_start", resizeStart);
1051 resizeStart->setShortcut(Qt::Key_1);
1052 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1054 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1055 collection->addAction("resize_timeline_clip_end", resizeEnd);
1056 resizeEnd->setShortcut(Qt::Key_2);
1057 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1059 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1060 monitorSeekBackward->setShortcut(Qt::Key_J);
1061 collection->addAction("monitor_seek_backward", monitorSeekBackward);
1062 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1064 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1065 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1066 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1067 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1069 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1070 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1071 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1072 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1074 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1075 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1076 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1077 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1079 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1080 monitorSeekForward->setShortcut(Qt::Key_L);
1081 collection->addAction("monitor_seek_forward", monitorSeekForward);
1082 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1084 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1085 clipStart->setShortcut(Qt::Key_Home);
1086 collection->addAction("seek_clip_start", clipStart);
1087 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1089 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1090 clipEnd->setShortcut(Qt::Key_End);
1091 collection->addAction("seek_clip_end", clipEnd);
1092 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1094 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1095 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1096 collection->addAction("seek_zone_start", zoneStart);
1097 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1099 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1100 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1101 collection->addAction("seek_zone_end", zoneEnd);
1102 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1104 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1105 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1106 collection->addAction("seek_start", projectStart);
1107 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1109 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1110 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1111 collection->addAction("seek_end", projectEnd);
1112 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1114 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1115 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1116 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1117 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1119 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1120 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1121 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1122 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1124 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1125 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1126 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1127 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1129 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1130 deleteItem->setShortcut(Qt::Key_Delete);
1131 collection->addAction("delete_timeline_clip", deleteItem);
1132 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1134 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1135 collection->addAction("change_clip_speed", editTimelineClipSpeed);
1136 editTimelineClipSpeed->setData("change_speed");
1137 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1139 KAction *stickTransition = collection->addAction("auto_transition");
1140 stickTransition->setData(QString("auto"));
1141 stickTransition->setCheckable(true);
1142 stickTransition->setEnabled(false);
1143 stickTransition->setText(i18n("Automatic Transition"));
1144 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1146 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1147 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1148 collection->addAction("group_clip", groupClip);
1149 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1151 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1152 collection->addAction("ungroup_clip", ungroupClip);
1153 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1154 ungroupClip->setData("ungroup_clip");
1155 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1157 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1158 collection->addAction("edit_item_duration", editItemDuration);
1159 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1161 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1162 collection->addAction("clip_in_project_tree", clipInProjectTree);
1163 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1165 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1166 collection->addAction("clip_to_project_tree", clipToProjectTree);
1167 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1169 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1170 insertOvertwrite->setShortcut(Qt::Key_V);
1171 collection->addAction("overwrite_to_in_point", insertOvertwrite);
1172 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1174 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1175 selectTimelineClip->setShortcut(Qt::Key_Plus);
1176 collection->addAction("select_timeline_clip", selectTimelineClip);
1177 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1179 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1180 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1181 collection->addAction("deselect_timeline_clip", deselectTimelineClip);
1182 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1184 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1185 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1186 collection->addAction("select_add_timeline_clip", selectAddTimelineClip);
1187 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1189 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1190 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1191 collection->addAction("select_timeline_transition", selectTimelineTransition);
1192 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1194 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1195 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1196 collection->addAction("deselect_timeline_transition", deselectTimelineTransition);
1197 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1199 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1200 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1201 collection->addAction("select_add_timeline_transition", selectAddTimelineTransition);
1202 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1204 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1205 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1206 collection->addAction("cut_timeline_clip", cutTimelineClip);
1207 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1209 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1210 collection->addAction("add_clip_marker", addClipMarker);
1211 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1213 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1214 collection->addAction("delete_clip_marker", deleteClipMarker);
1215 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1217 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1218 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
1219 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1221 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1222 collection->addAction("edit_clip_marker", editClipMarker);
1223 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1225 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1226 collection->addAction("split_audio", splitAudio);
1227 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1229 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1230 collection->addAction("clip_audio_only", audioOnly);
1231 audioOnly->setData("clip_audio_only");
1232 audioOnly->setCheckable(true);
1234 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1235 collection->addAction("clip_video_only", videoOnly);
1236 videoOnly->setData("clip_video_only");
1237 videoOnly->setCheckable(true);
1239 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1240 collection->addAction("clip_audio_and_video", audioAndVideo);
1241 audioAndVideo->setData("clip_audio_and_video");
1242 audioAndVideo->setCheckable(true);
1244 m_clipTypeGroup = new QActionGroup(this);
1245 m_clipTypeGroup->addAction(audioOnly);
1246 m_clipTypeGroup->addAction(videoOnly);
1247 m_clipTypeGroup->addAction(audioAndVideo);
1248 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1249 m_clipTypeGroup->setEnabled(false);
1251 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1252 collection->addAction("insert_space", insertSpace);
1253 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1255 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1256 collection->addAction("delete_space", removeSpace);
1257 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1259 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1260 collection->addAction("insert_track", insertTrack);
1261 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1263 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1264 collection->addAction("delete_track", deleteTrack);
1265 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1267 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
1268 collection->addAction("config_tracks", configTracks);
1269 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1271 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1272 collection->addAction("add_guide", addGuide);
1273 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1275 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1276 collection->addAction("delete_guide", delGuide);
1277 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1279 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1280 collection->addAction("edit_guide", editGuide);
1281 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1283 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1284 collection->addAction("delete_all_guides", delAllGuides);
1285 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1287 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1288 collection->addAction("paste_effects", pasteEffects);
1289 pasteEffects->setData("paste_effects");
1290 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1292 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1293 collection->addAction("show_timeline", showTimeline);
1294 showTimeline->setCheckable(true);
1295 showTimeline->setChecked(true);
1296 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1298 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1299 collection->addAction("show_titlebars", showTitleBar);
1300 showTitleBar->setCheckable(true);
1301 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1302 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1303 slotShowTitleBars(KdenliveSettings::showtitlebars());
1305 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1306 collection->addAction("maximize_current", maxCurrent);
1307 maxCurrent->setCheckable(true);
1308 maxCurrent->setChecked(false);
1309 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1311 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1312 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1313 KStandardAction::open(this, SLOT(openFile()), collection);
1314 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1315 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1316 KStandardAction::openNew(this, SLOT(newFile()), collection);
1317 // TODO: make the following connection to slotEditKeys work
1318 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1319 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1320 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1321 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1322 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1323 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1325 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1326 undo->setEnabled(false);
1327 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1329 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1330 redo->setEnabled(false);
1331 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1334 //TODO: Add status tooltip to actions ?
1335 connect(collection, SIGNAL(actionHovered(QAction*)),
1336 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1339 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1340 collection->addAction("add_clip", addClip);
1341 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1343 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1344 collection->addAction("add_color_clip", addColorClip);
1345 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1347 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1348 collection->addAction("add_slide_clip", addSlideClip);
1349 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1351 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1352 collection->addAction("add_text_clip", addTitleClip);
1353 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1355 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1356 collection->addAction("add_text_template_clip", addTitleTemplateClip);
1357 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1359 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1360 collection->addAction("add_folder", addFolderButton);
1361 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1363 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1364 collection->addAction("clip_properties", clipProperties);
1365 clipProperties->setData("clip_properties");
1366 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1367 clipProperties->setEnabled(false);
1369 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1370 collection->addAction("edit_clip", openClip);
1371 openClip->setData("edit_clip");
1372 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1373 openClip->setEnabled(false);
1375 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1376 collection->addAction("delete_clip", deleteClip);
1377 deleteClip->setData("delete_clip");
1378 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1379 deleteClip->setEnabled(false);
1381 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1382 collection->addAction("reload_clip", reloadClip);
1383 reloadClip->setData("reload_clip");
1384 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1385 reloadClip->setEnabled(false);
1387 QMenu *addClips = new QMenu();
1388 addClips->addAction(addClip);
1389 addClips->addAction(addColorClip);
1390 addClips->addAction(addSlideClip);
1391 addClips->addAction(addTitleClip);
1392 addClips->addAction(addTitleTemplateClip);
1393 addClips->addAction(addFolderButton);
1395 addClips->addAction(reloadClip);
1396 addClips->addAction(clipProperties);
1397 addClips->addAction(openClip);
1398 addClips->addAction(deleteClip);
1399 m_projectList->setupMenu(addClips, addClip);
1401 // Setup effects and transitions actions.
1402 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1403 //KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), m_effectsActionCollection);
1404 KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), collection);
1405 m_videoEffects = new KAction*[videoEffects.count()];
1406 for (int i = 0; i < videoEffects.count(); ++i) {
1407 QStringList effectInfo = videoEffects.effectIdInfo(i);
1408 m_videoEffects[i] = new KAction(KIcon("kdenlive-show-video"), effectInfo.at(0), this);
1409 m_videoEffects[i]->setData(effectInfo);
1410 m_videoEffects[i]->setIconVisibleInMenu(false);
1411 videoEffectActions->addAction("video_effect_" + effectInfo.at(0), m_videoEffects[i]);
1413 //KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), m_effectsActionCollection);
1414 KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), collection);
1415 m_audioEffects = new KAction*[audioEffects.count()];
1416 for (int i = 0; i < audioEffects.count(); ++i) {
1417 QStringList effectInfo = audioEffects.effectIdInfo(i);
1418 m_audioEffects[i] = new KAction(KIcon("kdenlive-show-audio"), effectInfo.at(0), this);
1419 m_audioEffects[i]->setData(effectInfo);
1420 m_audioEffects[i]->setIconVisibleInMenu(false);
1421 audioEffectActions->addAction("audio_effect_" + effectInfo.at(0), m_audioEffects[i]);
1423 //KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), m_effectsActionCollection);
1424 KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), collection);
1425 m_customEffects = new KAction*[customEffects.count()];
1426 for (int i = 0; i < customEffects.count(); ++i) {
1427 QStringList effectInfo = customEffects.effectIdInfo(i);
1428 m_customEffects[i] = new KAction(KIcon("kdenlive-custom-effect"), effectInfo.at(0), this);
1429 m_customEffects[i]->setData(effectInfo);
1430 m_customEffects[i]->setIconVisibleInMenu(false);
1431 customEffectActions->addAction("custom_effect_" + effectInfo.at(0), m_customEffects[i]);
1433 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1434 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1435 m_transitions = new KAction*[transitions.count()];
1436 for (int i = 0; i < transitions.count(); i++) {
1437 QStringList effectInfo = transitions.effectIdInfo(i);
1438 m_transitions[i] = new KAction(effectInfo.at(0), this);
1439 m_transitions[i]->setData(effectInfo);
1440 m_transitions[i]->setIconVisibleInMenu(false);
1441 transitionActions->addAction("transition_" + effectInfo.at(0), m_transitions[i]);
1443 m_effectsActionCollection->readSettings();
1445 //connect(collection, SIGNAL( clearStatusText() ),
1446 //statusBar(), SLOT( clear() ) );
1449 void MainWindow::slotDisplayActionMessage(QAction *a)
1451 statusBar()->showMessage(a->data().toString(), 3000);
1454 void MainWindow::saveOptions()
1456 KdenliveSettings::self()->writeConfig();
1457 KSharedConfigPtr config = KGlobal::config();
1458 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1459 KConfigGroup treecolumns(config, "Project Tree");
1460 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1464 void MainWindow::readOptions()
1466 KSharedConfigPtr config = KGlobal::config();
1467 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1468 KConfigGroup initialGroup(config, "version");
1469 bool upgrade = false;
1470 if (initialGroup.exists()) {
1471 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1475 if (initialGroup.readEntry("version") == "0.7") {
1476 //Add new settings from 0.7.1
1477 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1478 QString path = QDir::homePath() + "/kdenlive";
1479 if (KStandardDirs::makeDir(path) == false) {
1480 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1481 } else KdenliveSettings::setDefaultprojectfolder(path);
1487 if (!initialGroup.exists() || upgrade) {
1488 // this is our first run, show Wizard
1489 Wizard *w = new Wizard(upgrade, this);
1490 if (w->exec() == QDialog::Accepted && w->isOk()) {
1491 w->adjustSettings();
1492 initialGroup.writeEntry("version", version);
1498 KConfigGroup treecolumns(config, "Project Tree");
1499 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1500 if (!state.isEmpty())
1501 m_projectList->setHeaderInfo(state);
1504 void MainWindow::slotRunWizard()
1506 Wizard *w = new Wizard(false, this);
1507 if (w->exec() == QDialog::Accepted && w->isOk()) {
1508 w->adjustSettings();
1513 void MainWindow::newFile(bool showProjectSettings, bool force)
1515 if (!m_timelineArea->isEnabled() && !force) return;
1516 m_fileRevert->setEnabled(false);
1517 QString profileName;
1519 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1520 if (!showProjectSettings) {
1521 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1522 profileName = KdenliveSettings::default_profile();
1523 projectFolder = KdenliveSettings::defaultprojectfolder();
1525 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1526 if (w->exec() != QDialog::Accepted) return;
1527 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1528 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
1529 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
1530 profileName = w->selectedProfile();
1531 projectFolder = w->selectedFolder();
1532 projectTracks = w->tracks();
1535 m_timelineArea->setEnabled(true);
1536 m_projectList->setEnabled(true);
1537 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1538 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1540 TrackView *trackView = new TrackView(doc, &ok, this);
1541 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1544 //m_timelineArea->setEnabled(false);
1545 //m_projectList->setEnabled(false);
1549 if (m_timelineArea->count() == 1) {
1550 connectDocumentInfo(doc);
1551 connectDocument(trackView, doc);
1552 } else m_timelineArea->setTabBarHidden(false);
1553 m_monitorManager->activateMonitor("clip");
1554 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1557 void MainWindow::activateDocument()
1559 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1560 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1561 KdenliveDoc *currentDoc = currentTab->document();
1562 connectDocumentInfo(currentDoc);
1563 connectDocument(currentTab, currentDoc);
1566 void MainWindow::closeCurrentDocument(bool saveChanges)
1568 QWidget *w = m_timelineArea->currentWidget();
1570 // closing current document
1571 int ix = m_timelineArea->currentIndex() + 1;
1572 if (ix == m_timelineArea->count()) ix = 0;
1573 m_timelineArea->setCurrentIndex(ix);
1574 TrackView *tabToClose = (TrackView *) w;
1575 KdenliveDoc *docToClose = tabToClose->document();
1576 if (docToClose && docToClose->isModified() && saveChanges) {
1577 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
1578 case KMessageBox::Yes :
1579 // save document here. If saving fails, return false;
1580 if (saveFile() == false) return;
1582 case KMessageBox::Cancel :
1589 m_clipMonitor->slotSetXml(NULL);
1590 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1591 if (m_timelineArea->count() == 1) {
1592 m_timelineArea->setTabBarHidden(true);
1593 m_closeAction->setEnabled(false);
1595 if (docToClose == m_activeDocument) {
1596 delete m_activeDocument;
1597 m_activeDocument = NULL;
1598 m_effectStack->clear();
1599 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1600 } else delete docToClose;
1601 if (w == m_activeTimeline) {
1602 delete m_activeTimeline;
1603 m_activeTimeline = NULL;
1607 bool MainWindow::saveFileAs(const QString &outputFileName)
1609 QString currentSceneList;
1610 m_monitorManager->stopActiveMonitor();
1611 if (KdenliveSettings::dropbframes()) {
1612 KdenliveSettings::setDropbframes(false);
1613 m_activeDocument->clipManager()->updatePreviewSettings();
1614 currentSceneList = m_projectMonitor->sceneList();
1615 KdenliveSettings::setDropbframes(true);
1616 m_activeDocument->clipManager()->updatePreviewSettings();
1617 } else currentSceneList = m_projectMonitor->sceneList();
1619 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1622 // Save timeline thumbnails
1623 m_activeTimeline->projectView()->saveThumbnails();
1624 m_activeDocument->setUrl(KUrl(outputFileName));
1625 if (m_activeDocument->m_autosave == NULL) {
1626 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1627 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1628 setCaption(m_activeDocument->description());
1629 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1630 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1631 m_activeDocument->setModified(false);
1632 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1633 m_fileRevert->setEnabled(true);
1637 bool MainWindow::saveFileAs()
1639 QString outputFile = KFileDialog::getSaveFileName(KUrl(), getMimeType());
1640 if (outputFile.isEmpty()) return false;
1641 if (QFile::exists(outputFile)) {
1642 // Show the file dialog again if the user does not want to overwrite the file
1643 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it?")) == KMessageBox::No)
1644 return saveFileAs();
1646 return saveFileAs(outputFile);
1649 bool MainWindow::saveFile()
1651 if (!m_activeDocument) return true;
1652 if (m_activeDocument->url().isEmpty()) {
1653 return saveFileAs();
1655 bool result = saveFileAs(m_activeDocument->url().path());
1656 m_activeDocument->m_autosave->resize(0);
1661 void MainWindow::openFile()
1663 if (!m_startUrl.isEmpty()) {
1664 openFile(m_startUrl);
1665 m_startUrl = KUrl();
1668 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
1669 if (url.isEmpty()) return;
1670 m_fileOpenRecent->addUrl(url);
1674 void MainWindow::openLastFile()
1676 KSharedConfigPtr config = KGlobal::config();
1677 KUrl::List urls = m_fileOpenRecent->urls();
1678 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1679 if (urls.isEmpty()) newFile(false);
1680 else openFile(urls.last());
1683 void MainWindow::openFile(const KUrl &url)
1685 // Check if the document is already opened
1686 const int ct = m_timelineArea->count();
1687 bool isOpened = false;
1689 for (i = 0; i < ct; i++) {
1690 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1691 KdenliveDoc *doc = tab->document();
1692 if (doc->url() == url) {
1698 m_timelineArea->setCurrentIndex(i);
1702 // Check for backup file
1703 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1704 if (!staleFiles.isEmpty()) {
1705 if (KMessageBox::questionYesNo(this,
1706 i18n("Auto-saved files exist. Do you want to recover them now?"),
1707 i18n("File Recovery"),
1708 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1709 recoverFiles(staleFiles);
1712 // remove the stale files
1713 foreach(KAutoSaveFile *stale, staleFiles) {
1714 stale->open(QIODevice::ReadWrite);
1719 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1720 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
1721 m_messageLabel->repaint();
1722 doOpenFile(url, NULL);
1725 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1727 if (!m_timelineArea->isEnabled()) return;
1728 m_fileRevert->setEnabled(true);
1729 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, this);
1730 if (stale == NULL) {
1731 stale = new KAutoSaveFile(url, doc);
1732 doc->m_autosave = stale;
1734 doc->m_autosave = stale;
1735 doc->setUrl(stale->managedFile());
1736 doc->setModified(true);
1737 stale->setParent(doc);
1739 connectDocumentInfo(doc);
1741 TrackView *trackView = new TrackView(doc, &ok, this);
1742 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1744 m_timelineArea->setEnabled(false);
1745 m_projectList->setEnabled(false);
1746 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
1747 slotGotProgressInfo(QString(), -1);
1748 newFile(false, true);
1751 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1752 trackView->setDuration(trackView->duration());
1753 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1755 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1756 slotGotProgressInfo(QString(), -1);
1757 m_projectMonitor->adjustRulerSize(trackView->duration());
1758 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1759 m_clipMonitor->refreshMonitor(true);
1762 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1764 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1765 foreach(KAutoSaveFile *stale, staleFiles) {
1766 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1767 // show an error message; we could not steal the lockfile
1768 // maybe another application got to the file before us?
1772 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1773 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
1774 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1775 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1779 void MainWindow::parseProfiles(const QString &mltPath)
1781 //KdenliveSettings::setDefaulttmpfolder();
1782 if (!mltPath.isEmpty()) {
1783 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1784 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
1787 if (KdenliveSettings::mltpath().isEmpty())
1788 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1790 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
1791 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
1792 if (!QFile::exists(meltPath))
1793 meltPath = KStandardDirs::findExe("melt");
1794 KdenliveSettings::setRendererpath(meltPath);
1797 if (KdenliveSettings::rendererpath().isEmpty()) {
1798 // Cannot find the MLT melt renderer, ask for location
1799 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
1800 if (getUrl->exec() == QDialog::Rejected) {
1803 KUrl rendererPath = getUrl->selectedUrl();
1805 if (rendererPath.isEmpty()) ::exit(0);
1806 KdenliveSettings::setRendererpath(rendererPath.path());
1809 QStringList profilesFilter;
1810 profilesFilter << "*";
1811 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1812 if (profilesList.isEmpty()) {
1813 // Cannot find MLT path, try finding melt
1814 QString profilePath = KdenliveSettings::rendererpath();
1815 if (!profilePath.isEmpty()) {
1816 profilePath = profilePath.section('/', 0, -3);
1817 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1818 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1820 if (profilesList.isEmpty()) {
1821 // Cannot find the MLT profiles, ask for location
1822 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
1823 getUrl->fileDialog()->setMode(KFile::Directory);
1824 if (getUrl->exec() == QDialog::Rejected) {
1827 KUrl mltPath = getUrl->selectedUrl();
1829 if (mltPath.isEmpty()) ::exit(0);
1830 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
1831 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1835 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1837 // Parse again MLT profiles to build a list of available video formats
1838 if (profilesList.isEmpty()) parseProfiles();
1842 void MainWindow::slotEditProfiles()
1844 ProfilesDialog *w = new ProfilesDialog;
1845 if (w->exec() == QDialog::Accepted) {
1846 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1847 if (d) d->checkProfile();
1852 void MainWindow::slotDetectAudioDriver()
1854 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
1855 leading to no audio output, see bug #934 */
1857 //decide which audio driver is really best, in some cases SDL is wrong
1858 if (KdenliveSettings::audiodrivername().isEmpty()) {
1860 KProcess readProcess;
1861 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
1862 if (!KStandardDirs::findExe("pactl").isEmpty()) {
1863 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
1864 readProcess.setProgram("pactl", QStringList() << "stat");
1865 readProcess.execute(2000); // Kill it after 2 seconds
1867 QString result = QString(readProcess.readAllStandardOutput());
1868 kDebug() << "// / / / / / READING PACTL: ";
1870 if (!result.isEmpty()) {
1872 kDebug() << "// / / / / PULSEAUDIO DETECTED";
1876 KdenliveSettings::setAutoaudiodrivername(driver);
1880 void MainWindow::slotEditProjectSettings()
1882 QPoint p = m_activeDocument->getTracksCount();
1883 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
1885 if (w->exec() == QDialog::Accepted) {
1886 QString profile = w->selectedProfile();
1887 m_activeDocument->setProjectFolder(w->selectedFolder());
1888 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path(KUrl::AddTrailingSlash));
1889 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
1890 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
1891 if (m_activeDocument->profilePath() != profile) {
1892 // Profile was changed
1893 double dar = m_activeDocument->dar();
1895 // Deselect current effect / transition
1896 m_effectStack->slotClipItemSelected(NULL, 0);
1897 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1898 m_clipMonitor->slotSetXml(NULL);
1899 bool updateFps = m_activeDocument->setProfilePath(profile);
1900 KdenliveSettings::setCurrent_profile(profile);
1901 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1902 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1904 m_activeDocument->clipManager()->clearUnusedProducers();
1905 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1907 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
1908 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
1909 m_projectList->updateProjectFormat(m_activeDocument->timecode());
1910 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1911 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1912 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1913 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
1914 if (updateFps) m_activeTimeline->updateProjectFps();
1915 m_activeDocument->setModified(true);
1916 m_commandStack->activeStack()->clear();
1917 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
1918 slotUpdateMousePosition(0);
1919 // We need to desactivate & reactivate monitors to get a refresh
1920 //m_monitorManager->switchMonitors();
1927 void MainWindow::slotRenderProject()
1929 if (!m_renderWidget) {
1930 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
1931 m_renderWidget = new RenderWidget(projectfolder, this);
1932 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
1933 connect(m_renderWidget, SIGNAL(selectedRenderProfile(const QString &, const QString &, const QString &, const QString&)), this, SLOT(slotSetDocumentRenderProfile(const QString &, const QString &, const QString &, const QString&)));
1934 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
1935 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1936 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1937 if (m_activeDocument) {
1938 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1939 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1940 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
1941 m_renderWidget->setRenderProfile(m_activeDocument->getDocumentProperty("renderdestination"), m_activeDocument->getDocumentProperty("rendercategory"), m_activeDocument->getDocumentProperty("renderprofile"), m_activeDocument->getDocumentProperty("renderurl"));
1944 slotCheckRenderStatus();
1945 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1946 if (currentTab) m_renderWidget->setTimeline(currentTab);
1947 m_renderWidget->setDocument(m_activeDocument);*/
1948 m_renderWidget->show();
1949 m_renderWidget->showNormal();
1951 m_activeTimeline->tracksNumber();
1952 m_renderWidget->enableAudio(false);
1953 //m_renderWidget->export_audio;
1956 void MainWindow::slotCheckRenderStatus()
1958 // Make sure there are no missing clips
1960 m_renderWidget->missingClips(m_projectList->hasMissingClips());
1963 void MainWindow::setRenderingProgress(const QString &url, int progress)
1966 m_renderWidget->setRenderJob(url, progress);
1969 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
1972 m_renderWidget->setRenderStatus(url, status, error);
1975 void MainWindow::slotCleanProject()
1977 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
1978 m_projectList->cleanup();
1981 void MainWindow::slotUpdateMousePosition(int pos)
1983 if (m_activeDocument)
1984 switch (m_timecodeFormat->currentIndex()) {
1986 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1989 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1993 void MainWindow::slotUpdateDocumentState(bool modified)
1995 if (!m_activeDocument) return;
1996 setCaption(m_activeDocument->description(), modified);
1997 m_saveAction->setEnabled(modified);
1999 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2000 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2002 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2003 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2007 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2009 if (m_activeDocument) {
2010 if (m_activeDocument == doc) return;
2011 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2013 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2016 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2018 //m_projectMonitor->stop();
2019 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2020 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2021 if (m_activeDocument) {
2022 if (m_activeDocument == doc) return;
2023 if (m_activeTimeline) {
2024 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2025 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2026 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2027 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2028 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
2030 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2031 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2032 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2033 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
2034 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2035 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2036 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
2037 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2038 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2039 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2040 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2041 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2042 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2043 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2044 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2045 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2046 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2047 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2048 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2049 disconnect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
2050 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
2051 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
2052 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
2053 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2054 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2055 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2056 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2057 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2058 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2059 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2060 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2061 disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2062 disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2063 m_effectStack->clear();
2065 //m_activeDocument->setRenderer(NULL);
2066 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
2067 disconnect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2068 m_clipMonitor->stop();
2070 KdenliveSettings::setCurrent_profile(doc->profilePath());
2071 KdenliveSettings::setProject_fps(doc->fps());
2072 m_monitorManager->resetProfiles(doc->timecode());
2073 m_projectList->setDocument(doc);
2074 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2075 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2076 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint)));
2077 connect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2078 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), trackView->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2080 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2081 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2083 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
2086 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2087 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2088 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2089 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2090 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2091 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2092 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2093 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2094 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
2095 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2096 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
2098 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2099 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2100 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
2101 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2102 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2104 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
2105 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2106 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2109 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2110 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2112 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2113 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2114 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2115 m_zoomSlider->setValue(doc->zoom().x());
2116 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2117 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2118 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2119 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2121 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2122 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2125 connect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
2126 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2127 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
2128 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
2129 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
2130 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2131 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2132 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2133 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2134 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2136 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2137 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2138 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2139 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2140 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2143 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2144 m_activeTimeline = trackView;
2145 if (m_renderWidget) {
2146 slotCheckRenderStatus();
2147 m_renderWidget->setProfile(doc->mltProfile());
2148 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2149 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2150 m_renderWidget->setRenderProfile(doc->getDocumentProperty("renderdestination"), doc->getDocumentProperty("rendercategory"), doc->getDocumentProperty("renderprofile"), doc->getDocumentProperty("renderurl"));
2152 //doc->setRenderer(m_projectMonitor->render);
2153 m_commandStack->setActiveStack(doc->commandStack());
2154 KdenliveSettings::setProject_display_ratio(doc->dar());
2155 //doc->clipManager()->checkAudioThumbs();
2157 //m_overView->setScene(trackView->projectScene());
2158 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2159 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2161 setCaption(doc->description(), doc->isModified());
2162 m_saveAction->setEnabled(doc->isModified());
2163 m_normalEditTool->setChecked(true);
2164 m_activeDocument = doc;
2165 m_activeTimeline->updateProjectFps();
2166 m_activeDocument->checkProjectClips();
2167 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
2168 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2169 slotUpdateMousePosition(0);
2170 // set tool to select tool
2171 m_buttonSelectTool->setChecked(true);
2174 void MainWindow::slotZoneMoved(int start, int end)
2176 m_activeDocument->setZone(start, end);
2177 m_projectMonitor->slotZoneMoved(start, end);
2180 void MainWindow::slotGuidesUpdated()
2183 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2186 void MainWindow::slotEditKeys()
2188 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2189 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2190 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2194 void MainWindow::slotPreferences(int page, int option)
2196 //An instance of your dialog could be already created and could be
2197 // cached, in which case you want to display the cached dialog
2198 // instead of creating another one
2199 if (KConfigDialog::showDialog("settings")) {
2200 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2201 if (page != -1) d->showPage(page, option);
2205 // KConfigDialog didn't find an instance of this dialog, so lets
2207 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
2208 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2209 //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
2210 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2211 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2213 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
2215 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2217 if (page != -1) dialog->showPage(page, option);
2220 void MainWindow::slotUpdatePreviewSettings()
2222 if (m_activeDocument) {
2223 m_clipMonitor->slotSetXml(NULL);
2224 m_activeDocument->updatePreviewSettings();
2228 void MainWindow::updateConfiguration()
2230 //TODO: we should apply settings to all projects, not only the current one
2231 if (m_activeTimeline) {
2232 m_activeTimeline->refresh();
2233 m_activeTimeline->projectView()->checkAutoScroll();
2234 m_activeTimeline->projectView()->checkTrackHeight();
2235 if (m_activeDocument)
2236 m_activeDocument->clipManager()->checkAudioThumbs();
2238 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2239 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2240 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2242 // Update list of transcoding profiles
2244 #ifndef NO_JOGSHUTTLE
2245 activateShuttleDevice();
2246 #endif /* NO_JOGSHUTTLE */
2250 void MainWindow::slotSwitchSplitAudio()
2252 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2253 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2256 void MainWindow::slotSwitchVideoThumbs()
2258 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2259 if (m_activeTimeline)
2260 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2261 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2264 void MainWindow::slotSwitchAudioThumbs()
2266 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2267 if (m_activeTimeline) {
2268 m_activeTimeline->refresh();
2269 m_activeTimeline->projectView()->checkAutoScroll();
2270 if (m_activeDocument)
2271 m_activeDocument->clipManager()->checkAudioThumbs();
2273 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2276 void MainWindow::slotSwitchMarkersComments()
2278 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2279 if (m_activeTimeline)
2280 m_activeTimeline->refresh();
2281 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2284 void MainWindow::slotSwitchSnap()
2286 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2287 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2291 void MainWindow::slotDeleteItem()
2293 if (QApplication::focusWidget() &&
2294 QApplication::focusWidget()->parentWidget() &&
2295 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2296 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2297 m_projectList->slotRemoveClip();
2300 QWidget *widget = QApplication::focusWidget();
2302 if (widget == m_effectStackDock) {
2303 m_effectStack->slotItemDel();
2306 widget = widget->parentWidget();
2309 // effect stack has no focus
2310 if (m_activeTimeline)
2311 m_activeTimeline->projectView()->deleteSelectedClips();
2315 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2317 if (m_clipMonitor->isActive())
2318 m_clipMonitor->checkOverlay();
2319 m_clipMonitor->updateMarkers(clip);
2322 void MainWindow::slotAddClipMarker()
2324 DocClipBase *clip = NULL;
2326 if (m_projectMonitor->isActive()) {
2327 if (m_activeTimeline) {
2328 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2330 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2331 clip = item->baseClip();
2335 clip = m_clipMonitor->activeClip();
2336 pos = m_clipMonitor->position();
2339 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2342 QString id = clip->getId();
2343 CommentedTime marker(pos, i18n("Marker"));
2344 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2345 if (d.exec() == QDialog::Accepted)
2346 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2349 void MainWindow::slotDeleteClipMarker()
2351 DocClipBase *clip = NULL;
2353 if (m_projectMonitor->isActive()) {
2354 if (m_activeTimeline) {
2355 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2357 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2358 clip = item->baseClip();
2362 clip = m_clipMonitor->activeClip();
2363 pos = m_clipMonitor->position();
2366 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2370 QString id = clip->getId();
2371 QString comment = clip->markerComment(pos);
2372 if (comment.isEmpty()) {
2373 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2376 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2379 void MainWindow::slotDeleteAllClipMarkers()
2381 DocClipBase *clip = NULL;
2382 if (m_projectMonitor->isActive()) {
2383 if (m_activeTimeline) {
2384 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2386 clip = item->baseClip();
2390 clip = m_clipMonitor->activeClip();
2393 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2396 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2399 void MainWindow::slotEditClipMarker()
2401 DocClipBase *clip = NULL;
2403 if (m_projectMonitor->isActive()) {
2404 if (m_activeTimeline) {
2405 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2407 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2408 clip = item->baseClip();
2412 clip = m_clipMonitor->activeClip();
2413 pos = m_clipMonitor->position();
2416 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2420 QString id = clip->getId();
2421 QString oldcomment = clip->markerComment(pos);
2422 if (oldcomment.isEmpty()) {
2423 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2427 CommentedTime marker(pos, oldcomment);
2428 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2429 if (d.exec() == QDialog::Accepted) {
2430 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2431 if (d.newMarker().time() != pos) {
2432 // remove old marker
2433 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2438 void MainWindow::slotAddGuide()
2440 if (m_activeTimeline)
2441 m_activeTimeline->projectView()->slotAddGuide();
2444 void MainWindow::slotInsertSpace()
2446 if (m_activeTimeline)
2447 m_activeTimeline->projectView()->slotInsertSpace();
2450 void MainWindow::slotRemoveSpace()
2452 if (m_activeTimeline)
2453 m_activeTimeline->projectView()->slotRemoveSpace();
2456 void MainWindow::slotInsertTrack(int ix)
2458 m_projectMonitor->activateMonitor();
2459 if (m_activeTimeline)
2460 m_activeTimeline->projectView()->slotInsertTrack(ix);
2461 if (m_activeDocument)
2462 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2465 void MainWindow::slotDeleteTrack(int ix)
2467 m_projectMonitor->activateMonitor();
2468 if (m_activeTimeline)
2469 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2470 if (m_activeDocument)
2471 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2474 void MainWindow::slotConfigTrack(int ix)
2476 m_projectMonitor->activateMonitor();
2477 if (m_activeTimeline)
2478 m_activeTimeline->projectView()->slotConfigTracks(ix);
2479 if (m_activeDocument)
2480 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2483 void MainWindow::slotEditGuide()
2485 if (m_activeTimeline)
2486 m_activeTimeline->projectView()->slotEditGuide();
2489 void MainWindow::slotDeleteGuide()
2491 if (m_activeTimeline)
2492 m_activeTimeline->projectView()->slotDeleteGuide();
2495 void MainWindow::slotDeleteAllGuides()
2497 if (m_activeTimeline)
2498 m_activeTimeline->projectView()->slotDeleteAllGuides();
2501 void MainWindow::slotCutTimelineClip()
2503 if (m_activeTimeline)
2504 m_activeTimeline->projectView()->cutSelectedClips();
2507 void MainWindow::slotInsertClipOverwrite()
2509 if (m_activeTimeline) {
2510 QStringList data = m_clipMonitor->getZoneInfo();
2511 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2515 void MainWindow::slotSelectTimelineClip()
2517 if (m_activeTimeline)
2518 m_activeTimeline->projectView()->selectClip(true);
2521 void MainWindow::slotSelectTimelineTransition()
2523 if (m_activeTimeline)
2524 m_activeTimeline->projectView()->selectTransition(true);
2527 void MainWindow::slotDeselectTimelineClip()
2529 if (m_activeTimeline)
2530 m_activeTimeline->projectView()->selectClip(false, true);
2533 void MainWindow::slotDeselectTimelineTransition()
2535 if (m_activeTimeline)
2536 m_activeTimeline->projectView()->selectTransition(false, true);
2539 void MainWindow::slotSelectAddTimelineClip()
2541 if (m_activeTimeline)
2542 m_activeTimeline->projectView()->selectClip(true, true);
2545 void MainWindow::slotSelectAddTimelineTransition()
2547 if (m_activeTimeline)
2548 m_activeTimeline->projectView()->selectTransition(true, true);
2551 void MainWindow::slotGroupClips()
2553 if (m_activeTimeline)
2554 m_activeTimeline->projectView()->groupClips();
2557 void MainWindow::slotUnGroupClips()
2559 if (m_activeTimeline)
2560 m_activeTimeline->projectView()->groupClips(false);
2563 void MainWindow::slotEditItemDuration()
2565 if (m_activeTimeline)
2566 m_activeTimeline->projectView()->editItemDuration();
2569 void MainWindow::slotAddProjectClip(KUrl url)
2571 if (m_activeDocument)
2572 m_activeDocument->slotAddClipFile(url, QString());
2575 void MainWindow::slotAddTransition(QAction *result)
2577 if (!result) return;
2578 QStringList info = result->data().toStringList();
2579 if (info.isEmpty()) return;
2580 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2581 if (m_activeTimeline && !transition.isNull()) {
2582 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2586 void MainWindow::slotAddVideoEffect(QAction *result)
2588 if (!result) return;
2589 QStringList info = result->data().toStringList();
2590 if (info.isEmpty()) return;
2591 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2592 slotAddEffect(effect);
2595 void MainWindow::slotAddAudioEffect(QAction *result)
2597 if (!result) return;
2598 QStringList info = result->data().toStringList();
2599 if (info.isEmpty()) return;
2600 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2601 slotAddEffect(effect);
2604 void MainWindow::slotAddCustomEffect(QAction *result)
2606 if (!result) return;
2607 QStringList info = result->data().toStringList();
2608 if (info.isEmpty()) return;
2609 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2610 slotAddEffect(effect);
2613 void MainWindow::slotZoomIn()
2615 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2616 slotShowZoomSliderToolTip();
2619 void MainWindow::slotZoomOut()
2621 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2622 slotShowZoomSliderToolTip();
2625 void MainWindow::slotFitZoom()
2627 if (m_activeTimeline)
2628 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2631 void MainWindow::slotSetZoom(int value)
2633 if (m_activeTimeline)
2634 m_activeTimeline->slotChangeZoom(value);
2636 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
2637 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
2638 slotUpdateZoomSliderToolTip(value);
2640 m_zoomSlider->blockSignals(true);
2641 m_zoomSlider->setValue(value);
2642 m_zoomSlider->blockSignals(false);
2645 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
2647 if (zoomlevel != -1)
2648 slotUpdateZoomSliderToolTip(zoomlevel);
2650 QPoint global = m_zoomSlider->rect().topLeft();
2651 global.ry() += m_zoomSlider->height() / 2;
2652 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
2653 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
2656 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
2658 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
2661 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2663 m_statusProgressBar->setValue(progress);
2664 if (progress >= 0) {
2665 if (!message.isEmpty())
2666 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2667 m_statusProgressBar->setVisible(true);
2668 } else if (progress == -2) {
2669 if (!message.isEmpty())
2670 m_messageLabel->setMessage(message, ErrorMessage);
2671 m_statusProgressBar->setVisible(false);
2673 m_messageLabel->setMessage(QString(), DefaultMessage);
2674 m_statusProgressBar->setVisible(false);
2678 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2680 if (clip->clipType() == TEXT) {
2681 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
2682 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
2683 // template text clip
2685 // Get the list of existing templates
2687 filter << "*.kdenlivetitle";
2688 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
2690 QDialog *dia = new QDialog(this);
2691 Ui::TemplateClip_UI dia_ui;
2692 dia_ui.setupUi(dia);
2694 const QString templatePath = clip->getProperty("resource");
2695 for (int i = 0; i < templateFiles.size(); ++i) {
2696 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
2697 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
2699 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
2700 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
2701 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
2702 //warning: setting base directory doesn't work??
2703 KUrl startDir(titlepath);
2704 dia_ui.template_list->fileDialog()->setUrl(startDir);
2705 dia_ui.description->setText(clip->getProperty("description"));
2706 if (dia->exec() == QDialog::Accepted) {
2707 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
2708 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
2710 QMap <QString, QString> newprops;
2712 if (KUrl(textTemplate).path() != templatePath) {
2713 // The template was changed
2714 newprops.insert("resource", textTemplate);
2717 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
2718 newprops.insert("description", dia_ui.description->toPlainText());
2721 QString newtemplate = newprops.value("xmltemplate");
2722 if (newtemplate.isEmpty()) newtemplate = templatePath;
2724 // template modified we need to update xmldata
2725 QString description = newprops.value("description");
2726 if (description.isEmpty()) description = clip->getProperty("description");
2727 else newprops.insert("templatetext", description);
2728 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
2729 if (!newprops.isEmpty()) {
2730 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2731 m_activeDocument->commandStack()->push(command);
2737 QString path = clip->getProperty("resource");
2738 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
2740 doc.setContent(clip->getProperty("xmldata"));
2741 dia_ui->setXml(doc);
2742 if (dia_ui->exec() == QDialog::Accepted) {
2743 QMap <QString, QString> newprops;
2744 newprops.insert("xmldata", dia_ui->xml().toString());
2745 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
2746 // duration changed, we need to update duration
2747 newprops.insert("out", QString::number(dia_ui->outPoint()));
2749 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2750 m_activeDocument->commandStack()->push(command);
2751 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
2752 m_activeDocument->setModified(true);
2756 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2759 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2760 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2761 if (dia.exec() == QDialog::Accepted) {
2762 QMap <QString, QString> newprops = dia.properties();
2763 if (newprops.isEmpty()) return;
2764 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2765 m_activeDocument->commandStack()->push(command);
2767 if (dia.needsTimelineRefresh()) {
2768 // update clip occurences in timeline
2769 m_activeTimeline->projectView()->slotUpdateClip(clip->getId(), dia.needsTimelineReload());
2775 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
2777 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
2778 if (dia.exec() == QDialog::Accepted) {
2779 QUndoCommand *command = new QUndoCommand();
2780 command->setText(i18n("Edit clips"));
2781 for (int i = 0; i < cliplist.count(); i++) {
2782 DocClipBase *clip = cliplist.at(i);
2783 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true, command);
2785 m_activeDocument->commandStack()->push(command);
2786 for (int i = 0; i < cliplist.count(); i++)
2787 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
2791 void MainWindow::customEvent(QEvent* e)
2793 if (e->type() == QEvent::User)
2794 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
2796 void MainWindow::slotActivateEffectStackView()
2798 m_effectStack->raiseWindow(m_effectStackDock);
2801 void MainWindow::slotActivateTransitionView(Transition *t)
2804 m_transitionConfig->raiseWindow(m_transitionConfigDock);
2807 void MainWindow::slotSnapRewind()
2809 if (m_projectMonitor->isActive()) {
2810 if (m_activeTimeline)
2811 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2813 m_clipMonitor->slotSeekToPreviousSnap();
2817 void MainWindow::slotSnapForward()
2819 if (m_projectMonitor->isActive()) {
2820 if (m_activeTimeline)
2821 m_activeTimeline->projectView()->slotSeekToNextSnap();
2823 m_clipMonitor->slotSeekToNextSnap();
2827 void MainWindow::slotClipStart()
2829 if (m_projectMonitor->isActive()) {
2830 if (m_activeTimeline)
2831 m_activeTimeline->projectView()->clipStart();
2835 void MainWindow::slotClipEnd()
2837 if (m_projectMonitor->isActive()) {
2838 if (m_activeTimeline)
2839 m_activeTimeline->projectView()->clipEnd();
2843 void MainWindow::slotZoneStart()
2845 if (m_projectMonitor->isActive())
2846 m_projectMonitor->slotZoneStart();
2848 m_clipMonitor->slotZoneStart();
2851 void MainWindow::slotZoneEnd()
2853 if (m_projectMonitor->isActive())
2854 m_projectMonitor->slotZoneEnd();
2856 m_clipMonitor->slotZoneEnd();
2859 void MainWindow::slotChangeTool(QAction * action)
2861 if (action == m_buttonSelectTool)
2862 slotSetTool(SELECTTOOL);
2863 else if (action == m_buttonRazorTool)
2864 slotSetTool(RAZORTOOL);
2865 else if (action == m_buttonSpacerTool)
2866 slotSetTool(SPACERTOOL);
2869 void MainWindow::slotChangeEdit(QAction * action)
2871 if (!m_activeTimeline)
2874 if (action == m_overwriteEditTool)
2875 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
2876 else if (action == m_insertEditTool)
2877 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
2879 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
2882 void MainWindow::slotSetTool(PROJECTTOOL tool)
2884 if (m_activeDocument && m_activeTimeline) {
2885 //m_activeDocument->setTool(tool);
2889 message = i18n("Ctrl + click to use spacer on current track only");
2892 message = i18n("Click on a clip to cut it");
2895 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
2898 m_messageLabel->setMessage(message, InformationMessage);
2899 m_activeTimeline->projectView()->setTool(tool);
2903 void MainWindow::slotCopy()
2905 if (m_activeDocument && m_activeTimeline)
2906 m_activeTimeline->projectView()->copyClip();
2909 void MainWindow::slotPaste()
2911 if (m_activeDocument && m_activeTimeline)
2912 m_activeTimeline->projectView()->pasteClip();
2915 void MainWindow::slotPasteEffects()
2917 if (m_activeDocument && m_activeTimeline)
2918 m_activeTimeline->projectView()->pasteClipEffects();
2921 void MainWindow::slotFind()
2923 if (!m_activeDocument || !m_activeTimeline) return;
2924 m_projectSearch->setEnabled(false);
2925 m_findActivated = true;
2926 m_findString.clear();
2927 m_activeTimeline->projectView()->initSearchStrings();
2928 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2929 m_findTimer.start(5000);
2930 qApp->installEventFilter(this);
2933 void MainWindow::slotFindNext()
2935 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
2936 statusBar()->showMessage(i18n("Found: %1", m_findString));
2938 statusBar()->showMessage(i18n("Reached end of project"));
2939 m_findTimer.start(4000);
2942 void MainWindow::findAhead()
2944 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
2945 m_projectSearchNext->setEnabled(true);
2946 statusBar()->showMessage(i18n("Found: %1", m_findString));
2948 m_projectSearchNext->setEnabled(false);
2949 statusBar()->showMessage(i18n("Not found: %1", m_findString));
2953 void MainWindow::findTimeout()
2955 m_projectSearchNext->setEnabled(false);
2956 m_findActivated = false;
2957 m_findString.clear();
2958 statusBar()->showMessage(i18n("Find stopped"), 3000);
2959 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
2960 m_projectSearch->setEnabled(true);
2961 removeEventFilter(this);
2964 void MainWindow::slotClipInTimeline(const QString &clipId)
2966 if (m_activeTimeline && m_activeDocument) {
2967 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
2969 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
2970 inTimelineMenu->clear();
2972 QList <QAction *> actionList;
2974 for (int i = 0; i < matching.count(); ++i) {
2975 QString track = QString::number(matching.at(i).track);
2976 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
2978 QAction *a = new QAction(track + ": " + start, this);
2979 a->setData(QStringList() << track << start);
2980 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
2981 while (j < actionList.count()) {
2982 if (actionList.at(j)->text() > a->text()) break;
2985 actionList.insert(j, a);
2987 inTimelineMenu->addActions(actionList);
2989 if (matching.empty())
2990 inTimelineMenu->setEnabled(false);
2992 inTimelineMenu->setEnabled(true);
2996 void MainWindow::slotClipInProjectTree()
2998 if (m_activeTimeline) {
2999 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3000 if (clipIds.isEmpty())
3002 m_projectListDock->raise();
3003 for (int i = 0; i < clipIds.count(); i++)
3004 m_projectList->selectItemById(clipIds.at(i));
3005 if (m_projectMonitor->isActive())
3006 slotSwitchMonitors();
3010 /*void MainWindow::slotClipToProjectTree()
3012 if (m_activeTimeline) {
3013 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3014 if (clips.isEmpty()) return;
3015 for (int i = 0; i < clips.count(); i++) {
3016 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3018 //m_projectList->selectItemById(clipIds.at(i));
3022 void MainWindow::slotSelectClipInTimeline()
3024 if (m_activeTimeline) {
3025 QAction *action = qobject_cast<QAction *>(sender());
3026 QStringList data = action->data().toStringList();
3027 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3031 void MainWindow::keyPressEvent(QKeyEvent *ke)
3033 if (m_findActivated) {
3034 if (ke->key() == Qt::Key_Backspace) {
3035 m_findString = m_findString.left(m_findString.length() - 1);
3037 if (!m_findString.isEmpty())
3042 m_findTimer.start(4000);
3045 } else if (ke->key() == Qt::Key_Escape) {
3049 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3050 m_findString += ke->text();
3054 m_findTimer.start(4000);
3059 KXmlGuiWindow::keyPressEvent(ke);
3064 /** Gets called when the window gets hidden */
3065 void MainWindow::hideEvent(QHideEvent */*event*/)
3068 if (m_monitorManager)
3069 m_monitorManager->stopActiveMonitor();
3072 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3074 if (m_findActivated) {
3075 if (event->type() == QEvent::ShortcutOverride) {
3076 QKeyEvent* ke = (QKeyEvent*) event;
3077 if (ke->text().trimmed().isEmpty()) return false;
3084 // pass the event on to the parent class
3085 return QMainWindow::eventFilter(obj, event);
3090 void MainWindow::slotSaveZone(Render *render, QPoint zone)
3092 KDialog *dialog = new KDialog(this);
3093 dialog->setCaption("Save clip zone");
3094 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3096 QWidget *widget = new QWidget(dialog);
3097 dialog->setMainWidget(widget);
3099 QVBoxLayout *vbox = new QVBoxLayout(widget);
3100 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3101 QString path = m_activeDocument->projectFolder().path();
3103 path.append("untitled.mlt");
3104 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
3105 url->setFilter("video/mlt-playlist");
3106 QLabel *label2 = new QLabel(i18n("Description:"), this);
3107 KLineEdit *edit = new KLineEdit(this);
3108 vbox->addWidget(label1);
3109 vbox->addWidget(url);
3110 vbox->addWidget(label2);
3111 vbox->addWidget(edit);
3112 if (dialog->exec() == QDialog::Accepted)
3113 render->saveZone(url->url(), edit->text(), zone);
3117 void MainWindow::slotSetInPoint()
3119 if (m_clipMonitor->isActive())
3120 m_clipMonitor->slotSetZoneStart();
3122 m_projectMonitor->slotSetZoneStart();
3123 //else m_activeTimeline->projectView()->setInPoint();
3126 void MainWindow::slotSetOutPoint()
3128 if (m_clipMonitor->isActive())
3129 m_clipMonitor->slotSetZoneEnd();
3131 m_projectMonitor->slotSetZoneEnd();
3132 // else m_activeTimeline->projectView()->setOutPoint();
3135 void MainWindow::slotResizeItemStart()
3137 if (m_activeTimeline)
3138 m_activeTimeline->projectView()->setInPoint();
3141 void MainWindow::slotResizeItemEnd()
3143 if (m_activeTimeline)
3144 m_activeTimeline->projectView()->setOutPoint();
3147 int MainWindow::getNewStuff(const QString &configFile)
3149 KNS3::Entry::List entries;
3150 #if KDE_IS_VERSION(4,3,80)
3151 KNS3::DownloadDialog dialog(configFile);
3153 entries = dialog.changedEntries();
3154 foreach(const KNS3::Entry &entry, entries) {
3155 if (entry.status() == KNS3::Entry::Installed)
3156 kDebug() << "// Installed files: " << entry.installedFiles();
3159 KNS::Engine engine(0);
3160 if (engine.init(configFile))
3161 entries = engine.downloadDialogModal(this);
3162 foreach(KNS::Entry *entry, entries) {
3163 if (entry->status() == KNS::Entry::Installed)
3164 kDebug() << "// Installed files: " << entry->installedFiles();
3166 #endif /* KDE_IS_VERSION(4,3,80) */
3167 return entries.size();
3170 void MainWindow::slotGetNewTitleStuff()
3172 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3173 TitleWidget::refreshTitleTemplates();
3176 void MainWindow::slotGetNewLumaStuff()
3178 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3179 initEffects::refreshLumas();
3180 m_activeTimeline->projectView()->reloadTransitionLumas();
3184 void MainWindow::slotGetNewRenderStuff()
3186 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3188 m_renderWidget->reloadProfiles();
3191 void MainWindow::slotGetNewMltProfileStuff()
3193 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3194 // update the list of profiles in settings dialog
3195 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3201 void MainWindow::slotAutoTransition()
3203 if (m_activeTimeline)
3204 m_activeTimeline->projectView()->autoTransition();
3207 void MainWindow::slotSplitAudio()
3209 if (m_activeTimeline)
3210 m_activeTimeline->projectView()->splitAudio();
3213 void MainWindow::slotUpdateClipType(QAction *action)
3215 if (m_activeTimeline) {
3216 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3217 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3218 else m_activeTimeline->projectView()->setAudioAndVideo();
3222 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3224 // We must stop the monitors since we create a new on in the dvd wizard
3225 m_clipMonitor->stop();
3226 m_projectMonitor->stop();
3227 DvdWizard w(url, profile, this);
3229 m_projectMonitor->start();
3232 void MainWindow::slotShowTimeline(bool show)
3234 if (show == false) {
3235 m_timelineState = saveState();
3236 centralWidget()->setHidden(true);
3238 centralWidget()->setHidden(false);
3239 restoreState(m_timelineState);
3243 void MainWindow::slotMaximizeCurrent(bool /*show*/)
3245 //TODO: is there a way to maximize current widget?
3248 m_timelineState = saveState();
3249 QWidget *par = focusWidget()->parentWidget();
3250 while (par->parentWidget() && par->parentWidget() != this)
3251 par = par->parentWidget();
3252 kDebug() << "CURRENT WIDGET: " << par->objectName();
3255 //centralWidget()->setHidden(false);
3256 //restoreState(m_timelineState);
3260 void MainWindow::loadTranscoders()
3262 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3265 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3266 KConfigGroup transConfig(config, "Transcoding");
3268 QMap< QString, QString > profiles = transConfig.entryMap();
3269 QMapIterator<QString, QString> i(profiles);
3270 while (i.hasNext()) {
3272 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3273 QAction *a = transMenu->addAction(i.key());
3275 if (data.count() > 1)
3276 a->setToolTip(data.at(1));
3277 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3281 void MainWindow::slotTranscode(KUrl::List urls)
3286 if (urls.isEmpty()) {
3287 QAction *action = qobject_cast<QAction *>(sender());
3288 QStringList data = action->data().toStringList();
3289 params = data.at(0);
3290 if (data.count() > 1) desc = data.at(1);
3291 if (data.count() > 2) condition = data.at(2);
3292 urls << m_projectList->getConditionalUrls(condition);
3293 urls.removeAll(KUrl());
3295 if (urls.isEmpty()) {
3296 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3299 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3300 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3302 //QProcess::startDetached("ffmpeg", parameters);
3305 void MainWindow::slotTranscodeClip()
3307 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3308 if (urls.isEmpty()) return;
3309 slotTranscode(urls);
3312 void MainWindow::slotSetDocumentRenderProfile(const QString &dest, const QString &group, const QString &name, const QString &file)
3314 if (m_activeDocument == NULL) return;
3315 m_activeDocument->setDocumentProperty("renderdestination", dest);
3316 m_activeDocument->setDocumentProperty("rendercategory", group);
3317 m_activeDocument->setDocumentProperty("renderprofile", name);
3318 m_activeDocument->setDocumentProperty("renderurl", file);
3319 m_activeDocument->setModified(true);
3323 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3325 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3327 QString playlistPath;
3330 QString scriptsFolder = m_activeDocument->projectFolder().path() + "/scripts/";
3331 QString path = m_renderWidget->getFreeScriptName();
3332 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3333 if (!ok || scriptPath.isEmpty()) return;
3334 scriptPath.prepend(scriptsFolder);
3335 QFile f(scriptPath);
3337 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3340 playlistPath = scriptPath + ".mlt";
3341 m_projectMonitor->saveSceneList(playlistPath);
3343 KTemporaryFile temp;
3344 temp.setAutoRemove(false);
3345 temp.setSuffix(".mlt");
3347 playlistPath = temp.fileName();
3348 m_projectMonitor->saveSceneList(playlistPath);
3351 if (!chapterFile.isEmpty()) {
3354 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3356 in = m_activeTimeline->inPoint();
3357 out = m_activeTimeline->outPoint();
3360 QDomElement chapters = doc.createElement("chapters");
3361 chapters.setAttribute("fps", m_activeDocument->fps());
3362 doc.appendChild(chapters);
3364 QDomElement guidesxml = m_activeDocument->guidesXml();
3365 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3366 for (int i = 0; i < nodes.count(); i++) {
3367 QDomElement e = nodes.item(i).toElement();
3369 QString comment = e.attribute("comment");
3370 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3371 if (time >= in && time < out) {
3372 if (zoneOnly) time = time - in;
3373 QDomElement chapter = doc.createElement("chapter");
3374 chapters.appendChild(chapter);
3375 chapter.setAttribute("title", comment);
3376 chapter.setAttribute("time", time);
3380 if (chapters.childNodes().count() > 0) {
3381 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3382 // Always insert a guide in pos 0
3383 QDomElement chapter = doc.createElement("chapter");
3384 chapters.insertBefore(chapter, QDomNode());
3385 chapter.setAttribute("title", i18n("Start"));
3386 chapter.setAttribute("time", "0");
3388 // save chapters file
3389 QFile file(chapterFile);
3390 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3391 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3393 file.write(doc.toString().toUtf8());
3394 if (file.error() != QFile::NoError) {
3395 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3402 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath);
3405 void MainWindow::slotUpdateTimecodeFormat(int ix)
3407 KdenliveSettings::setFrametimecode(ix == 1);
3408 m_clipMonitor->updateTimecodeFormat();
3409 m_projectMonitor->updateTimecodeFormat();
3410 m_transitionConfig->updateTimecodeFormat();
3411 m_effectStack->updateTimecodeFormat();
3412 //m_activeTimeline->projectView()->clearSelection();
3413 m_activeTimeline->updateRuler();
3416 void MainWindow::slotRemoveFocus()
3418 statusBar()->setFocus();
3419 statusBar()->clearFocus();
3422 void MainWindow::slotRevert()
3424 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;
3425 KUrl url = m_activeDocument->url();
3426 closeCurrentDocument(false);
3427 doOpenFile(url, NULL);
3431 void MainWindow::slotShutdown()
3433 if (m_activeDocument) m_activeDocument->setModified(false);
3435 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
3436 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
3437 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
3438 smserver.call("logout", 1, 2, 2);
3439 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
3440 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
3441 smserver.call("Shutdown");
3445 void MainWindow::slotUpdateTrackInfo()
3447 if (m_activeDocument)
3448 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
3451 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
3453 // Load the theme file
3455 if (action == NULL) theme = themename;
3456 else theme = action->data().toString();
3457 KdenliveSettings::setColortheme(theme);
3458 // Make palette for all widgets.
3460 if (theme.isEmpty())
3461 plt = QApplication::desktop()->palette();
3463 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
3464 plt = KGlobalSettings::createApplicationPalette(config);
3467 kapp->setPalette(plt);
3468 const QObjectList children = statusBar()->children();
3470 foreach(QObject *child, children) {
3471 if (child->isWidgetType())
3472 ((QWidget*)child)->setPalette(plt);
3473 const QObjectList subchildren = child->children();
3474 foreach(QObject *subchild, subchildren) {
3475 if (subchild->isWidgetType())
3476 ((QWidget*)subchild)->setPalette(plt);
3479 if (m_activeTimeline)
3480 m_activeTimeline->projectView()->updatePalette();
3484 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
3486 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
3487 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
3488 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
3489 const QSize bitsSize(24, 2);
3490 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
3491 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
3493 QPixmap pixmap(23, 16);
3494 pixmap.fill(Qt::black); // ### use some color other than black for borders?
3496 KConfigGroup group(config, "WM");
3497 QPainter p(&pixmap);
3498 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
3499 p.fillRect(1, 1, 7, 7, windowScheme.background());
3500 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
3502 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
3503 p.fillRect(8, 1, 7, 7, buttonScheme.background());
3504 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
3506 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
3507 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
3509 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
3510 p.fillRect(1, 8, 7, 7, viewScheme.background());
3511 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
3513 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
3514 p.fillRect(8, 8, 7, 7, selectionScheme.background());
3515 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
3517 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
3518 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
3524 void MainWindow::slotSwitchMonitors()
3526 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
3527 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
3528 else m_projectList->focusTree();
3531 void MainWindow::slotInsertZoneToTree()
3533 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
3534 QStringList info = m_clipMonitor->getZoneInfo();
3535 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
3538 void MainWindow::slotInsertZoneToTimeline()
3540 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
3541 QStringList info = m_clipMonitor->getZoneInfo();
3542 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
3546 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
3548 if (m_activeDocument && m_activeTimeline) {
3549 if (!ids.isEmpty()) {
3550 for (int i = 0; i < ids.size(); ++i) {
3551 m_activeTimeline->slotDeleteClip(ids.at(i));
3553 m_activeDocument->clipManager()->slotDeleteClips(ids);
3555 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
3556 m_activeDocument->setModified(true);
3560 void MainWindow::slotShowTitleBars(bool show)
3563 m_effectStackDock->setTitleBarWidget(0);
3564 m_clipMonitorDock->setTitleBarWidget(0);
3565 m_projectMonitorDock->setTitleBarWidget(0);
3567 m_recMonitorDock->setTitleBarWidget(0);
3569 m_effectListDock->setTitleBarWidget(0);
3570 m_transitionConfigDock->setTitleBarWidget(0);
3571 m_projectListDock->setTitleBarWidget(0);
3572 m_undoViewDock->setTitleBarWidget(0);
3573 m_vectorscopeDock->setTitleBarWidget(0);
3575 if (!m_effectStackDock->isFloating()) { m_effectStackDock->setTitleBarWidget(new QWidget(this)); }
3576 if (!m_clipMonitorDock->isFloating()) { m_clipMonitorDock->setTitleBarWidget(new QWidget(this)); }
3577 if (!m_projectMonitorDock->isFloating()) { m_projectMonitorDock->setTitleBarWidget(new QWidget(this)); }
3579 if (!m_recMonitorDock->isFloating()) { m_recMonitorDock->setTitleBarWidget(new QWidget(this)); }
3581 if (!m_effectListDock->isFloating()) { m_effectListDock->setTitleBarWidget(new QWidget(this)); }
3582 if (!m_transitionConfigDock->isFloating()) { m_transitionConfigDock->setTitleBarWidget(new QWidget(this)); }
3583 if (!m_projectListDock->isFloating()) { m_projectListDock->setTitleBarWidget(new QWidget(this)); }
3584 if (!m_undoViewDock->isFloating()) { m_undoViewDock->setTitleBarWidget(new QWidget(this)); }
3585 if (!m_vectorscopeDock->isFloating()) { m_vectorscopeDock->setTitleBarWidget(new QWidget(this)); }
3587 KdenliveSettings::setShowtitlebars(show);
3590 void MainWindow::slotSwitchTitles()
3592 slotShowTitleBars(!KdenliveSettings::showtitlebars());
3595 QString MainWindow::getMimeType()
3597 QString mimetype = "application/x-kdenlive";
3598 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
3599 if (!mime) mimetype = "*.kdenlive";
3603 #include "mainwindow.moc"