1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
21 #include "mainwindow.h"
22 #include "mainwindowadaptor.h"
23 #include "kdenlivesettings.h"
24 #include "kdenlivesettingsdialog.h"
25 #include "initeffects.h"
26 #include "profilesdialog.h"
27 #include "projectsettings.h"
29 #include "clipmanager.h"
30 #include "projectlist.h"
32 #include "recmonitor.h"
33 #include "monitormanager.h"
34 #include "kdenlivedoc.h"
35 #include "trackview.h"
36 #include "customtrackview.h"
37 #include "effectslistview.h"
38 #include "effectstackview.h"
39 #include "transitionsettings.h"
40 #include "renderwidget.h"
43 #include "jogshuttle.h"
44 #endif /* NO_JOGSHUTTLE */
45 #include "clipproperties.h"
47 #include "editclipcommand.h"
48 #include "titlewidget.h"
49 #include "markerdialog.h"
51 #include "interfaces.h"
52 #include "kdenlive-config.h"
53 #include "cliptranscode.h"
54 #include "ui_templateclip_ui.h"
55 #include "vectorscope.h"
57 #include <KApplication>
61 #include <KActionCollection>
62 #include <KActionCategory>
63 #include <KStandardAction>
64 #include <KShortcutsDialog>
65 #include <KFileDialog>
66 #include <KMessageBox>
68 #include <KIO/NetAccess>
71 #include <KConfigDialog>
72 #include <KXMLGUIFactory>
74 #include <kstandarddirs.h>
75 #include <KUrlRequesterDialog>
76 #include <KTemporaryFile>
78 #include <KActionMenu>
81 #include <ktogglefullscreenaction.h>
83 #include <KNotification>
84 #include <KNotifyConfigWidget>
85 #if KDE_IS_VERSION(4,3,80)
86 #include <knewstuff3/downloaddialog.h>
87 #include <knewstuff3/knewstuffaction.h>
89 #include <knewstuff2/engine.h>
90 #include <knewstuff2/ui/knewstuffaction.h>
92 #endif /* KDE_IS_VERSION(4,3,80) */
94 #include <KColorScheme>
96 #include <QTextStream>
100 #include <QInputDialog>
101 #include <QDesktopWidget>
106 static const char version[] = VERSION;
108 static const int ID_TIMELINE_POS = 0;
115 EffectsList MainWindow::videoEffects;
116 EffectsList MainWindow::audioEffects;
117 EffectsList MainWindow::customEffects;
118 EffectsList MainWindow::transitions;
120 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent) :
121 KXmlGuiWindow(parent),
122 m_activeDocument(NULL),
123 m_activeTimeline(NULL),
124 m_renderWidget(NULL),
125 #ifndef NO_JOGSHUTTLE
127 #endif /* NO_JOGSHUTTLE */
128 m_findActivated(false)
131 // Create DBus interface
132 new MainWindowAdaptor(this);
133 QDBusConnection dbus = QDBusConnection::sessionBus();
134 dbus.registerObject("/MainWindow", this);
136 setlocale(LC_NUMERIC, "POSIX");
137 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
138 setFont(KGlobalSettings::toolBarFont());
139 parseProfiles(MltPath);
140 m_commandStack = new QUndoGroup;
141 m_timelineArea = new KTabWidget(this);
142 m_timelineArea->setTabReorderingEnabled(true);
143 m_timelineArea->setTabBarHidden(true);
144 m_timelineArea->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
145 m_timelineArea->setMinimumHeight(200);
147 QToolButton *closeTabButton = new QToolButton;
148 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
149 closeTabButton->setIcon(KIcon("tab-close"));
150 closeTabButton->adjustSize();
151 closeTabButton->setToolTip(i18n("Close the current tab"));
152 m_timelineArea->setCornerWidget(closeTabButton);
153 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
155 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
156 m_findTimer.setSingleShot(true);
158 // FIXME: the next call returns a newly allocated object, which leaks
159 initEffects::parseEffectFiles();
160 //initEffects::parseCustomEffectsFile();
162 m_monitorManager = new MonitorManager();
164 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
165 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
170 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
171 m_projectListDock->setObjectName("project_tree");
172 m_projectList = new ProjectList(this);
173 m_projectListDock->setWidget(m_projectList);
174 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
176 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
177 m_effectStackDock->setObjectName("effect_stack");
178 m_effectStack = new EffectStackView(this);
179 m_effectStackDock->setWidget(m_effectStack);
180 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
182 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
183 m_transitionConfigDock->setObjectName("transition");
184 m_transitionConfig = new TransitionSettings(this);
185 m_transitionConfigDock->setWidget(m_transitionConfig);
186 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
188 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
189 m_clipMonitorDock->setObjectName("clip_monitor");
190 m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), this);
191 m_clipMonitorDock->setWidget(m_clipMonitor);
192 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
194 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
195 m_projectMonitorDock->setObjectName("project_monitor");
196 m_projectMonitor = new Monitor("project", m_monitorManager, QString(), this);
197 m_projectMonitorDock->setWidget(m_projectMonitor);
198 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
201 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
202 m_recMonitorDock->setObjectName("record_monitor");
203 m_recMonitor = new RecMonitor("record", this);
204 m_recMonitorDock->setWidget(m_recMonitor);
205 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
206 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
207 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
210 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
211 m_effectListDock->setObjectName("effect_list");
212 m_effectList = new EffectsListView();
213 m_effectListDock->setWidget(m_effectList);
214 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
216 m_vectorscope = new Vectorscope(m_projectMonitor->render, m_clipMonitor->render, this);
217 m_vectorscopeDock = new QDockWidget(i18n("Vectorscope"), this);
218 m_vectorscopeDock->setObjectName("vectorscope");
219 m_vectorscopeDock->setWidget(m_vectorscope);
220 addDockWidget(Qt::TopDockWidgetArea, m_vectorscopeDock);
223 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
224 m_undoViewDock->setObjectName("undo_history");
225 m_undoView = new QUndoView(this);
226 m_undoView->setCleanIcon(KIcon("edit-clear"));
227 m_undoView->setEmptyLabel(i18n("Clean"));
228 m_undoViewDock->setWidget(m_undoView);
229 m_undoView->setGroup(m_commandStack);
230 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
232 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
233 //overviewDock->setObjectName("project_overview");
234 //m_overView = new CustomTrackView(NULL, NULL, this);
235 //overviewDock->setWidget(m_overView);
236 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
241 /// Tabify Widgets ///
242 tabifyDockWidget(m_projectListDock, m_effectStackDock);
243 tabifyDockWidget(m_projectListDock, m_transitionConfigDock);
246 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
248 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
251 tabifyDockWidget(m_vectorscopeDock, m_undoViewDock);
252 tabifyDockWidget(m_vectorscopeDock, m_effectListDock);
255 setCentralWidget(m_timelineArea);
258 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
259 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
261 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
262 m_fileRevert->setEnabled(false);
268 // Find QDockWidget tab bars and show / hide widget title bars on right click
269 QList <QTabBar *> tabs = findChildren<QTabBar *>();
270 for (int i = 0; i < tabs.count(); i++) {
271 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
272 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
275 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
276 guiFactory()->addClient(sp);*/
280 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
282 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone);
283 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
285 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
286 clipInTimeline->setIcon(KIcon("go-jump"));
287 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)),
288 static_cast<QMenu*>(factory()->container("transcoders", this)),
292 // build themes menus
293 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
294 QActionGroup *themegroup = new QActionGroup(this);
295 themegroup->setExclusive(true);
296 action = new KAction(i18n("Default"), this);
297 action->setCheckable(true);
298 themegroup->addAction(action);
299 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
301 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
303 for (int i = 0; i < schemeFiles.size(); ++i) {
305 const QString filename = schemeFiles.at(i);
306 const QFileInfo info(filename);
309 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
310 QIcon icon = createSchemePreviewIcon(config);
311 KConfigGroup group(config, "General");
312 const QString name = group.readEntry("Name", info.baseName());
313 action = new KAction(name, this);
314 action->setData(filename);
315 action->setIcon(icon);
316 action->setCheckable(true);
317 themegroup->addAction(action);
318 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
321 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
322 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
323 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
326 action = new QAction(fi.fileName(), this);
327 action->setData(*it);
328 action->setCheckable(true);
329 themegroup->addAction(action);
330 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
332 themesMenu->addActions(themegroup->actions());
333 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
335 // Setup and fill effects and transitions menus.
336 m_videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
337 for (int i = 0; i < videoEffects.count(); ++i)
338 m_videoEffectsMenu->addAction(m_videoEffects[i]);
339 m_audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
340 for (int i = 0; i < audioEffects.count(); ++i)
341 m_audioEffectsMenu->addAction(m_audioEffects[i]);
342 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
343 if (customEffects.isEmpty())
344 m_customEffectsMenu->setEnabled(false);
346 m_customEffectsMenu->setEnabled(true);
347 for (int i = 0; i < customEffects.count(); ++i)
348 m_customEffectsMenu->addAction(m_customEffects[i]);
349 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
350 for (int i = 0; i < transitions.count(); ++i)
351 m_transitionsMenu->addAction(m_transitions[i]);
353 connect(m_videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
354 connect(m_audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
355 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
356 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
358 QMenu *newEffect = new QMenu(this);
359 newEffect->addMenu(m_videoEffectsMenu);
360 newEffect->addMenu(m_audioEffectsMenu);
361 newEffect->addMenu(m_customEffectsMenu);
362 m_effectStack->setMenu(newEffect);
364 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
365 const QList<QAction *> viewActions = createPopupMenu()->actions();
366 viewMenu->insertActions(NULL, viewActions);
368 m_timelineContextMenu = new QMenu(this);
369 m_timelineContextClipMenu = new QMenu(this);
370 m_timelineContextTransitionMenu = new QMenu(this);
372 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
373 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
374 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
376 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
377 //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
378 m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
379 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
380 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
381 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
382 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
383 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
384 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
385 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
387 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
388 m_timelineContextClipMenu->addMenu(markersMenu);
389 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
390 m_timelineContextClipMenu->addMenu(m_videoEffectsMenu);
391 m_timelineContextClipMenu->addMenu(m_audioEffectsMenu);
392 //TODO: re-enable custom effects menu when it is implemented
393 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
395 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
396 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
397 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
399 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
401 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
402 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
403 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
404 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
405 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), m_vectorscope, SLOT(slotActiveMonitorChanged(bool)));
406 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
407 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
409 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
410 slotConnectMonitors();
412 // Disable drop B frames, see Kdenlive issue #1330, see also kdenlivesettingsdialog.cpp
413 KdenliveSettings::setDropbframes(false);
415 // Open or create a file. Command line argument passed in Url has
416 // precedence, then "openlastproject", then just a plain empty file.
417 // If opening Url fails, openlastproject will _not_ be used.
418 if (!Url.isEmpty()) {
419 // delay loading so that the window shows up
421 QTimer::singleShot(500, this, SLOT(openFile()));
422 } else if (KdenliveSettings::openlastproject()) {
423 QTimer::singleShot(500, this, SLOT(openLastFile()));
424 } else { //if (m_timelineArea->count() == 0) {
428 #ifndef NO_JOGSHUTTLE
429 activateShuttleDevice();
430 #endif /* NO_JOGSHUTTLE */
431 m_projectListDock->raise();
434 void MainWindow::queryQuit()
437 if (m_projectMonitor) m_projectMonitor->stop();
438 if (m_clipMonitor) m_clipMonitor->stop();
439 delete m_effectStack;
440 delete m_activeTimeline;
442 // This sometimes causes crash on exit on OS X for some reason.
443 delete m_projectMonitor;
444 delete m_clipMonitor;
446 delete m_activeDocument;
447 delete m_shortcutRemoveFocus;
448 Mlt::Factory::close();
454 bool MainWindow::queryClose()
456 if (m_renderWidget) {
457 int waitingJobs = m_renderWidget->waitingJobsCount();
458 if (waitingJobs > 0) {
459 switch (KMessageBox::warningYesNoCancel(this, i18np("You have 1 rendering job waiting in the queue.\nWhat do you want to do with this job?", "You have %1 rendering jobs waiting in the queue.\nWhat do you want to do with these jobs?", waitingJobs), QString(), KGuiItem(i18n("Start them now")), KGuiItem(i18n("Delete them")))) {
460 case KMessageBox::Yes :
461 // create script with waiting jobs and start it
462 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
464 case KMessageBox::No :
465 // Don't do anything, jobs will be deleted
473 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
474 // warn the user to save if document is modified and we have clips in our project list
475 if (m_activeDocument && m_activeDocument->isModified() &&
476 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
477 !m_projectList->documentClipList().isEmpty())) {
479 if (m_activeDocument->url().fileName().isEmpty())
480 message = i18n("Save changes to document?");
482 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
483 switch (KMessageBox::warningYesNoCancel(this, message)) {
484 case KMessageBox::Yes :
485 // save document here. If saving fails, return false;
487 case KMessageBox::No :
488 // User does not want to save the changes, clear recovery files
489 m_activeDocument->m_autosave->resize(0);
498 void MainWindow::loadPlugins()
500 foreach(QObject *plugin, QPluginLoader::staticInstances()) {
501 populateMenus(plugin);
504 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
506 filters << "libkdenlive*";
507 foreach(const QString &folder, directories) {
508 kDebug() << "Parsing plugin folder: " << folder;
509 QDir pluginsDir(folder);
510 foreach(const QString &fileName,
511 pluginsDir.entryList(filters, QDir::Files)) {
513 * Avoid loading the same plugin twice when there is more than one
516 if (!m_pluginFileNames.contains(fileName)) {
517 kDebug() << "Found plugin: " << fileName;
518 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
519 QObject *plugin = loader.instance();
521 populateMenus(plugin);
522 m_pluginFileNames += fileName;
524 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
530 void MainWindow::populateMenus(QObject *plugin)
532 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
533 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
535 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
539 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
540 QMenu *menu, const char *member,
541 QActionGroup *actionGroup)
543 kDebug() << "// ADD to MENU" << texts;
544 foreach(const QString &text, texts) {
545 QAction *action = new QAction(text, plugin);
546 action->setData(text);
547 connect(action, SIGNAL(triggered()), this, member);
548 menu->addAction(action);
551 action->setCheckable(true);
552 actionGroup->addAction(action);
557 void MainWindow::aboutPlugins()
559 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
564 void MainWindow::generateClip()
566 QAction *action = qobject_cast<QAction *>(sender());
567 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
569 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
570 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
571 if (!clipUrl.isEmpty()) {
572 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
576 void MainWindow::saveProperties(KConfigGroup &config)
578 // save properties here,used by session management
580 KMainWindow::saveProperties(config);
584 void MainWindow::readProperties(const KConfigGroup &config)
586 // read properties here,used by session management
587 KMainWindow::readProperties(config);
588 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
589 openFile(KUrl(Lastproject));
592 void MainWindow::slotReloadEffects()
594 m_customEffectsMenu->clear();
595 initEffects::parseCustomEffectsFile();
597 QStringList effectInfo;
598 QMap<QString, QStringList> effectsList;
599 for (int ix = 0; ix < customEffects.count(); ix++) {
600 effectInfo = customEffects.effectIdInfo(ix);
601 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
603 if (effectsList.isEmpty())
604 m_customEffectsMenu->setEnabled(false);
606 m_customEffectsMenu->setEnabled(true);
608 foreach(const QStringList &value, effectsList) {
609 action = new QAction(value.at(0), this);
610 action->setData(value);
611 m_customEffectsMenu->addAction(action);
613 m_effectList->reloadEffectList();
616 #ifndef NO_JOGSHUTTLE
617 void MainWindow::activateShuttleDevice()
621 if (KdenliveSettings::enableshuttle() == false) return;
622 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
623 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
624 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
625 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
626 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
627 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
628 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
631 void MainWindow::slotShuttleButton(int code)
635 slotShuttleAction(KdenliveSettings::shuttle1());
638 slotShuttleAction(KdenliveSettings::shuttle2());
641 slotShuttleAction(KdenliveSettings::shuttle3());
644 slotShuttleAction(KdenliveSettings::shuttle4());
647 slotShuttleAction(KdenliveSettings::shuttle5());
652 void MainWindow::slotShuttleAction(int code)
658 m_monitorManager->slotPlay();
661 m_monitorManager->slotPlay();
665 #endif /* NO_JOGSHUTTLE */
667 void MainWindow::configureNotifications()
669 KNotifyConfigWidget::configure(this);
672 void MainWindow::slotFullScreen()
674 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
677 void MainWindow::slotAddEffect(const QDomElement effect, GenTime pos, int track)
679 if (!m_activeDocument) return;
680 if (effect.isNull()) {
681 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
684 QDomElement effectToAdd = effect.cloneNode().toElement();
685 m_activeTimeline->projectView()->slotAddEffect(effectToAdd, pos, track);
688 void MainWindow::slotRaiseMonitor(bool clipMonitor)
690 if (clipMonitor) m_clipMonitorDock->raise();
691 else m_projectMonitorDock->raise();
694 void MainWindow::slotUpdateClip(const QString &id)
696 if (!m_activeDocument) return;
697 m_activeTimeline->projectView()->slotUpdateClip(id);
700 void MainWindow::slotConnectMonitors()
702 m_projectList->setRenderer(m_projectMonitor->render);
703 //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
704 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
705 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
706 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
707 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, int, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, int, bool)));
708 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
709 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)));
711 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
713 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
715 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
716 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
718 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
719 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
722 void MainWindow::slotAdjustClipMonitor()
724 m_clipMonitorDock->updateGeometry();
725 m_clipMonitorDock->adjustSize();
726 m_clipMonitor->resetSize();
729 void MainWindow::slotAdjustProjectMonitor()
731 m_projectMonitorDock->updateGeometry();
732 m_projectMonitorDock->adjustSize();
733 m_projectMonitor->resetSize();
736 void MainWindow::setupActions()
739 KActionCollection* collection = actionCollection();
740 m_timecodeFormat = new KComboBox(this);
741 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
742 m_timecodeFormat->addItem(i18n("Frames"));
743 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
744 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
746 m_statusProgressBar = new QProgressBar(this);
747 m_statusProgressBar->setMinimum(0);
748 m_statusProgressBar->setMaximum(100);
749 m_statusProgressBar->setMaximumWidth(150);
750 m_statusProgressBar->setVisible(false);
752 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
753 toolbar->setMovable(false);
754 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
755 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;}";
756 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
758 //create edit mode buttons
759 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
760 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
761 toolbar->addAction(m_normalEditTool);
762 m_normalEditTool->setCheckable(true);
763 m_normalEditTool->setChecked(true);
765 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
766 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
767 toolbar->addAction(m_overwriteEditTool);
768 m_overwriteEditTool->setCheckable(true);
769 m_overwriteEditTool->setChecked(false);
771 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
772 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
773 toolbar->addAction(m_insertEditTool);
774 m_insertEditTool->setCheckable(true);
775 m_insertEditTool->setChecked(false);
776 // not implemented yet
777 m_insertEditTool->setEnabled(false);
779 QActionGroup *editGroup = new QActionGroup(this);
780 editGroup->addAction(m_normalEditTool);
781 editGroup->addAction(m_overwriteEditTool);
782 editGroup->addAction(m_insertEditTool);
783 editGroup->setExclusive(true);
784 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
785 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
787 toolbar->addSeparator();
789 // create tools buttons
790 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
791 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
792 toolbar->addAction(m_buttonSelectTool);
793 m_buttonSelectTool->setCheckable(true);
794 m_buttonSelectTool->setChecked(true);
796 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
797 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
798 toolbar->addAction(m_buttonRazorTool);
799 m_buttonRazorTool->setCheckable(true);
800 m_buttonRazorTool->setChecked(false);
802 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
803 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
804 toolbar->addAction(m_buttonSpacerTool);
805 m_buttonSpacerTool->setCheckable(true);
806 m_buttonSpacerTool->setChecked(false);
808 QActionGroup *toolGroup = new QActionGroup(this);
809 toolGroup->addAction(m_buttonSelectTool);
810 toolGroup->addAction(m_buttonRazorTool);
811 toolGroup->addAction(m_buttonSpacerTool);
812 toolGroup->setExclusive(true);
813 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
815 QWidget * actionWidget;
816 int max = toolbar->iconSizeDefault() + 2;
817 actionWidget = toolbar->widgetForAction(m_normalEditTool);
818 actionWidget->setMaximumWidth(max);
819 actionWidget->setMaximumHeight(max - 4);
821 actionWidget = toolbar->widgetForAction(m_insertEditTool);
822 actionWidget->setMaximumWidth(max);
823 actionWidget->setMaximumHeight(max - 4);
825 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
826 actionWidget->setMaximumWidth(max);
827 actionWidget->setMaximumHeight(max - 4);
829 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
830 actionWidget->setMaximumWidth(max);
831 actionWidget->setMaximumHeight(max - 4);
833 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
834 actionWidget->setMaximumWidth(max);
835 actionWidget->setMaximumHeight(max - 4);
837 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
838 actionWidget->setMaximumWidth(max);
839 actionWidget->setMaximumHeight(max - 4);
841 toolbar->setStyleSheet(style1);
842 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
844 toolbar->addSeparator();
845 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
846 toolbar->addAction(m_buttonFitZoom);
847 m_buttonFitZoom->setCheckable(false);
849 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
850 toolbar->addAction(m_zoomOut);
851 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
853 m_zoomSlider = new QSlider(Qt::Horizontal, this);
854 m_zoomSlider->setMaximum(13);
855 m_zoomSlider->setPageStep(1);
856 m_zoomSlider->setInvertedAppearance(true);
858 m_zoomSlider->setMaximumWidth(150);
859 m_zoomSlider->setMinimumWidth(100);
860 toolbar->addWidget(m_zoomSlider);
862 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
863 toolbar->addAction(m_zoomIn);
864 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
866 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
867 actionWidget->setMaximumWidth(max);
868 actionWidget->setMaximumHeight(max - 4);
869 actionWidget->setStyleSheet(styleBorderless);
871 actionWidget = toolbar->widgetForAction(m_zoomIn);
872 actionWidget->setMaximumWidth(max);
873 actionWidget->setMaximumHeight(max - 4);
874 actionWidget->setStyleSheet(styleBorderless);
876 actionWidget = toolbar->widgetForAction(m_zoomOut);
877 actionWidget->setMaximumWidth(max);
878 actionWidget->setMaximumHeight(max - 4);
879 actionWidget->setStyleSheet(styleBorderless);
881 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
882 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
883 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
884 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
885 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
887 toolbar->addSeparator();
889 //create automatic audio split button
890 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
891 toolbar->addAction(m_buttonAutomaticSplitAudio);
892 m_buttonAutomaticSplitAudio->setCheckable(true);
893 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
894 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
896 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
897 toolbar->addAction(m_buttonVideoThumbs);
898 m_buttonVideoThumbs->setCheckable(true);
899 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
900 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
902 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
903 toolbar->addAction(m_buttonAudioThumbs);
904 m_buttonAudioThumbs->setCheckable(true);
905 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
906 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
908 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
909 toolbar->addAction(m_buttonShowMarkers);
910 m_buttonShowMarkers->setCheckable(true);
911 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
912 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
914 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
915 toolbar->addAction(m_buttonSnap);
916 m_buttonSnap->setCheckable(true);
917 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
918 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
920 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
921 actionWidget->setMaximumWidth(max);
922 actionWidget->setMaximumHeight(max - 4);
924 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
925 actionWidget->setMaximumWidth(max);
926 actionWidget->setMaximumHeight(max - 4);
928 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
929 actionWidget->setMaximumWidth(max);
930 actionWidget->setMaximumHeight(max - 4);
932 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
933 actionWidget->setMaximumWidth(max);
934 actionWidget->setMaximumHeight(max - 4);
936 actionWidget = toolbar->widgetForAction(m_buttonSnap);
937 actionWidget->setMaximumWidth(max);
938 actionWidget->setMaximumHeight(max - 4);
940 m_messageLabel = new StatusBarMessageLabel(this);
941 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
943 statusBar()->addWidget(m_messageLabel, 10);
944 statusBar()->addWidget(m_statusProgressBar, 0);
945 statusBar()->addPermanentWidget(toolbar);
946 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
947 statusBar()->addPermanentWidget(m_timecodeFormat);
948 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
950 collection->addAction("normal_mode", m_normalEditTool);
951 collection->addAction("overwrite_mode", m_overwriteEditTool);
952 collection->addAction("insert_mode", m_insertEditTool);
953 collection->addAction("select_tool", m_buttonSelectTool);
954 collection->addAction("razor_tool", m_buttonRazorTool);
955 collection->addAction("spacer_tool", m_buttonSpacerTool);
957 collection->addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
958 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
959 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
960 collection->addAction("show_markers", m_buttonShowMarkers);
961 collection->addAction("snap", m_buttonSnap);
962 collection->addAction("zoom_fit", m_buttonFitZoom);
963 collection->addAction("zoom_in", m_zoomIn);
964 collection->addAction("zoom_out", m_zoomOut);
966 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
967 collection->addAction("project_find", m_projectSearch);
968 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
969 m_projectSearch->setShortcut(Qt::Key_Slash);
971 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
972 collection->addAction("project_find_next", m_projectSearchNext);
973 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
974 m_projectSearchNext->setShortcut(Qt::Key_F3);
975 m_projectSearchNext->setEnabled(false);
977 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
978 collection->addAction("manage_profiles", profilesAction);
979 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
981 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
982 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
983 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
984 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
986 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
987 collection->addAction("run_wizard", wizAction);
988 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
990 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
991 collection->addAction("project_settings", projectAction);
992 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
994 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
995 collection->addAction("project_render", projectRender);
996 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
997 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
999 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1000 collection->addAction("project_clean", projectClean);
1001 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1003 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1004 KShortcut playShortcut;
1005 playShortcut.setPrimary(Qt::Key_Space);
1006 playShortcut.setAlternate(Qt::Key_K);
1007 monitorPlay->setShortcut(playShortcut);
1008 collection->addAction("monitor_play", monitorPlay);
1009 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1011 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1012 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1013 collection->addAction("monitor_play_zone", m_playZone);
1014 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1016 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1017 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1018 collection->addAction("monitor_loop_zone", m_loopZone);
1019 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1021 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1022 collection->addAction("dvd_wizard", dvdWizard);
1023 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1025 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1026 collection->addAction("transcode_clip", transcodeClip);
1027 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1029 KAction *markIn = collection->addAction("mark_in");
1030 markIn->setText(i18n("Set Zone In"));
1031 markIn->setShortcut(Qt::Key_I);
1032 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1034 KAction *markOut = collection->addAction("mark_out");
1035 markOut->setText(i18n("Set Zone Out"));
1036 markOut->setShortcut(Qt::Key_O);
1037 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1039 KAction *switchMon = collection->addAction("switch_monitor");
1040 switchMon->setText(i18n("Switch monitor"));
1041 switchMon->setShortcut(Qt::Key_T);
1042 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1044 KAction *insertTree = collection->addAction("insert_project_tree");
1045 insertTree->setText(i18n("Insert zone in project tree"));
1046 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1047 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1049 KAction *insertTimeline = collection->addAction("insert_timeline");
1050 insertTimeline->setText(i18n("Insert zone in timeline"));
1051 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1052 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1054 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1055 collection->addAction("resize_timeline_clip_start", resizeStart);
1056 resizeStart->setShortcut(Qt::Key_1);
1057 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1059 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1060 collection->addAction("resize_timeline_clip_end", resizeEnd);
1061 resizeEnd->setShortcut(Qt::Key_2);
1062 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1064 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1065 monitorSeekBackward->setShortcut(Qt::Key_J);
1066 collection->addAction("monitor_seek_backward", monitorSeekBackward);
1067 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1069 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1070 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1071 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1072 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1074 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1075 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1076 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1077 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1079 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1080 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1081 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1082 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1084 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1085 monitorSeekForward->setShortcut(Qt::Key_L);
1086 collection->addAction("monitor_seek_forward", monitorSeekForward);
1087 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1089 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1090 clipStart->setShortcut(Qt::Key_Home);
1091 collection->addAction("seek_clip_start", clipStart);
1092 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1094 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1095 clipEnd->setShortcut(Qt::Key_End);
1096 collection->addAction("seek_clip_end", clipEnd);
1097 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1099 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1100 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1101 collection->addAction("seek_zone_start", zoneStart);
1102 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1104 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1105 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1106 collection->addAction("seek_zone_end", zoneEnd);
1107 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1109 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1110 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1111 collection->addAction("seek_start", projectStart);
1112 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1114 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1115 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1116 collection->addAction("seek_end", projectEnd);
1117 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1119 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1120 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1121 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1122 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1124 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1125 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1126 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1127 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1129 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1130 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1131 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1132 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1134 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1135 deleteItem->setShortcut(Qt::Key_Delete);
1136 collection->addAction("delete_timeline_clip", deleteItem);
1137 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1139 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1140 collection->addAction("change_clip_speed", editTimelineClipSpeed);
1141 editTimelineClipSpeed->setData("change_speed");
1142 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1144 KAction *stickTransition = collection->addAction("auto_transition");
1145 stickTransition->setData(QString("auto"));
1146 stickTransition->setCheckable(true);
1147 stickTransition->setEnabled(false);
1148 stickTransition->setText(i18n("Automatic Transition"));
1149 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1151 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1152 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1153 collection->addAction("group_clip", groupClip);
1154 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1156 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1157 collection->addAction("ungroup_clip", ungroupClip);
1158 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1159 ungroupClip->setData("ungroup_clip");
1160 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1162 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1163 collection->addAction("edit_item_duration", editItemDuration);
1164 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1166 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1167 collection->addAction("clip_in_project_tree", clipInProjectTree);
1168 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1170 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1171 collection->addAction("clip_to_project_tree", clipToProjectTree);
1172 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1174 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1175 insertOvertwrite->setShortcut(Qt::Key_V);
1176 collection->addAction("overwrite_to_in_point", insertOvertwrite);
1177 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1179 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1180 selectTimelineClip->setShortcut(Qt::Key_Plus);
1181 collection->addAction("select_timeline_clip", selectTimelineClip);
1182 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1184 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1185 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1186 collection->addAction("deselect_timeline_clip", deselectTimelineClip);
1187 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1189 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1190 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1191 collection->addAction("select_add_timeline_clip", selectAddTimelineClip);
1192 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1194 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1195 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1196 collection->addAction("select_timeline_transition", selectTimelineTransition);
1197 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1199 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1200 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1201 collection->addAction("deselect_timeline_transition", deselectTimelineTransition);
1202 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1204 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1205 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1206 collection->addAction("select_add_timeline_transition", selectAddTimelineTransition);
1207 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1209 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1210 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1211 collection->addAction("cut_timeline_clip", cutTimelineClip);
1212 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1214 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1215 collection->addAction("add_clip_marker", addClipMarker);
1216 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1218 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1219 collection->addAction("delete_clip_marker", deleteClipMarker);
1220 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1222 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1223 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
1224 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1226 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1227 collection->addAction("edit_clip_marker", editClipMarker);
1228 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1230 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1231 collection->addAction("split_audio", splitAudio);
1232 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1234 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1235 collection->addAction("clip_audio_only", audioOnly);
1236 audioOnly->setData("clip_audio_only");
1237 audioOnly->setCheckable(true);
1239 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1240 collection->addAction("clip_video_only", videoOnly);
1241 videoOnly->setData("clip_video_only");
1242 videoOnly->setCheckable(true);
1244 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1245 collection->addAction("clip_audio_and_video", audioAndVideo);
1246 audioAndVideo->setData("clip_audio_and_video");
1247 audioAndVideo->setCheckable(true);
1249 m_clipTypeGroup = new QActionGroup(this);
1250 m_clipTypeGroup->addAction(audioOnly);
1251 m_clipTypeGroup->addAction(videoOnly);
1252 m_clipTypeGroup->addAction(audioAndVideo);
1253 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1254 m_clipTypeGroup->setEnabled(false);
1256 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1257 collection->addAction("insert_space", insertSpace);
1258 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1260 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1261 collection->addAction("delete_space", removeSpace);
1262 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1264 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1265 collection->addAction("insert_track", insertTrack);
1266 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1268 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1269 collection->addAction("delete_track", deleteTrack);
1270 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1272 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
1273 collection->addAction("config_tracks", configTracks);
1274 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1276 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1277 collection->addAction("add_guide", addGuide);
1278 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1280 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1281 collection->addAction("delete_guide", delGuide);
1282 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1284 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1285 collection->addAction("edit_guide", editGuide);
1286 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1288 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1289 collection->addAction("delete_all_guides", delAllGuides);
1290 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1292 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1293 collection->addAction("paste_effects", pasteEffects);
1294 pasteEffects->setData("paste_effects");
1295 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1297 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1298 collection->addAction("show_timeline", showTimeline);
1299 showTimeline->setCheckable(true);
1300 showTimeline->setChecked(true);
1301 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1303 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1304 collection->addAction("show_titlebars", showTitleBar);
1305 showTitleBar->setCheckable(true);
1306 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1307 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1308 slotShowTitleBars(KdenliveSettings::showtitlebars());
1310 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1311 collection->addAction("maximize_current", maxCurrent);
1312 maxCurrent->setCheckable(true);
1313 maxCurrent->setChecked(false);
1314 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1316 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1317 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1318 KStandardAction::open(this, SLOT(openFile()), collection);
1319 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1320 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1321 KStandardAction::openNew(this, SLOT(newFile()), collection);
1322 // TODO: make the following connection to slotEditKeys work
1323 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1324 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1325 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1326 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1327 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1328 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1330 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1331 undo->setEnabled(false);
1332 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1334 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1335 redo->setEnabled(false);
1336 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1339 //TODO: Add status tooltip to actions ?
1340 connect(collection, SIGNAL(actionHovered(QAction*)),
1341 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1344 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1345 collection->addAction("add_clip", addClip);
1346 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1348 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1349 collection->addAction("add_color_clip", addColorClip);
1350 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1352 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1353 collection->addAction("add_slide_clip", addSlideClip);
1354 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1356 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1357 collection->addAction("add_text_clip", addTitleClip);
1358 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1360 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1361 collection->addAction("add_text_template_clip", addTitleTemplateClip);
1362 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1364 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1365 collection->addAction("add_folder", addFolderButton);
1366 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1368 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1369 collection->addAction("clip_properties", clipProperties);
1370 clipProperties->setData("clip_properties");
1371 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1372 clipProperties->setEnabled(false);
1374 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1375 collection->addAction("edit_clip", openClip);
1376 openClip->setData("edit_clip");
1377 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1378 openClip->setEnabled(false);
1380 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1381 collection->addAction("delete_clip", deleteClip);
1382 deleteClip->setData("delete_clip");
1383 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1384 deleteClip->setEnabled(false);
1386 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1387 collection->addAction("reload_clip", reloadClip);
1388 reloadClip->setData("reload_clip");
1389 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1390 reloadClip->setEnabled(false);
1392 QMenu *addClips = new QMenu();
1393 addClips->addAction(addClip);
1394 addClips->addAction(addColorClip);
1395 addClips->addAction(addSlideClip);
1396 addClips->addAction(addTitleClip);
1397 addClips->addAction(addTitleTemplateClip);
1398 addClips->addAction(addFolderButton);
1400 addClips->addAction(reloadClip);
1401 addClips->addAction(clipProperties);
1402 addClips->addAction(openClip);
1403 addClips->addAction(deleteClip);
1404 m_projectList->setupMenu(addClips, addClip);
1406 // Setup effects and transitions actions.
1407 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1408 //KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), m_effectsActionCollection);
1409 KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), collection);
1410 m_videoEffects = new KAction*[videoEffects.count()];
1411 for (int i = 0; i < videoEffects.count(); ++i) {
1412 QStringList effectInfo = videoEffects.effectIdInfo(i);
1413 m_videoEffects[i] = new KAction(KIcon("kdenlive-show-video"), effectInfo.at(0), this);
1414 m_videoEffects[i]->setData(effectInfo);
1415 m_videoEffects[i]->setIconVisibleInMenu(false);
1416 videoEffectActions->addAction("video_effect_" + effectInfo.at(0), m_videoEffects[i]);
1418 //KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), m_effectsActionCollection);
1419 KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), collection);
1420 m_audioEffects = new KAction*[audioEffects.count()];
1421 for (int i = 0; i < audioEffects.count(); ++i) {
1422 QStringList effectInfo = audioEffects.effectIdInfo(i);
1423 m_audioEffects[i] = new KAction(KIcon("kdenlive-show-audio"), effectInfo.at(0), this);
1424 m_audioEffects[i]->setData(effectInfo);
1425 m_audioEffects[i]->setIconVisibleInMenu(false);
1426 audioEffectActions->addAction("audio_effect_" + effectInfo.at(0), m_audioEffects[i]);
1428 //KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), m_effectsActionCollection);
1429 KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), collection);
1430 m_customEffects = new KAction*[customEffects.count()];
1431 for (int i = 0; i < customEffects.count(); ++i) {
1432 QStringList effectInfo = customEffects.effectIdInfo(i);
1433 m_customEffects[i] = new KAction(KIcon("kdenlive-custom-effect"), effectInfo.at(0), this);
1434 m_customEffects[i]->setData(effectInfo);
1435 m_customEffects[i]->setIconVisibleInMenu(false);
1436 customEffectActions->addAction("custom_effect_" + effectInfo.at(0), m_customEffects[i]);
1438 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1439 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1440 m_transitions = new KAction*[transitions.count()];
1441 for (int i = 0; i < transitions.count(); i++) {
1442 QStringList effectInfo = transitions.effectIdInfo(i);
1443 m_transitions[i] = new KAction(effectInfo.at(0), this);
1444 m_transitions[i]->setData(effectInfo);
1445 m_transitions[i]->setIconVisibleInMenu(false);
1446 transitionActions->addAction("transition_" + effectInfo.at(0), m_transitions[i]);
1448 m_effectsActionCollection->readSettings();
1450 //connect(collection, SIGNAL( clearStatusText() ),
1451 //statusBar(), SLOT( clear() ) );
1454 void MainWindow::slotDisplayActionMessage(QAction *a)
1456 statusBar()->showMessage(a->data().toString(), 3000);
1459 void MainWindow::saveOptions()
1461 KdenliveSettings::self()->writeConfig();
1462 KSharedConfigPtr config = KGlobal::config();
1463 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1464 KConfigGroup treecolumns(config, "Project Tree");
1465 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1469 void MainWindow::readOptions()
1471 KSharedConfigPtr config = KGlobal::config();
1472 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1473 KConfigGroup initialGroup(config, "version");
1474 bool upgrade = false;
1475 if (initialGroup.exists()) {
1476 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1480 if (initialGroup.readEntry("version") == "0.7") {
1481 //Add new settings from 0.7.1
1482 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1483 QString path = QDir::homePath() + "/kdenlive";
1484 if (KStandardDirs::makeDir(path) == false) {
1485 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1486 } else KdenliveSettings::setDefaultprojectfolder(path);
1492 if (!initialGroup.exists() || upgrade) {
1493 // this is our first run, show Wizard
1494 Wizard *w = new Wizard(upgrade, this);
1495 if (w->exec() == QDialog::Accepted && w->isOk()) {
1496 w->adjustSettings();
1497 initialGroup.writeEntry("version", version);
1503 KConfigGroup treecolumns(config, "Project Tree");
1504 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1505 if (!state.isEmpty())
1506 m_projectList->setHeaderInfo(state);
1509 void MainWindow::slotRunWizard()
1511 Wizard *w = new Wizard(false, this);
1512 if (w->exec() == QDialog::Accepted && w->isOk()) {
1513 w->adjustSettings();
1518 void MainWindow::newFile(bool showProjectSettings, bool force)
1520 if (!m_timelineArea->isEnabled() && !force) return;
1521 m_fileRevert->setEnabled(false);
1522 QString profileName;
1524 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1525 if (!showProjectSettings) {
1526 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1527 profileName = KdenliveSettings::default_profile();
1528 projectFolder = KdenliveSettings::defaultprojectfolder();
1530 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1531 if (w->exec() != QDialog::Accepted) return;
1532 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1533 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
1534 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
1535 profileName = w->selectedProfile();
1536 projectFolder = w->selectedFolder();
1537 projectTracks = w->tracks();
1540 m_timelineArea->setEnabled(true);
1541 m_projectList->setEnabled(true);
1542 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1543 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1545 TrackView *trackView = new TrackView(doc, &ok, this);
1546 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1549 //m_timelineArea->setEnabled(false);
1550 //m_projectList->setEnabled(false);
1554 if (m_timelineArea->count() == 1) {
1555 connectDocumentInfo(doc);
1556 connectDocument(trackView, doc);
1557 } else m_timelineArea->setTabBarHidden(false);
1558 m_monitorManager->activateMonitor("clip");
1559 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1562 void MainWindow::activateDocument()
1564 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1565 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1566 KdenliveDoc *currentDoc = currentTab->document();
1567 connectDocumentInfo(currentDoc);
1568 connectDocument(currentTab, currentDoc);
1571 void MainWindow::closeCurrentDocument(bool saveChanges)
1573 QWidget *w = m_timelineArea->currentWidget();
1575 // closing current document
1576 int ix = m_timelineArea->currentIndex() + 1;
1577 if (ix == m_timelineArea->count()) ix = 0;
1578 m_timelineArea->setCurrentIndex(ix);
1579 TrackView *tabToClose = (TrackView *) w;
1580 KdenliveDoc *docToClose = tabToClose->document();
1581 if (docToClose && docToClose->isModified() && saveChanges) {
1583 if (m_activeDocument->url().fileName().isEmpty())
1584 message = i18n("Save changes to document?");
1586 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1587 switch (KMessageBox::warningYesNoCancel(this, message)) {
1588 case KMessageBox::Yes :
1589 // save document here. If saving fails, return false;
1590 if (saveFile() == false) return;
1592 case KMessageBox::Cancel :
1599 m_clipMonitor->slotSetXml(NULL);
1600 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1601 if (m_timelineArea->count() == 1) {
1602 m_timelineArea->setTabBarHidden(true);
1603 m_closeAction->setEnabled(false);
1605 if (docToClose == m_activeDocument) {
1606 delete m_activeDocument;
1607 m_activeDocument = NULL;
1608 m_effectStack->clear();
1609 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1613 if (w == m_activeTimeline) {
1614 delete m_activeTimeline;
1615 m_activeTimeline = NULL;
1621 bool MainWindow::saveFileAs(const QString &outputFileName)
1623 QString currentSceneList;
1624 m_monitorManager->stopActiveMonitor();
1625 if (KdenliveSettings::dropbframes()) {
1626 KdenliveSettings::setDropbframes(false);
1627 m_activeDocument->clipManager()->updatePreviewSettings();
1628 currentSceneList = m_projectMonitor->sceneList();
1629 KdenliveSettings::setDropbframes(true);
1630 m_activeDocument->clipManager()->updatePreviewSettings();
1631 } else currentSceneList = m_projectMonitor->sceneList();
1633 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1636 // Save timeline thumbnails
1637 m_activeTimeline->projectView()->saveThumbnails();
1638 m_activeDocument->setUrl(KUrl(outputFileName));
1639 if (m_activeDocument->m_autosave == NULL) {
1640 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1641 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1642 setCaption(m_activeDocument->description());
1643 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1644 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1645 m_activeDocument->setModified(false);
1646 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1647 m_fileRevert->setEnabled(true);
1651 bool MainWindow::saveFileAs()
1653 QString outputFile = KFileDialog::getSaveFileName(KUrl(), getMimeType());
1654 if (outputFile.isEmpty()) return false;
1655 if (QFile::exists(outputFile)) {
1656 // Show the file dialog again if the user does not want to overwrite the file
1657 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it?")) == KMessageBox::No)
1658 return saveFileAs();
1660 return saveFileAs(outputFile);
1663 bool MainWindow::saveFile()
1665 if (!m_activeDocument) return true;
1666 if (m_activeDocument->url().isEmpty()) {
1667 return saveFileAs();
1669 bool result = saveFileAs(m_activeDocument->url().path());
1670 m_activeDocument->m_autosave->resize(0);
1675 void MainWindow::openFile()
1677 if (!m_startUrl.isEmpty()) {
1678 openFile(m_startUrl);
1679 m_startUrl = KUrl();
1682 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
1683 if (url.isEmpty()) return;
1684 m_fileOpenRecent->addUrl(url);
1688 void MainWindow::openLastFile()
1690 KSharedConfigPtr config = KGlobal::config();
1691 KUrl::List urls = m_fileOpenRecent->urls();
1692 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1693 if (urls.isEmpty()) newFile(false);
1694 else openFile(urls.last());
1697 void MainWindow::openFile(const KUrl &url)
1699 // Check if the document is already opened
1700 const int ct = m_timelineArea->count();
1701 bool isOpened = false;
1703 for (i = 0; i < ct; i++) {
1704 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1705 KdenliveDoc *doc = tab->document();
1706 if (doc->url() == url) {
1712 m_timelineArea->setCurrentIndex(i);
1716 // Check for backup file
1717 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1718 if (!staleFiles.isEmpty()) {
1719 if (KMessageBox::questionYesNo(this,
1720 i18n("Auto-saved files exist. Do you want to recover them now?"),
1721 i18n("File Recovery"),
1722 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1723 recoverFiles(staleFiles);
1726 // remove the stale files
1727 foreach(KAutoSaveFile *stale, staleFiles) {
1728 stale->open(QIODevice::ReadWrite);
1733 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1734 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
1735 m_messageLabel->repaint();
1736 doOpenFile(url, NULL);
1739 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1741 if (!m_timelineArea->isEnabled()) return;
1742 m_fileRevert->setEnabled(true);
1743 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, this);
1744 if (stale == NULL) {
1745 stale = new KAutoSaveFile(url, doc);
1746 doc->m_autosave = stale;
1748 doc->m_autosave = stale;
1749 doc->setUrl(stale->managedFile());
1750 doc->setModified(true);
1751 stale->setParent(doc);
1753 connectDocumentInfo(doc);
1755 TrackView *trackView = new TrackView(doc, &ok, this);
1756 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1758 m_timelineArea->setEnabled(false);
1759 m_projectList->setEnabled(false);
1760 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
1761 slotGotProgressInfo(QString(), -1);
1762 newFile(false, true);
1765 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1766 trackView->setDuration(trackView->duration());
1767 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1769 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1770 slotGotProgressInfo(QString(), -1);
1771 m_projectMonitor->adjustRulerSize(trackView->duration());
1772 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1773 m_clipMonitor->refreshMonitor(true);
1776 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1778 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1779 foreach(KAutoSaveFile *stale, staleFiles) {
1780 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1781 // show an error message; we could not steal the lockfile
1782 // maybe another application got to the file before us?
1786 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1787 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
1788 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1789 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1793 void MainWindow::parseProfiles(const QString &mltPath)
1795 //KdenliveSettings::setDefaulttmpfolder();
1796 if (!mltPath.isEmpty()) {
1797 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1798 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
1801 if (KdenliveSettings::mltpath().isEmpty())
1802 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1804 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
1805 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
1806 if (!QFile::exists(meltPath))
1807 meltPath = KStandardDirs::findExe("melt");
1808 KdenliveSettings::setRendererpath(meltPath);
1811 if (KdenliveSettings::rendererpath().isEmpty()) {
1812 // Cannot find the MLT melt renderer, ask for location
1813 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
1814 if (getUrl->exec() == QDialog::Rejected) {
1817 KUrl rendererPath = getUrl->selectedUrl();
1819 if (rendererPath.isEmpty()) ::exit(0);
1820 KdenliveSettings::setRendererpath(rendererPath.path());
1823 QStringList profilesFilter;
1824 profilesFilter << "*";
1825 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1826 if (profilesList.isEmpty()) {
1827 // Cannot find MLT path, try finding melt
1828 QString profilePath = KdenliveSettings::rendererpath();
1829 if (!profilePath.isEmpty()) {
1830 profilePath = profilePath.section('/', 0, -3);
1831 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1832 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1834 if (profilesList.isEmpty()) {
1835 // Cannot find the MLT profiles, ask for location
1836 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
1837 getUrl->fileDialog()->setMode(KFile::Directory);
1838 if (getUrl->exec() == QDialog::Rejected) {
1841 KUrl mltPath = getUrl->selectedUrl();
1843 if (mltPath.isEmpty()) ::exit(0);
1844 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
1845 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1849 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1851 // Parse again MLT profiles to build a list of available video formats
1852 if (profilesList.isEmpty()) parseProfiles();
1856 void MainWindow::slotEditProfiles()
1858 ProfilesDialog *w = new ProfilesDialog;
1859 if (w->exec() == QDialog::Accepted) {
1860 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1861 if (d) d->checkProfile();
1866 void MainWindow::slotDetectAudioDriver()
1868 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
1869 leading to no audio output, see bug #934 */
1871 //decide which audio driver is really best, in some cases SDL is wrong
1872 if (KdenliveSettings::audiodrivername().isEmpty()) {
1874 KProcess readProcess;
1875 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
1876 if (!KStandardDirs::findExe("pactl").isEmpty()) {
1877 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
1878 readProcess.setProgram("pactl", QStringList() << "stat");
1879 readProcess.execute(2000); // Kill it after 2 seconds
1881 QString result = QString(readProcess.readAllStandardOutput());
1882 kDebug() << "// / / / / / READING PACTL: ";
1884 if (!result.isEmpty()) {
1886 kDebug() << "// / / / / PULSEAUDIO DETECTED";
1890 KdenliveSettings::setAutoaudiodrivername(driver);
1894 void MainWindow::slotEditProjectSettings()
1896 QPoint p = m_activeDocument->getTracksCount();
1897 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
1899 if (w->exec() == QDialog::Accepted) {
1900 QString profile = w->selectedProfile();
1901 m_activeDocument->setProjectFolder(w->selectedFolder());
1902 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path(KUrl::AddTrailingSlash));
1903 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
1904 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
1905 if (m_activeDocument->profilePath() != profile) {
1906 // Profile was changed
1907 double dar = m_activeDocument->dar();
1909 // Deselect current effect / transition
1910 m_effectStack->slotClipItemSelected(NULL, 0);
1911 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1912 m_clipMonitor->slotSetXml(NULL);
1913 bool updateFps = m_activeDocument->setProfilePath(profile);
1914 KdenliveSettings::setCurrent_profile(profile);
1915 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1916 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1918 m_activeDocument->clipManager()->clearUnusedProducers();
1919 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1921 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
1922 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
1923 m_projectList->updateProjectFormat(m_activeDocument->timecode());
1924 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1925 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1926 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1927 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
1928 if (updateFps) m_activeTimeline->updateProjectFps();
1929 m_activeDocument->setModified(true);
1930 m_commandStack->activeStack()->clear();
1931 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
1932 slotUpdateMousePosition(0);
1933 // We need to desactivate & reactivate monitors to get a refresh
1934 //m_monitorManager->switchMonitors();
1941 void MainWindow::slotRenderProject()
1943 if (!m_renderWidget) {
1944 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
1945 m_renderWidget = new RenderWidget(projectfolder, this);
1946 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
1947 connect(m_renderWidget, SIGNAL(selectedRenderProfile(const QString &, const QString &, const QString &, const QString&)), this, SLOT(slotSetDocumentRenderProfile(const QString &, const QString &, const QString &, const QString&)));
1948 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
1949 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1950 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1951 if (m_activeDocument) {
1952 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1953 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1954 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
1955 m_renderWidget->setRenderProfile(m_activeDocument->getDocumentProperty("renderdestination"), m_activeDocument->getDocumentProperty("rendercategory"), m_activeDocument->getDocumentProperty("renderprofile"), m_activeDocument->getDocumentProperty("renderurl"));
1958 slotCheckRenderStatus();
1959 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1960 if (currentTab) m_renderWidget->setTimeline(currentTab);
1961 m_renderWidget->setDocument(m_activeDocument);*/
1962 m_renderWidget->show();
1963 m_renderWidget->showNormal();
1965 m_activeTimeline->tracksNumber();
1966 m_renderWidget->enableAudio(false);
1967 //m_renderWidget->export_audio;
1970 void MainWindow::slotCheckRenderStatus()
1972 // Make sure there are no missing clips
1974 m_renderWidget->missingClips(m_projectList->hasMissingClips());
1977 void MainWindow::setRenderingProgress(const QString &url, int progress)
1980 m_renderWidget->setRenderJob(url, progress);
1983 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
1986 m_renderWidget->setRenderStatus(url, status, error);
1989 void MainWindow::slotCleanProject()
1991 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
1992 m_projectList->cleanup();
1995 void MainWindow::slotUpdateMousePosition(int pos)
1997 if (m_activeDocument)
1998 switch (m_timecodeFormat->currentIndex()) {
2000 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2003 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2007 void MainWindow::slotUpdateDocumentState(bool modified)
2009 if (!m_activeDocument) return;
2010 setCaption(m_activeDocument->description(), modified);
2011 m_saveAction->setEnabled(modified);
2013 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2014 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2016 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2017 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2021 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2023 if (m_activeDocument) {
2024 if (m_activeDocument == doc) return;
2025 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2027 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2030 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2032 //m_projectMonitor->stop();
2033 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2034 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2035 if (m_activeDocument) {
2036 if (m_activeDocument == doc) return;
2037 if (m_activeTimeline) {
2038 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2039 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2040 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2041 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2042 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
2044 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2045 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2046 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2047 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
2048 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2049 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2050 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
2051 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2052 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2053 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2054 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2055 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2056 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2057 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2058 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2059 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2060 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2061 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2062 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2063 disconnect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
2064 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
2065 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
2066 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
2067 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2068 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2069 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2070 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2071 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2072 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2073 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2074 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2075 disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2076 disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2077 m_effectStack->clear();
2079 //m_activeDocument->setRenderer(NULL);
2080 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
2081 disconnect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2082 m_clipMonitor->stop();
2084 KdenliveSettings::setCurrent_profile(doc->profilePath());
2085 KdenliveSettings::setProject_fps(doc->fps());
2086 m_monitorManager->resetProfiles(doc->timecode());
2087 m_projectList->setDocument(doc);
2088 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2089 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2090 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint)));
2091 connect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2092 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), trackView->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2094 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2095 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2097 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
2100 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2101 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2102 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2103 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2104 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2105 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2106 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2107 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2108 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
2109 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2110 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
2112 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2113 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2114 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
2115 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2116 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2118 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
2119 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2120 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2123 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2124 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2126 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2127 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2128 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2129 m_zoomSlider->setValue(doc->zoom().x());
2130 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2131 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2132 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2133 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2135 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2136 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2139 connect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
2140 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2141 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
2142 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
2143 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
2144 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2145 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2146 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2147 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2148 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2150 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2151 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2152 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2153 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2154 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2157 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2158 m_activeTimeline = trackView;
2159 if (m_renderWidget) {
2160 slotCheckRenderStatus();
2161 m_renderWidget->setProfile(doc->mltProfile());
2162 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2163 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2164 m_renderWidget->setRenderProfile(doc->getDocumentProperty("renderdestination"), doc->getDocumentProperty("rendercategory"), doc->getDocumentProperty("renderprofile"), doc->getDocumentProperty("renderurl"));
2166 //doc->setRenderer(m_projectMonitor->render);
2167 m_commandStack->setActiveStack(doc->commandStack());
2168 KdenliveSettings::setProject_display_ratio(doc->dar());
2169 //doc->clipManager()->checkAudioThumbs();
2171 //m_overView->setScene(trackView->projectScene());
2172 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2173 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2175 setCaption(doc->description(), doc->isModified());
2176 m_saveAction->setEnabled(doc->isModified());
2177 m_normalEditTool->setChecked(true);
2178 m_activeDocument = doc;
2179 m_activeTimeline->updateProjectFps();
2180 m_activeDocument->checkProjectClips();
2181 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
2182 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2183 slotUpdateMousePosition(0);
2184 // set tool to select tool
2185 m_buttonSelectTool->setChecked(true);
2188 void MainWindow::slotZoneMoved(int start, int end)
2190 m_activeDocument->setZone(start, end);
2191 m_projectMonitor->slotZoneMoved(start, end);
2194 void MainWindow::slotGuidesUpdated()
2197 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2200 void MainWindow::slotEditKeys()
2202 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2203 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2204 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2208 void MainWindow::slotPreferences(int page, int option)
2210 //An instance of your dialog could be already created and could be
2211 // cached, in which case you want to display the cached dialog
2212 // instead of creating another one
2213 if (KConfigDialog::showDialog("settings")) {
2214 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2215 if (page != -1) d->showPage(page, option);
2219 // KConfigDialog didn't find an instance of this dialog, so lets
2221 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
2222 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2223 //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
2224 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2225 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2227 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
2229 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2231 if (page != -1) dialog->showPage(page, option);
2234 void MainWindow::slotUpdatePreviewSettings()
2236 if (m_activeDocument) {
2237 m_clipMonitor->slotSetXml(NULL);
2238 m_activeDocument->updatePreviewSettings();
2242 void MainWindow::updateConfiguration()
2244 //TODO: we should apply settings to all projects, not only the current one
2245 if (m_activeTimeline) {
2246 m_activeTimeline->refresh();
2247 m_activeTimeline->projectView()->checkAutoScroll();
2248 m_activeTimeline->projectView()->checkTrackHeight();
2249 if (m_activeDocument)
2250 m_activeDocument->clipManager()->checkAudioThumbs();
2252 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2253 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2254 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2256 // Update list of transcoding profiles
2258 #ifndef NO_JOGSHUTTLE
2259 activateShuttleDevice();
2260 #endif /* NO_JOGSHUTTLE */
2264 void MainWindow::slotSwitchSplitAudio()
2266 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2267 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2270 void MainWindow::slotSwitchVideoThumbs()
2272 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2273 if (m_activeTimeline)
2274 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2275 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2278 void MainWindow::slotSwitchAudioThumbs()
2280 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2281 if (m_activeTimeline) {
2282 m_activeTimeline->refresh();
2283 m_activeTimeline->projectView()->checkAutoScroll();
2284 if (m_activeDocument)
2285 m_activeDocument->clipManager()->checkAudioThumbs();
2287 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2290 void MainWindow::slotSwitchMarkersComments()
2292 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2293 if (m_activeTimeline)
2294 m_activeTimeline->refresh();
2295 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2298 void MainWindow::slotSwitchSnap()
2300 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2301 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2305 void MainWindow::slotDeleteItem()
2307 if (QApplication::focusWidget() &&
2308 QApplication::focusWidget()->parentWidget() &&
2309 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2310 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2311 m_projectList->slotRemoveClip();
2314 QWidget *widget = QApplication::focusWidget();
2316 if (widget == m_effectStackDock) {
2317 m_effectStack->slotItemDel();
2320 widget = widget->parentWidget();
2323 // effect stack has no focus
2324 if (m_activeTimeline)
2325 m_activeTimeline->projectView()->deleteSelectedClips();
2329 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2331 if (m_clipMonitor->isActive())
2332 m_clipMonitor->checkOverlay();
2333 m_clipMonitor->updateMarkers(clip);
2336 void MainWindow::slotAddClipMarker()
2338 DocClipBase *clip = NULL;
2340 if (m_projectMonitor->isActive()) {
2341 if (m_activeTimeline) {
2342 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2344 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2345 clip = item->baseClip();
2349 clip = m_clipMonitor->activeClip();
2350 pos = m_clipMonitor->position();
2353 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2356 QString id = clip->getId();
2357 CommentedTime marker(pos, i18n("Marker"));
2358 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2359 if (d.exec() == QDialog::Accepted)
2360 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2363 void MainWindow::slotDeleteClipMarker()
2365 DocClipBase *clip = NULL;
2367 if (m_projectMonitor->isActive()) {
2368 if (m_activeTimeline) {
2369 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2371 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2372 clip = item->baseClip();
2376 clip = m_clipMonitor->activeClip();
2377 pos = m_clipMonitor->position();
2380 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2384 QString id = clip->getId();
2385 QString comment = clip->markerComment(pos);
2386 if (comment.isEmpty()) {
2387 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2390 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2393 void MainWindow::slotDeleteAllClipMarkers()
2395 DocClipBase *clip = NULL;
2396 if (m_projectMonitor->isActive()) {
2397 if (m_activeTimeline) {
2398 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2400 clip = item->baseClip();
2404 clip = m_clipMonitor->activeClip();
2407 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2410 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2413 void MainWindow::slotEditClipMarker()
2415 DocClipBase *clip = NULL;
2417 if (m_projectMonitor->isActive()) {
2418 if (m_activeTimeline) {
2419 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2421 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2422 clip = item->baseClip();
2426 clip = m_clipMonitor->activeClip();
2427 pos = m_clipMonitor->position();
2430 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2434 QString id = clip->getId();
2435 QString oldcomment = clip->markerComment(pos);
2436 if (oldcomment.isEmpty()) {
2437 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2441 CommentedTime marker(pos, oldcomment);
2442 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2443 if (d.exec() == QDialog::Accepted) {
2444 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2445 if (d.newMarker().time() != pos) {
2446 // remove old marker
2447 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2452 void MainWindow::slotAddGuide()
2454 if (m_activeTimeline)
2455 m_activeTimeline->projectView()->slotAddGuide();
2458 void MainWindow::slotInsertSpace()
2460 if (m_activeTimeline)
2461 m_activeTimeline->projectView()->slotInsertSpace();
2464 void MainWindow::slotRemoveSpace()
2466 if (m_activeTimeline)
2467 m_activeTimeline->projectView()->slotRemoveSpace();
2470 void MainWindow::slotInsertTrack(int ix)
2472 m_projectMonitor->activateMonitor();
2473 if (m_activeTimeline)
2474 m_activeTimeline->projectView()->slotInsertTrack(ix);
2475 if (m_activeDocument)
2476 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2479 void MainWindow::slotDeleteTrack(int ix)
2481 m_projectMonitor->activateMonitor();
2482 if (m_activeTimeline)
2483 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2484 if (m_activeDocument)
2485 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2488 void MainWindow::slotConfigTrack(int ix)
2490 m_projectMonitor->activateMonitor();
2491 if (m_activeTimeline)
2492 m_activeTimeline->projectView()->slotConfigTracks(ix);
2493 if (m_activeDocument)
2494 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2497 void MainWindow::slotEditGuide()
2499 if (m_activeTimeline)
2500 m_activeTimeline->projectView()->slotEditGuide();
2503 void MainWindow::slotDeleteGuide()
2505 if (m_activeTimeline)
2506 m_activeTimeline->projectView()->slotDeleteGuide();
2509 void MainWindow::slotDeleteAllGuides()
2511 if (m_activeTimeline)
2512 m_activeTimeline->projectView()->slotDeleteAllGuides();
2515 void MainWindow::slotCutTimelineClip()
2517 if (m_activeTimeline)
2518 m_activeTimeline->projectView()->cutSelectedClips();
2521 void MainWindow::slotInsertClipOverwrite()
2523 if (m_activeTimeline) {
2524 QStringList data = m_clipMonitor->getZoneInfo();
2525 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2529 void MainWindow::slotSelectTimelineClip()
2531 if (m_activeTimeline)
2532 m_activeTimeline->projectView()->selectClip(true);
2535 void MainWindow::slotSelectTimelineTransition()
2537 if (m_activeTimeline)
2538 m_activeTimeline->projectView()->selectTransition(true);
2541 void MainWindow::slotDeselectTimelineClip()
2543 if (m_activeTimeline)
2544 m_activeTimeline->projectView()->selectClip(false, true);
2547 void MainWindow::slotDeselectTimelineTransition()
2549 if (m_activeTimeline)
2550 m_activeTimeline->projectView()->selectTransition(false, true);
2553 void MainWindow::slotSelectAddTimelineClip()
2555 if (m_activeTimeline)
2556 m_activeTimeline->projectView()->selectClip(true, true);
2559 void MainWindow::slotSelectAddTimelineTransition()
2561 if (m_activeTimeline)
2562 m_activeTimeline->projectView()->selectTransition(true, true);
2565 void MainWindow::slotGroupClips()
2567 if (m_activeTimeline)
2568 m_activeTimeline->projectView()->groupClips();
2571 void MainWindow::slotUnGroupClips()
2573 if (m_activeTimeline)
2574 m_activeTimeline->projectView()->groupClips(false);
2577 void MainWindow::slotEditItemDuration()
2579 if (m_activeTimeline)
2580 m_activeTimeline->projectView()->editItemDuration();
2583 void MainWindow::slotAddProjectClip(KUrl url)
2585 if (m_activeDocument)
2586 m_activeDocument->slotAddClipFile(url, QString());
2589 void MainWindow::slotAddTransition(QAction *result)
2591 if (!result) return;
2592 QStringList info = result->data().toStringList();
2593 if (info.isEmpty()) return;
2594 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2595 if (m_activeTimeline && !transition.isNull()) {
2596 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2600 void MainWindow::slotAddVideoEffect(QAction *result)
2602 if (!result) return;
2603 QStringList info = result->data().toStringList();
2604 if (info.isEmpty()) return;
2605 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2606 slotAddEffect(effect);
2609 void MainWindow::slotAddAudioEffect(QAction *result)
2611 if (!result) return;
2612 QStringList info = result->data().toStringList();
2613 if (info.isEmpty()) return;
2614 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2615 slotAddEffect(effect);
2618 void MainWindow::slotAddCustomEffect(QAction *result)
2620 if (!result) return;
2621 QStringList info = result->data().toStringList();
2622 if (info.isEmpty()) return;
2623 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2624 slotAddEffect(effect);
2627 void MainWindow::slotZoomIn()
2629 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2630 slotShowZoomSliderToolTip();
2633 void MainWindow::slotZoomOut()
2635 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2636 slotShowZoomSliderToolTip();
2639 void MainWindow::slotFitZoom()
2641 if (m_activeTimeline)
2642 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2645 void MainWindow::slotSetZoom(int value)
2647 if (m_activeTimeline)
2648 m_activeTimeline->slotChangeZoom(value);
2650 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
2651 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
2652 slotUpdateZoomSliderToolTip(value);
2654 m_zoomSlider->blockSignals(true);
2655 m_zoomSlider->setValue(value);
2656 m_zoomSlider->blockSignals(false);
2659 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
2661 if (zoomlevel != -1)
2662 slotUpdateZoomSliderToolTip(zoomlevel);
2664 QPoint global = m_zoomSlider->rect().topLeft();
2665 global.ry() += m_zoomSlider->height() / 2;
2666 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
2667 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
2670 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
2672 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
2675 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2677 m_statusProgressBar->setValue(progress);
2678 if (progress >= 0) {
2679 if (!message.isEmpty())
2680 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2681 m_statusProgressBar->setVisible(true);
2682 } else if (progress == -2) {
2683 if (!message.isEmpty())
2684 m_messageLabel->setMessage(message, ErrorMessage);
2685 m_statusProgressBar->setVisible(false);
2687 m_messageLabel->setMessage(QString(), DefaultMessage);
2688 m_statusProgressBar->setVisible(false);
2692 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2694 if (clip->clipType() == TEXT) {
2695 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
2696 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
2697 // template text clip
2699 // Get the list of existing templates
2701 filter << "*.kdenlivetitle";
2702 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
2704 QDialog *dia = new QDialog(this);
2705 Ui::TemplateClip_UI dia_ui;
2706 dia_ui.setupUi(dia);
2708 const QString templatePath = clip->getProperty("resource");
2709 for (int i = 0; i < templateFiles.size(); ++i) {
2710 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
2711 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
2713 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
2714 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
2715 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
2716 //warning: setting base directory doesn't work??
2717 KUrl startDir(titlepath);
2718 dia_ui.template_list->fileDialog()->setUrl(startDir);
2719 dia_ui.description->setText(clip->getProperty("description"));
2720 if (dia->exec() == QDialog::Accepted) {
2721 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
2722 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
2724 QMap <QString, QString> newprops;
2726 if (KUrl(textTemplate).path() != templatePath) {
2727 // The template was changed
2728 newprops.insert("resource", textTemplate);
2731 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
2732 newprops.insert("description", dia_ui.description->toPlainText());
2735 QString newtemplate = newprops.value("xmltemplate");
2736 if (newtemplate.isEmpty()) newtemplate = templatePath;
2738 // template modified we need to update xmldata
2739 QString description = newprops.value("description");
2740 if (description.isEmpty()) description = clip->getProperty("description");
2741 else newprops.insert("templatetext", description);
2742 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
2743 if (!newprops.isEmpty()) {
2744 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2745 m_activeDocument->commandStack()->push(command);
2751 QString path = clip->getProperty("resource");
2752 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
2754 doc.setContent(clip->getProperty("xmldata"));
2755 dia_ui->setXml(doc);
2756 if (dia_ui->exec() == QDialog::Accepted) {
2757 QMap <QString, QString> newprops;
2758 newprops.insert("xmldata", dia_ui->xml().toString());
2759 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
2760 // duration changed, we need to update duration
2761 newprops.insert("out", QString::number(dia_ui->outPoint()));
2763 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2764 m_activeDocument->commandStack()->push(command);
2765 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
2766 m_activeDocument->setModified(true);
2770 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2773 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2774 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2775 if (dia.exec() == QDialog::Accepted) {
2776 QMap <QString, QString> newprops = dia.properties();
2777 if (newprops.isEmpty()) return;
2778 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2779 m_activeDocument->commandStack()->push(command);
2781 if (dia.needsTimelineRefresh()) {
2782 // update clip occurences in timeline
2783 m_activeTimeline->projectView()->slotUpdateClip(clip->getId(), dia.needsTimelineReload());
2789 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
2791 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
2792 if (dia.exec() == QDialog::Accepted) {
2793 QUndoCommand *command = new QUndoCommand();
2794 command->setText(i18n("Edit clips"));
2795 for (int i = 0; i < cliplist.count(); i++) {
2796 DocClipBase *clip = cliplist.at(i);
2797 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true, command);
2799 m_activeDocument->commandStack()->push(command);
2800 for (int i = 0; i < cliplist.count(); i++)
2801 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
2805 void MainWindow::customEvent(QEvent* e)
2807 if (e->type() == QEvent::User)
2808 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
2810 void MainWindow::slotActivateEffectStackView()
2812 m_effectStack->raiseWindow(m_effectStackDock);
2815 void MainWindow::slotActivateTransitionView(Transition *t)
2818 m_transitionConfig->raiseWindow(m_transitionConfigDock);
2821 void MainWindow::slotSnapRewind()
2823 if (m_projectMonitor->isActive()) {
2824 if (m_activeTimeline)
2825 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2827 m_clipMonitor->slotSeekToPreviousSnap();
2831 void MainWindow::slotSnapForward()
2833 if (m_projectMonitor->isActive()) {
2834 if (m_activeTimeline)
2835 m_activeTimeline->projectView()->slotSeekToNextSnap();
2837 m_clipMonitor->slotSeekToNextSnap();
2841 void MainWindow::slotClipStart()
2843 if (m_projectMonitor->isActive()) {
2844 if (m_activeTimeline)
2845 m_activeTimeline->projectView()->clipStart();
2849 void MainWindow::slotClipEnd()
2851 if (m_projectMonitor->isActive()) {
2852 if (m_activeTimeline)
2853 m_activeTimeline->projectView()->clipEnd();
2857 void MainWindow::slotZoneStart()
2859 if (m_projectMonitor->isActive())
2860 m_projectMonitor->slotZoneStart();
2862 m_clipMonitor->slotZoneStart();
2865 void MainWindow::slotZoneEnd()
2867 if (m_projectMonitor->isActive())
2868 m_projectMonitor->slotZoneEnd();
2870 m_clipMonitor->slotZoneEnd();
2873 void MainWindow::slotChangeTool(QAction * action)
2875 if (action == m_buttonSelectTool)
2876 slotSetTool(SELECTTOOL);
2877 else if (action == m_buttonRazorTool)
2878 slotSetTool(RAZORTOOL);
2879 else if (action == m_buttonSpacerTool)
2880 slotSetTool(SPACERTOOL);
2883 void MainWindow::slotChangeEdit(QAction * action)
2885 if (!m_activeTimeline)
2888 if (action == m_overwriteEditTool)
2889 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
2890 else if (action == m_insertEditTool)
2891 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
2893 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
2896 void MainWindow::slotSetTool(PROJECTTOOL tool)
2898 if (m_activeDocument && m_activeTimeline) {
2899 //m_activeDocument->setTool(tool);
2903 message = i18n("Ctrl + click to use spacer on current track only");
2906 message = i18n("Click on a clip to cut it");
2909 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
2912 m_messageLabel->setMessage(message, InformationMessage);
2913 m_activeTimeline->projectView()->setTool(tool);
2917 void MainWindow::slotCopy()
2919 if (m_activeDocument && m_activeTimeline)
2920 m_activeTimeline->projectView()->copyClip();
2923 void MainWindow::slotPaste()
2925 if (m_activeDocument && m_activeTimeline)
2926 m_activeTimeline->projectView()->pasteClip();
2929 void MainWindow::slotPasteEffects()
2931 if (m_activeDocument && m_activeTimeline)
2932 m_activeTimeline->projectView()->pasteClipEffects();
2935 void MainWindow::slotFind()
2937 if (!m_activeDocument || !m_activeTimeline) return;
2938 m_projectSearch->setEnabled(false);
2939 m_findActivated = true;
2940 m_findString.clear();
2941 m_activeTimeline->projectView()->initSearchStrings();
2942 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2943 m_findTimer.start(5000);
2944 qApp->installEventFilter(this);
2947 void MainWindow::slotFindNext()
2949 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
2950 statusBar()->showMessage(i18n("Found: %1", m_findString));
2952 statusBar()->showMessage(i18n("Reached end of project"));
2953 m_findTimer.start(4000);
2956 void MainWindow::findAhead()
2958 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
2959 m_projectSearchNext->setEnabled(true);
2960 statusBar()->showMessage(i18n("Found: %1", m_findString));
2962 m_projectSearchNext->setEnabled(false);
2963 statusBar()->showMessage(i18n("Not found: %1", m_findString));
2967 void MainWindow::findTimeout()
2969 m_projectSearchNext->setEnabled(false);
2970 m_findActivated = false;
2971 m_findString.clear();
2972 statusBar()->showMessage(i18n("Find stopped"), 3000);
2973 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
2974 m_projectSearch->setEnabled(true);
2975 removeEventFilter(this);
2978 void MainWindow::slotClipInTimeline(const QString &clipId)
2980 if (m_activeTimeline && m_activeDocument) {
2981 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
2983 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
2984 inTimelineMenu->clear();
2986 QList <QAction *> actionList;
2988 for (int i = 0; i < matching.count(); ++i) {
2989 QString track = QString::number(matching.at(i).track);
2990 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
2992 QAction *a = new QAction(track + ": " + start, this);
2993 a->setData(QStringList() << track << start);
2994 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
2995 while (j < actionList.count()) {
2996 if (actionList.at(j)->text() > a->text()) break;
2999 actionList.insert(j, a);
3001 inTimelineMenu->addActions(actionList);
3003 if (matching.empty())
3004 inTimelineMenu->setEnabled(false);
3006 inTimelineMenu->setEnabled(true);
3010 void MainWindow::slotClipInProjectTree()
3012 if (m_activeTimeline) {
3013 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3014 if (clipIds.isEmpty())
3016 m_projectListDock->raise();
3017 for (int i = 0; i < clipIds.count(); i++)
3018 m_projectList->selectItemById(clipIds.at(i));
3019 if (m_projectMonitor->isActive())
3020 slotSwitchMonitors();
3024 /*void MainWindow::slotClipToProjectTree()
3026 if (m_activeTimeline) {
3027 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3028 if (clips.isEmpty()) return;
3029 for (int i = 0; i < clips.count(); i++) {
3030 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3032 //m_projectList->selectItemById(clipIds.at(i));
3036 void MainWindow::slotSelectClipInTimeline()
3038 if (m_activeTimeline) {
3039 QAction *action = qobject_cast<QAction *>(sender());
3040 QStringList data = action->data().toStringList();
3041 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3045 void MainWindow::keyPressEvent(QKeyEvent *ke)
3047 if (m_findActivated) {
3048 if (ke->key() == Qt::Key_Backspace) {
3049 m_findString = m_findString.left(m_findString.length() - 1);
3051 if (!m_findString.isEmpty())
3056 m_findTimer.start(4000);
3059 } else if (ke->key() == Qt::Key_Escape) {
3063 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3064 m_findString += ke->text();
3068 m_findTimer.start(4000);
3073 KXmlGuiWindow::keyPressEvent(ke);
3078 /** Gets called when the window gets hidden */
3079 void MainWindow::hideEvent(QHideEvent */*event*/)
3082 if (m_monitorManager)
3083 m_monitorManager->stopActiveMonitor();
3086 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3088 if (m_findActivated) {
3089 if (event->type() == QEvent::ShortcutOverride) {
3090 QKeyEvent* ke = (QKeyEvent*) event;
3091 if (ke->text().trimmed().isEmpty()) return false;
3098 // pass the event on to the parent class
3099 return QMainWindow::eventFilter(obj, event);
3104 void MainWindow::slotSaveZone(Render *render, QPoint zone)
3106 KDialog *dialog = new KDialog(this);
3107 dialog->setCaption("Save clip zone");
3108 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3110 QWidget *widget = new QWidget(dialog);
3111 dialog->setMainWidget(widget);
3113 QVBoxLayout *vbox = new QVBoxLayout(widget);
3114 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3115 QString path = m_activeDocument->projectFolder().path();
3117 path.append("untitled.mlt");
3118 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
3119 url->setFilter("video/mlt-playlist");
3120 QLabel *label2 = new QLabel(i18n("Description:"), this);
3121 KLineEdit *edit = new KLineEdit(this);
3122 vbox->addWidget(label1);
3123 vbox->addWidget(url);
3124 vbox->addWidget(label2);
3125 vbox->addWidget(edit);
3126 if (dialog->exec() == QDialog::Accepted)
3127 render->saveZone(url->url(), edit->text(), zone);
3131 void MainWindow::slotSetInPoint()
3133 if (m_clipMonitor->isActive())
3134 m_clipMonitor->slotSetZoneStart();
3136 m_projectMonitor->slotSetZoneStart();
3137 //else m_activeTimeline->projectView()->setInPoint();
3140 void MainWindow::slotSetOutPoint()
3142 if (m_clipMonitor->isActive())
3143 m_clipMonitor->slotSetZoneEnd();
3145 m_projectMonitor->slotSetZoneEnd();
3146 // else m_activeTimeline->projectView()->setOutPoint();
3149 void MainWindow::slotResizeItemStart()
3151 if (m_activeTimeline)
3152 m_activeTimeline->projectView()->setInPoint();
3155 void MainWindow::slotResizeItemEnd()
3157 if (m_activeTimeline)
3158 m_activeTimeline->projectView()->setOutPoint();
3161 int MainWindow::getNewStuff(const QString &configFile)
3163 KNS3::Entry::List entries;
3164 #if KDE_IS_VERSION(4,3,80)
3165 KNS3::DownloadDialog dialog(configFile);
3167 entries = dialog.changedEntries();
3168 foreach(const KNS3::Entry &entry, entries) {
3169 if (entry.status() == KNS3::Entry::Installed)
3170 kDebug() << "// Installed files: " << entry.installedFiles();
3173 KNS::Engine engine(0);
3174 if (engine.init(configFile))
3175 entries = engine.downloadDialogModal(this);
3176 foreach(KNS::Entry *entry, entries) {
3177 if (entry->status() == KNS::Entry::Installed)
3178 kDebug() << "// Installed files: " << entry->installedFiles();
3180 #endif /* KDE_IS_VERSION(4,3,80) */
3181 return entries.size();
3184 void MainWindow::slotGetNewTitleStuff()
3186 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3187 TitleWidget::refreshTitleTemplates();
3190 void MainWindow::slotGetNewLumaStuff()
3192 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3193 initEffects::refreshLumas();
3194 m_activeTimeline->projectView()->reloadTransitionLumas();
3198 void MainWindow::slotGetNewRenderStuff()
3200 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3202 m_renderWidget->reloadProfiles();
3205 void MainWindow::slotGetNewMltProfileStuff()
3207 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3208 // update the list of profiles in settings dialog
3209 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3215 void MainWindow::slotAutoTransition()
3217 if (m_activeTimeline)
3218 m_activeTimeline->projectView()->autoTransition();
3221 void MainWindow::slotSplitAudio()
3223 if (m_activeTimeline)
3224 m_activeTimeline->projectView()->splitAudio();
3227 void MainWindow::slotUpdateClipType(QAction *action)
3229 if (m_activeTimeline) {
3230 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3231 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3232 else m_activeTimeline->projectView()->setAudioAndVideo();
3236 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3238 // We must stop the monitors since we create a new on in the dvd wizard
3239 m_clipMonitor->stop();
3240 m_projectMonitor->stop();
3241 DvdWizard w(url, profile, this);
3243 m_projectMonitor->start();
3246 void MainWindow::slotShowTimeline(bool show)
3248 if (show == false) {
3249 m_timelineState = saveState();
3250 centralWidget()->setHidden(true);
3252 centralWidget()->setHidden(false);
3253 restoreState(m_timelineState);
3257 void MainWindow::slotMaximizeCurrent(bool /*show*/)
3259 //TODO: is there a way to maximize current widget?
3262 m_timelineState = saveState();
3263 QWidget *par = focusWidget()->parentWidget();
3264 while (par->parentWidget() && par->parentWidget() != this)
3265 par = par->parentWidget();
3266 kDebug() << "CURRENT WIDGET: " << par->objectName();
3269 //centralWidget()->setHidden(false);
3270 //restoreState(m_timelineState);
3274 void MainWindow::loadTranscoders()
3276 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3279 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3280 KConfigGroup transConfig(config, "Transcoding");
3282 QMap< QString, QString > profiles = transConfig.entryMap();
3283 QMapIterator<QString, QString> i(profiles);
3284 while (i.hasNext()) {
3286 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3287 QAction *a = transMenu->addAction(i.key());
3289 if (data.count() > 1)
3290 a->setToolTip(data.at(1));
3291 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3295 void MainWindow::slotTranscode(KUrl::List urls)
3300 if (urls.isEmpty()) {
3301 QAction *action = qobject_cast<QAction *>(sender());
3302 QStringList data = action->data().toStringList();
3303 params = data.at(0);
3304 if (data.count() > 1) desc = data.at(1);
3305 if (data.count() > 2) condition = data.at(2);
3306 urls << m_projectList->getConditionalUrls(condition);
3307 urls.removeAll(KUrl());
3309 if (urls.isEmpty()) {
3310 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3313 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3314 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3316 //QProcess::startDetached("ffmpeg", parameters);
3319 void MainWindow::slotTranscodeClip()
3321 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3322 if (urls.isEmpty()) return;
3323 slotTranscode(urls);
3326 void MainWindow::slotSetDocumentRenderProfile(const QString &dest, const QString &group, const QString &name, const QString &file)
3328 if (m_activeDocument == NULL) return;
3329 m_activeDocument->setDocumentProperty("renderdestination", dest);
3330 m_activeDocument->setDocumentProperty("rendercategory", group);
3331 m_activeDocument->setDocumentProperty("renderprofile", name);
3332 m_activeDocument->setDocumentProperty("renderurl", file);
3333 m_activeDocument->setModified(true);
3337 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3339 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3341 QString playlistPath;
3344 QString scriptsFolder = m_activeDocument->projectFolder().path() + "/scripts/";
3345 QString path = m_renderWidget->getFreeScriptName();
3346 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3347 if (!ok || scriptPath.isEmpty()) return;
3348 scriptPath.prepend(scriptsFolder);
3349 QFile f(scriptPath);
3351 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3354 playlistPath = scriptPath + ".mlt";
3355 m_projectMonitor->saveSceneList(playlistPath);
3357 KTemporaryFile temp;
3358 temp.setAutoRemove(false);
3359 temp.setSuffix(".mlt");
3361 playlistPath = temp.fileName();
3362 m_projectMonitor->saveSceneList(playlistPath);
3365 if (!chapterFile.isEmpty()) {
3368 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3370 in = m_activeTimeline->inPoint();
3371 out = m_activeTimeline->outPoint();
3374 QDomElement chapters = doc.createElement("chapters");
3375 chapters.setAttribute("fps", m_activeDocument->fps());
3376 doc.appendChild(chapters);
3378 QDomElement guidesxml = m_activeDocument->guidesXml();
3379 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3380 for (int i = 0; i < nodes.count(); i++) {
3381 QDomElement e = nodes.item(i).toElement();
3383 QString comment = e.attribute("comment");
3384 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3385 if (time >= in && time < out) {
3386 if (zoneOnly) time = time - in;
3387 QDomElement chapter = doc.createElement("chapter");
3388 chapters.appendChild(chapter);
3389 chapter.setAttribute("title", comment);
3390 chapter.setAttribute("time", time);
3394 if (chapters.childNodes().count() > 0) {
3395 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3396 // Always insert a guide in pos 0
3397 QDomElement chapter = doc.createElement("chapter");
3398 chapters.insertBefore(chapter, QDomNode());
3399 chapter.setAttribute("title", i18n("Start"));
3400 chapter.setAttribute("time", "0");
3402 // save chapters file
3403 QFile file(chapterFile);
3404 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3405 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3407 file.write(doc.toString().toUtf8());
3408 if (file.error() != QFile::NoError) {
3409 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3416 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath);
3419 void MainWindow::slotUpdateTimecodeFormat(int ix)
3421 KdenliveSettings::setFrametimecode(ix == 1);
3422 m_clipMonitor->updateTimecodeFormat();
3423 m_projectMonitor->updateTimecodeFormat();
3424 m_transitionConfig->updateTimecodeFormat();
3425 m_effectStack->updateTimecodeFormat();
3426 //m_activeTimeline->projectView()->clearSelection();
3427 m_activeTimeline->updateRuler();
3430 void MainWindow::slotRemoveFocus()
3432 statusBar()->setFocus();
3433 statusBar()->clearFocus();
3436 void MainWindow::slotRevert()
3438 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;
3439 KUrl url = m_activeDocument->url();
3440 closeCurrentDocument(false);
3441 doOpenFile(url, NULL);
3445 void MainWindow::slotShutdown()
3447 if (m_activeDocument) m_activeDocument->setModified(false);
3449 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
3450 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
3451 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
3452 smserver.call("logout", 1, 2, 2);
3453 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
3454 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
3455 smserver.call("Shutdown");
3459 void MainWindow::slotUpdateTrackInfo()
3461 if (m_activeDocument)
3462 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
3465 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
3467 // Load the theme file
3469 if (action == NULL) theme = themename;
3470 else theme = action->data().toString();
3471 KdenliveSettings::setColortheme(theme);
3472 // Make palette for all widgets.
3474 if (theme.isEmpty())
3475 plt = QApplication::desktop()->palette();
3477 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
3478 plt = KGlobalSettings::createApplicationPalette(config);
3481 kapp->setPalette(plt);
3482 const QObjectList children = statusBar()->children();
3484 foreach(QObject *child, children) {
3485 if (child->isWidgetType())
3486 ((QWidget*)child)->setPalette(plt);
3487 const QObjectList subchildren = child->children();
3488 foreach(QObject *subchild, subchildren) {
3489 if (subchild->isWidgetType())
3490 ((QWidget*)subchild)->setPalette(plt);
3493 if (m_activeTimeline)
3494 m_activeTimeline->projectView()->updatePalette();
3498 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
3500 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
3501 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
3502 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
3503 const QSize bitsSize(24, 2);
3504 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
3505 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
3507 QPixmap pixmap(23, 16);
3508 pixmap.fill(Qt::black); // ### use some color other than black for borders?
3510 KConfigGroup group(config, "WM");
3511 QPainter p(&pixmap);
3512 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
3513 p.fillRect(1, 1, 7, 7, windowScheme.background());
3514 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
3516 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
3517 p.fillRect(8, 1, 7, 7, buttonScheme.background());
3518 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
3520 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
3521 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
3523 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
3524 p.fillRect(1, 8, 7, 7, viewScheme.background());
3525 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
3527 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
3528 p.fillRect(8, 8, 7, 7, selectionScheme.background());
3529 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
3531 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
3532 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
3538 void MainWindow::slotSwitchMonitors()
3540 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
3541 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
3542 else m_projectList->focusTree();
3545 void MainWindow::slotInsertZoneToTree()
3547 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
3548 QStringList info = m_clipMonitor->getZoneInfo();
3549 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
3552 void MainWindow::slotInsertZoneToTimeline()
3554 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
3555 QStringList info = m_clipMonitor->getZoneInfo();
3556 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
3560 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
3562 if (m_activeDocument && m_activeTimeline) {
3563 if (!ids.isEmpty()) {
3564 for (int i = 0; i < ids.size(); ++i) {
3565 m_activeTimeline->slotDeleteClip(ids.at(i));
3567 m_activeDocument->clipManager()->slotDeleteClips(ids);
3569 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
3570 m_activeDocument->setModified(true);
3574 void MainWindow::slotShowTitleBars(bool show)
3577 m_effectStackDock->setTitleBarWidget(0);
3578 m_clipMonitorDock->setTitleBarWidget(0);
3579 m_projectMonitorDock->setTitleBarWidget(0);
3581 m_recMonitorDock->setTitleBarWidget(0);
3583 m_effectListDock->setTitleBarWidget(0);
3584 m_transitionConfigDock->setTitleBarWidget(0);
3585 m_projectListDock->setTitleBarWidget(0);
3586 m_undoViewDock->setTitleBarWidget(0);
3587 m_vectorscopeDock->setTitleBarWidget(0);
3589 if (!m_effectStackDock->isFloating()) { m_effectStackDock->setTitleBarWidget(new QWidget(this)); }
3590 if (!m_clipMonitorDock->isFloating()) { m_clipMonitorDock->setTitleBarWidget(new QWidget(this)); }
3591 if (!m_projectMonitorDock->isFloating()) { m_projectMonitorDock->setTitleBarWidget(new QWidget(this)); }
3593 if (!m_recMonitorDock->isFloating()) { m_recMonitorDock->setTitleBarWidget(new QWidget(this)); }
3595 if (!m_effectListDock->isFloating()) { m_effectListDock->setTitleBarWidget(new QWidget(this)); }
3596 if (!m_transitionConfigDock->isFloating()) { m_transitionConfigDock->setTitleBarWidget(new QWidget(this)); }
3597 if (!m_projectListDock->isFloating()) { m_projectListDock->setTitleBarWidget(new QWidget(this)); }
3598 if (!m_undoViewDock->isFloating()) { m_undoViewDock->setTitleBarWidget(new QWidget(this)); }
3599 if (!m_vectorscopeDock->isFloating()) { m_vectorscopeDock->setTitleBarWidget(new QWidget(this)); }
3601 KdenliveSettings::setShowtitlebars(show);
3604 void MainWindow::slotSwitchTitles()
3606 slotShowTitleBars(!KdenliveSettings::showtitlebars());
3609 QString MainWindow::getMimeType()
3611 QString mimetype = "application/x-kdenlive";
3612 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
3613 if (!mime) mimetype = "*.kdenlive";
3617 #include "mainwindow.moc"