1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
21 #include "mainwindow.h"
22 #include "mainwindowadaptor.h"
23 #include "kdenlivesettings.h"
24 #include "kdenlivesettingsdialog.h"
25 #include "initeffects.h"
26 #include "profilesdialog.h"
27 #include "projectsettings.h"
29 #include "clipmanager.h"
30 #include "projectlist.h"
32 #include "recmonitor.h"
33 #include "monitormanager.h"
34 #include "kdenlivedoc.h"
35 #include "trackview.h"
36 #include "customtrackview.h"
37 #include "effectslistview.h"
38 #include "effectstackview.h"
39 #include "transitionsettings.h"
40 #include "renderwidget.h"
43 #include "jogshuttle.h"
44 #endif /* NO_JOGSHUTTLE */
45 #include "clipproperties.h"
47 #include "editclipcommand.h"
48 #include "titlewidget.h"
49 #include "markerdialog.h"
51 #include "interfaces.h"
52 #include "kdenlive-config.h"
53 #include "cliptranscode.h"
54 #include "ui_templateclip_ui.h"
56 #include <KApplication>
60 #include <KActionCollection>
61 #include <KActionCategory>
62 #include <KStandardAction>
63 #include <KShortcutsDialog>
64 #include <KFileDialog>
65 #include <KMessageBox>
67 #include <KIO/NetAccess>
70 #include <KConfigDialog>
71 #include <KXMLGUIFactory>
73 #include <kstandarddirs.h>
74 #include <KUrlRequesterDialog>
75 #include <KTemporaryFile>
77 #include <KActionMenu>
80 #include <ktogglefullscreenaction.h>
82 #include <KNotification>
83 #include <KNotifyConfigWidget>
84 #if KDE_IS_VERSION(4,3,80)
85 #include <knewstuff3/downloaddialog.h>
86 #include <knewstuff3/knewstuffaction.h>
88 #include <knewstuff2/engine.h>
89 #include <knewstuff2/ui/knewstuffaction.h>
91 #endif /* KDE_IS_VERSION(4,3,80) */
93 #include <KColorScheme>
95 #include <QTextStream>
99 #include <QInputDialog>
100 #include <QDesktopWidget>
105 static const char version[] = VERSION;
107 static const int ID_TIMELINE_POS = 0;
114 EffectsList MainWindow::videoEffects;
115 EffectsList MainWindow::audioEffects;
116 EffectsList MainWindow::customEffects;
117 EffectsList MainWindow::transitions;
119 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent) :
120 KXmlGuiWindow(parent),
121 m_activeDocument(NULL),
122 m_activeTimeline(NULL),
123 m_renderWidget(NULL),
124 #ifndef NO_JOGSHUTTLE
126 #endif /* NO_JOGSHUTTLE */
127 m_findActivated(false)
130 // Create DBus interface
131 new MainWindowAdaptor(this);
132 QDBusConnection dbus = QDBusConnection::sessionBus();
133 dbus.registerObject("/MainWindow", this);
135 setlocale(LC_NUMERIC, "POSIX");
136 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
137 setFont(KGlobalSettings::toolBarFont());
138 parseProfiles(MltPath);
139 m_commandStack = new QUndoGroup;
140 m_timelineArea = new KTabWidget(this);
141 m_timelineArea->setTabReorderingEnabled(true);
142 m_timelineArea->setTabBarHidden(true);
144 QToolButton *closeTabButton = new QToolButton;
145 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
146 closeTabButton->setIcon(KIcon("tab-close"));
147 closeTabButton->adjustSize();
148 closeTabButton->setToolTip(i18n("Close the current tab"));
149 m_timelineArea->setCornerWidget(closeTabButton);
150 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
152 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
153 m_findTimer.setSingleShot(true);
155 // FIXME: the next call returns a newly allocated object, which leaks
156 initEffects::parseEffectFiles();
157 //initEffects::parseCustomEffectsFile();
159 m_monitorManager = new MonitorManager();
161 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
162 m_projectListDock->setObjectName("project_tree");
163 m_projectList = new ProjectList(this);
164 m_projectListDock->setWidget(m_projectList);
165 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
167 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
168 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
170 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
171 m_effectListDock->setObjectName("effect_list");
172 m_effectList = new EffectsListView();
174 //m_effectList = new KListWidget(this);
175 m_effectListDock->setWidget(m_effectList);
176 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
178 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
179 m_effectStackDock->setObjectName("effect_stack");
180 m_effectStack = new EffectStackView(this);
181 m_effectStackDock->setWidget(m_effectStack);
182 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
184 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
185 m_transitionConfigDock->setObjectName("transition");
186 m_transitionConfig = new TransitionSettings(this);
187 m_transitionConfigDock->setWidget(m_transitionConfig);
188 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
190 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
191 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
193 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
194 m_fileRevert->setEnabled(false);
196 //slotDetectAudioDriver();
198 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
199 m_clipMonitorDock->setObjectName("clip_monitor");
200 m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), this);
201 m_clipMonitorDock->setWidget(m_clipMonitor);
202 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
203 //m_clipMonitor->stop();
205 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
206 m_projectMonitorDock->setObjectName("project_monitor");
207 m_projectMonitor = new Monitor("project", m_monitorManager, QString(), this);
208 m_projectMonitorDock->setWidget(m_projectMonitor);
209 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
212 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
213 m_recMonitorDock->setObjectName("record_monitor");
214 m_recMonitor = new RecMonitor("record", this);
215 m_recMonitorDock->setWidget(m_recMonitor);
216 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
218 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
219 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
222 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
223 m_undoViewDock->setObjectName("undo_history");
224 m_undoView = new QUndoView(this);
225 m_undoView->setCleanIcon(KIcon("edit-clear"));
226 m_undoView->setEmptyLabel(i18n("Clean"));
227 m_undoViewDock->setWidget(m_undoView);
228 m_undoView->setGroup(m_commandStack);
229 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
231 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
232 //overviewDock->setObjectName("project_overview");
233 //m_overView = new CustomTrackView(NULL, NULL, this);
234 //overviewDock->setWidget(m_overView);
235 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
238 //tabifyDockWidget(projectListDock, effectListDock);
239 tabifyDockWidget(m_projectListDock, m_effectStackDock);
240 tabifyDockWidget(m_projectListDock, m_transitionConfigDock);
241 //tabifyDockWidget(projectListDock, undoViewDock);
244 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
246 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
248 setCentralWidget(m_timelineArea);
251 // Find QDockWidget tab bars and show / hide widget title bars on right click
252 QList <QTabBar *> tabs = findChildren<QTabBar *>();
253 for (int i = 0; i < tabs.count(); i++) {
254 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
255 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
258 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
259 guiFactory()->addClient(sp);*/
263 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
265 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone);
266 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
268 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
269 clipInTimeline->setIcon(KIcon("go-jump"));
270 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)),
271 static_cast<QMenu*>(factory()->container("transcoders", this)),
275 // build themes menus
276 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
277 QActionGroup *themegroup = new QActionGroup(this);
278 themegroup->setExclusive(true);
279 action = new KAction(i18n("Default"), this);
280 action->setCheckable(true);
281 themegroup->addAction(action);
282 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
284 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
286 for (int i = 0; i < schemeFiles.size(); ++i) {
288 const QString filename = schemeFiles.at(i);
289 const QFileInfo info(filename);
292 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
293 QIcon icon = createSchemePreviewIcon(config);
294 KConfigGroup group(config, "General");
295 const QString name = group.readEntry("Name", info.baseName());
296 action = new KAction(name, this);
297 action->setData(filename);
298 action->setIcon(icon);
299 action->setCheckable(true);
300 themegroup->addAction(action);
301 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
304 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
305 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
306 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
309 action = new QAction(fi.fileName(), this);
310 action->setData(*it);
311 action->setCheckable(true);
312 themegroup->addAction(action);
313 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
315 themesMenu->addActions(themegroup->actions());
316 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
318 // Setup and fill effects and transitions menus.
319 m_videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
320 for (int i = 0; i < videoEffects.count(); ++i)
321 m_videoEffectsMenu->addAction(m_videoEffects[i]);
322 m_audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
323 for (int i = 0; i < audioEffects.count(); ++i)
324 m_audioEffectsMenu->addAction(m_audioEffects[i]);
325 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
326 if (customEffects.isEmpty())
327 m_customEffectsMenu->setEnabled(false);
329 m_customEffectsMenu->setEnabled(true);
330 for (int i = 0; i < customEffects.count(); ++i)
331 m_customEffectsMenu->addAction(m_customEffects[i]);
332 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
333 for (int i = 0; i < transitions.count(); ++i)
334 m_transitionsMenu->addAction(m_transitions[i]);
336 connect(m_videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
337 connect(m_audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
338 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
339 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
341 QMenu *newEffect = new QMenu(this);
342 newEffect->addMenu(m_videoEffectsMenu);
343 newEffect->addMenu(m_audioEffectsMenu);
344 newEffect->addMenu(m_customEffectsMenu);
345 m_effectStack->setMenu(newEffect);
347 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
348 const QList<QAction *> viewActions = createPopupMenu()->actions();
349 viewMenu->insertActions(NULL, viewActions);
351 m_timelineContextMenu = new QMenu(this);
352 m_timelineContextClipMenu = new QMenu(this);
353 m_timelineContextTransitionMenu = new QMenu(this);
355 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
356 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
357 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
359 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
360 //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
361 m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
362 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
363 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
364 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
365 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
366 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
367 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
368 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
370 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
371 m_timelineContextClipMenu->addMenu(markersMenu);
372 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
373 m_timelineContextClipMenu->addMenu(m_videoEffectsMenu);
374 m_timelineContextClipMenu->addMenu(m_audioEffectsMenu);
375 //TODO: re-enable custom effects menu when it is implemented
376 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
378 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
379 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
380 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
382 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
384 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
385 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
386 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
387 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
388 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
389 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
391 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
392 slotConnectMonitors();
394 // Disable drop B frames, see Kdenlive issue #1330, see also kdenlivesettingsdialog.cpp
395 KdenliveSettings::setDropbframes(false);
397 // Open or create a file. Command line argument passed in Url has
398 // precedence, then "openlastproject", then just a plain empty file.
399 // If opening Url fails, openlastproject will _not_ be used.
400 if (!Url.isEmpty()) {
401 // delay loading so that the window shows up
403 QTimer::singleShot(500, this, SLOT(openFile()));
404 } else if (KdenliveSettings::openlastproject()) {
405 QTimer::singleShot(500, this, SLOT(openLastFile()));
406 } else { //if (m_timelineArea->count() == 0) {
410 #ifndef NO_JOGSHUTTLE
411 activateShuttleDevice();
412 #endif /* NO_JOGSHUTTLE */
413 m_projectListDock->raise();
416 void MainWindow::queryQuit()
419 if (m_projectMonitor) m_projectMonitor->stop();
420 if (m_clipMonitor) m_clipMonitor->stop();
421 delete m_effectStack;
422 delete m_activeTimeline;
424 // This sometimes causes crash on exit on OS X for some reason.
425 delete m_projectMonitor;
426 delete m_clipMonitor;
428 delete m_activeDocument;
429 delete m_shortcutRemoveFocus;
430 Mlt::Factory::close();
436 bool MainWindow::queryClose()
438 if (m_renderWidget) {
439 int waitingJobs = m_renderWidget->waitingJobsCount();
440 if (waitingJobs > 0) {
441 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")))) {
442 case KMessageBox::Yes :
443 // create script with waiting jobs and start it
444 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
446 case KMessageBox::No :
447 // Don't do anything, jobs will be deleted
455 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
456 // warn the user to save if document is modified and we have clips in our project list
457 if (m_activeDocument && m_activeDocument->isModified()
458 && ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty())
459 || !m_projectList->documentClipList().isEmpty())) {
460 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
461 case KMessageBox::Yes :
462 // save document here. If saving fails, return false;
464 case KMessageBox::No :
465 // User does not want to save the changes, clear recovery files
466 m_activeDocument->m_autosave->resize(0);
476 void MainWindow::loadPlugins()
478 foreach(QObject *plugin, QPluginLoader::staticInstances())
479 populateMenus(plugin);
481 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
483 filters << "libkdenlive*";
484 foreach(const QString &folder, directories) {
485 kDebug() << "// PARSING FIOLER: " << folder;
486 QDir pluginsDir(folder);
487 foreach(const QString &fileName, pluginsDir.entryList(filters, QDir::Files)) {
488 kDebug() << "// FOUND PLUGIN: " << fileName << "= " << pluginsDir.absoluteFilePath(fileName);
489 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
490 QObject *plugin = loader.instance();
492 populateMenus(plugin);
493 m_pluginFileNames += fileName;
494 } else kDebug() << "// ERROR LOADING PLUGIN: " << fileName << ", " << loader.errorString();
500 void MainWindow::populateMenus(QObject *plugin)
502 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
503 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
505 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
509 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
510 QMenu *menu, const char *member,
511 QActionGroup *actionGroup)
513 kDebug() << "// ADD to MENU" << texts;
514 foreach(const QString &text, texts) {
515 QAction *action = new QAction(text, plugin);
516 action->setData(text);
517 connect(action, SIGNAL(triggered()), this, member);
518 menu->addAction(action);
521 action->setCheckable(true);
522 actionGroup->addAction(action);
527 void MainWindow::aboutPlugins()
529 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
534 void MainWindow::generateClip()
536 QAction *action = qobject_cast<QAction *>(sender());
537 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
539 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
540 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
541 if (!clipUrl.isEmpty()) {
542 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
546 void MainWindow::saveProperties(KConfigGroup &config)
548 // save properties here,used by session management
550 KMainWindow::saveProperties(config);
554 void MainWindow::readProperties(const KConfigGroup &config)
556 // read properties here,used by session management
557 KMainWindow::readProperties(config);
558 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
559 openFile(KUrl(Lastproject));
562 void MainWindow::slotReloadEffects()
564 m_customEffectsMenu->clear();
565 initEffects::parseCustomEffectsFile();
567 QStringList effectInfo;
568 QMap<QString, QStringList> effectsList;
569 for (int ix = 0; ix < customEffects.count(); ix++) {
570 effectInfo = customEffects.effectIdInfo(ix);
571 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
573 if (effectsList.isEmpty())
574 m_customEffectsMenu->setEnabled(false);
576 m_customEffectsMenu->setEnabled(true);
578 foreach(const QStringList &value, effectsList) {
579 action = new QAction(value.at(0), this);
580 action->setData(value);
581 m_customEffectsMenu->addAction(action);
583 m_effectList->reloadEffectList();
586 #ifndef NO_JOGSHUTTLE
587 void MainWindow::activateShuttleDevice()
591 if (KdenliveSettings::enableshuttle() == false) return;
592 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
593 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
594 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
595 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
596 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
597 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
598 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
601 void MainWindow::slotShuttleButton(int code)
605 slotShuttleAction(KdenliveSettings::shuttle1());
608 slotShuttleAction(KdenliveSettings::shuttle2());
611 slotShuttleAction(KdenliveSettings::shuttle3());
614 slotShuttleAction(KdenliveSettings::shuttle4());
617 slotShuttleAction(KdenliveSettings::shuttle5());
622 void MainWindow::slotShuttleAction(int code)
628 m_monitorManager->slotPlay();
631 m_monitorManager->slotPlay();
635 #endif /* NO_JOGSHUTTLE */
637 void MainWindow::configureNotifications()
639 KNotifyConfigWidget::configure(this);
642 void MainWindow::slotFullScreen()
644 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
647 void MainWindow::slotAddEffect(const QDomElement effect, GenTime pos, int track)
649 if (!m_activeDocument) return;
650 if (effect.isNull()) {
651 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
654 QDomElement effectToAdd = effect.cloneNode().toElement();
655 m_activeTimeline->projectView()->slotAddEffect(effectToAdd, pos, track);
658 void MainWindow::slotRaiseMonitor(bool clipMonitor)
660 if (clipMonitor) m_clipMonitorDock->raise();
661 else m_projectMonitorDock->raise();
664 void MainWindow::slotUpdateClip(const QString &id)
666 if (!m_activeDocument) return;
667 m_activeTimeline->projectView()->slotUpdateClip(id);
670 void MainWindow::slotConnectMonitors()
672 m_projectList->setRenderer(m_projectMonitor->render);
673 //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
674 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
675 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
676 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
677 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, int, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, int, bool)));
678 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
679 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)));
681 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
683 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
685 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
686 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
688 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
689 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
692 void MainWindow::slotAdjustClipMonitor()
694 m_clipMonitorDock->updateGeometry();
695 m_clipMonitorDock->adjustSize();
696 m_clipMonitor->resetSize();
699 void MainWindow::slotAdjustProjectMonitor()
701 m_projectMonitorDock->updateGeometry();
702 m_projectMonitorDock->adjustSize();
703 m_projectMonitor->resetSize();
706 void MainWindow::setupActions()
709 KActionCollection* collection = actionCollection();
710 m_timecodeFormat = new KComboBox(this);
711 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
712 m_timecodeFormat->addItem(i18n("Frames"));
713 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
714 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
716 m_statusProgressBar = new QProgressBar(this);
717 m_statusProgressBar->setMinimum(0);
718 m_statusProgressBar->setMaximum(100);
719 m_statusProgressBar->setMaximumWidth(150);
720 m_statusProgressBar->setVisible(false);
722 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
723 toolbar->setMovable(false);
724 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
725 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;}";
726 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
728 //create edit mode buttons
729 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
730 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
731 toolbar->addAction(m_normalEditTool);
732 m_normalEditTool->setCheckable(true);
733 m_normalEditTool->setChecked(true);
735 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
736 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
737 toolbar->addAction(m_overwriteEditTool);
738 m_overwriteEditTool->setCheckable(true);
739 m_overwriteEditTool->setChecked(false);
741 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
742 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
743 toolbar->addAction(m_insertEditTool);
744 m_insertEditTool->setCheckable(true);
745 m_insertEditTool->setChecked(false);
746 // not implemented yet
747 m_insertEditTool->setEnabled(false);
749 QActionGroup *editGroup = new QActionGroup(this);
750 editGroup->addAction(m_normalEditTool);
751 editGroup->addAction(m_overwriteEditTool);
752 editGroup->addAction(m_insertEditTool);
753 editGroup->setExclusive(true);
754 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
755 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
757 toolbar->addSeparator();
759 // create tools buttons
760 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
761 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
762 toolbar->addAction(m_buttonSelectTool);
763 m_buttonSelectTool->setCheckable(true);
764 m_buttonSelectTool->setChecked(true);
766 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
767 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
768 toolbar->addAction(m_buttonRazorTool);
769 m_buttonRazorTool->setCheckable(true);
770 m_buttonRazorTool->setChecked(false);
772 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
773 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
774 toolbar->addAction(m_buttonSpacerTool);
775 m_buttonSpacerTool->setCheckable(true);
776 m_buttonSpacerTool->setChecked(false);
778 QActionGroup *toolGroup = new QActionGroup(this);
779 toolGroup->addAction(m_buttonSelectTool);
780 toolGroup->addAction(m_buttonRazorTool);
781 toolGroup->addAction(m_buttonSpacerTool);
782 toolGroup->setExclusive(true);
783 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
785 QWidget * actionWidget;
786 int max = toolbar->iconSizeDefault() + 2;
787 actionWidget = toolbar->widgetForAction(m_normalEditTool);
788 actionWidget->setMaximumWidth(max);
789 actionWidget->setMaximumHeight(max - 4);
791 actionWidget = toolbar->widgetForAction(m_insertEditTool);
792 actionWidget->setMaximumWidth(max);
793 actionWidget->setMaximumHeight(max - 4);
795 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
796 actionWidget->setMaximumWidth(max);
797 actionWidget->setMaximumHeight(max - 4);
799 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
800 actionWidget->setMaximumWidth(max);
801 actionWidget->setMaximumHeight(max - 4);
803 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
804 actionWidget->setMaximumWidth(max);
805 actionWidget->setMaximumHeight(max - 4);
807 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
808 actionWidget->setMaximumWidth(max);
809 actionWidget->setMaximumHeight(max - 4);
811 toolbar->setStyleSheet(style1);
812 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
814 toolbar->addSeparator();
815 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
816 toolbar->addAction(m_buttonFitZoom);
817 m_buttonFitZoom->setCheckable(false);
819 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
820 toolbar->addAction(m_zoomOut);
821 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
823 m_zoomSlider = new QSlider(Qt::Horizontal, this);
824 m_zoomSlider->setMaximum(13);
825 m_zoomSlider->setPageStep(1);
826 m_zoomSlider->setInvertedAppearance(true);
828 m_zoomSlider->setMaximumWidth(150);
829 m_zoomSlider->setMinimumWidth(100);
830 toolbar->addWidget(m_zoomSlider);
832 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
833 toolbar->addAction(m_zoomIn);
834 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
836 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
837 actionWidget->setMaximumWidth(max);
838 actionWidget->setMaximumHeight(max - 4);
839 actionWidget->setStyleSheet(styleBorderless);
841 actionWidget = toolbar->widgetForAction(m_zoomIn);
842 actionWidget->setMaximumWidth(max);
843 actionWidget->setMaximumHeight(max - 4);
844 actionWidget->setStyleSheet(styleBorderless);
846 actionWidget = toolbar->widgetForAction(m_zoomOut);
847 actionWidget->setMaximumWidth(max);
848 actionWidget->setMaximumHeight(max - 4);
849 actionWidget->setStyleSheet(styleBorderless);
851 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
852 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
853 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
854 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
855 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
857 toolbar->addSeparator();
859 //create automatic audio split button
860 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
861 toolbar->addAction(m_buttonAutomaticSplitAudio);
862 m_buttonAutomaticSplitAudio->setCheckable(true);
863 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
864 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
866 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
867 toolbar->addAction(m_buttonVideoThumbs);
868 m_buttonVideoThumbs->setCheckable(true);
869 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
870 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
872 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
873 toolbar->addAction(m_buttonAudioThumbs);
874 m_buttonAudioThumbs->setCheckable(true);
875 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
876 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
878 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
879 toolbar->addAction(m_buttonShowMarkers);
880 m_buttonShowMarkers->setCheckable(true);
881 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
882 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
884 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
885 toolbar->addAction(m_buttonSnap);
886 m_buttonSnap->setCheckable(true);
887 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
888 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
890 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
891 actionWidget->setMaximumWidth(max);
892 actionWidget->setMaximumHeight(max - 4);
894 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
895 actionWidget->setMaximumWidth(max);
896 actionWidget->setMaximumHeight(max - 4);
898 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
899 actionWidget->setMaximumWidth(max);
900 actionWidget->setMaximumHeight(max - 4);
902 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
903 actionWidget->setMaximumWidth(max);
904 actionWidget->setMaximumHeight(max - 4);
906 actionWidget = toolbar->widgetForAction(m_buttonSnap);
907 actionWidget->setMaximumWidth(max);
908 actionWidget->setMaximumHeight(max - 4);
910 m_messageLabel = new StatusBarMessageLabel(this);
911 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
913 statusBar()->addWidget(m_messageLabel, 10);
914 statusBar()->addWidget(m_statusProgressBar, 0);
915 statusBar()->addPermanentWidget(toolbar);
916 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
917 statusBar()->addPermanentWidget(m_timecodeFormat);
918 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
920 collection->addAction("normal_mode", m_normalEditTool);
921 collection->addAction("overwrite_mode", m_overwriteEditTool);
922 collection->addAction("insert_mode", m_insertEditTool);
923 collection->addAction("select_tool", m_buttonSelectTool);
924 collection->addAction("razor_tool", m_buttonRazorTool);
925 collection->addAction("spacer_tool", m_buttonSpacerTool);
927 collection->addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
928 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
929 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
930 collection->addAction("show_markers", m_buttonShowMarkers);
931 collection->addAction("snap", m_buttonSnap);
932 collection->addAction("zoom_fit", m_buttonFitZoom);
933 collection->addAction("zoom_in", m_zoomIn);
934 collection->addAction("zoom_out", m_zoomOut);
936 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
937 collection->addAction("project_find", m_projectSearch);
938 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
939 m_projectSearch->setShortcut(Qt::Key_Slash);
941 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
942 collection->addAction("project_find_next", m_projectSearchNext);
943 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
944 m_projectSearchNext->setShortcut(Qt::Key_F3);
945 m_projectSearchNext->setEnabled(false);
947 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
948 collection->addAction("manage_profiles", profilesAction);
949 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
951 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
952 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
953 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
954 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
956 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
957 collection->addAction("run_wizard", wizAction);
958 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
960 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
961 collection->addAction("project_settings", projectAction);
962 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
964 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
965 collection->addAction("project_render", projectRender);
966 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
967 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
969 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
970 collection->addAction("project_clean", projectClean);
971 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
973 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
974 KShortcut playShortcut;
975 playShortcut.setPrimary(Qt::Key_Space);
976 playShortcut.setAlternate(Qt::Key_K);
977 monitorPlay->setShortcut(playShortcut);
978 collection->addAction("monitor_play", monitorPlay);
979 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
981 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
982 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
983 collection->addAction("monitor_play_zone", m_playZone);
984 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
986 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
987 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
988 collection->addAction("monitor_loop_zone", m_loopZone);
989 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
991 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
992 collection->addAction("dvd_wizard", dvdWizard);
993 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
995 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
996 collection->addAction("transcode_clip", transcodeClip);
997 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
999 KAction *markIn = collection->addAction("mark_in");
1000 markIn->setText(i18n("Set Zone In"));
1001 markIn->setShortcut(Qt::Key_I);
1002 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1004 KAction *markOut = collection->addAction("mark_out");
1005 markOut->setText(i18n("Set Zone Out"));
1006 markOut->setShortcut(Qt::Key_O);
1007 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1009 KAction *switchMon = collection->addAction("switch_monitor");
1010 switchMon->setText(i18n("Switch monitor"));
1011 switchMon->setShortcut(Qt::Key_T);
1012 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1014 KAction *insertTree = collection->addAction("insert_project_tree");
1015 insertTree->setText(i18n("Insert zone in project tree"));
1016 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1017 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1019 KAction *insertTimeline = collection->addAction("insert_timeline");
1020 insertTimeline->setText(i18n("Insert zone in timeline"));
1021 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1022 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1024 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1025 collection->addAction("resize_timeline_clip_start", resizeStart);
1026 resizeStart->setShortcut(Qt::Key_1);
1027 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1029 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1030 collection->addAction("resize_timeline_clip_end", resizeEnd);
1031 resizeEnd->setShortcut(Qt::Key_2);
1032 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1034 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1035 monitorSeekBackward->setShortcut(Qt::Key_J);
1036 collection->addAction("monitor_seek_backward", monitorSeekBackward);
1037 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1039 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1040 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1041 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1042 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1044 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1045 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1046 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1047 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1049 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1050 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1051 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1052 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1054 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1055 monitorSeekForward->setShortcut(Qt::Key_L);
1056 collection->addAction("monitor_seek_forward", monitorSeekForward);
1057 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1059 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1060 clipStart->setShortcut(Qt::Key_Home);
1061 collection->addAction("seek_clip_start", clipStart);
1062 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1064 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1065 clipEnd->setShortcut(Qt::Key_End);
1066 collection->addAction("seek_clip_end", clipEnd);
1067 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1069 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1070 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1071 collection->addAction("seek_zone_start", zoneStart);
1072 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1074 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1075 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1076 collection->addAction("seek_zone_end", zoneEnd);
1077 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1079 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1080 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1081 collection->addAction("seek_start", projectStart);
1082 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1084 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1085 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1086 collection->addAction("seek_end", projectEnd);
1087 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1089 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1090 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1091 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1092 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1094 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1095 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1096 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1097 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1099 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1100 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1101 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1102 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1104 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1105 deleteItem->setShortcut(Qt::Key_Delete);
1106 collection->addAction("delete_timeline_clip", deleteItem);
1107 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1109 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1110 collection->addAction("change_clip_speed", editTimelineClipSpeed);
1111 editTimelineClipSpeed->setData("change_speed");
1112 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1114 KAction *stickTransition = collection->addAction("auto_transition");
1115 stickTransition->setData(QString("auto"));
1116 stickTransition->setCheckable(true);
1117 stickTransition->setEnabled(false);
1118 stickTransition->setText(i18n("Automatic Transition"));
1119 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1121 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1122 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1123 collection->addAction("group_clip", groupClip);
1124 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1126 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1127 collection->addAction("ungroup_clip", ungroupClip);
1128 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1129 ungroupClip->setData("ungroup_clip");
1130 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1132 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1133 collection->addAction("edit_item_duration", editItemDuration);
1134 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1136 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1137 collection->addAction("clip_in_project_tree", clipInProjectTree);
1138 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1140 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1141 collection->addAction("clip_to_project_tree", clipToProjectTree);
1142 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1144 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1145 insertOvertwrite->setShortcut(Qt::Key_V);
1146 collection->addAction("overwrite_to_in_point", insertOvertwrite);
1147 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1149 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1150 selectTimelineClip->setShortcut(Qt::Key_Plus);
1151 collection->addAction("select_timeline_clip", selectTimelineClip);
1152 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1154 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1155 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1156 collection->addAction("deselect_timeline_clip", deselectTimelineClip);
1157 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1159 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1160 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1161 collection->addAction("select_add_timeline_clip", selectAddTimelineClip);
1162 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1164 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1165 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1166 collection->addAction("select_timeline_transition", selectTimelineTransition);
1167 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1169 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1170 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1171 collection->addAction("deselect_timeline_transition", deselectTimelineTransition);
1172 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1174 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1175 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1176 collection->addAction("select_add_timeline_transition", selectAddTimelineTransition);
1177 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1179 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1180 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1181 collection->addAction("cut_timeline_clip", cutTimelineClip);
1182 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1184 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1185 collection->addAction("add_clip_marker", addClipMarker);
1186 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1188 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1189 collection->addAction("delete_clip_marker", deleteClipMarker);
1190 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1192 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1193 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
1194 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1196 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1197 collection->addAction("edit_clip_marker", editClipMarker);
1198 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1200 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1201 collection->addAction("split_audio", splitAudio);
1202 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1204 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1205 collection->addAction("clip_audio_only", audioOnly);
1206 audioOnly->setData("clip_audio_only");
1207 audioOnly->setCheckable(true);
1209 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1210 collection->addAction("clip_video_only", videoOnly);
1211 videoOnly->setData("clip_video_only");
1212 videoOnly->setCheckable(true);
1214 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1215 collection->addAction("clip_audio_and_video", audioAndVideo);
1216 audioAndVideo->setData("clip_audio_and_video");
1217 audioAndVideo->setCheckable(true);
1219 m_clipTypeGroup = new QActionGroup(this);
1220 m_clipTypeGroup->addAction(audioOnly);
1221 m_clipTypeGroup->addAction(videoOnly);
1222 m_clipTypeGroup->addAction(audioAndVideo);
1223 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1224 m_clipTypeGroup->setEnabled(false);
1226 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1227 collection->addAction("insert_space", insertSpace);
1228 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1230 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1231 collection->addAction("delete_space", removeSpace);
1232 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1234 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1235 collection->addAction("insert_track", insertTrack);
1236 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1238 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1239 collection->addAction("delete_track", deleteTrack);
1240 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1242 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
1243 collection->addAction("config_tracks", configTracks);
1244 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1246 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1247 collection->addAction("add_guide", addGuide);
1248 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1250 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1251 collection->addAction("delete_guide", delGuide);
1252 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1254 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1255 collection->addAction("edit_guide", editGuide);
1256 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1258 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1259 collection->addAction("delete_all_guides", delAllGuides);
1260 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1262 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1263 collection->addAction("paste_effects", pasteEffects);
1264 pasteEffects->setData("paste_effects");
1265 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1267 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1268 collection->addAction("show_timeline", showTimeline);
1269 showTimeline->setCheckable(true);
1270 showTimeline->setChecked(true);
1271 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1273 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1274 collection->addAction("show_titlebars", showTitleBar);
1275 showTitleBar->setCheckable(true);
1276 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1277 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1278 slotShowTitleBars(KdenliveSettings::showtitlebars());
1280 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1281 collection->addAction("maximize_current", maxCurrent);
1282 maxCurrent->setCheckable(true);
1283 maxCurrent->setChecked(false);
1284 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1286 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1287 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1288 KStandardAction::open(this, SLOT(openFile()), collection);
1289 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1290 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1291 KStandardAction::openNew(this, SLOT(newFile()), collection);
1292 // TODO: make the following connection to slotEditKeys work
1293 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1294 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1295 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1296 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1297 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1298 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1300 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1301 undo->setEnabled(false);
1302 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1304 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1305 redo->setEnabled(false);
1306 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1309 //TODO: Add status tooltip to actions ?
1310 connect(collection, SIGNAL(actionHovered(QAction*)),
1311 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1314 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1315 collection->addAction("add_clip", addClip);
1316 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1318 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1319 collection->addAction("add_color_clip", addColorClip);
1320 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1322 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1323 collection->addAction("add_slide_clip", addSlideClip);
1324 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1326 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1327 collection->addAction("add_text_clip", addTitleClip);
1328 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1330 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1331 collection->addAction("add_text_template_clip", addTitleTemplateClip);
1332 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1334 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1335 collection->addAction("add_folder", addFolderButton);
1336 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1338 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1339 collection->addAction("clip_properties", clipProperties);
1340 clipProperties->setData("clip_properties");
1341 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1342 clipProperties->setEnabled(false);
1344 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1345 collection->addAction("edit_clip", openClip);
1346 openClip->setData("edit_clip");
1347 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1348 openClip->setEnabled(false);
1350 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1351 collection->addAction("delete_clip", deleteClip);
1352 deleteClip->setData("delete_clip");
1353 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1354 deleteClip->setEnabled(false);
1356 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1357 collection->addAction("reload_clip", reloadClip);
1358 reloadClip->setData("reload_clip");
1359 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1360 reloadClip->setEnabled(false);
1362 QMenu *addClips = new QMenu();
1363 addClips->addAction(addClip);
1364 addClips->addAction(addColorClip);
1365 addClips->addAction(addSlideClip);
1366 addClips->addAction(addTitleClip);
1367 addClips->addAction(addTitleTemplateClip);
1368 addClips->addAction(addFolderButton);
1370 addClips->addAction(reloadClip);
1371 addClips->addAction(clipProperties);
1372 addClips->addAction(openClip);
1373 addClips->addAction(deleteClip);
1374 m_projectList->setupMenu(addClips, addClip);
1376 // Setup effects and transitions actions.
1377 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1378 //KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), m_effectsActionCollection);
1379 KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), collection);
1380 m_videoEffects = new KAction*[videoEffects.count()];
1381 for (int i = 0; i < videoEffects.count(); ++i) {
1382 QStringList effectInfo = videoEffects.effectIdInfo(i);
1383 m_videoEffects[i] = new KAction(KIcon("kdenlive-show-video"), effectInfo.at(0), this);
1384 m_videoEffects[i]->setData(effectInfo);
1385 m_videoEffects[i]->setIconVisibleInMenu(false);
1386 videoEffectActions->addAction("video_effect_" + effectInfo.at(0), m_videoEffects[i]);
1388 //KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), m_effectsActionCollection);
1389 KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), collection);
1390 m_audioEffects = new KAction*[audioEffects.count()];
1391 for (int i = 0; i < audioEffects.count(); ++i) {
1392 QStringList effectInfo = audioEffects.effectIdInfo(i);
1393 m_audioEffects[i] = new KAction(KIcon("kdenlive-show-audio"), effectInfo.at(0), this);
1394 m_audioEffects[i]->setData(effectInfo);
1395 m_audioEffects[i]->setIconVisibleInMenu(false);
1396 audioEffectActions->addAction("audio_effect_" + effectInfo.at(0), m_audioEffects[i]);
1398 //KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), m_effectsActionCollection);
1399 KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), collection);
1400 m_customEffects = new KAction*[customEffects.count()];
1401 for (int i = 0; i < customEffects.count(); ++i) {
1402 QStringList effectInfo = customEffects.effectIdInfo(i);
1403 m_customEffects[i] = new KAction(KIcon("kdenlive-custom-effect"), effectInfo.at(0), this);
1404 m_customEffects[i]->setData(effectInfo);
1405 m_customEffects[i]->setIconVisibleInMenu(false);
1406 customEffectActions->addAction("custom_effect_" + effectInfo.at(0), m_customEffects[i]);
1408 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1409 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1410 m_transitions = new KAction*[transitions.count()];
1411 for (int i = 0; i < transitions.count(); i++) {
1412 QStringList effectInfo = transitions.effectIdInfo(i);
1413 m_transitions[i] = new KAction(effectInfo.at(0), this);
1414 m_transitions[i]->setData(effectInfo);
1415 m_transitions[i]->setIconVisibleInMenu(false);
1416 transitionActions->addAction("transition_" + effectInfo.at(0), m_transitions[i]);
1418 m_effectsActionCollection->readSettings();
1420 //connect(collection, SIGNAL( clearStatusText() ),
1421 //statusBar(), SLOT( clear() ) );
1424 void MainWindow::slotDisplayActionMessage(QAction *a)
1426 statusBar()->showMessage(a->data().toString(), 3000);
1429 void MainWindow::saveOptions()
1431 KdenliveSettings::self()->writeConfig();
1432 KSharedConfigPtr config = KGlobal::config();
1433 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1434 KConfigGroup treecolumns(config, "Project Tree");
1435 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1439 void MainWindow::readOptions()
1441 KSharedConfigPtr config = KGlobal::config();
1442 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1443 KConfigGroup initialGroup(config, "version");
1444 bool upgrade = false;
1445 if (initialGroup.exists()) {
1446 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1450 if (initialGroup.readEntry("version") == "0.7") {
1451 //Add new settings from 0.7.1
1452 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1453 QString path = QDir::homePath() + "/kdenlive";
1454 if (KStandardDirs::makeDir(path) == false) {
1455 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1456 } else KdenliveSettings::setDefaultprojectfolder(path);
1462 if (!initialGroup.exists() || upgrade) {
1463 // this is our first run, show Wizard
1464 Wizard *w = new Wizard(upgrade, this);
1465 if (w->exec() == QDialog::Accepted && w->isOk()) {
1466 w->adjustSettings();
1467 initialGroup.writeEntry("version", version);
1473 KConfigGroup treecolumns(config, "Project Tree");
1474 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1475 if (!state.isEmpty())
1476 m_projectList->setHeaderInfo(state);
1479 void MainWindow::slotRunWizard()
1481 Wizard *w = new Wizard(false, this);
1482 if (w->exec() == QDialog::Accepted && w->isOk()) {
1483 w->adjustSettings();
1488 void MainWindow::newFile(bool showProjectSettings, bool force)
1490 if (!m_timelineArea->isEnabled() && !force) return;
1491 m_fileRevert->setEnabled(false);
1492 QString profileName;
1494 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1495 if (!showProjectSettings) {
1496 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1497 profileName = KdenliveSettings::default_profile();
1498 projectFolder = KdenliveSettings::defaultprojectfolder();
1500 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1501 if (w->exec() != QDialog::Accepted) return;
1502 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1503 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
1504 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
1505 profileName = w->selectedProfile();
1506 projectFolder = w->selectedFolder();
1507 projectTracks = w->tracks();
1510 m_timelineArea->setEnabled(true);
1511 m_projectList->setEnabled(true);
1512 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1513 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1515 TrackView *trackView = new TrackView(doc, &ok, this);
1516 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1519 //m_timelineArea->setEnabled(false);
1520 //m_projectList->setEnabled(false);
1524 if (m_timelineArea->count() == 1) {
1525 connectDocumentInfo(doc);
1526 connectDocument(trackView, doc);
1527 } else m_timelineArea->setTabBarHidden(false);
1528 m_monitorManager->activateMonitor("clip");
1529 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1532 void MainWindow::activateDocument()
1534 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1535 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1536 KdenliveDoc *currentDoc = currentTab->document();
1537 connectDocumentInfo(currentDoc);
1538 connectDocument(currentTab, currentDoc);
1541 void MainWindow::closeCurrentDocument(bool saveChanges)
1543 QWidget *w = m_timelineArea->currentWidget();
1545 // closing current document
1546 int ix = m_timelineArea->currentIndex() + 1;
1547 if (ix == m_timelineArea->count()) ix = 0;
1548 m_timelineArea->setCurrentIndex(ix);
1549 TrackView *tabToClose = (TrackView *) w;
1550 KdenliveDoc *docToClose = tabToClose->document();
1551 if (docToClose && docToClose->isModified() && saveChanges) {
1552 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
1553 case KMessageBox::Yes :
1554 // save document here. If saving fails, return false;
1555 if (saveFile() == false) return;
1557 case KMessageBox::Cancel :
1564 m_clipMonitor->slotSetXml(NULL);
1565 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1566 if (m_timelineArea->count() == 1) {
1567 m_timelineArea->setTabBarHidden(true);
1568 m_closeAction->setEnabled(false);
1570 if (docToClose == m_activeDocument) {
1571 delete m_activeDocument;
1572 m_activeDocument = NULL;
1573 m_effectStack->clear();
1574 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1575 } else delete docToClose;
1576 if (w == m_activeTimeline) {
1577 delete m_activeTimeline;
1578 m_activeTimeline = NULL;
1582 bool MainWindow::saveFileAs(const QString &outputFileName)
1584 QString currentSceneList;
1585 m_monitorManager->stopActiveMonitor();
1586 if (KdenliveSettings::dropbframes()) {
1587 KdenliveSettings::setDropbframes(false);
1588 m_activeDocument->clipManager()->updatePreviewSettings();
1589 currentSceneList = m_projectMonitor->sceneList();
1590 KdenliveSettings::setDropbframes(true);
1591 m_activeDocument->clipManager()->updatePreviewSettings();
1592 } else currentSceneList = m_projectMonitor->sceneList();
1594 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1597 // Save timeline thumbnails
1598 m_activeTimeline->projectView()->saveThumbnails();
1599 m_activeDocument->setUrl(KUrl(outputFileName));
1600 if (m_activeDocument->m_autosave == NULL) {
1601 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1602 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1603 setCaption(m_activeDocument->description());
1604 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1605 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1606 m_activeDocument->setModified(false);
1607 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1608 m_fileRevert->setEnabled(true);
1612 bool MainWindow::saveFileAs()
1614 QString outputFile = KFileDialog::getSaveFileName(KUrl(), getMimeType());
1615 if (outputFile.isEmpty()) return false;
1616 if (QFile::exists(outputFile)) {
1617 // Show the file dialog again if the user does not want to overwrite the file
1618 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it?")) == KMessageBox::No)
1619 return saveFileAs();
1621 return saveFileAs(outputFile);
1624 bool MainWindow::saveFile()
1626 if (!m_activeDocument) return true;
1627 if (m_activeDocument->url().isEmpty()) {
1628 return saveFileAs();
1630 bool result = saveFileAs(m_activeDocument->url().path());
1631 m_activeDocument->m_autosave->resize(0);
1636 void MainWindow::openFile()
1638 if (!m_startUrl.isEmpty()) {
1639 openFile(m_startUrl);
1640 m_startUrl = KUrl();
1643 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
1644 if (url.isEmpty()) return;
1645 m_fileOpenRecent->addUrl(url);
1649 void MainWindow::openLastFile()
1651 KSharedConfigPtr config = KGlobal::config();
1652 KUrl::List urls = m_fileOpenRecent->urls();
1653 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1654 if (urls.isEmpty()) newFile(false);
1655 else openFile(urls.last());
1658 void MainWindow::openFile(const KUrl &url)
1660 // Check if the document is already opened
1661 const int ct = m_timelineArea->count();
1662 bool isOpened = false;
1664 for (i = 0; i < ct; i++) {
1665 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1666 KdenliveDoc *doc = tab->document();
1667 if (doc->url() == url) {
1673 m_timelineArea->setCurrentIndex(i);
1677 // Check for backup file
1678 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1679 if (!staleFiles.isEmpty()) {
1680 if (KMessageBox::questionYesNo(this,
1681 i18n("Auto-saved files exist. Do you want to recover them now?"),
1682 i18n("File Recovery"),
1683 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1684 recoverFiles(staleFiles);
1687 // remove the stale files
1688 foreach(KAutoSaveFile *stale, staleFiles) {
1689 stale->open(QIODevice::ReadWrite);
1694 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1695 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
1696 m_messageLabel->repaint();
1697 doOpenFile(url, NULL);
1700 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1702 if (!m_timelineArea->isEnabled()) return;
1703 m_fileRevert->setEnabled(true);
1704 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, this);
1705 if (stale == NULL) {
1706 stale = new KAutoSaveFile(url, doc);
1707 doc->m_autosave = stale;
1709 doc->m_autosave = stale;
1710 doc->setUrl(stale->managedFile());
1711 doc->setModified(true);
1712 stale->setParent(doc);
1714 connectDocumentInfo(doc);
1716 TrackView *trackView = new TrackView(doc, &ok, this);
1717 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1719 m_timelineArea->setEnabled(false);
1720 m_projectList->setEnabled(false);
1721 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
1722 slotGotProgressInfo(QString(), -1);
1723 newFile(false, true);
1726 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1727 trackView->setDuration(trackView->duration());
1728 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1730 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1731 slotGotProgressInfo(QString(), -1);
1732 m_projectMonitor->adjustRulerSize(trackView->duration());
1733 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1734 m_clipMonitor->refreshMonitor(true);
1737 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1739 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1740 foreach(KAutoSaveFile *stale, staleFiles) {
1741 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1742 // show an error message; we could not steal the lockfile
1743 // maybe another application got to the file before us?
1747 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1748 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
1749 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1750 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1754 void MainWindow::parseProfiles(const QString &mltPath)
1756 //KdenliveSettings::setDefaulttmpfolder();
1757 if (!mltPath.isEmpty()) {
1758 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1759 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
1762 if (KdenliveSettings::mltpath().isEmpty())
1763 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1765 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
1766 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
1767 if (!QFile::exists(meltPath))
1768 meltPath = KStandardDirs::findExe("melt");
1769 KdenliveSettings::setRendererpath(meltPath);
1772 if (KdenliveSettings::rendererpath().isEmpty()) {
1773 // Cannot find the MLT melt renderer, ask for location
1774 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
1775 if (getUrl->exec() == QDialog::Rejected) {
1778 KUrl rendererPath = getUrl->selectedUrl();
1780 if (rendererPath.isEmpty()) ::exit(0);
1781 KdenliveSettings::setRendererpath(rendererPath.path());
1784 QStringList profilesFilter;
1785 profilesFilter << "*";
1786 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1787 if (profilesList.isEmpty()) {
1788 // Cannot find MLT path, try finding melt
1789 QString profilePath = KdenliveSettings::rendererpath();
1790 if (!profilePath.isEmpty()) {
1791 profilePath = profilePath.section('/', 0, -3);
1792 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1793 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1795 if (profilesList.isEmpty()) {
1796 // Cannot find the MLT profiles, ask for location
1797 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
1798 getUrl->fileDialog()->setMode(KFile::Directory);
1799 if (getUrl->exec() == QDialog::Rejected) {
1802 KUrl mltPath = getUrl->selectedUrl();
1804 if (mltPath.isEmpty()) ::exit(0);
1805 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
1806 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1810 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1812 // Parse again MLT profiles to build a list of available video formats
1813 if (profilesList.isEmpty()) parseProfiles();
1817 void MainWindow::slotEditProfiles()
1819 ProfilesDialog *w = new ProfilesDialog;
1820 if (w->exec() == QDialog::Accepted) {
1821 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1822 if (d) d->checkProfile();
1827 void MainWindow::slotDetectAudioDriver()
1829 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
1830 leading to no audio output, see bug #934 */
1832 //decide which audio driver is really best, in some cases SDL is wrong
1833 if (KdenliveSettings::audiodrivername().isEmpty()) {
1835 KProcess readProcess;
1836 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
1837 if (!KStandardDirs::findExe("pactl").isEmpty()) {
1838 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
1839 readProcess.setProgram("pactl", QStringList() << "stat");
1840 readProcess.execute(2000); // Kill it after 2 seconds
1842 QString result = QString(readProcess.readAllStandardOutput());
1843 kDebug() << "// / / / / / READING PACTL: ";
1845 if (!result.isEmpty()) {
1847 kDebug() << "// / / / / PULSEAUDIO DETECTED";
1851 KdenliveSettings::setAutoaudiodrivername(driver);
1855 void MainWindow::slotEditProjectSettings()
1857 QPoint p = m_activeDocument->getTracksCount();
1858 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
1860 if (w->exec() == QDialog::Accepted) {
1861 QString profile = w->selectedProfile();
1862 m_activeDocument->setProjectFolder(w->selectedFolder());
1863 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path(KUrl::AddTrailingSlash));
1864 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
1865 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
1866 if (m_activeDocument->profilePath() != profile) {
1867 // Profile was changed
1868 double dar = m_activeDocument->dar();
1870 // Deselect current effect / transition
1871 m_effectStack->slotClipItemSelected(NULL, 0);
1872 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1873 m_clipMonitor->slotSetXml(NULL);
1874 bool updateFps = m_activeDocument->setProfilePath(profile);
1875 KdenliveSettings::setCurrent_profile(profile);
1876 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1877 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1879 m_activeDocument->clipManager()->clearUnusedProducers();
1880 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1882 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
1883 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
1884 m_projectList->updateProjectFormat(m_activeDocument->timecode());
1885 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1886 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1887 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1888 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
1889 if (updateFps) m_activeTimeline->updateProjectFps();
1890 m_activeDocument->setModified(true);
1891 m_commandStack->activeStack()->clear();
1892 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
1893 slotUpdateMousePosition(0);
1894 // We need to desactivate & reactivate monitors to get a refresh
1895 //m_monitorManager->switchMonitors();
1902 void MainWindow::slotRenderProject()
1904 if (!m_renderWidget) {
1905 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
1906 m_renderWidget = new RenderWidget(projectfolder, this);
1907 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
1908 connect(m_renderWidget, SIGNAL(selectedRenderProfile(const QString &, const QString &, const QString &, const QString&)), this, SLOT(slotSetDocumentRenderProfile(const QString &, const QString &, const QString &, const QString&)));
1909 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
1910 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1911 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1912 if (m_activeDocument) {
1913 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1914 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1915 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
1916 m_renderWidget->setRenderProfile(m_activeDocument->getDocumentProperty("renderdestination"), m_activeDocument->getDocumentProperty("rendercategory"), m_activeDocument->getDocumentProperty("renderprofile"), m_activeDocument->getDocumentProperty("renderurl"));
1919 slotCheckRenderStatus();
1920 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1921 if (currentTab) m_renderWidget->setTimeline(currentTab);
1922 m_renderWidget->setDocument(m_activeDocument);*/
1923 m_renderWidget->show();
1924 m_renderWidget->showNormal();
1927 void MainWindow::slotCheckRenderStatus()
1929 // Make sure there are no missing clips
1931 m_renderWidget->missingClips(m_projectList->hasMissingClips());
1934 void MainWindow::setRenderingProgress(const QString &url, int progress)
1937 m_renderWidget->setRenderJob(url, progress);
1940 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
1943 m_renderWidget->setRenderStatus(url, status, error);
1946 void MainWindow::slotCleanProject()
1948 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
1949 m_projectList->cleanup();
1952 void MainWindow::slotUpdateMousePosition(int pos)
1954 if (m_activeDocument)
1955 switch (m_timecodeFormat->currentIndex()) {
1957 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1960 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1964 void MainWindow::slotUpdateDocumentState(bool modified)
1966 if (!m_activeDocument) return;
1967 setCaption(m_activeDocument->description(), modified);
1968 m_saveAction->setEnabled(modified);
1970 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1971 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1973 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1974 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1978 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
1980 if (m_activeDocument) {
1981 if (m_activeDocument == doc) return;
1982 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1984 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1987 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
1989 //m_projectMonitor->stop();
1990 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1991 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1992 if (m_activeDocument) {
1993 if (m_activeDocument == doc) return;
1994 if (m_activeTimeline) {
1995 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1996 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1997 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1998 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1999 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
2001 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2002 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2003 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2004 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
2005 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2006 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2007 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
2008 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2009 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2010 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2011 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2012 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2013 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2014 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2015 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2016 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2017 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2018 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2019 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2020 disconnect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
2021 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
2022 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
2023 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
2024 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2025 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2026 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2027 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2028 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2029 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2030 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2031 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2032 disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2033 disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2034 m_effectStack->clear();
2036 //m_activeDocument->setRenderer(NULL);
2037 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
2038 disconnect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2039 m_clipMonitor->stop();
2041 KdenliveSettings::setCurrent_profile(doc->profilePath());
2042 KdenliveSettings::setProject_fps(doc->fps());
2043 m_monitorManager->resetProfiles(doc->timecode());
2044 m_projectList->setDocument(doc);
2045 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2046 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2047 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint)));
2048 connect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2049 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), trackView->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2051 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2052 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2054 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
2057 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2058 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2059 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2060 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2061 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2062 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2063 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2064 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2065 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
2066 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2067 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
2069 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2070 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2071 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
2072 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2073 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2075 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
2076 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2077 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2080 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2081 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2083 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2084 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2085 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2086 m_zoomSlider->setValue(doc->zoom().x());
2087 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2088 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2089 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2090 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2092 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2093 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2096 connect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
2097 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2098 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
2099 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
2100 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
2101 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2102 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2103 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2104 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2105 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2107 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2108 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2109 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2110 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2111 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2114 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2115 m_activeTimeline = trackView;
2116 if (m_renderWidget) {
2117 slotCheckRenderStatus();
2118 m_renderWidget->setProfile(doc->mltProfile());
2119 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2120 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2121 m_renderWidget->setRenderProfile(doc->getDocumentProperty("renderdestination"), doc->getDocumentProperty("rendercategory"), doc->getDocumentProperty("renderprofile"), doc->getDocumentProperty("renderurl"));
2123 //doc->setRenderer(m_projectMonitor->render);
2124 m_commandStack->setActiveStack(doc->commandStack());
2125 KdenliveSettings::setProject_display_ratio(doc->dar());
2126 //doc->clipManager()->checkAudioThumbs();
2128 //m_overView->setScene(trackView->projectScene());
2129 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2130 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2132 setCaption(doc->description(), doc->isModified());
2133 m_saveAction->setEnabled(doc->isModified());
2134 m_normalEditTool->setChecked(true);
2135 m_activeDocument = doc;
2136 m_activeTimeline->updateProjectFps();
2137 m_activeDocument->checkProjectClips();
2138 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
2139 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2140 slotUpdateMousePosition(0);
2141 // set tool to select tool
2142 m_buttonSelectTool->setChecked(true);
2145 void MainWindow::slotZoneMoved(int start, int end)
2147 m_activeDocument->setZone(start, end);
2148 m_projectMonitor->slotZoneMoved(start, end);
2151 void MainWindow::slotGuidesUpdated()
2154 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2157 void MainWindow::slotEditKeys()
2159 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2160 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2161 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2165 void MainWindow::slotPreferences(int page, int option)
2167 //An instance of your dialog could be already created and could be
2168 // cached, in which case you want to display the cached dialog
2169 // instead of creating another one
2170 if (KConfigDialog::showDialog("settings")) {
2171 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2172 if (page != -1) d->showPage(page, option);
2176 // KConfigDialog didn't find an instance of this dialog, so lets
2178 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
2179 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2180 //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
2181 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2182 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2184 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
2186 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2188 if (page != -1) dialog->showPage(page, option);
2191 void MainWindow::slotUpdatePreviewSettings()
2193 if (m_activeDocument) {
2194 m_clipMonitor->slotSetXml(NULL);
2195 m_activeDocument->updatePreviewSettings();
2199 void MainWindow::updateConfiguration()
2201 //TODO: we should apply settings to all projects, not only the current one
2202 if (m_activeTimeline) {
2203 m_activeTimeline->refresh();
2204 m_activeTimeline->projectView()->checkAutoScroll();
2205 m_activeTimeline->projectView()->checkTrackHeight();
2206 if (m_activeDocument)
2207 m_activeDocument->clipManager()->checkAudioThumbs();
2209 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2210 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2211 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2213 // Update list of transcoding profiles
2215 #ifndef NO_JOGSHUTTLE
2216 activateShuttleDevice();
2217 #endif /* NO_JOGSHUTTLE */
2221 void MainWindow::slotSwitchSplitAudio()
2223 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2224 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2227 void MainWindow::slotSwitchVideoThumbs()
2229 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2230 if (m_activeTimeline)
2231 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2232 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2235 void MainWindow::slotSwitchAudioThumbs()
2237 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2238 if (m_activeTimeline) {
2239 m_activeTimeline->refresh();
2240 m_activeTimeline->projectView()->checkAutoScroll();
2241 if (m_activeDocument)
2242 m_activeDocument->clipManager()->checkAudioThumbs();
2244 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2247 void MainWindow::slotSwitchMarkersComments()
2249 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2250 if (m_activeTimeline)
2251 m_activeTimeline->refresh();
2252 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2255 void MainWindow::slotSwitchSnap()
2257 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2258 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2262 void MainWindow::slotDeleteItem()
2264 if (QApplication::focusWidget()
2265 && QApplication::focusWidget()->parentWidget()
2266 && QApplication::focusWidget()->parentWidget()->parentWidget()
2267 && QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2268 m_projectList->slotRemoveClip();
2271 QWidget *widget = QApplication::focusWidget();
2273 if (widget == m_effectStackDock) {
2274 m_effectStack->slotItemDel();
2277 widget = widget->parentWidget();
2280 // effect stack has no focus
2281 if (m_activeTimeline)
2282 m_activeTimeline->projectView()->deleteSelectedClips();
2286 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2288 if (m_clipMonitor->isActive())
2289 m_clipMonitor->checkOverlay();
2290 m_clipMonitor->updateMarkers(clip);
2293 void MainWindow::slotAddClipMarker()
2295 DocClipBase *clip = NULL;
2297 if (m_projectMonitor->isActive()) {
2298 if (m_activeTimeline) {
2299 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2301 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2302 clip = item->baseClip();
2306 clip = m_clipMonitor->activeClip();
2307 pos = m_clipMonitor->position();
2310 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2313 QString id = clip->getId();
2314 CommentedTime marker(pos, i18n("Marker"));
2315 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2316 if (d.exec() == QDialog::Accepted)
2317 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2320 void MainWindow::slotDeleteClipMarker()
2322 DocClipBase *clip = NULL;
2324 if (m_projectMonitor->isActive()) {
2325 if (m_activeTimeline) {
2326 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2328 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2329 clip = item->baseClip();
2333 clip = m_clipMonitor->activeClip();
2334 pos = m_clipMonitor->position();
2337 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2341 QString id = clip->getId();
2342 QString comment = clip->markerComment(pos);
2343 if (comment.isEmpty()) {
2344 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2347 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2350 void MainWindow::slotDeleteAllClipMarkers()
2352 DocClipBase *clip = NULL;
2353 if (m_projectMonitor->isActive()) {
2354 if (m_activeTimeline) {
2355 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2357 clip = item->baseClip();
2361 clip = m_clipMonitor->activeClip();
2364 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2367 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2370 void MainWindow::slotEditClipMarker()
2372 DocClipBase *clip = NULL;
2374 if (m_projectMonitor->isActive()) {
2375 if (m_activeTimeline) {
2376 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2378 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2379 clip = item->baseClip();
2383 clip = m_clipMonitor->activeClip();
2384 pos = m_clipMonitor->position();
2387 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2391 QString id = clip->getId();
2392 QString oldcomment = clip->markerComment(pos);
2393 if (oldcomment.isEmpty()) {
2394 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2398 CommentedTime marker(pos, oldcomment);
2399 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2400 if (d.exec() == QDialog::Accepted) {
2401 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2402 if (d.newMarker().time() != pos) {
2403 // remove old marker
2404 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2409 void MainWindow::slotAddGuide()
2411 if (m_activeTimeline)
2412 m_activeTimeline->projectView()->slotAddGuide();
2415 void MainWindow::slotInsertSpace()
2417 if (m_activeTimeline)
2418 m_activeTimeline->projectView()->slotInsertSpace();
2421 void MainWindow::slotRemoveSpace()
2423 if (m_activeTimeline)
2424 m_activeTimeline->projectView()->slotRemoveSpace();
2427 void MainWindow::slotInsertTrack(int ix)
2429 m_projectMonitor->activateMonitor();
2430 if (m_activeTimeline)
2431 m_activeTimeline->projectView()->slotInsertTrack(ix);
2432 if (m_activeDocument)
2433 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2436 void MainWindow::slotDeleteTrack(int ix)
2438 m_projectMonitor->activateMonitor();
2439 if (m_activeTimeline)
2440 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2441 if (m_activeDocument)
2442 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2445 void MainWindow::slotConfigTrack(int ix)
2447 m_projectMonitor->activateMonitor();
2448 if (m_activeTimeline)
2449 m_activeTimeline->projectView()->slotConfigTracks(ix);
2450 if (m_activeDocument)
2451 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2454 void MainWindow::slotEditGuide()
2456 if (m_activeTimeline)
2457 m_activeTimeline->projectView()->slotEditGuide();
2460 void MainWindow::slotDeleteGuide()
2462 if (m_activeTimeline)
2463 m_activeTimeline->projectView()->slotDeleteGuide();
2466 void MainWindow::slotDeleteAllGuides()
2468 if (m_activeTimeline)
2469 m_activeTimeline->projectView()->slotDeleteAllGuides();
2472 void MainWindow::slotCutTimelineClip()
2474 if (m_activeTimeline)
2475 m_activeTimeline->projectView()->cutSelectedClips();
2478 void MainWindow::slotInsertClipOverwrite()
2480 if (m_activeTimeline) {
2481 QStringList data = m_clipMonitor->getZoneInfo();
2482 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2486 void MainWindow::slotSelectTimelineClip()
2488 if (m_activeTimeline)
2489 m_activeTimeline->projectView()->selectClip(true);
2492 void MainWindow::slotSelectTimelineTransition()
2494 if (m_activeTimeline)
2495 m_activeTimeline->projectView()->selectTransition(true);
2498 void MainWindow::slotDeselectTimelineClip()
2500 if (m_activeTimeline)
2501 m_activeTimeline->projectView()->selectClip(false, true);
2504 void MainWindow::slotDeselectTimelineTransition()
2506 if (m_activeTimeline)
2507 m_activeTimeline->projectView()->selectTransition(false, true);
2510 void MainWindow::slotSelectAddTimelineClip()
2512 if (m_activeTimeline)
2513 m_activeTimeline->projectView()->selectClip(true, true);
2516 void MainWindow::slotSelectAddTimelineTransition()
2518 if (m_activeTimeline)
2519 m_activeTimeline->projectView()->selectTransition(true, true);
2522 void MainWindow::slotGroupClips()
2524 if (m_activeTimeline)
2525 m_activeTimeline->projectView()->groupClips();
2528 void MainWindow::slotUnGroupClips()
2530 if (m_activeTimeline)
2531 m_activeTimeline->projectView()->groupClips(false);
2534 void MainWindow::slotEditItemDuration()
2536 if (m_activeTimeline)
2537 m_activeTimeline->projectView()->editItemDuration();
2540 void MainWindow::slotAddProjectClip(KUrl url)
2542 if (m_activeDocument)
2543 m_activeDocument->slotAddClipFile(url, QString());
2546 void MainWindow::slotAddTransition(QAction *result)
2548 if (!result) return;
2549 QStringList info = result->data().toStringList();
2550 if (info.isEmpty()) return;
2551 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2552 if (m_activeTimeline && !transition.isNull()) {
2553 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2557 void MainWindow::slotAddVideoEffect(QAction *result)
2559 if (!result) return;
2560 QStringList info = result->data().toStringList();
2561 if (info.isEmpty()) return;
2562 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2563 slotAddEffect(effect);
2566 void MainWindow::slotAddAudioEffect(QAction *result)
2568 if (!result) return;
2569 QStringList info = result->data().toStringList();
2570 if (info.isEmpty()) return;
2571 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2572 slotAddEffect(effect);
2575 void MainWindow::slotAddCustomEffect(QAction *result)
2577 if (!result) return;
2578 QStringList info = result->data().toStringList();
2579 if (info.isEmpty()) return;
2580 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2581 slotAddEffect(effect);
2584 void MainWindow::slotZoomIn()
2586 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2587 slotShowZoomSliderToolTip();
2590 void MainWindow::slotZoomOut()
2592 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2593 slotShowZoomSliderToolTip();
2596 void MainWindow::slotFitZoom()
2598 if (m_activeTimeline)
2599 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2602 void MainWindow::slotSetZoom(int value)
2604 if (m_activeTimeline)
2605 m_activeTimeline->slotChangeZoom(value);
2607 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
2608 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
2609 slotUpdateZoomSliderToolTip(value);
2611 m_zoomSlider->blockSignals(true);
2612 m_zoomSlider->setValue(value);
2613 m_zoomSlider->blockSignals(false);
2616 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
2618 if (zoomlevel != -1)
2619 slotUpdateZoomSliderToolTip(zoomlevel);
2621 QPoint global = m_zoomSlider->rect().topLeft();
2622 global.ry() += m_zoomSlider->height() / 2;
2623 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
2624 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
2627 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
2629 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
2632 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2634 m_statusProgressBar->setValue(progress);
2635 if (progress >= 0) {
2636 if (!message.isEmpty())
2637 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2638 m_statusProgressBar->setVisible(true);
2639 } else if (progress == -2) {
2640 if (!message.isEmpty())
2641 m_messageLabel->setMessage(message, ErrorMessage);
2642 m_statusProgressBar->setVisible(false);
2644 m_messageLabel->setMessage(QString(), DefaultMessage);
2645 m_statusProgressBar->setVisible(false);
2649 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2651 if (clip->clipType() == TEXT) {
2652 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
2653 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
2654 // template text clip
2656 // Get the list of existing templates
2658 filter << "*.kdenlivetitle";
2659 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
2661 QDialog *dia = new QDialog(this);
2662 Ui::TemplateClip_UI dia_ui;
2663 dia_ui.setupUi(dia);
2665 const QString templatePath = clip->getProperty("resource");
2666 for (int i = 0; i < templateFiles.size(); ++i) {
2667 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
2668 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
2670 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
2671 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
2672 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
2673 //warning: setting base directory doesn't work??
2674 KUrl startDir(titlepath);
2675 dia_ui.template_list->fileDialog()->setUrl(startDir);
2676 dia_ui.description->setText(clip->getProperty("description"));
2677 if (dia->exec() == QDialog::Accepted) {
2678 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
2679 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
2681 QMap <QString, QString> newprops;
2683 if (KUrl(textTemplate).path() != templatePath) {
2684 // The template was changed
2685 newprops.insert("resource", textTemplate);
2688 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
2689 newprops.insert("description", dia_ui.description->toPlainText());
2692 QString newtemplate = newprops.value("xmltemplate");
2693 if (newtemplate.isEmpty()) newtemplate = templatePath;
2695 // template modified we need to update xmldata
2696 QString description = newprops.value("description");
2697 if (description.isEmpty()) description = clip->getProperty("description");
2698 else newprops.insert("templatetext", description);
2699 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
2700 if (!newprops.isEmpty()) {
2701 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2702 m_activeDocument->commandStack()->push(command);
2708 QString path = clip->getProperty("resource");
2709 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
2711 doc.setContent(clip->getProperty("xmldata"));
2712 dia_ui->setXml(doc);
2713 if (dia_ui->exec() == QDialog::Accepted) {
2714 QMap <QString, QString> newprops;
2715 newprops.insert("xmldata", dia_ui->xml().toString());
2716 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
2717 // duration changed, we need to update duration
2718 newprops.insert("out", QString::number(dia_ui->outPoint()));
2720 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2721 m_activeDocument->commandStack()->push(command);
2722 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
2723 m_activeDocument->setModified(true);
2727 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2730 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2731 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2732 if (dia.exec() == QDialog::Accepted) {
2733 QMap <QString, QString> newprops = dia.properties();
2734 if (newprops.isEmpty()) return;
2735 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2736 m_activeDocument->commandStack()->push(command);
2738 if (dia.needsTimelineRefresh()) {
2739 // update clip occurences in timeline
2740 m_activeTimeline->projectView()->slotUpdateClip(clip->getId(), dia.needsTimelineReload());
2746 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
2748 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
2749 if (dia.exec() == QDialog::Accepted) {
2750 QUndoCommand *command = new QUndoCommand();
2751 command->setText(i18n("Edit clips"));
2752 for (int i = 0; i < cliplist.count(); i++) {
2753 DocClipBase *clip = cliplist.at(i);
2754 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true, command);
2756 m_activeDocument->commandStack()->push(command);
2757 for (int i = 0; i < cliplist.count(); i++)
2758 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
2762 void MainWindow::customEvent(QEvent* e)
2764 if (e->type() == QEvent::User)
2765 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
2767 void MainWindow::slotActivateEffectStackView()
2769 m_effectStack->raiseWindow(m_effectStackDock);
2772 void MainWindow::slotActivateTransitionView(Transition *t)
2775 m_transitionConfig->raiseWindow(m_transitionConfigDock);
2778 void MainWindow::slotSnapRewind()
2780 if (m_projectMonitor->isActive()) {
2781 if (m_activeTimeline)
2782 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2784 m_clipMonitor->slotSeekToPreviousSnap();
2788 void MainWindow::slotSnapForward()
2790 if (m_projectMonitor->isActive()) {
2791 if (m_activeTimeline)
2792 m_activeTimeline->projectView()->slotSeekToNextSnap();
2794 m_clipMonitor->slotSeekToNextSnap();
2798 void MainWindow::slotClipStart()
2800 if (m_projectMonitor->isActive()) {
2801 if (m_activeTimeline)
2802 m_activeTimeline->projectView()->clipStart();
2806 void MainWindow::slotClipEnd()
2808 if (m_projectMonitor->isActive()) {
2809 if (m_activeTimeline)
2810 m_activeTimeline->projectView()->clipEnd();
2814 void MainWindow::slotZoneStart()
2816 if (m_projectMonitor->isActive())
2817 m_projectMonitor->slotZoneStart();
2819 m_clipMonitor->slotZoneStart();
2822 void MainWindow::slotZoneEnd()
2824 if (m_projectMonitor->isActive())
2825 m_projectMonitor->slotZoneEnd();
2827 m_clipMonitor->slotZoneEnd();
2830 void MainWindow::slotChangeTool(QAction * action)
2832 if (action == m_buttonSelectTool)
2833 slotSetTool(SELECTTOOL);
2834 else if (action == m_buttonRazorTool)
2835 slotSetTool(RAZORTOOL);
2836 else if (action == m_buttonSpacerTool)
2837 slotSetTool(SPACERTOOL);
2840 void MainWindow::slotChangeEdit(QAction * action)
2842 if (!m_activeTimeline)
2845 if (action == m_overwriteEditTool)
2846 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
2847 else if (action == m_insertEditTool)
2848 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
2850 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
2853 void MainWindow::slotSetTool(PROJECTTOOL tool)
2855 if (m_activeDocument && m_activeTimeline) {
2856 //m_activeDocument->setTool(tool);
2860 message = i18n("Ctrl + click to use spacer on current track only");
2863 message = i18n("Click on a clip to cut it");
2866 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
2869 m_messageLabel->setMessage(message, InformationMessage);
2870 m_activeTimeline->projectView()->setTool(tool);
2874 void MainWindow::slotCopy()
2876 if (m_activeDocument && m_activeTimeline)
2877 m_activeTimeline->projectView()->copyClip();
2880 void MainWindow::slotPaste()
2882 if (m_activeDocument && m_activeTimeline)
2883 m_activeTimeline->projectView()->pasteClip();
2886 void MainWindow::slotPasteEffects()
2888 if (m_activeDocument && m_activeTimeline)
2889 m_activeTimeline->projectView()->pasteClipEffects();
2892 void MainWindow::slotFind()
2894 if (!m_activeDocument || !m_activeTimeline) return;
2895 m_projectSearch->setEnabled(false);
2896 m_findActivated = true;
2897 m_findString.clear();
2898 m_activeTimeline->projectView()->initSearchStrings();
2899 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2900 m_findTimer.start(5000);
2901 qApp->installEventFilter(this);
2904 void MainWindow::slotFindNext()
2906 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
2907 statusBar()->showMessage(i18n("Found: %1", m_findString));
2909 statusBar()->showMessage(i18n("Reached end of project"));
2910 m_findTimer.start(4000);
2913 void MainWindow::findAhead()
2915 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
2916 m_projectSearchNext->setEnabled(true);
2917 statusBar()->showMessage(i18n("Found: %1", m_findString));
2919 m_projectSearchNext->setEnabled(false);
2920 statusBar()->showMessage(i18n("Not found: %1", m_findString));
2924 void MainWindow::findTimeout()
2926 m_projectSearchNext->setEnabled(false);
2927 m_findActivated = false;
2928 m_findString.clear();
2929 statusBar()->showMessage(i18n("Find stopped"), 3000);
2930 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
2931 m_projectSearch->setEnabled(true);
2932 removeEventFilter(this);
2935 void MainWindow::slotClipInTimeline(const QString &clipId)
2937 if (m_activeTimeline && m_activeDocument) {
2938 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
2940 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
2941 inTimelineMenu->clear();
2943 QList <QAction *> actionList;
2945 for (int i = 0; i < matching.count(); ++i) {
2946 QString track = QString::number(matching.at(i).track);
2947 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
2949 QAction *a = new QAction(track + ": " + start, this);
2950 a->setData(QStringList() << track << start);
2951 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
2952 while (j < actionList.count()) {
2953 if (actionList.at(j)->text() > a->text()) break;
2956 actionList.insert(j, a);
2958 inTimelineMenu->addActions(actionList);
2960 if (matching.empty())
2961 inTimelineMenu->setEnabled(false);
2963 inTimelineMenu->setEnabled(true);
2967 void MainWindow::slotClipInProjectTree()
2969 if (m_activeTimeline) {
2970 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
2971 if (clipIds.isEmpty())
2973 m_projectListDock->raise();
2974 for (int i = 0; i < clipIds.count(); i++)
2975 m_projectList->selectItemById(clipIds.at(i));
2976 if (m_projectMonitor->isActive())
2977 slotSwitchMonitors();
2981 /*void MainWindow::slotClipToProjectTree()
2983 if (m_activeTimeline) {
2984 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
2985 if (clips.isEmpty()) return;
2986 for (int i = 0; i < clips.count(); i++) {
2987 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
2989 //m_projectList->selectItemById(clipIds.at(i));
2993 void MainWindow::slotSelectClipInTimeline()
2995 if (m_activeTimeline) {
2996 QAction *action = qobject_cast<QAction *>(sender());
2997 QStringList data = action->data().toStringList();
2998 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3002 void MainWindow::keyPressEvent(QKeyEvent *ke)
3004 if (m_findActivated) {
3005 if (ke->key() == Qt::Key_Backspace) {
3006 m_findString = m_findString.left(m_findString.length() - 1);
3008 if (!m_findString.isEmpty())
3013 m_findTimer.start(4000);
3016 } else if (ke->key() == Qt::Key_Escape) {
3020 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3021 m_findString += ke->text();
3025 m_findTimer.start(4000);
3030 KXmlGuiWindow::keyPressEvent(ke);
3035 /** Gets called when the window gets hidden */
3036 void MainWindow::hideEvent(QHideEvent */*event*/)
3039 if (m_monitorManager)
3040 m_monitorManager->stopActiveMonitor();
3043 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3045 if (m_findActivated) {
3046 if (event->type() == QEvent::ShortcutOverride) {
3047 QKeyEvent* ke = (QKeyEvent*) event;
3048 if (ke->text().trimmed().isEmpty()) return false;
3055 // pass the event on to the parent class
3056 return QMainWindow::eventFilter(obj, event);
3061 void MainWindow::slotSaveZone(Render *render, QPoint zone)
3063 KDialog *dialog = new KDialog(this);
3064 dialog->setCaption("Save clip zone");
3065 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3067 QWidget *widget = new QWidget(dialog);
3068 dialog->setMainWidget(widget);
3070 QVBoxLayout *vbox = new QVBoxLayout(widget);
3071 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3072 QString path = m_activeDocument->projectFolder().path();
3074 path.append("untitled.mlt");
3075 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
3076 url->setFilter("video/mlt-playlist");
3077 QLabel *label2 = new QLabel(i18n("Description:"), this);
3078 KLineEdit *edit = new KLineEdit(this);
3079 vbox->addWidget(label1);
3080 vbox->addWidget(url);
3081 vbox->addWidget(label2);
3082 vbox->addWidget(edit);
3083 if (dialog->exec() == QDialog::Accepted)
3084 render->saveZone(url->url(), edit->text(), zone);
3088 void MainWindow::slotSetInPoint()
3090 if (m_clipMonitor->isActive())
3091 m_clipMonitor->slotSetZoneStart();
3093 m_projectMonitor->slotSetZoneStart();
3094 //else m_activeTimeline->projectView()->setInPoint();
3097 void MainWindow::slotSetOutPoint()
3099 if (m_clipMonitor->isActive())
3100 m_clipMonitor->slotSetZoneEnd();
3102 m_projectMonitor->slotSetZoneEnd();
3103 // else m_activeTimeline->projectView()->setOutPoint();
3106 void MainWindow::slotResizeItemStart()
3108 if (m_activeTimeline)
3109 m_activeTimeline->projectView()->setInPoint();
3112 void MainWindow::slotResizeItemEnd()
3114 if (m_activeTimeline)
3115 m_activeTimeline->projectView()->setOutPoint();
3118 int MainWindow::getNewStuff(const QString &configFile)
3120 KNS3::Entry::List entries;
3121 #if KDE_IS_VERSION(4,3,80)
3122 KNS3::DownloadDialog dialog(configFile);
3124 entries = dialog.changedEntries();
3125 foreach(const KNS3::Entry &entry, entries) {
3126 if (entry.status() == KNS3::Entry::Installed)
3127 kDebug() << "// Installed files: " << entry.installedFiles();
3130 KNS::Engine engine(0);
3131 if (engine.init(configFile))
3132 entries = engine.downloadDialogModal(this);
3133 foreach(KNS::Entry *entry, entries) {
3134 if (entry->status() == KNS::Entry::Installed)
3135 kDebug() << "// Installed files: " << entry->installedFiles();
3137 #endif /* KDE_IS_VERSION(4,3,80) */
3138 return entries.size();
3141 void MainWindow::slotGetNewTitleStuff()
3143 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3144 TitleWidget::refreshTitleTemplates();
3147 void MainWindow::slotGetNewLumaStuff()
3149 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3150 initEffects::refreshLumas();
3151 m_activeTimeline->projectView()->reloadTransitionLumas();
3155 void MainWindow::slotGetNewRenderStuff()
3157 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3159 m_renderWidget->reloadProfiles();
3162 void MainWindow::slotGetNewMltProfileStuff()
3164 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3165 // update the list of profiles in settings dialog
3166 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3172 void MainWindow::slotAutoTransition()
3174 if (m_activeTimeline)
3175 m_activeTimeline->projectView()->autoTransition();
3178 void MainWindow::slotSplitAudio()
3180 if (m_activeTimeline)
3181 m_activeTimeline->projectView()->splitAudio();
3184 void MainWindow::slotUpdateClipType(QAction *action)
3186 if (m_activeTimeline) {
3187 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3188 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3189 else m_activeTimeline->projectView()->setAudioAndVideo();
3193 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3195 // We must stop the monitors since we create a new on in the dvd wizard
3196 m_clipMonitor->stop();
3197 m_projectMonitor->stop();
3198 DvdWizard w(url, profile, this);
3200 m_projectMonitor->start();
3203 void MainWindow::slotShowTimeline(bool show)
3205 if (show == false) {
3206 m_timelineState = saveState();
3207 centralWidget()->setHidden(true);
3209 centralWidget()->setHidden(false);
3210 restoreState(m_timelineState);
3214 void MainWindow::slotMaximizeCurrent(bool /*show*/)
3216 //TODO: is there a way to maximize current widget?
3219 m_timelineState = saveState();
3220 QWidget *par = focusWidget()->parentWidget();
3221 while (par->parentWidget() && par->parentWidget() != this)
3222 par = par->parentWidget();
3223 kDebug() << "CURRENT WIDGET: " << par->objectName();
3226 //centralWidget()->setHidden(false);
3227 //restoreState(m_timelineState);
3231 void MainWindow::loadTranscoders()
3233 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3236 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3237 KConfigGroup transConfig(config, "Transcoding");
3239 QMap< QString, QString > profiles = transConfig.entryMap();
3240 QMapIterator<QString, QString> i(profiles);
3241 while (i.hasNext()) {
3243 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3244 QAction *a = transMenu->addAction(i.key());
3246 if (data.count() > 1)
3247 a->setToolTip(data.at(1));
3248 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3252 void MainWindow::slotTranscode(KUrl::List urls)
3257 if (urls.isEmpty()) {
3258 QAction *action = qobject_cast<QAction *>(sender());
3259 QStringList data = action->data().toStringList();
3260 params = data.at(0);
3261 if (data.count() > 1) desc = data.at(1);
3262 if (data.count() > 2) condition = data.at(2);
3263 urls << m_projectList->getConditionalUrls(condition);
3264 urls.removeAll(KUrl());
3266 if (urls.isEmpty()) {
3267 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3270 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3271 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3273 //QProcess::startDetached("ffmpeg", parameters);
3276 void MainWindow::slotTranscodeClip()
3278 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3279 if (urls.isEmpty()) return;
3280 slotTranscode(urls);
3283 void MainWindow::slotSetDocumentRenderProfile(const QString &dest, const QString &group, const QString &name, const QString &file)
3285 if (m_activeDocument == NULL) return;
3286 m_activeDocument->setDocumentProperty("renderdestination", dest);
3287 m_activeDocument->setDocumentProperty("rendercategory", group);
3288 m_activeDocument->setDocumentProperty("renderprofile", name);
3289 m_activeDocument->setDocumentProperty("renderurl", file);
3290 m_activeDocument->setModified(true);
3294 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3296 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3298 QString playlistPath;
3301 QString scriptsFolder = m_activeDocument->projectFolder().path() + "/scripts/";
3302 QString path = m_renderWidget->getFreeScriptName();
3303 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3304 if (!ok || scriptPath.isEmpty()) return;
3305 scriptPath.prepend(scriptsFolder);
3306 QFile f(scriptPath);
3308 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3311 playlistPath = scriptPath + ".mlt";
3312 m_projectMonitor->saveSceneList(playlistPath);
3314 KTemporaryFile temp;
3315 temp.setAutoRemove(false);
3316 temp.setSuffix(".mlt");
3318 playlistPath = temp.fileName();
3319 m_projectMonitor->saveSceneList(playlistPath);
3322 if (!chapterFile.isEmpty()) {
3325 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3327 in = m_activeTimeline->inPoint();
3328 out = m_activeTimeline->outPoint();
3331 QDomElement chapters = doc.createElement("chapters");
3332 chapters.setAttribute("fps", m_activeDocument->fps());
3333 doc.appendChild(chapters);
3335 QDomElement guidesxml = m_activeDocument->guidesXml();
3336 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3337 for (int i = 0; i < nodes.count(); i++) {
3338 QDomElement e = nodes.item(i).toElement();
3340 QString comment = e.attribute("comment");
3341 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3342 if (time >= in && time < out) {
3343 if (zoneOnly) time = time - in;
3344 QDomElement chapter = doc.createElement("chapter");
3345 chapters.appendChild(chapter);
3346 chapter.setAttribute("title", comment);
3347 chapter.setAttribute("time", time);
3351 if (chapters.childNodes().count() > 0) {
3352 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3353 // Always insert a guide in pos 0
3354 QDomElement chapter = doc.createElement("chapter");
3355 chapters.insertBefore(chapter, QDomNode());
3356 chapter.setAttribute("title", i18n("Start"));
3357 chapter.setAttribute("time", "0");
3359 // save chapters file
3360 QFile file(chapterFile);
3361 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3362 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3364 file.write(doc.toString().toUtf8());
3365 if (file.error() != QFile::NoError) {
3366 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3373 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath);
3376 void MainWindow::slotUpdateTimecodeFormat(int ix)
3378 KdenliveSettings::setFrametimecode(ix == 1);
3379 m_clipMonitor->updateTimecodeFormat();
3380 m_projectMonitor->updateTimecodeFormat();
3381 m_transitionConfig->updateTimecodeFormat();
3382 m_effectStack->updateTimecodeFormat();
3383 //m_activeTimeline->projectView()->clearSelection();
3384 m_activeTimeline->updateRuler();
3387 void MainWindow::slotRemoveFocus()
3389 statusBar()->setFocus();
3390 statusBar()->clearFocus();
3393 void MainWindow::slotRevert()
3395 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;
3396 KUrl url = m_activeDocument->url();
3397 closeCurrentDocument(false);
3398 doOpenFile(url, NULL);
3402 void MainWindow::slotShutdown()
3404 if (m_activeDocument) m_activeDocument->setModified(false);
3406 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
3407 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
3408 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
3409 smserver.call("logout", 1, 2, 2);
3410 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
3411 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
3412 smserver.call("Shutdown");
3416 void MainWindow::slotUpdateTrackInfo()
3418 if (m_activeDocument)
3419 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
3422 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
3424 // Load the theme file
3426 if (action == NULL) theme = themename;
3427 else theme = action->data().toString();
3428 KdenliveSettings::setColortheme(theme);
3429 // Make palette for all widgets.
3431 if (theme.isEmpty())
3432 plt = QApplication::desktop()->palette();
3434 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
3435 plt = KGlobalSettings::createApplicationPalette(config);
3438 kapp->setPalette(plt);
3439 const QObjectList children = statusBar()->children();
3441 foreach(QObject *child, children) {
3442 if (child->isWidgetType())
3443 ((QWidget*)child)->setPalette(plt);
3444 const QObjectList subchildren = child->children();
3445 foreach(QObject *subchild, subchildren) {
3446 if (subchild->isWidgetType())
3447 ((QWidget*)subchild)->setPalette(plt);
3450 if (m_activeTimeline)
3451 m_activeTimeline->projectView()->updatePalette();
3455 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
3457 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
3458 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
3459 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
3460 const QSize bitsSize(24, 2);
3461 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
3462 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
3464 QPixmap pixmap(23, 16);
3465 pixmap.fill(Qt::black); // ### use some color other than black for borders?
3467 KConfigGroup group(config, "WM");
3468 QPainter p(&pixmap);
3469 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
3470 p.fillRect(1, 1, 7, 7, windowScheme.background());
3471 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
3473 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
3474 p.fillRect(8, 1, 7, 7, buttonScheme.background());
3475 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
3477 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
3478 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
3480 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
3481 p.fillRect(1, 8, 7, 7, viewScheme.background());
3482 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
3484 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
3485 p.fillRect(8, 8, 7, 7, selectionScheme.background());
3486 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
3488 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
3489 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
3495 void MainWindow::slotSwitchMonitors()
3497 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
3498 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
3499 else m_projectList->focusTree();
3502 void MainWindow::slotInsertZoneToTree()
3504 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
3505 QStringList info = m_clipMonitor->getZoneInfo();
3506 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
3509 void MainWindow::slotInsertZoneToTimeline()
3511 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
3512 QStringList info = m_clipMonitor->getZoneInfo();
3513 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
3517 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
3519 if (m_activeDocument && m_activeTimeline) {
3520 if (!ids.isEmpty()) {
3521 for (int i = 0; i < ids.size(); ++i) {
3522 m_activeTimeline->slotDeleteClip(ids.at(i));
3524 m_activeDocument->clipManager()->slotDeleteClips(ids);
3526 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
3527 m_activeDocument->setModified(true);
3531 void MainWindow::slotShowTitleBars(bool show)
3534 m_effectStackDock->setTitleBarWidget(0);
3535 m_clipMonitorDock->setTitleBarWidget(0);
3536 m_projectMonitorDock->setTitleBarWidget(0);
3538 m_recMonitorDock->setTitleBarWidget(0);
3540 m_effectListDock->setTitleBarWidget(0);
3541 m_transitionConfigDock->setTitleBarWidget(0);
3542 m_projectListDock->setTitleBarWidget(0);
3543 m_undoViewDock->setTitleBarWidget(0);
3545 if (!m_effectStackDock->isFloating()) m_effectStackDock->setTitleBarWidget(new QWidget(this));
3546 if (!m_clipMonitorDock->isFloating()) m_clipMonitorDock->setTitleBarWidget(new QWidget(this));
3547 if (!m_projectMonitorDock->isFloating()) m_projectMonitorDock->setTitleBarWidget(new QWidget(this));
3549 if (!m_recMonitorDock->isFloating()) m_recMonitorDock->setTitleBarWidget(new QWidget(this));
3551 if (!m_effectListDock->isFloating()) m_effectListDock->setTitleBarWidget(new QWidget(this));
3552 if (!m_transitionConfigDock->isFloating()) m_transitionConfigDock->setTitleBarWidget(new QWidget(this));
3553 if (!m_projectListDock->isFloating()) m_projectListDock->setTitleBarWidget(new QWidget(this));
3554 if (!m_undoViewDock->isFloating()) m_undoViewDock->setTitleBarWidget(new QWidget(this));
3556 KdenliveSettings::setShowtitlebars(show);
3559 void MainWindow::slotSwitchTitles()
3561 slotShowTitleBars(!KdenliveSettings::showtitlebars());
3564 QString MainWindow::getMimeType()
3566 QString mimetype = "application/x-kdenlive";
3567 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
3568 if (!mime) mimetype = "*.kdenlive";
3572 #include "mainwindow.moc"