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, m_clipMonitor, 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->addSeparator();
381 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
382 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
383 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
384 m_timelineContextClipMenu->addSeparator();
385 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
386 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
387 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
388 m_timelineContextClipMenu->addSeparator();
390 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
391 m_timelineContextClipMenu->addMenu(markersMenu);
392 m_timelineContextClipMenu->addSeparator();
393 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
394 m_timelineContextClipMenu->addMenu(m_videoEffectsMenu);
395 m_timelineContextClipMenu->addMenu(m_audioEffectsMenu);
396 //TODO: re-enable custom effects menu when it is implemented
397 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
399 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
400 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
401 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
403 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
405 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
406 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
407 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
408 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
409 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), m_vectorscope, SLOT(slotActiveMonitorChanged(bool)));
410 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
411 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
413 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
414 slotConnectMonitors();
416 // Disable drop B frames, see Kdenlive issue #1330, see also kdenlivesettingsdialog.cpp
417 KdenliveSettings::setDropbframes(false);
419 // Open or create a file. Command line argument passed in Url has
420 // precedence, then "openlastproject", then just a plain empty file.
421 // If opening Url fails, openlastproject will _not_ be used.
422 if (!Url.isEmpty()) {
423 // delay loading so that the window shows up
425 QTimer::singleShot(500, this, SLOT(openFile()));
426 } else if (KdenliveSettings::openlastproject()) {
427 QTimer::singleShot(500, this, SLOT(openLastFile()));
428 } else { //if (m_timelineArea->count() == 0) {
432 #ifndef NO_JOGSHUTTLE
433 activateShuttleDevice();
434 #endif /* NO_JOGSHUTTLE */
435 m_projectListDock->raise();
438 void MainWindow::queryQuit()
441 if (m_projectMonitor) m_projectMonitor->stop();
442 if (m_clipMonitor) m_clipMonitor->stop();
443 delete m_effectStack;
444 delete m_activeTimeline;
446 // This sometimes causes crash on exit on OS X for some reason.
447 delete m_projectMonitor;
448 delete m_clipMonitor;
450 delete m_activeDocument;
451 delete m_shortcutRemoveFocus;
452 Mlt::Factory::close();
458 bool MainWindow::queryClose()
460 if (m_renderWidget) {
461 int waitingJobs = m_renderWidget->waitingJobsCount();
462 if (waitingJobs > 0) {
463 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")))) {
464 case KMessageBox::Yes :
465 // create script with waiting jobs and start it
466 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
468 case KMessageBox::No :
469 // Don't do anything, jobs will be deleted
477 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
478 // warn the user to save if document is modified and we have clips in our project list
479 if (m_activeDocument && m_activeDocument->isModified() &&
480 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
481 !m_projectList->documentClipList().isEmpty())) {
483 if (m_activeDocument->url().fileName().isEmpty())
484 message = i18n("Save changes to document?");
486 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
487 switch (KMessageBox::warningYesNoCancel(this, message)) {
488 case KMessageBox::Yes :
489 // save document here. If saving fails, return false;
491 case KMessageBox::No :
492 // User does not want to save the changes, clear recovery files
493 m_activeDocument->m_autosave->resize(0);
502 void MainWindow::loadPlugins()
504 foreach(QObject *plugin, QPluginLoader::staticInstances()) {
505 populateMenus(plugin);
508 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
510 filters << "libkdenlive*";
511 foreach(const QString &folder, directories) {
512 kDebug() << "Parsing plugin folder: " << folder;
513 QDir pluginsDir(folder);
514 foreach(const QString &fileName,
515 pluginsDir.entryList(filters, QDir::Files)) {
517 * Avoid loading the same plugin twice when there is more than one
520 if (!m_pluginFileNames.contains(fileName)) {
521 kDebug() << "Found plugin: " << fileName;
522 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
523 QObject *plugin = loader.instance();
525 populateMenus(plugin);
526 m_pluginFileNames += fileName;
528 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
534 void MainWindow::populateMenus(QObject *plugin)
536 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
537 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
539 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
543 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
544 QMenu *menu, const char *member,
545 QActionGroup *actionGroup)
547 kDebug() << "// ADD to MENU" << texts;
548 foreach(const QString &text, texts) {
549 QAction *action = new QAction(text, plugin);
550 action->setData(text);
551 connect(action, SIGNAL(triggered()), this, member);
552 menu->addAction(action);
555 action->setCheckable(true);
556 actionGroup->addAction(action);
561 void MainWindow::aboutPlugins()
563 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
568 void MainWindow::generateClip()
570 QAction *action = qobject_cast<QAction *>(sender());
571 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
573 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
574 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
575 if (!clipUrl.isEmpty()) {
576 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
580 void MainWindow::saveProperties(KConfigGroup &config)
582 // save properties here,used by session management
584 KMainWindow::saveProperties(config);
588 void MainWindow::readProperties(const KConfigGroup &config)
590 // read properties here,used by session management
591 KMainWindow::readProperties(config);
592 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
593 openFile(KUrl(Lastproject));
596 void MainWindow::slotReloadEffects()
598 m_customEffectsMenu->clear();
599 initEffects::parseCustomEffectsFile();
601 QStringList effectInfo;
602 QMap<QString, QStringList> effectsList;
603 for (int ix = 0; ix < customEffects.count(); ix++) {
604 effectInfo = customEffects.effectIdInfo(ix);
605 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
607 if (effectsList.isEmpty())
608 m_customEffectsMenu->setEnabled(false);
610 m_customEffectsMenu->setEnabled(true);
612 foreach(const QStringList &value, effectsList) {
613 action = new QAction(value.at(0), this);
614 action->setData(value);
615 m_customEffectsMenu->addAction(action);
617 m_effectList->reloadEffectList();
620 #ifndef NO_JOGSHUTTLE
621 void MainWindow::activateShuttleDevice()
625 if (KdenliveSettings::enableshuttle() == false) return;
626 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
627 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
628 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
629 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
630 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
631 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
632 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
635 void MainWindow::slotShuttleButton(int code)
639 slotShuttleAction(KdenliveSettings::shuttle1());
642 slotShuttleAction(KdenliveSettings::shuttle2());
645 slotShuttleAction(KdenliveSettings::shuttle3());
648 slotShuttleAction(KdenliveSettings::shuttle4());
651 slotShuttleAction(KdenliveSettings::shuttle5());
656 void MainWindow::slotShuttleAction(int code)
662 m_monitorManager->slotPlay();
665 m_monitorManager->slotPlay();
669 #endif /* NO_JOGSHUTTLE */
671 void MainWindow::configureNotifications()
673 KNotifyConfigWidget::configure(this);
676 void MainWindow::slotFullScreen()
678 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
681 void MainWindow::slotAddEffect(const QDomElement effect, GenTime pos, int track)
683 if (!m_activeDocument) return;
684 if (effect.isNull()) {
685 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
688 QDomElement effectToAdd = effect.cloneNode().toElement();
689 m_activeTimeline->projectView()->slotAddEffect(effectToAdd, pos, track);
692 void MainWindow::slotRaiseMonitor(bool clipMonitor)
694 if (clipMonitor) m_clipMonitorDock->raise();
695 else m_projectMonitorDock->raise();
698 void MainWindow::slotUpdateClip(const QString &id)
700 if (!m_activeDocument) return;
701 m_activeTimeline->projectView()->slotUpdateClip(id);
704 void MainWindow::slotConnectMonitors()
706 m_projectList->setRenderer(m_projectMonitor->render);
707 //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
708 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
709 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
710 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
711 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, int, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, int, bool)));
712 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
713 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)));
715 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
717 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
719 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
720 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
722 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
723 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
726 void MainWindow::slotAdjustClipMonitor()
728 m_clipMonitorDock->updateGeometry();
729 m_clipMonitorDock->adjustSize();
730 m_clipMonitor->resetSize();
733 void MainWindow::slotAdjustProjectMonitor()
735 m_projectMonitorDock->updateGeometry();
736 m_projectMonitorDock->adjustSize();
737 m_projectMonitor->resetSize();
740 void MainWindow::setupActions()
743 KActionCollection* collection = actionCollection();
744 m_timecodeFormat = new KComboBox(this);
745 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
746 m_timecodeFormat->addItem(i18n("Frames"));
747 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
748 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
750 m_statusProgressBar = new QProgressBar(this);
751 m_statusProgressBar->setMinimum(0);
752 m_statusProgressBar->setMaximum(100);
753 m_statusProgressBar->setMaximumWidth(150);
754 m_statusProgressBar->setVisible(false);
756 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
757 toolbar->setMovable(false);
758 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
759 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;}";
760 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
762 //create edit mode buttons
763 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
764 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
765 toolbar->addAction(m_normalEditTool);
766 m_normalEditTool->setCheckable(true);
767 m_normalEditTool->setChecked(true);
769 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
770 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
771 toolbar->addAction(m_overwriteEditTool);
772 m_overwriteEditTool->setCheckable(true);
773 m_overwriteEditTool->setChecked(false);
775 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
776 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
777 toolbar->addAction(m_insertEditTool);
778 m_insertEditTool->setCheckable(true);
779 m_insertEditTool->setChecked(false);
780 // not implemented yet
781 m_insertEditTool->setEnabled(false);
783 QActionGroup *editGroup = new QActionGroup(this);
784 editGroup->addAction(m_normalEditTool);
785 editGroup->addAction(m_overwriteEditTool);
786 editGroup->addAction(m_insertEditTool);
787 editGroup->setExclusive(true);
788 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
789 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
791 toolbar->addSeparator();
793 // create tools buttons
794 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
795 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
796 toolbar->addAction(m_buttonSelectTool);
797 m_buttonSelectTool->setCheckable(true);
798 m_buttonSelectTool->setChecked(true);
800 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
801 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
802 toolbar->addAction(m_buttonRazorTool);
803 m_buttonRazorTool->setCheckable(true);
804 m_buttonRazorTool->setChecked(false);
806 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
807 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
808 toolbar->addAction(m_buttonSpacerTool);
809 m_buttonSpacerTool->setCheckable(true);
810 m_buttonSpacerTool->setChecked(false);
812 QActionGroup *toolGroup = new QActionGroup(this);
813 toolGroup->addAction(m_buttonSelectTool);
814 toolGroup->addAction(m_buttonRazorTool);
815 toolGroup->addAction(m_buttonSpacerTool);
816 toolGroup->setExclusive(true);
817 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
819 QWidget * actionWidget;
820 int max = toolbar->iconSizeDefault() + 2;
821 actionWidget = toolbar->widgetForAction(m_normalEditTool);
822 actionWidget->setMaximumWidth(max);
823 actionWidget->setMaximumHeight(max - 4);
825 actionWidget = toolbar->widgetForAction(m_insertEditTool);
826 actionWidget->setMaximumWidth(max);
827 actionWidget->setMaximumHeight(max - 4);
829 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
830 actionWidget->setMaximumWidth(max);
831 actionWidget->setMaximumHeight(max - 4);
833 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
834 actionWidget->setMaximumWidth(max);
835 actionWidget->setMaximumHeight(max - 4);
837 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
838 actionWidget->setMaximumWidth(max);
839 actionWidget->setMaximumHeight(max - 4);
841 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
842 actionWidget->setMaximumWidth(max);
843 actionWidget->setMaximumHeight(max - 4);
845 toolbar->setStyleSheet(style1);
846 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
848 toolbar->addSeparator();
849 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
850 toolbar->addAction(m_buttonFitZoom);
851 m_buttonFitZoom->setCheckable(false);
853 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
854 toolbar->addAction(m_zoomOut);
855 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
857 m_zoomSlider = new QSlider(Qt::Horizontal, this);
858 m_zoomSlider->setMaximum(13);
859 m_zoomSlider->setPageStep(1);
860 m_zoomSlider->setInvertedAppearance(true);
862 m_zoomSlider->setMaximumWidth(150);
863 m_zoomSlider->setMinimumWidth(100);
864 toolbar->addWidget(m_zoomSlider);
866 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
867 toolbar->addAction(m_zoomIn);
868 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
870 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
871 actionWidget->setMaximumWidth(max);
872 actionWidget->setMaximumHeight(max - 4);
873 actionWidget->setStyleSheet(styleBorderless);
875 actionWidget = toolbar->widgetForAction(m_zoomIn);
876 actionWidget->setMaximumWidth(max);
877 actionWidget->setMaximumHeight(max - 4);
878 actionWidget->setStyleSheet(styleBorderless);
880 actionWidget = toolbar->widgetForAction(m_zoomOut);
881 actionWidget->setMaximumWidth(max);
882 actionWidget->setMaximumHeight(max - 4);
883 actionWidget->setStyleSheet(styleBorderless);
885 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
886 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
887 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
888 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
889 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
891 toolbar->addSeparator();
893 //create automatic audio split button
894 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
895 toolbar->addAction(m_buttonAutomaticSplitAudio);
896 m_buttonAutomaticSplitAudio->setCheckable(true);
897 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
898 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
900 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
901 toolbar->addAction(m_buttonVideoThumbs);
902 m_buttonVideoThumbs->setCheckable(true);
903 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
904 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
906 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
907 toolbar->addAction(m_buttonAudioThumbs);
908 m_buttonAudioThumbs->setCheckable(true);
909 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
910 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
912 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
913 toolbar->addAction(m_buttonShowMarkers);
914 m_buttonShowMarkers->setCheckable(true);
915 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
916 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
918 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
919 toolbar->addAction(m_buttonSnap);
920 m_buttonSnap->setCheckable(true);
921 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
922 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
924 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
925 actionWidget->setMaximumWidth(max);
926 actionWidget->setMaximumHeight(max - 4);
928 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
929 actionWidget->setMaximumWidth(max);
930 actionWidget->setMaximumHeight(max - 4);
932 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
933 actionWidget->setMaximumWidth(max);
934 actionWidget->setMaximumHeight(max - 4);
936 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
937 actionWidget->setMaximumWidth(max);
938 actionWidget->setMaximumHeight(max - 4);
940 actionWidget = toolbar->widgetForAction(m_buttonSnap);
941 actionWidget->setMaximumWidth(max);
942 actionWidget->setMaximumHeight(max - 4);
944 m_messageLabel = new StatusBarMessageLabel(this);
945 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
947 statusBar()->addWidget(m_messageLabel, 10);
948 statusBar()->addWidget(m_statusProgressBar, 0);
949 statusBar()->addPermanentWidget(toolbar);
950 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
951 statusBar()->addPermanentWidget(m_timecodeFormat);
952 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
954 collection->addAction("normal_mode", m_normalEditTool);
955 collection->addAction("overwrite_mode", m_overwriteEditTool);
956 collection->addAction("insert_mode", m_insertEditTool);
957 collection->addAction("select_tool", m_buttonSelectTool);
958 collection->addAction("razor_tool", m_buttonRazorTool);
959 collection->addAction("spacer_tool", m_buttonSpacerTool);
961 collection->addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
962 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
963 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
964 collection->addAction("show_markers", m_buttonShowMarkers);
965 collection->addAction("snap", m_buttonSnap);
966 collection->addAction("zoom_fit", m_buttonFitZoom);
967 collection->addAction("zoom_in", m_zoomIn);
968 collection->addAction("zoom_out", m_zoomOut);
970 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
971 collection->addAction("project_find", m_projectSearch);
972 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
973 m_projectSearch->setShortcut(Qt::Key_Slash);
975 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
976 collection->addAction("project_find_next", m_projectSearchNext);
977 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
978 m_projectSearchNext->setShortcut(Qt::Key_F3);
979 m_projectSearchNext->setEnabled(false);
981 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
982 collection->addAction("manage_profiles", profilesAction);
983 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
985 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
986 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
987 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
988 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
990 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
991 collection->addAction("run_wizard", wizAction);
992 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
994 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
995 collection->addAction("project_settings", projectAction);
996 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
998 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
999 collection->addAction("project_render", projectRender);
1000 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
1001 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
1003 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1004 collection->addAction("project_clean", projectClean);
1005 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1007 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1008 KShortcut playShortcut;
1009 playShortcut.setPrimary(Qt::Key_Space);
1010 playShortcut.setAlternate(Qt::Key_K);
1011 monitorPlay->setShortcut(playShortcut);
1012 collection->addAction("monitor_play", monitorPlay);
1013 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1015 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1016 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1017 collection->addAction("monitor_play_zone", m_playZone);
1018 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1020 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1021 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1022 collection->addAction("monitor_loop_zone", m_loopZone);
1023 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1025 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1026 collection->addAction("dvd_wizard", dvdWizard);
1027 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1029 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1030 collection->addAction("transcode_clip", transcodeClip);
1031 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1033 KAction *markIn = collection->addAction("mark_in");
1034 markIn->setText(i18n("Set Zone In"));
1035 markIn->setShortcut(Qt::Key_I);
1036 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1038 KAction *markOut = collection->addAction("mark_out");
1039 markOut->setText(i18n("Set Zone Out"));
1040 markOut->setShortcut(Qt::Key_O);
1041 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1043 KAction *switchMon = collection->addAction("switch_monitor");
1044 switchMon->setText(i18n("Switch monitor"));
1045 switchMon->setShortcut(Qt::Key_T);
1046 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1048 KAction *insertTree = collection->addAction("insert_project_tree");
1049 insertTree->setText(i18n("Insert zone in project tree"));
1050 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1051 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1053 KAction *insertTimeline = collection->addAction("insert_timeline");
1054 insertTimeline->setText(i18n("Insert zone in timeline"));
1055 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1056 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1058 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1059 collection->addAction("resize_timeline_clip_start", resizeStart);
1060 resizeStart->setShortcut(Qt::Key_1);
1061 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1063 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1064 collection->addAction("resize_timeline_clip_end", resizeEnd);
1065 resizeEnd->setShortcut(Qt::Key_2);
1066 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1068 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1069 monitorSeekBackward->setShortcut(Qt::Key_J);
1070 collection->addAction("monitor_seek_backward", monitorSeekBackward);
1071 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1073 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1074 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1075 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1076 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1078 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1079 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1080 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1081 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1083 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1084 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1085 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1086 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1088 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1089 monitorSeekForward->setShortcut(Qt::Key_L);
1090 collection->addAction("monitor_seek_forward", monitorSeekForward);
1091 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1093 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1094 clipStart->setShortcut(Qt::Key_Home);
1095 collection->addAction("seek_clip_start", clipStart);
1096 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1098 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1099 clipEnd->setShortcut(Qt::Key_End);
1100 collection->addAction("seek_clip_end", clipEnd);
1101 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1103 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1104 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1105 collection->addAction("seek_zone_start", zoneStart);
1106 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1108 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1109 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1110 collection->addAction("seek_zone_end", zoneEnd);
1111 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1113 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1114 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1115 collection->addAction("seek_start", projectStart);
1116 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1118 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1119 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1120 collection->addAction("seek_end", projectEnd);
1121 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1123 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1124 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1125 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1126 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1128 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1129 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1130 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1131 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1133 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1134 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1135 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1136 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1138 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1139 deleteItem->setShortcut(Qt::Key_Delete);
1140 collection->addAction("delete_timeline_clip", deleteItem);
1141 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1143 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1144 collection->addAction("change_clip_speed", editTimelineClipSpeed);
1145 editTimelineClipSpeed->setData("change_speed");
1146 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1148 KAction *stickTransition = collection->addAction("auto_transition");
1149 stickTransition->setData(QString("auto"));
1150 stickTransition->setCheckable(true);
1151 stickTransition->setEnabled(false);
1152 stickTransition->setText(i18n("Automatic Transition"));
1153 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1155 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1156 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1157 collection->addAction("group_clip", groupClip);
1158 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1160 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1161 collection->addAction("ungroup_clip", ungroupClip);
1162 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1163 ungroupClip->setData("ungroup_clip");
1164 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1166 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1167 collection->addAction("edit_item_duration", editItemDuration);
1168 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1170 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1171 collection->addAction("clip_in_project_tree", clipInProjectTree);
1172 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1174 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1175 collection->addAction("clip_to_project_tree", clipToProjectTree);
1176 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1178 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1179 insertOvertwrite->setShortcut(Qt::Key_V);
1180 collection->addAction("overwrite_to_in_point", insertOvertwrite);
1181 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1183 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1184 selectTimelineClip->setShortcut(Qt::Key_Plus);
1185 collection->addAction("select_timeline_clip", selectTimelineClip);
1186 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1188 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1189 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1190 collection->addAction("deselect_timeline_clip", deselectTimelineClip);
1191 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1193 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1194 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1195 collection->addAction("select_add_timeline_clip", selectAddTimelineClip);
1196 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1198 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1199 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1200 collection->addAction("select_timeline_transition", selectTimelineTransition);
1201 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1203 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1204 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1205 collection->addAction("deselect_timeline_transition", deselectTimelineTransition);
1206 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1208 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1209 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1210 collection->addAction("select_add_timeline_transition", selectAddTimelineTransition);
1211 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1213 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1214 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1215 collection->addAction("cut_timeline_clip", cutTimelineClip);
1216 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1218 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1219 collection->addAction("add_clip_marker", addClipMarker);
1220 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1222 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1223 collection->addAction("delete_clip_marker", deleteClipMarker);
1224 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1226 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1227 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
1228 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1230 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1231 collection->addAction("edit_clip_marker", editClipMarker);
1232 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1234 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1235 collection->addAction("split_audio", splitAudio);
1236 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1238 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1239 collection->addAction("clip_audio_only", audioOnly);
1240 audioOnly->setData("clip_audio_only");
1241 audioOnly->setCheckable(true);
1243 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1244 collection->addAction("clip_video_only", videoOnly);
1245 videoOnly->setData("clip_video_only");
1246 videoOnly->setCheckable(true);
1248 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1249 collection->addAction("clip_audio_and_video", audioAndVideo);
1250 audioAndVideo->setData("clip_audio_and_video");
1251 audioAndVideo->setCheckable(true);
1253 m_clipTypeGroup = new QActionGroup(this);
1254 m_clipTypeGroup->addAction(audioOnly);
1255 m_clipTypeGroup->addAction(videoOnly);
1256 m_clipTypeGroup->addAction(audioAndVideo);
1257 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1258 m_clipTypeGroup->setEnabled(false);
1260 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1261 collection->addAction("insert_space", insertSpace);
1262 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1264 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1265 collection->addAction("delete_space", removeSpace);
1266 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1268 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1269 collection->addAction("insert_track", insertTrack);
1270 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1272 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1273 collection->addAction("delete_track", deleteTrack);
1274 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1276 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
1277 collection->addAction("config_tracks", configTracks);
1278 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1280 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1281 collection->addAction("add_guide", addGuide);
1282 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1284 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1285 collection->addAction("delete_guide", delGuide);
1286 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1288 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1289 collection->addAction("edit_guide", editGuide);
1290 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1292 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1293 collection->addAction("delete_all_guides", delAllGuides);
1294 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1296 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1297 collection->addAction("paste_effects", pasteEffects);
1298 pasteEffects->setData("paste_effects");
1299 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1301 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1302 collection->addAction("show_timeline", showTimeline);
1303 showTimeline->setCheckable(true);
1304 showTimeline->setChecked(true);
1305 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1307 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1308 collection->addAction("show_titlebars", showTitleBar);
1309 showTitleBar->setCheckable(true);
1310 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1311 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1312 slotShowTitleBars(KdenliveSettings::showtitlebars());
1314 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1315 collection->addAction("maximize_current", maxCurrent);
1316 maxCurrent->setCheckable(true);
1317 maxCurrent->setChecked(false);
1318 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1320 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1321 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1322 KStandardAction::open(this, SLOT(openFile()), collection);
1323 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1324 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1325 KStandardAction::openNew(this, SLOT(newFile()), collection);
1326 // TODO: make the following connection to slotEditKeys work
1327 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1328 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1329 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1330 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1331 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1332 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1334 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1335 undo->setEnabled(false);
1336 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1338 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1339 redo->setEnabled(false);
1340 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1343 //TODO: Add status tooltip to actions ?
1344 connect(collection, SIGNAL(actionHovered(QAction*)),
1345 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1348 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1349 collection->addAction("add_clip", addClip);
1350 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1352 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1353 collection->addAction("add_color_clip", addColorClip);
1354 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1356 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1357 collection->addAction("add_slide_clip", addSlideClip);
1358 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1360 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1361 collection->addAction("add_text_clip", addTitleClip);
1362 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1364 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1365 collection->addAction("add_text_template_clip", addTitleTemplateClip);
1366 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1368 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1369 collection->addAction("add_folder", addFolderButton);
1370 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1372 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1373 collection->addAction("clip_properties", clipProperties);
1374 clipProperties->setData("clip_properties");
1375 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1376 clipProperties->setEnabled(false);
1378 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1379 collection->addAction("edit_clip", openClip);
1380 openClip->setData("edit_clip");
1381 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1382 openClip->setEnabled(false);
1384 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1385 collection->addAction("delete_clip", deleteClip);
1386 deleteClip->setData("delete_clip");
1387 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1388 deleteClip->setEnabled(false);
1390 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1391 collection->addAction("reload_clip", reloadClip);
1392 reloadClip->setData("reload_clip");
1393 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1394 reloadClip->setEnabled(false);
1396 QMenu *addClips = new QMenu();
1397 addClips->addAction(addClip);
1398 addClips->addAction(addColorClip);
1399 addClips->addAction(addSlideClip);
1400 addClips->addAction(addTitleClip);
1401 addClips->addAction(addTitleTemplateClip);
1402 addClips->addAction(addFolderButton);
1404 addClips->addAction(reloadClip);
1405 addClips->addAction(clipProperties);
1406 addClips->addAction(openClip);
1407 addClips->addAction(deleteClip);
1408 m_projectList->setupMenu(addClips, addClip);
1410 // Setup effects and transitions actions.
1411 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1412 //KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), m_effectsActionCollection);
1413 KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), collection);
1414 m_videoEffects = new KAction*[videoEffects.count()];
1415 for (int i = 0; i < videoEffects.count(); ++i) {
1416 QStringList effectInfo = videoEffects.effectIdInfo(i);
1417 m_videoEffects[i] = new KAction(KIcon("kdenlive-show-video"), effectInfo.at(0), this);
1418 m_videoEffects[i]->setData(effectInfo);
1419 m_videoEffects[i]->setIconVisibleInMenu(false);
1420 videoEffectActions->addAction("video_effect_" + effectInfo.at(0), m_videoEffects[i]);
1422 //KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), m_effectsActionCollection);
1423 KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), collection);
1424 m_audioEffects = new KAction*[audioEffects.count()];
1425 for (int i = 0; i < audioEffects.count(); ++i) {
1426 QStringList effectInfo = audioEffects.effectIdInfo(i);
1427 m_audioEffects[i] = new KAction(KIcon("kdenlive-show-audio"), effectInfo.at(0), this);
1428 m_audioEffects[i]->setData(effectInfo);
1429 m_audioEffects[i]->setIconVisibleInMenu(false);
1430 audioEffectActions->addAction("audio_effect_" + effectInfo.at(0), m_audioEffects[i]);
1432 //KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), m_effectsActionCollection);
1433 KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), collection);
1434 m_customEffects = new KAction*[customEffects.count()];
1435 for (int i = 0; i < customEffects.count(); ++i) {
1436 QStringList effectInfo = customEffects.effectIdInfo(i);
1437 m_customEffects[i] = new KAction(KIcon("kdenlive-custom-effect"), effectInfo.at(0), this);
1438 m_customEffects[i]->setData(effectInfo);
1439 m_customEffects[i]->setIconVisibleInMenu(false);
1440 customEffectActions->addAction("custom_effect_" + effectInfo.at(0), m_customEffects[i]);
1442 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1443 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1444 m_transitions = new KAction*[transitions.count()];
1445 for (int i = 0; i < transitions.count(); i++) {
1446 QStringList effectInfo = transitions.effectIdInfo(i);
1447 m_transitions[i] = new KAction(effectInfo.at(0), this);
1448 m_transitions[i]->setData(effectInfo);
1449 m_transitions[i]->setIconVisibleInMenu(false);
1450 transitionActions->addAction("transition_" + effectInfo.at(0), m_transitions[i]);
1452 m_effectsActionCollection->readSettings();
1454 //connect(collection, SIGNAL( clearStatusText() ),
1455 //statusBar(), SLOT( clear() ) );
1458 void MainWindow::slotDisplayActionMessage(QAction *a)
1460 statusBar()->showMessage(a->data().toString(), 3000);
1463 void MainWindow::saveOptions()
1465 KdenliveSettings::self()->writeConfig();
1466 KSharedConfigPtr config = KGlobal::config();
1467 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1468 KConfigGroup treecolumns(config, "Project Tree");
1469 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1473 void MainWindow::readOptions()
1475 KSharedConfigPtr config = KGlobal::config();
1476 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1477 KConfigGroup initialGroup(config, "version");
1478 bool upgrade = false;
1479 if (initialGroup.exists()) {
1480 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1484 if (initialGroup.readEntry("version") == "0.7") {
1485 //Add new settings from 0.7.1
1486 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1487 QString path = QDir::homePath() + "/kdenlive";
1488 if (KStandardDirs::makeDir(path) == false) {
1489 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1490 } else KdenliveSettings::setDefaultprojectfolder(path);
1496 if (!initialGroup.exists() || upgrade) {
1497 // this is our first run, show Wizard
1498 Wizard *w = new Wizard(upgrade, this);
1499 if (w->exec() == QDialog::Accepted && w->isOk()) {
1500 w->adjustSettings();
1501 initialGroup.writeEntry("version", version);
1507 KConfigGroup treecolumns(config, "Project Tree");
1508 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1509 if (!state.isEmpty())
1510 m_projectList->setHeaderInfo(state);
1513 void MainWindow::slotRunWizard()
1515 Wizard *w = new Wizard(false, this);
1516 if (w->exec() == QDialog::Accepted && w->isOk()) {
1517 w->adjustSettings();
1522 void MainWindow::newFile(bool showProjectSettings, bool force)
1524 if (!m_timelineArea->isEnabled() && !force) return;
1525 m_fileRevert->setEnabled(false);
1526 QString profileName;
1528 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1529 if (!showProjectSettings) {
1530 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1531 profileName = KdenliveSettings::default_profile();
1532 projectFolder = KdenliveSettings::defaultprojectfolder();
1534 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1535 if (w->exec() != QDialog::Accepted) return;
1536 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1537 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
1538 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
1539 profileName = w->selectedProfile();
1540 projectFolder = w->selectedFolder();
1541 projectTracks = w->tracks();
1544 m_timelineArea->setEnabled(true);
1545 m_projectList->setEnabled(true);
1546 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1547 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1549 TrackView *trackView = new TrackView(doc, &ok, this);
1550 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1553 //m_timelineArea->setEnabled(false);
1554 //m_projectList->setEnabled(false);
1558 if (m_timelineArea->count() == 1) {
1559 connectDocumentInfo(doc);
1560 connectDocument(trackView, doc);
1561 } else m_timelineArea->setTabBarHidden(false);
1562 m_monitorManager->activateMonitor("clip");
1563 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1566 void MainWindow::activateDocument()
1568 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1569 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1570 KdenliveDoc *currentDoc = currentTab->document();
1571 connectDocumentInfo(currentDoc);
1572 connectDocument(currentTab, currentDoc);
1575 void MainWindow::closeCurrentDocument(bool saveChanges)
1577 QWidget *w = m_timelineArea->currentWidget();
1579 // closing current document
1580 int ix = m_timelineArea->currentIndex() + 1;
1581 if (ix == m_timelineArea->count()) ix = 0;
1582 m_timelineArea->setCurrentIndex(ix);
1583 TrackView *tabToClose = (TrackView *) w;
1584 KdenliveDoc *docToClose = tabToClose->document();
1585 if (docToClose && docToClose->isModified() && saveChanges) {
1587 if (m_activeDocument->url().fileName().isEmpty())
1588 message = i18n("Save changes to document?");
1590 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1591 switch (KMessageBox::warningYesNoCancel(this, message)) {
1592 case KMessageBox::Yes :
1593 // save document here. If saving fails, return false;
1594 if (saveFile() == false) return;
1596 case KMessageBox::Cancel :
1603 m_clipMonitor->slotSetXml(NULL);
1604 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1605 if (m_timelineArea->count() == 1) {
1606 m_timelineArea->setTabBarHidden(true);
1607 m_closeAction->setEnabled(false);
1609 if (docToClose == m_activeDocument) {
1610 delete m_activeDocument;
1611 m_activeDocument = NULL;
1612 m_effectStack->clear();
1613 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1617 if (w == m_activeTimeline) {
1618 delete m_activeTimeline;
1619 m_activeTimeline = NULL;
1625 bool MainWindow::saveFileAs(const QString &outputFileName)
1627 QString currentSceneList;
1628 m_monitorManager->stopActiveMonitor();
1629 if (KdenliveSettings::dropbframes()) {
1630 KdenliveSettings::setDropbframes(false);
1631 m_activeDocument->clipManager()->updatePreviewSettings();
1632 currentSceneList = m_projectMonitor->sceneList();
1633 KdenliveSettings::setDropbframes(true);
1634 m_activeDocument->clipManager()->updatePreviewSettings();
1635 } else currentSceneList = m_projectMonitor->sceneList();
1637 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1640 // Save timeline thumbnails
1641 m_activeTimeline->projectView()->saveThumbnails();
1642 m_activeDocument->setUrl(KUrl(outputFileName));
1643 if (m_activeDocument->m_autosave == NULL) {
1644 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1645 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1646 setCaption(m_activeDocument->description());
1647 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1648 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1649 m_activeDocument->setModified(false);
1650 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1651 m_fileRevert->setEnabled(true);
1655 bool MainWindow::saveFileAs()
1657 QString outputFile = KFileDialog::getSaveFileName(KUrl(), getMimeType());
1658 if (outputFile.isEmpty()) return false;
1659 if (QFile::exists(outputFile)) {
1660 // Show the file dialog again if the user does not want to overwrite the file
1661 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it?")) == KMessageBox::No)
1662 return saveFileAs();
1664 return saveFileAs(outputFile);
1667 bool MainWindow::saveFile()
1669 if (!m_activeDocument) return true;
1670 if (m_activeDocument->url().isEmpty()) {
1671 return saveFileAs();
1673 bool result = saveFileAs(m_activeDocument->url().path());
1674 m_activeDocument->m_autosave->resize(0);
1679 void MainWindow::openFile()
1681 if (!m_startUrl.isEmpty()) {
1682 openFile(m_startUrl);
1683 m_startUrl = KUrl();
1686 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
1687 if (url.isEmpty()) return;
1688 m_fileOpenRecent->addUrl(url);
1692 void MainWindow::openLastFile()
1694 KSharedConfigPtr config = KGlobal::config();
1695 KUrl::List urls = m_fileOpenRecent->urls();
1696 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1697 if (urls.isEmpty()) newFile(false);
1698 else openFile(urls.last());
1701 void MainWindow::openFile(const KUrl &url)
1703 // Check if the document is already opened
1704 const int ct = m_timelineArea->count();
1705 bool isOpened = false;
1707 for (i = 0; i < ct; i++) {
1708 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1709 KdenliveDoc *doc = tab->document();
1710 if (doc->url() == url) {
1716 m_timelineArea->setCurrentIndex(i);
1720 // Check for backup file
1721 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1722 if (!staleFiles.isEmpty()) {
1723 if (KMessageBox::questionYesNo(this,
1724 i18n("Auto-saved files exist. Do you want to recover them now?"),
1725 i18n("File Recovery"),
1726 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1727 recoverFiles(staleFiles);
1730 // remove the stale files
1731 foreach(KAutoSaveFile *stale, staleFiles) {
1732 stale->open(QIODevice::ReadWrite);
1737 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1738 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
1739 m_messageLabel->repaint();
1740 doOpenFile(url, NULL);
1743 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1745 if (!m_timelineArea->isEnabled()) return;
1746 m_fileRevert->setEnabled(true);
1747 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, this);
1748 if (stale == NULL) {
1749 stale = new KAutoSaveFile(url, doc);
1750 doc->m_autosave = stale;
1752 doc->m_autosave = stale;
1753 doc->setUrl(stale->managedFile());
1754 doc->setModified(true);
1755 stale->setParent(doc);
1757 connectDocumentInfo(doc);
1759 TrackView *trackView = new TrackView(doc, &ok, this);
1760 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1762 m_timelineArea->setEnabled(false);
1763 m_projectList->setEnabled(false);
1764 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
1765 slotGotProgressInfo(QString(), -1);
1766 newFile(false, true);
1769 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1770 trackView->setDuration(trackView->duration());
1771 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1773 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1774 slotGotProgressInfo(QString(), -1);
1775 m_projectMonitor->adjustRulerSize(trackView->duration());
1776 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1777 m_clipMonitor->refreshMonitor(true);
1780 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1782 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1783 foreach(KAutoSaveFile *stale, staleFiles) {
1784 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1785 // show an error message; we could not steal the lockfile
1786 // maybe another application got to the file before us?
1790 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1791 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
1792 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1793 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1797 void MainWindow::parseProfiles(const QString &mltPath)
1799 //KdenliveSettings::setDefaulttmpfolder();
1800 if (!mltPath.isEmpty()) {
1801 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1802 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
1805 if (KdenliveSettings::mltpath().isEmpty())
1806 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1808 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
1809 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
1810 if (!QFile::exists(meltPath))
1811 meltPath = KStandardDirs::findExe("melt");
1812 KdenliveSettings::setRendererpath(meltPath);
1815 if (KdenliveSettings::rendererpath().isEmpty()) {
1816 // Cannot find the MLT melt renderer, ask for location
1817 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
1818 if (getUrl->exec() == QDialog::Rejected) {
1821 KUrl rendererPath = getUrl->selectedUrl();
1823 if (rendererPath.isEmpty()) ::exit(0);
1824 KdenliveSettings::setRendererpath(rendererPath.path());
1827 QStringList profilesFilter;
1828 profilesFilter << "*";
1829 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1830 if (profilesList.isEmpty()) {
1831 // Cannot find MLT path, try finding melt
1832 QString profilePath = KdenliveSettings::rendererpath();
1833 if (!profilePath.isEmpty()) {
1834 profilePath = profilePath.section('/', 0, -3);
1835 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1836 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1838 if (profilesList.isEmpty()) {
1839 // Cannot find the MLT profiles, ask for location
1840 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
1841 getUrl->fileDialog()->setMode(KFile::Directory);
1842 if (getUrl->exec() == QDialog::Rejected) {
1845 KUrl mltPath = getUrl->selectedUrl();
1847 if (mltPath.isEmpty()) ::exit(0);
1848 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
1849 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1853 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1855 // Parse again MLT profiles to build a list of available video formats
1856 if (profilesList.isEmpty()) parseProfiles();
1860 void MainWindow::slotEditProfiles()
1862 ProfilesDialog *w = new ProfilesDialog;
1863 if (w->exec() == QDialog::Accepted) {
1864 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1865 if (d) d->checkProfile();
1870 void MainWindow::slotDetectAudioDriver()
1872 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
1873 leading to no audio output, see bug #934 */
1875 //decide which audio driver is really best, in some cases SDL is wrong
1876 if (KdenliveSettings::audiodrivername().isEmpty()) {
1878 KProcess readProcess;
1879 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
1880 if (!KStandardDirs::findExe("pactl").isEmpty()) {
1881 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
1882 readProcess.setProgram("pactl", QStringList() << "stat");
1883 readProcess.execute(2000); // Kill it after 2 seconds
1885 QString result = QString(readProcess.readAllStandardOutput());
1886 kDebug() << "// / / / / / READING PACTL: ";
1888 if (!result.isEmpty()) {
1890 kDebug() << "// / / / / PULSEAUDIO DETECTED";
1894 KdenliveSettings::setAutoaudiodrivername(driver);
1898 void MainWindow::slotEditProjectSettings()
1900 QPoint p = m_activeDocument->getTracksCount();
1901 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
1903 if (w->exec() == QDialog::Accepted) {
1904 QString profile = w->selectedProfile();
1905 m_activeDocument->setProjectFolder(w->selectedFolder());
1906 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path(KUrl::AddTrailingSlash));
1907 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
1908 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
1909 if (m_activeDocument->profilePath() != profile) {
1910 // Profile was changed
1911 double dar = m_activeDocument->dar();
1913 // Deselect current effect / transition
1914 m_effectStack->slotClipItemSelected(NULL, 0);
1915 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1916 m_clipMonitor->slotSetXml(NULL);
1917 bool updateFps = m_activeDocument->setProfilePath(profile);
1918 KdenliveSettings::setCurrent_profile(profile);
1919 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1920 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1922 m_activeDocument->clipManager()->clearUnusedProducers();
1923 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1925 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
1926 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
1927 m_projectList->updateProjectFormat(m_activeDocument->timecode());
1928 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1929 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1930 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1931 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
1932 if (updateFps) m_activeTimeline->updateProjectFps();
1933 m_activeDocument->setModified(true);
1934 m_commandStack->activeStack()->clear();
1935 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
1936 slotUpdateMousePosition(0);
1937 // We need to desactivate & reactivate monitors to get a refresh
1938 //m_monitorManager->switchMonitors();
1945 void MainWindow::slotRenderProject()
1947 if (!m_renderWidget) {
1948 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
1949 m_renderWidget = new RenderWidget(projectfolder, this);
1950 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
1951 connect(m_renderWidget, SIGNAL(selectedRenderProfile(const QString &, const QString &, const QString &, const QString&)), this, SLOT(slotSetDocumentRenderProfile(const QString &, const QString &, const QString &, const QString&)));
1952 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
1953 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1954 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1955 if (m_activeDocument) {
1956 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1957 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1958 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
1959 m_renderWidget->setRenderProfile(m_activeDocument->getDocumentProperty("renderdestination"), m_activeDocument->getDocumentProperty("rendercategory"), m_activeDocument->getDocumentProperty("renderprofile"), m_activeDocument->getDocumentProperty("renderurl"));
1962 slotCheckRenderStatus();
1963 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1964 if (currentTab) m_renderWidget->setTimeline(currentTab);
1965 m_renderWidget->setDocument(m_activeDocument);*/
1966 m_renderWidget->show();
1967 m_renderWidget->showNormal();
1969 m_activeTimeline->tracksNumber();
1970 m_renderWidget->enableAudio(false);
1971 //m_renderWidget->export_audio;
1974 void MainWindow::slotCheckRenderStatus()
1976 // Make sure there are no missing clips
1978 m_renderWidget->missingClips(m_projectList->hasMissingClips());
1981 void MainWindow::setRenderingProgress(const QString &url, int progress)
1984 m_renderWidget->setRenderJob(url, progress);
1987 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
1990 m_renderWidget->setRenderStatus(url, status, error);
1993 void MainWindow::slotCleanProject()
1995 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
1996 m_projectList->cleanup();
1999 void MainWindow::slotUpdateMousePosition(int pos)
2001 if (m_activeDocument)
2002 switch (m_timecodeFormat->currentIndex()) {
2004 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2007 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2011 void MainWindow::slotUpdateDocumentState(bool modified)
2013 if (!m_activeDocument) return;
2014 setCaption(m_activeDocument->description(), modified);
2015 m_saveAction->setEnabled(modified);
2017 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2018 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2020 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2021 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2025 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2027 if (m_activeDocument) {
2028 if (m_activeDocument == doc) return;
2029 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2031 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2034 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2036 //m_projectMonitor->stop();
2037 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2038 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2039 if (m_activeDocument) {
2040 if (m_activeDocument == doc) return;
2041 if (m_activeTimeline) {
2042 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2043 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2044 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2045 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2046 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
2048 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2049 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2050 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2051 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
2052 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2053 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2054 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
2055 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2056 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2057 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2058 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2059 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2060 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2061 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2062 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2063 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2064 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2065 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2066 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2067 disconnect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
2068 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
2069 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
2070 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
2071 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2072 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2073 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2074 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2075 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2076 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2077 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2078 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2079 disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2080 disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2081 m_effectStack->clear();
2083 //m_activeDocument->setRenderer(NULL);
2084 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
2085 disconnect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2086 m_clipMonitor->stop();
2088 KdenliveSettings::setCurrent_profile(doc->profilePath());
2089 KdenliveSettings::setProject_fps(doc->fps());
2090 m_monitorManager->resetProfiles(doc->timecode());
2091 m_projectList->setDocument(doc);
2092 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2093 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2094 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint)));
2095 connect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2096 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), trackView->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2098 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2099 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2101 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
2104 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2105 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2106 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2107 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2108 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2109 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2110 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2111 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2112 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
2113 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2114 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
2116 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2117 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2118 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
2119 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2120 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2122 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
2123 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2124 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2127 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2128 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2130 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2131 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2132 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2133 m_zoomSlider->setValue(doc->zoom().x());
2134 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2135 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2136 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2137 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2139 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2140 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2143 connect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
2144 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2145 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
2146 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
2147 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
2148 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2149 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2150 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2151 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2152 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2154 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2155 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2156 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2157 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2158 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2161 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2162 m_activeTimeline = trackView;
2163 if (m_renderWidget) {
2164 slotCheckRenderStatus();
2165 m_renderWidget->setProfile(doc->mltProfile());
2166 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2167 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2168 m_renderWidget->setRenderProfile(doc->getDocumentProperty("renderdestination"), doc->getDocumentProperty("rendercategory"), doc->getDocumentProperty("renderprofile"), doc->getDocumentProperty("renderurl"));
2170 //doc->setRenderer(m_projectMonitor->render);
2171 m_commandStack->setActiveStack(doc->commandStack());
2172 KdenliveSettings::setProject_display_ratio(doc->dar());
2173 //doc->clipManager()->checkAudioThumbs();
2175 //m_overView->setScene(trackView->projectScene());
2176 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2177 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2179 setCaption(doc->description(), doc->isModified());
2180 m_saveAction->setEnabled(doc->isModified());
2181 m_normalEditTool->setChecked(true);
2182 m_activeDocument = doc;
2183 m_activeTimeline->updateProjectFps();
2184 m_activeDocument->checkProjectClips();
2185 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
2186 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2187 slotUpdateMousePosition(0);
2188 // set tool to select tool
2189 m_buttonSelectTool->setChecked(true);
2192 void MainWindow::slotZoneMoved(int start, int end)
2194 m_activeDocument->setZone(start, end);
2195 m_projectMonitor->slotZoneMoved(start, end);
2198 void MainWindow::slotGuidesUpdated()
2201 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2204 void MainWindow::slotEditKeys()
2206 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2207 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2208 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2212 void MainWindow::slotPreferences(int page, int option)
2214 //An instance of your dialog could be already created and could be
2215 // cached, in which case you want to display the cached dialog
2216 // instead of creating another one
2217 if (KConfigDialog::showDialog("settings")) {
2218 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2219 if (page != -1) d->showPage(page, option);
2223 // KConfigDialog didn't find an instance of this dialog, so lets
2225 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
2226 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2227 //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
2228 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2229 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2231 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
2233 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2235 if (page != -1) dialog->showPage(page, option);
2238 void MainWindow::slotUpdatePreviewSettings()
2240 if (m_activeDocument) {
2241 m_clipMonitor->slotSetXml(NULL);
2242 m_activeDocument->updatePreviewSettings();
2246 void MainWindow::updateConfiguration()
2248 //TODO: we should apply settings to all projects, not only the current one
2249 if (m_activeTimeline) {
2250 m_activeTimeline->refresh();
2251 m_activeTimeline->projectView()->checkAutoScroll();
2252 m_activeTimeline->projectView()->checkTrackHeight();
2253 if (m_activeDocument)
2254 m_activeDocument->clipManager()->checkAudioThumbs();
2256 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2257 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2258 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2260 // Update list of transcoding profiles
2262 #ifndef NO_JOGSHUTTLE
2263 activateShuttleDevice();
2264 #endif /* NO_JOGSHUTTLE */
2268 void MainWindow::slotSwitchSplitAudio()
2270 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2271 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2274 void MainWindow::slotSwitchVideoThumbs()
2276 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2277 if (m_activeTimeline)
2278 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2279 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2282 void MainWindow::slotSwitchAudioThumbs()
2284 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2285 if (m_activeTimeline) {
2286 m_activeTimeline->refresh();
2287 m_activeTimeline->projectView()->checkAutoScroll();
2288 if (m_activeDocument)
2289 m_activeDocument->clipManager()->checkAudioThumbs();
2291 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2294 void MainWindow::slotSwitchMarkersComments()
2296 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2297 if (m_activeTimeline)
2298 m_activeTimeline->refresh();
2299 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2302 void MainWindow::slotSwitchSnap()
2304 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2305 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2309 void MainWindow::slotDeleteItem()
2311 if (QApplication::focusWidget() &&
2312 QApplication::focusWidget()->parentWidget() &&
2313 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2314 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2315 m_projectList->slotRemoveClip();
2318 QWidget *widget = QApplication::focusWidget();
2320 if (widget == m_effectStackDock) {
2321 m_effectStack->slotItemDel();
2324 widget = widget->parentWidget();
2327 // effect stack has no focus
2328 if (m_activeTimeline)
2329 m_activeTimeline->projectView()->deleteSelectedClips();
2333 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2335 if (m_clipMonitor->isActive())
2336 m_clipMonitor->checkOverlay();
2337 m_clipMonitor->updateMarkers(clip);
2340 void MainWindow::slotAddClipMarker()
2342 DocClipBase *clip = NULL;
2344 if (m_projectMonitor->isActive()) {
2345 if (m_activeTimeline) {
2346 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2348 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2349 clip = item->baseClip();
2353 clip = m_clipMonitor->activeClip();
2354 pos = m_clipMonitor->position();
2357 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2360 QString id = clip->getId();
2361 CommentedTime marker(pos, i18n("Marker"));
2362 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2363 if (d.exec() == QDialog::Accepted)
2364 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2367 void MainWindow::slotDeleteClipMarker()
2369 DocClipBase *clip = NULL;
2371 if (m_projectMonitor->isActive()) {
2372 if (m_activeTimeline) {
2373 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2375 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2376 clip = item->baseClip();
2380 clip = m_clipMonitor->activeClip();
2381 pos = m_clipMonitor->position();
2384 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2388 QString id = clip->getId();
2389 QString comment = clip->markerComment(pos);
2390 if (comment.isEmpty()) {
2391 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2394 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2397 void MainWindow::slotDeleteAllClipMarkers()
2399 DocClipBase *clip = NULL;
2400 if (m_projectMonitor->isActive()) {
2401 if (m_activeTimeline) {
2402 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2404 clip = item->baseClip();
2408 clip = m_clipMonitor->activeClip();
2411 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2414 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2417 void MainWindow::slotEditClipMarker()
2419 DocClipBase *clip = NULL;
2421 if (m_projectMonitor->isActive()) {
2422 if (m_activeTimeline) {
2423 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2425 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2426 clip = item->baseClip();
2430 clip = m_clipMonitor->activeClip();
2431 pos = m_clipMonitor->position();
2434 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2438 QString id = clip->getId();
2439 QString oldcomment = clip->markerComment(pos);
2440 if (oldcomment.isEmpty()) {
2441 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2445 CommentedTime marker(pos, oldcomment);
2446 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2447 if (d.exec() == QDialog::Accepted) {
2448 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2449 if (d.newMarker().time() != pos) {
2450 // remove old marker
2451 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2456 void MainWindow::slotAddGuide()
2458 if (m_activeTimeline)
2459 m_activeTimeline->projectView()->slotAddGuide();
2462 void MainWindow::slotInsertSpace()
2464 if (m_activeTimeline)
2465 m_activeTimeline->projectView()->slotInsertSpace();
2468 void MainWindow::slotRemoveSpace()
2470 if (m_activeTimeline)
2471 m_activeTimeline->projectView()->slotRemoveSpace();
2474 void MainWindow::slotInsertTrack(int ix)
2476 m_projectMonitor->activateMonitor();
2477 if (m_activeTimeline)
2478 m_activeTimeline->projectView()->slotInsertTrack(ix);
2479 if (m_activeDocument)
2480 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2483 void MainWindow::slotDeleteTrack(int ix)
2485 m_projectMonitor->activateMonitor();
2486 if (m_activeTimeline)
2487 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2488 if (m_activeDocument)
2489 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2492 void MainWindow::slotConfigTrack(int ix)
2494 m_projectMonitor->activateMonitor();
2495 if (m_activeTimeline)
2496 m_activeTimeline->projectView()->slotConfigTracks(ix);
2497 if (m_activeDocument)
2498 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2501 void MainWindow::slotEditGuide()
2503 if (m_activeTimeline)
2504 m_activeTimeline->projectView()->slotEditGuide();
2507 void MainWindow::slotDeleteGuide()
2509 if (m_activeTimeline)
2510 m_activeTimeline->projectView()->slotDeleteGuide();
2513 void MainWindow::slotDeleteAllGuides()
2515 if (m_activeTimeline)
2516 m_activeTimeline->projectView()->slotDeleteAllGuides();
2519 void MainWindow::slotCutTimelineClip()
2521 if (m_activeTimeline)
2522 m_activeTimeline->projectView()->cutSelectedClips();
2525 void MainWindow::slotInsertClipOverwrite()
2527 if (m_activeTimeline) {
2528 QStringList data = m_clipMonitor->getZoneInfo();
2529 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2533 void MainWindow::slotSelectTimelineClip()
2535 if (m_activeTimeline)
2536 m_activeTimeline->projectView()->selectClip(true);
2539 void MainWindow::slotSelectTimelineTransition()
2541 if (m_activeTimeline)
2542 m_activeTimeline->projectView()->selectTransition(true);
2545 void MainWindow::slotDeselectTimelineClip()
2547 if (m_activeTimeline)
2548 m_activeTimeline->projectView()->selectClip(false, true);
2551 void MainWindow::slotDeselectTimelineTransition()
2553 if (m_activeTimeline)
2554 m_activeTimeline->projectView()->selectTransition(false, true);
2557 void MainWindow::slotSelectAddTimelineClip()
2559 if (m_activeTimeline)
2560 m_activeTimeline->projectView()->selectClip(true, true);
2563 void MainWindow::slotSelectAddTimelineTransition()
2565 if (m_activeTimeline)
2566 m_activeTimeline->projectView()->selectTransition(true, true);
2569 void MainWindow::slotGroupClips()
2571 if (m_activeTimeline)
2572 m_activeTimeline->projectView()->groupClips();
2575 void MainWindow::slotUnGroupClips()
2577 if (m_activeTimeline)
2578 m_activeTimeline->projectView()->groupClips(false);
2581 void MainWindow::slotEditItemDuration()
2583 if (m_activeTimeline)
2584 m_activeTimeline->projectView()->editItemDuration();
2587 void MainWindow::slotAddProjectClip(KUrl url)
2589 if (m_activeDocument)
2590 m_activeDocument->slotAddClipFile(url, QString());
2593 void MainWindow::slotAddTransition(QAction *result)
2595 if (!result) return;
2596 QStringList info = result->data().toStringList();
2597 if (info.isEmpty()) return;
2598 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2599 if (m_activeTimeline && !transition.isNull()) {
2600 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2604 void MainWindow::slotAddVideoEffect(QAction *result)
2606 if (!result) return;
2607 QStringList info = result->data().toStringList();
2608 if (info.isEmpty()) return;
2609 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2610 slotAddEffect(effect);
2613 void MainWindow::slotAddAudioEffect(QAction *result)
2615 if (!result) return;
2616 QStringList info = result->data().toStringList();
2617 if (info.isEmpty()) return;
2618 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2619 slotAddEffect(effect);
2622 void MainWindow::slotAddCustomEffect(QAction *result)
2624 if (!result) return;
2625 QStringList info = result->data().toStringList();
2626 if (info.isEmpty()) return;
2627 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2628 slotAddEffect(effect);
2631 void MainWindow::slotZoomIn()
2633 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2634 slotShowZoomSliderToolTip();
2637 void MainWindow::slotZoomOut()
2639 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2640 slotShowZoomSliderToolTip();
2643 void MainWindow::slotFitZoom()
2645 if (m_activeTimeline)
2646 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2649 void MainWindow::slotSetZoom(int value)
2651 if (m_activeTimeline)
2652 m_activeTimeline->slotChangeZoom(value);
2654 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
2655 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
2656 slotUpdateZoomSliderToolTip(value);
2658 m_zoomSlider->blockSignals(true);
2659 m_zoomSlider->setValue(value);
2660 m_zoomSlider->blockSignals(false);
2663 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
2665 if (zoomlevel != -1)
2666 slotUpdateZoomSliderToolTip(zoomlevel);
2668 QPoint global = m_zoomSlider->rect().topLeft();
2669 global.ry() += m_zoomSlider->height() / 2;
2670 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
2671 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
2674 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
2676 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
2679 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2681 m_statusProgressBar->setValue(progress);
2682 if (progress >= 0) {
2683 if (!message.isEmpty())
2684 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2685 m_statusProgressBar->setVisible(true);
2686 } else if (progress == -2) {
2687 if (!message.isEmpty())
2688 m_messageLabel->setMessage(message, ErrorMessage);
2689 m_statusProgressBar->setVisible(false);
2691 m_messageLabel->setMessage(QString(), DefaultMessage);
2692 m_statusProgressBar->setVisible(false);
2696 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2698 if (clip->clipType() == TEXT) {
2699 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
2700 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
2701 // template text clip
2703 // Get the list of existing templates
2705 filter << "*.kdenlivetitle";
2706 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
2708 QDialog *dia = new QDialog(this);
2709 Ui::TemplateClip_UI dia_ui;
2710 dia_ui.setupUi(dia);
2712 const QString templatePath = clip->getProperty("resource");
2713 for (int i = 0; i < templateFiles.size(); ++i) {
2714 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
2715 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
2717 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
2718 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
2719 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
2720 //warning: setting base directory doesn't work??
2721 KUrl startDir(titlepath);
2722 dia_ui.template_list->fileDialog()->setUrl(startDir);
2723 dia_ui.description->setText(clip->getProperty("description"));
2724 if (dia->exec() == QDialog::Accepted) {
2725 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
2726 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
2728 QMap <QString, QString> newprops;
2730 if (KUrl(textTemplate).path() != templatePath) {
2731 // The template was changed
2732 newprops.insert("resource", textTemplate);
2735 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
2736 newprops.insert("description", dia_ui.description->toPlainText());
2739 QString newtemplate = newprops.value("xmltemplate");
2740 if (newtemplate.isEmpty()) newtemplate = templatePath;
2742 // template modified we need to update xmldata
2743 QString description = newprops.value("description");
2744 if (description.isEmpty()) description = clip->getProperty("description");
2745 else newprops.insert("templatetext", description);
2746 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
2747 if (!newprops.isEmpty()) {
2748 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2749 m_activeDocument->commandStack()->push(command);
2755 QString path = clip->getProperty("resource");
2756 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
2758 doc.setContent(clip->getProperty("xmldata"));
2759 dia_ui->setXml(doc);
2760 if (dia_ui->exec() == QDialog::Accepted) {
2761 QMap <QString, QString> newprops;
2762 newprops.insert("xmldata", dia_ui->xml().toString());
2763 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
2764 // duration changed, we need to update duration
2765 newprops.insert("out", QString::number(dia_ui->outPoint()));
2767 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2768 m_activeDocument->commandStack()->push(command);
2769 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
2770 m_activeDocument->setModified(true);
2774 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2777 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2778 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2779 if (dia.exec() == QDialog::Accepted) {
2780 QMap <QString, QString> newprops = dia.properties();
2781 if (newprops.isEmpty()) return;
2782 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2783 m_activeDocument->commandStack()->push(command);
2785 if (dia.needsTimelineRefresh()) {
2786 // update clip occurences in timeline
2787 m_activeTimeline->projectView()->slotUpdateClip(clip->getId(), dia.needsTimelineReload());
2793 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
2795 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
2796 if (dia.exec() == QDialog::Accepted) {
2797 QUndoCommand *command = new QUndoCommand();
2798 command->setText(i18n("Edit clips"));
2799 for (int i = 0; i < cliplist.count(); i++) {
2800 DocClipBase *clip = cliplist.at(i);
2801 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true, command);
2803 m_activeDocument->commandStack()->push(command);
2804 for (int i = 0; i < cliplist.count(); i++)
2805 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
2809 void MainWindow::customEvent(QEvent* e)
2811 if (e->type() == QEvent::User)
2812 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
2814 void MainWindow::slotActivateEffectStackView()
2816 m_effectStack->raiseWindow(m_effectStackDock);
2819 void MainWindow::slotActivateTransitionView(Transition *t)
2822 m_transitionConfig->raiseWindow(m_transitionConfigDock);
2825 void MainWindow::slotSnapRewind()
2827 if (m_projectMonitor->isActive()) {
2828 if (m_activeTimeline)
2829 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2831 m_clipMonitor->slotSeekToPreviousSnap();
2835 void MainWindow::slotSnapForward()
2837 if (m_projectMonitor->isActive()) {
2838 if (m_activeTimeline)
2839 m_activeTimeline->projectView()->slotSeekToNextSnap();
2841 m_clipMonitor->slotSeekToNextSnap();
2845 void MainWindow::slotClipStart()
2847 if (m_projectMonitor->isActive()) {
2848 if (m_activeTimeline)
2849 m_activeTimeline->projectView()->clipStart();
2853 void MainWindow::slotClipEnd()
2855 if (m_projectMonitor->isActive()) {
2856 if (m_activeTimeline)
2857 m_activeTimeline->projectView()->clipEnd();
2861 void MainWindow::slotZoneStart()
2863 if (m_projectMonitor->isActive())
2864 m_projectMonitor->slotZoneStart();
2866 m_clipMonitor->slotZoneStart();
2869 void MainWindow::slotZoneEnd()
2871 if (m_projectMonitor->isActive())
2872 m_projectMonitor->slotZoneEnd();
2874 m_clipMonitor->slotZoneEnd();
2877 void MainWindow::slotChangeTool(QAction * action)
2879 if (action == m_buttonSelectTool)
2880 slotSetTool(SELECTTOOL);
2881 else if (action == m_buttonRazorTool)
2882 slotSetTool(RAZORTOOL);
2883 else if (action == m_buttonSpacerTool)
2884 slotSetTool(SPACERTOOL);
2887 void MainWindow::slotChangeEdit(QAction * action)
2889 if (!m_activeTimeline)
2892 if (action == m_overwriteEditTool)
2893 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
2894 else if (action == m_insertEditTool)
2895 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
2897 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
2900 void MainWindow::slotSetTool(PROJECTTOOL tool)
2902 if (m_activeDocument && m_activeTimeline) {
2903 //m_activeDocument->setTool(tool);
2907 message = i18n("Ctrl + click to use spacer on current track only");
2910 message = i18n("Click on a clip to cut it");
2913 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
2916 m_messageLabel->setMessage(message, InformationMessage);
2917 m_activeTimeline->projectView()->setTool(tool);
2921 void MainWindow::slotCopy()
2923 if (m_activeDocument && m_activeTimeline)
2924 m_activeTimeline->projectView()->copyClip();
2927 void MainWindow::slotPaste()
2929 if (m_activeDocument && m_activeTimeline)
2930 m_activeTimeline->projectView()->pasteClip();
2933 void MainWindow::slotPasteEffects()
2935 if (m_activeDocument && m_activeTimeline)
2936 m_activeTimeline->projectView()->pasteClipEffects();
2939 void MainWindow::slotFind()
2941 if (!m_activeDocument || !m_activeTimeline) return;
2942 m_projectSearch->setEnabled(false);
2943 m_findActivated = true;
2944 m_findString.clear();
2945 m_activeTimeline->projectView()->initSearchStrings();
2946 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2947 m_findTimer.start(5000);
2948 qApp->installEventFilter(this);
2951 void MainWindow::slotFindNext()
2953 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
2954 statusBar()->showMessage(i18n("Found: %1", m_findString));
2956 statusBar()->showMessage(i18n("Reached end of project"));
2957 m_findTimer.start(4000);
2960 void MainWindow::findAhead()
2962 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
2963 m_projectSearchNext->setEnabled(true);
2964 statusBar()->showMessage(i18n("Found: %1", m_findString));
2966 m_projectSearchNext->setEnabled(false);
2967 statusBar()->showMessage(i18n("Not found: %1", m_findString));
2971 void MainWindow::findTimeout()
2973 m_projectSearchNext->setEnabled(false);
2974 m_findActivated = false;
2975 m_findString.clear();
2976 statusBar()->showMessage(i18n("Find stopped"), 3000);
2977 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
2978 m_projectSearch->setEnabled(true);
2979 removeEventFilter(this);
2982 void MainWindow::slotClipInTimeline(const QString &clipId)
2984 if (m_activeTimeline && m_activeDocument) {
2985 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
2987 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
2988 inTimelineMenu->clear();
2990 QList <QAction *> actionList;
2992 for (int i = 0; i < matching.count(); ++i) {
2993 QString track = QString::number(matching.at(i).track);
2994 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
2996 QAction *a = new QAction(track + ": " + start, this);
2997 a->setData(QStringList() << track << start);
2998 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
2999 while (j < actionList.count()) {
3000 if (actionList.at(j)->text() > a->text()) break;
3003 actionList.insert(j, a);
3005 inTimelineMenu->addActions(actionList);
3007 if (matching.empty())
3008 inTimelineMenu->setEnabled(false);
3010 inTimelineMenu->setEnabled(true);
3014 void MainWindow::slotClipInProjectTree()
3016 if (m_activeTimeline) {
3017 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3018 if (clipIds.isEmpty())
3020 m_projectListDock->raise();
3021 for (int i = 0; i < clipIds.count(); i++)
3022 m_projectList->selectItemById(clipIds.at(i));
3023 if (m_projectMonitor->isActive())
3024 slotSwitchMonitors();
3028 /*void MainWindow::slotClipToProjectTree()
3030 if (m_activeTimeline) {
3031 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3032 if (clips.isEmpty()) return;
3033 for (int i = 0; i < clips.count(); i++) {
3034 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3036 //m_projectList->selectItemById(clipIds.at(i));
3040 void MainWindow::slotSelectClipInTimeline()
3042 if (m_activeTimeline) {
3043 QAction *action = qobject_cast<QAction *>(sender());
3044 QStringList data = action->data().toStringList();
3045 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3049 void MainWindow::keyPressEvent(QKeyEvent *ke)
3051 if (m_findActivated) {
3052 if (ke->key() == Qt::Key_Backspace) {
3053 m_findString = m_findString.left(m_findString.length() - 1);
3055 if (!m_findString.isEmpty())
3060 m_findTimer.start(4000);
3063 } else if (ke->key() == Qt::Key_Escape) {
3067 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3068 m_findString += ke->text();
3072 m_findTimer.start(4000);
3077 KXmlGuiWindow::keyPressEvent(ke);
3082 /** Gets called when the window gets hidden */
3083 void MainWindow::hideEvent(QHideEvent */*event*/)
3086 if (m_monitorManager)
3087 m_monitorManager->stopActiveMonitor();
3090 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3092 if (m_findActivated) {
3093 if (event->type() == QEvent::ShortcutOverride) {
3094 QKeyEvent* ke = (QKeyEvent*) event;
3095 if (ke->text().trimmed().isEmpty()) return false;
3102 // pass the event on to the parent class
3103 return QMainWindow::eventFilter(obj, event);
3108 void MainWindow::slotSaveZone(Render *render, QPoint zone)
3110 KDialog *dialog = new KDialog(this);
3111 dialog->setCaption("Save clip zone");
3112 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3114 QWidget *widget = new QWidget(dialog);
3115 dialog->setMainWidget(widget);
3117 QVBoxLayout *vbox = new QVBoxLayout(widget);
3118 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3119 QString path = m_activeDocument->projectFolder().path();
3121 path.append("untitled.mlt");
3122 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
3123 url->setFilter("video/mlt-playlist");
3124 QLabel *label2 = new QLabel(i18n("Description:"), this);
3125 KLineEdit *edit = new KLineEdit(this);
3126 vbox->addWidget(label1);
3127 vbox->addWidget(url);
3128 vbox->addWidget(label2);
3129 vbox->addWidget(edit);
3130 if (dialog->exec() == QDialog::Accepted)
3131 render->saveZone(url->url(), edit->text(), zone);
3135 void MainWindow::slotSetInPoint()
3137 if (m_clipMonitor->isActive())
3138 m_clipMonitor->slotSetZoneStart();
3140 m_projectMonitor->slotSetZoneStart();
3141 //else m_activeTimeline->projectView()->setInPoint();
3144 void MainWindow::slotSetOutPoint()
3146 if (m_clipMonitor->isActive())
3147 m_clipMonitor->slotSetZoneEnd();
3149 m_projectMonitor->slotSetZoneEnd();
3150 // else m_activeTimeline->projectView()->setOutPoint();
3153 void MainWindow::slotResizeItemStart()
3155 if (m_activeTimeline)
3156 m_activeTimeline->projectView()->setInPoint();
3159 void MainWindow::slotResizeItemEnd()
3161 if (m_activeTimeline)
3162 m_activeTimeline->projectView()->setOutPoint();
3165 int MainWindow::getNewStuff(const QString &configFile)
3167 KNS3::Entry::List entries;
3168 #if KDE_IS_VERSION(4,3,80)
3169 KNS3::DownloadDialog dialog(configFile);
3171 entries = dialog.changedEntries();
3172 foreach(const KNS3::Entry &entry, entries) {
3173 if (entry.status() == KNS3::Entry::Installed)
3174 kDebug() << "// Installed files: " << entry.installedFiles();
3177 KNS::Engine engine(0);
3178 if (engine.init(configFile))
3179 entries = engine.downloadDialogModal(this);
3180 foreach(KNS::Entry *entry, entries) {
3181 if (entry->status() == KNS::Entry::Installed)
3182 kDebug() << "// Installed files: " << entry->installedFiles();
3184 #endif /* KDE_IS_VERSION(4,3,80) */
3185 return entries.size();
3188 void MainWindow::slotGetNewTitleStuff()
3190 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3191 TitleWidget::refreshTitleTemplates();
3194 void MainWindow::slotGetNewLumaStuff()
3196 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3197 initEffects::refreshLumas();
3198 m_activeTimeline->projectView()->reloadTransitionLumas();
3202 void MainWindow::slotGetNewRenderStuff()
3204 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3206 m_renderWidget->reloadProfiles();
3209 void MainWindow::slotGetNewMltProfileStuff()
3211 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3212 // update the list of profiles in settings dialog
3213 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3219 void MainWindow::slotAutoTransition()
3221 if (m_activeTimeline)
3222 m_activeTimeline->projectView()->autoTransition();
3225 void MainWindow::slotSplitAudio()
3227 if (m_activeTimeline)
3228 m_activeTimeline->projectView()->splitAudio();
3231 void MainWindow::slotUpdateClipType(QAction *action)
3233 if (m_activeTimeline) {
3234 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3235 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3236 else m_activeTimeline->projectView()->setAudioAndVideo();
3240 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3242 // We must stop the monitors since we create a new on in the dvd wizard
3243 m_clipMonitor->stop();
3244 m_projectMonitor->stop();
3245 DvdWizard w(url, profile, this);
3247 m_projectMonitor->start();
3250 void MainWindow::slotShowTimeline(bool show)
3252 if (show == false) {
3253 m_timelineState = saveState();
3254 centralWidget()->setHidden(true);
3256 centralWidget()->setHidden(false);
3257 restoreState(m_timelineState);
3261 void MainWindow::slotMaximizeCurrent(bool /*show*/)
3263 //TODO: is there a way to maximize current widget?
3266 m_timelineState = saveState();
3267 QWidget *par = focusWidget()->parentWidget();
3268 while (par->parentWidget() && par->parentWidget() != this)
3269 par = par->parentWidget();
3270 kDebug() << "CURRENT WIDGET: " << par->objectName();
3273 //centralWidget()->setHidden(false);
3274 //restoreState(m_timelineState);
3278 void MainWindow::loadTranscoders()
3280 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3283 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3284 KConfigGroup transConfig(config, "Transcoding");
3286 QMap< QString, QString > profiles = transConfig.entryMap();
3287 QMapIterator<QString, QString> i(profiles);
3288 while (i.hasNext()) {
3290 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3291 QAction *a = transMenu->addAction(i.key());
3293 if (data.count() > 1)
3294 a->setToolTip(data.at(1));
3295 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3299 void MainWindow::slotTranscode(KUrl::List urls)
3304 if (urls.isEmpty()) {
3305 QAction *action = qobject_cast<QAction *>(sender());
3306 QStringList data = action->data().toStringList();
3307 params = data.at(0);
3308 if (data.count() > 1) desc = data.at(1);
3309 if (data.count() > 2) condition = data.at(2);
3310 urls << m_projectList->getConditionalUrls(condition);
3311 urls.removeAll(KUrl());
3313 if (urls.isEmpty()) {
3314 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3317 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3318 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3320 //QProcess::startDetached("ffmpeg", parameters);
3323 void MainWindow::slotTranscodeClip()
3325 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3326 if (urls.isEmpty()) return;
3327 slotTranscode(urls);
3330 void MainWindow::slotSetDocumentRenderProfile(const QString &dest, const QString &group, const QString &name, const QString &file)
3332 if (m_activeDocument == NULL) return;
3333 m_activeDocument->setDocumentProperty("renderdestination", dest);
3334 m_activeDocument->setDocumentProperty("rendercategory", group);
3335 m_activeDocument->setDocumentProperty("renderprofile", name);
3336 m_activeDocument->setDocumentProperty("renderurl", file);
3337 m_activeDocument->setModified(true);
3341 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3343 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3345 QString playlistPath;
3348 QString scriptsFolder = m_activeDocument->projectFolder().path() + "/scripts/";
3349 QString path = m_renderWidget->getFreeScriptName();
3350 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3351 if (!ok || scriptPath.isEmpty()) return;
3352 scriptPath.prepend(scriptsFolder);
3353 QFile f(scriptPath);
3355 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3358 playlistPath = scriptPath + ".mlt";
3359 m_projectMonitor->saveSceneList(playlistPath);
3361 KTemporaryFile temp;
3362 temp.setAutoRemove(false);
3363 temp.setSuffix(".mlt");
3365 playlistPath = temp.fileName();
3366 m_projectMonitor->saveSceneList(playlistPath);
3369 if (!chapterFile.isEmpty()) {
3372 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3374 in = m_activeTimeline->inPoint();
3375 out = m_activeTimeline->outPoint();
3378 QDomElement chapters = doc.createElement("chapters");
3379 chapters.setAttribute("fps", m_activeDocument->fps());
3380 doc.appendChild(chapters);
3382 QDomElement guidesxml = m_activeDocument->guidesXml();
3383 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3384 for (int i = 0; i < nodes.count(); i++) {
3385 QDomElement e = nodes.item(i).toElement();
3387 QString comment = e.attribute("comment");
3388 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3389 if (time >= in && time < out) {
3390 if (zoneOnly) time = time - in;
3391 QDomElement chapter = doc.createElement("chapter");
3392 chapters.appendChild(chapter);
3393 chapter.setAttribute("title", comment);
3394 chapter.setAttribute("time", time);
3398 if (chapters.childNodes().count() > 0) {
3399 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3400 // Always insert a guide in pos 0
3401 QDomElement chapter = doc.createElement("chapter");
3402 chapters.insertBefore(chapter, QDomNode());
3403 chapter.setAttribute("title", i18n("Start"));
3404 chapter.setAttribute("time", "0");
3406 // save chapters file
3407 QFile file(chapterFile);
3408 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3409 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3411 file.write(doc.toString().toUtf8());
3412 if (file.error() != QFile::NoError) {
3413 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3420 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath);
3423 void MainWindow::slotUpdateTimecodeFormat(int ix)
3425 KdenliveSettings::setFrametimecode(ix == 1);
3426 m_clipMonitor->updateTimecodeFormat();
3427 m_projectMonitor->updateTimecodeFormat();
3428 m_transitionConfig->updateTimecodeFormat();
3429 m_effectStack->updateTimecodeFormat();
3430 //m_activeTimeline->projectView()->clearSelection();
3431 m_activeTimeline->updateRuler();
3434 void MainWindow::slotRemoveFocus()
3436 statusBar()->setFocus();
3437 statusBar()->clearFocus();
3440 void MainWindow::slotRevert()
3442 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;
3443 KUrl url = m_activeDocument->url();
3444 closeCurrentDocument(false);
3445 doOpenFile(url, NULL);
3449 void MainWindow::slotShutdown()
3451 if (m_activeDocument) m_activeDocument->setModified(false);
3453 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
3454 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
3455 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
3456 smserver.call("logout", 1, 2, 2);
3457 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
3458 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
3459 smserver.call("Shutdown");
3463 void MainWindow::slotUpdateTrackInfo()
3465 if (m_activeDocument)
3466 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
3469 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
3471 // Load the theme file
3473 if (action == NULL) theme = themename;
3474 else theme = action->data().toString();
3475 KdenliveSettings::setColortheme(theme);
3476 // Make palette for all widgets.
3478 if (theme.isEmpty())
3479 plt = QApplication::desktop()->palette();
3481 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
3482 plt = KGlobalSettings::createApplicationPalette(config);
3485 kapp->setPalette(plt);
3486 const QObjectList children = statusBar()->children();
3488 foreach(QObject *child, children) {
3489 if (child->isWidgetType())
3490 ((QWidget*)child)->setPalette(plt);
3491 const QObjectList subchildren = child->children();
3492 foreach(QObject *subchild, subchildren) {
3493 if (subchild->isWidgetType())
3494 ((QWidget*)subchild)->setPalette(plt);
3497 if (m_activeTimeline)
3498 m_activeTimeline->projectView()->updatePalette();
3502 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
3504 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
3505 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
3506 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
3507 const QSize bitsSize(24, 2);
3508 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
3509 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
3511 QPixmap pixmap(23, 16);
3512 pixmap.fill(Qt::black); // ### use some color other than black for borders?
3514 KConfigGroup group(config, "WM");
3515 QPainter p(&pixmap);
3516 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
3517 p.fillRect(1, 1, 7, 7, windowScheme.background());
3518 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
3520 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
3521 p.fillRect(8, 1, 7, 7, buttonScheme.background());
3522 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
3524 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
3525 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
3527 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
3528 p.fillRect(1, 8, 7, 7, viewScheme.background());
3529 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
3531 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
3532 p.fillRect(8, 8, 7, 7, selectionScheme.background());
3533 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
3535 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
3536 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
3542 void MainWindow::slotSwitchMonitors()
3544 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
3545 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
3546 else m_projectList->focusTree();
3549 void MainWindow::slotInsertZoneToTree()
3551 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
3552 QStringList info = m_clipMonitor->getZoneInfo();
3553 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
3556 void MainWindow::slotInsertZoneToTimeline()
3558 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
3559 QStringList info = m_clipMonitor->getZoneInfo();
3560 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
3564 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
3566 if (m_activeDocument && m_activeTimeline) {
3567 if (!ids.isEmpty()) {
3568 for (int i = 0; i < ids.size(); ++i) {
3569 m_activeTimeline->slotDeleteClip(ids.at(i));
3571 m_activeDocument->clipManager()->slotDeleteClips(ids);
3573 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
3574 m_activeDocument->setModified(true);
3578 void MainWindow::slotShowTitleBars(bool show)
3581 m_effectStackDock->setTitleBarWidget(0);
3582 m_clipMonitorDock->setTitleBarWidget(0);
3583 m_projectMonitorDock->setTitleBarWidget(0);
3585 m_recMonitorDock->setTitleBarWidget(0);
3587 m_effectListDock->setTitleBarWidget(0);
3588 m_transitionConfigDock->setTitleBarWidget(0);
3589 m_projectListDock->setTitleBarWidget(0);
3590 m_undoViewDock->setTitleBarWidget(0);
3591 m_vectorscopeDock->setTitleBarWidget(0);
3593 if (!m_effectStackDock->isFloating()) { m_effectStackDock->setTitleBarWidget(new QWidget(this)); }
3594 if (!m_clipMonitorDock->isFloating()) { m_clipMonitorDock->setTitleBarWidget(new QWidget(this)); }
3595 if (!m_projectMonitorDock->isFloating()) { m_projectMonitorDock->setTitleBarWidget(new QWidget(this)); }
3597 if (!m_recMonitorDock->isFloating()) { m_recMonitorDock->setTitleBarWidget(new QWidget(this)); }
3599 if (!m_effectListDock->isFloating()) { m_effectListDock->setTitleBarWidget(new QWidget(this)); }
3600 if (!m_transitionConfigDock->isFloating()) { m_transitionConfigDock->setTitleBarWidget(new QWidget(this)); }
3601 if (!m_projectListDock->isFloating()) { m_projectListDock->setTitleBarWidget(new QWidget(this)); }
3602 if (!m_undoViewDock->isFloating()) { m_undoViewDock->setTitleBarWidget(new QWidget(this)); }
3603 if (!m_vectorscopeDock->isFloating()) { m_vectorscopeDock->setTitleBarWidget(new QWidget(this)); }
3605 KdenliveSettings::setShowtitlebars(show);
3608 void MainWindow::slotSwitchTitles()
3610 slotShowTitleBars(!KdenliveSettings::showtitlebars());
3613 QString MainWindow::getMimeType()
3615 QString mimetype = "application/x-kdenlive";
3616 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
3617 if (!mime) mimetype = "*.kdenlive";
3621 #include "mainwindow.moc"