1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
21 #include "mainwindow.h"
22 #include "mainwindowadaptor.h"
23 #include "kdenlivesettings.h"
24 #include "kdenlivesettingsdialog.h"
25 #include "initeffects.h"
26 #include "profilesdialog.h"
27 #include "projectsettings.h"
29 #include "clipmanager.h"
30 #include "projectlist.h"
32 #include "recmonitor.h"
33 #include "monitormanager.h"
34 #include "kdenlivedoc.h"
35 #include "trackview.h"
36 #include "customtrackview.h"
37 #include "effectslistview.h"
38 #include "effectstackview.h"
39 #include "transitionsettings.h"
40 #include "renderwidget.h"
43 #include "jogshuttle.h"
44 #endif /* NO_JOGSHUTTLE */
45 #include "clipproperties.h"
47 #include "editclipcommand.h"
48 #include "titlewidget.h"
49 #include "markerdialog.h"
51 #include "interfaces.h"
52 #include "kdenlive-config.h"
53 #include "cliptranscode.h"
54 #include "ui_templateclip_ui.h"
56 #include <KApplication>
60 #include <KActionCollection>
61 #include <KStandardAction>
62 #include <KFileDialog>
63 #include <KMessageBox>
65 #include <KIO/NetAccess>
68 #include <KConfigDialog>
69 #include <KXMLGUIFactory>
71 #include <kstandarddirs.h>
72 #include <KUrlRequesterDialog>
73 #include <KTemporaryFile>
75 #include <KActionMenu>
78 #include <ktogglefullscreenaction.h>
80 #include <KNotification>
81 #include <KNotifyConfigWidget>
82 #if KDE_IS_VERSION(4,3,80)
83 #include <knewstuff3/downloaddialog.h>
84 #include <knewstuff3/knewstuffaction.h>
86 #include <knewstuff2/engine.h>
87 #include <knewstuff2/ui/knewstuffaction.h>
89 #endif /* KDE_IS_VERSION(4,3,80) */
91 #include <KColorScheme>
93 #include <QTextStream>
97 #include <QInputDialog>
98 #include <QDesktopWidget>
103 static const char version[] = VERSION;
105 static const int ID_TIMELINE_POS = 0;
112 EffectsList MainWindow::videoEffects;
113 EffectsList MainWindow::audioEffects;
114 EffectsList MainWindow::customEffects;
115 EffectsList MainWindow::transitions;
117 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent) :
118 KXmlGuiWindow(parent),
119 m_activeDocument(NULL),
120 m_activeTimeline(NULL),
121 m_renderWidget(NULL),
122 #ifndef NO_JOGSHUTTLE
124 #endif /* NO_JOGSHUTTLE */
125 m_findActivated(false)
128 // Create DBus interface
129 new MainWindowAdaptor(this);
130 QDBusConnection dbus = QDBusConnection::sessionBus();
131 dbus.registerObject("/MainWindow", this);
133 setlocale(LC_NUMERIC, "POSIX");
134 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
135 setFont(KGlobalSettings::toolBarFont());
136 parseProfiles(MltPath);
137 m_commandStack = new QUndoGroup;
138 m_timelineArea = new KTabWidget(this);
139 m_timelineArea->setTabReorderingEnabled(true);
140 m_timelineArea->setTabBarHidden(true);
142 QToolButton *closeTabButton = new QToolButton;
143 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
144 closeTabButton->setIcon(KIcon("tab-close"));
145 closeTabButton->adjustSize();
146 closeTabButton->setToolTip(i18n("Close the current tab"));
147 m_timelineArea->setCornerWidget(closeTabButton);
148 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
150 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
151 m_findTimer.setSingleShot(true);
153 // FIXME: the next call returns a newly allocated object, which leaks
154 initEffects::parseEffectFiles();
155 //initEffects::parseCustomEffectsFile();
157 m_monitorManager = new MonitorManager();
159 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
160 m_projectListDock->setObjectName("project_tree");
161 m_projectList = new ProjectList(this);
162 m_projectListDock->setWidget(m_projectList);
163 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
165 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
166 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
168 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
169 m_effectListDock->setObjectName("effect_list");
170 m_effectList = new EffectsListView();
172 //m_effectList = new KListWidget(this);
173 m_effectListDock->setWidget(m_effectList);
174 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
176 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
177 m_effectStackDock->setObjectName("effect_stack");
178 m_effectStack = new EffectStackView(this);
179 m_effectStackDock->setWidget(m_effectStack);
180 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
182 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
183 m_transitionConfigDock->setObjectName("transition");
184 m_transitionConfig = new TransitionSettings(this);
185 m_transitionConfigDock->setWidget(m_transitionConfig);
186 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
188 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
189 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
191 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
192 m_fileRevert->setEnabled(false);
194 //slotDetectAudioDriver();
196 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
197 m_clipMonitorDock->setObjectName("clip_monitor");
198 m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), this);
199 m_clipMonitorDock->setWidget(m_clipMonitor);
200 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
201 //m_clipMonitor->stop();
203 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
204 m_projectMonitorDock->setObjectName("project_monitor");
205 m_projectMonitor = new Monitor("project", m_monitorManager, QString(), this);
206 m_projectMonitorDock->setWidget(m_projectMonitor);
207 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
210 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
211 m_recMonitorDock->setObjectName("record_monitor");
212 m_recMonitor = new RecMonitor("record", this);
213 m_recMonitorDock->setWidget(m_recMonitor);
214 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
216 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
217 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
220 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
221 m_undoViewDock->setObjectName("undo_history");
222 m_undoView = new QUndoView(this);
223 m_undoView->setCleanIcon(KIcon("edit-clear"));
224 m_undoView->setEmptyLabel(i18n("Clean"));
225 m_undoViewDock->setWidget(m_undoView);
226 m_undoView->setGroup(m_commandStack);
227 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
229 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
230 //overviewDock->setObjectName("project_overview");
231 //m_overView = new CustomTrackView(NULL, NULL, this);
232 //overviewDock->setWidget(m_overView);
233 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
236 //tabifyDockWidget(projectListDock, effectListDock);
237 tabifyDockWidget(m_projectListDock, m_effectStackDock);
238 tabifyDockWidget(m_projectListDock, m_transitionConfigDock);
239 //tabifyDockWidget(projectListDock, undoViewDock);
242 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
244 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
246 setCentralWidget(m_timelineArea);
249 // Find QDockWidget tab bars and show / hide widget title bars on right click
250 QList <QTabBar *> tabs = findChildren<QTabBar *>();
251 for (int i = 0; i < tabs.count(); i++) {
252 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
253 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
256 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
257 guiFactory()->addClient(sp);*/
261 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
263 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone);
264 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
266 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
267 clipInTimeline->setIcon(KIcon("go-jump"));
268 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)),
269 static_cast<QMenu*>(factory()->container("transcoders", this)),
273 // build themes menus
274 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
275 QActionGroup *themegroup = new QActionGroup(this);
276 themegroup->setExclusive(true);
277 action = new KAction(i18n("Default"), this);
278 action->setCheckable(true);
279 themegroup->addAction(action);
280 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
282 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
284 for (int i = 0; i < schemeFiles.size(); ++i) {
286 const QString filename = schemeFiles.at(i);
287 const QFileInfo info(filename);
290 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
291 QIcon icon = createSchemePreviewIcon(config);
292 KConfigGroup group(config, "General");
293 const QString name = group.readEntry("Name", info.baseName());
294 action = new KAction(name, this);
295 action->setData(filename);
296 action->setIcon(icon);
297 action->setCheckable(true);
298 themegroup->addAction(action);
299 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
302 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
303 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
304 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
307 action = new QAction(fi.fileName(), this);
308 action->setData(*it);
309 action->setCheckable(true);
310 themegroup->addAction(action);
311 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
313 themesMenu->addActions(themegroup->actions());
314 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
316 // Setup and fill effects and transitions menus.
317 m_videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
318 for (int i = 0; i < videoEffects.count(); ++i)
319 m_videoEffectsMenu->addAction(m_videoEffects[i]);
320 m_audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
321 for (int i = 0; i < audioEffects.count(); ++i)
322 m_audioEffectsMenu->addAction(m_audioEffects[i]);
323 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
324 if (customEffects.isEmpty())
325 m_customEffectsMenu->setEnabled(false);
327 m_customEffectsMenu->setEnabled(true);
328 for (int i = 0; i < customEffects.count(); ++i)
329 m_customEffectsMenu->addAction(m_customEffects[i]);
330 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
331 for (int i = 0; i < transitions.count(); ++i)
332 m_transitionsMenu->addAction(m_transitions[i]);
334 connect(m_videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
335 connect(m_audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
336 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
337 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
339 QMenu *newEffect = new QMenu(this);
340 newEffect->addMenu(m_videoEffectsMenu);
341 newEffect->addMenu(m_audioEffectsMenu);
342 newEffect->addMenu(m_customEffectsMenu);
343 m_effectStack->setMenu(newEffect);
345 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
346 const QList<QAction *> viewActions = createPopupMenu()->actions();
347 viewMenu->insertActions(NULL, viewActions);
349 m_timelineContextMenu = new QMenu(this);
350 m_timelineContextClipMenu = new QMenu(this);
351 m_timelineContextTransitionMenu = new QMenu(this);
353 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
354 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
355 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
357 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
358 m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
359 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
360 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
361 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
362 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
363 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
364 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
365 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
367 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
368 m_timelineContextClipMenu->addMenu(markersMenu);
369 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
370 m_timelineContextClipMenu->addMenu(m_videoEffectsMenu);
371 m_timelineContextClipMenu->addMenu(m_audioEffectsMenu);
372 //TODO: re-enable custom effects menu when it is implemented
373 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
375 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
376 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
377 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
379 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
381 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
382 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
383 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
384 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
385 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
386 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
388 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
389 slotConnectMonitors();
391 // Disable drop B frames, see Kdenlive issue #1330, see also kdenlivesettingsdialog.cpp
392 KdenliveSettings::setDropbframes(false);
394 // Open or create a file. Command line argument passed in Url has
395 // precedence, then "openlastproject", then just a plain empty file.
396 // If opening Url fails, openlastproject will _not_ be used.
397 if (!Url.isEmpty()) {
398 // delay loading so that the window shows up
400 QTimer::singleShot(500, this, SLOT(openFile()));
401 } else if (KdenliveSettings::openlastproject()) {
402 QTimer::singleShot(500, this, SLOT(openLastFile()));
403 } else { //if (m_timelineArea->count() == 0) {
407 #ifndef NO_JOGSHUTTLE
408 activateShuttleDevice();
409 #endif /* NO_JOGSHUTTLE */
410 m_projectListDock->raise();
413 void MainWindow::queryQuit()
416 if (m_projectMonitor) m_projectMonitor->stop();
417 if (m_clipMonitor) m_clipMonitor->stop();
418 delete m_effectStack;
419 delete m_activeTimeline;
421 // This sometimes causes crash on exit on OS X for some reason.
422 delete m_projectMonitor;
423 delete m_clipMonitor;
425 delete m_activeDocument;
426 delete m_shortcutRemoveFocus;
427 Mlt::Factory::close();
433 bool MainWindow::queryClose()
435 if (m_renderWidget) {
436 int waitingJobs = m_renderWidget->waitingJobsCount();
437 if (waitingJobs > 0) {
438 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")))) {
439 case KMessageBox::Yes :
440 // create script with waiting jobs and start it
441 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
443 case KMessageBox::No :
444 // Don't do anything, jobs will be deleted
452 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
453 if (m_activeDocument && m_activeDocument->isModified()) {
454 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
455 case KMessageBox::Yes :
456 // save document here. If saving fails, return false;
458 case KMessageBox::No :
459 // User does not want to save the changes, clear recovery files
460 m_activeDocument->m_autosave->resize(0);
470 void MainWindow::loadPlugins()
472 foreach(QObject *plugin, QPluginLoader::staticInstances())
473 populateMenus(plugin);
475 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
477 filters << "libkdenlive*";
478 foreach(const QString &folder, directories) {
479 kDebug() << "// PARSING FIOLER: " << folder;
480 QDir pluginsDir(folder);
481 foreach(const QString &fileName, pluginsDir.entryList(filters, QDir::Files)) {
482 kDebug() << "// FOUND PLUGIN: " << fileName << "= " << pluginsDir.absoluteFilePath(fileName);
483 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
484 QObject *plugin = loader.instance();
486 populateMenus(plugin);
487 m_pluginFileNames += fileName;
488 } else kDebug() << "// ERROR LOADING PLUGIN: " << fileName << ", " << loader.errorString();
494 void MainWindow::populateMenus(QObject *plugin)
496 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
497 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
499 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
503 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
504 QMenu *menu, const char *member,
505 QActionGroup *actionGroup)
507 kDebug() << "// ADD to MENU" << texts;
508 foreach(const QString &text, texts) {
509 QAction *action = new QAction(text, plugin);
510 action->setData(text);
511 connect(action, SIGNAL(triggered()), this, member);
512 menu->addAction(action);
515 action->setCheckable(true);
516 actionGroup->addAction(action);
521 void MainWindow::aboutPlugins()
523 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
528 void MainWindow::generateClip()
530 QAction *action = qobject_cast<QAction *>(sender());
531 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
533 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
534 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
535 if (!clipUrl.isEmpty()) {
536 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
540 void MainWindow::saveProperties(KConfigGroup &config)
542 // save properties here,used by session management
544 KMainWindow::saveProperties(config);
548 void MainWindow::readProperties(const KConfigGroup &config)
550 // read properties here,used by session management
551 KMainWindow::readProperties(config);
552 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
553 openFile(KUrl(Lastproject));
556 void MainWindow::slotReloadEffects()
558 m_customEffectsMenu->clear();
559 initEffects::parseCustomEffectsFile();
561 QStringList effectInfo;
562 QMap<QString, QStringList> effectsList;
564 for (int ix = 0; ix < customEffects.count(); ix++) {
565 effectInfo = customEffects.effectIdInfo(ix);
566 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
568 if (effectsList.isEmpty()) {
569 m_customEffectsMenu->setEnabled(false);
571 } else m_customEffectsMenu->setEnabled(true);
573 foreach(const QStringList &value, effectsList) {
574 action = new QAction(value.at(0), this);
575 action->setData(value);
576 m_customEffectsMenu->addAction(action);
578 m_effectList->reloadEffectList();
581 #ifndef NO_JOGSHUTTLE
582 void MainWindow::activateShuttleDevice()
586 if (KdenliveSettings::enableshuttle() == false) return;
587 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
588 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
589 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
590 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
591 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
592 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
593 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
596 void MainWindow::slotShuttleButton(int code)
600 slotShuttleAction(KdenliveSettings::shuttle1());
603 slotShuttleAction(KdenliveSettings::shuttle2());
606 slotShuttleAction(KdenliveSettings::shuttle3());
609 slotShuttleAction(KdenliveSettings::shuttle4());
612 slotShuttleAction(KdenliveSettings::shuttle5());
617 void MainWindow::slotShuttleAction(int code)
623 m_monitorManager->slotPlay();
626 m_monitorManager->slotPlay();
630 #endif /* NO_JOGSHUTTLE */
632 void MainWindow::configureNotifications()
634 KNotifyConfigWidget::configure(this);
637 void MainWindow::slotFullScreen()
639 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
642 void MainWindow::slotAddEffect(const QDomElement effect, GenTime pos, int track)
644 if (!m_activeDocument) return;
645 if (effect.isNull()) {
646 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
649 QDomElement effectToAdd = effect.cloneNode().toElement();
650 m_activeTimeline->projectView()->slotAddEffect(effectToAdd, pos, track);
653 void MainWindow::slotRaiseMonitor(bool clipMonitor)
655 if (clipMonitor) m_clipMonitorDock->raise();
656 else m_projectMonitorDock->raise();
659 void MainWindow::slotUpdateClip(const QString &id)
661 if (!m_activeDocument) return;
662 m_activeTimeline->projectView()->slotUpdateClip(id);
665 void MainWindow::slotConnectMonitors()
667 m_projectList->setRenderer(m_projectMonitor->render);
668 //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
669 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
670 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
671 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
672 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, int, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, int, bool)));
673 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
674 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)));
676 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
678 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
680 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
681 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
683 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
684 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
687 void MainWindow::slotAdjustClipMonitor()
689 m_clipMonitorDock->updateGeometry();
690 m_clipMonitorDock->adjustSize();
691 m_clipMonitor->resetSize();
694 void MainWindow::slotAdjustProjectMonitor()
696 m_projectMonitorDock->updateGeometry();
697 m_projectMonitorDock->adjustSize();
698 m_projectMonitor->resetSize();
701 void MainWindow::setupActions()
704 KActionCollection* collection = actionCollection();
705 m_timecodeFormat = new KComboBox(this);
706 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
707 m_timecodeFormat->addItem(i18n("Frames"));
708 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
709 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
711 m_statusProgressBar = new QProgressBar(this);
712 m_statusProgressBar->setMinimum(0);
713 m_statusProgressBar->setMaximum(100);
714 m_statusProgressBar->setMaximumWidth(150);
715 m_statusProgressBar->setVisible(false);
717 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
718 toolbar->setMovable(false);
719 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
720 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;}";
721 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
723 //create edit mode buttons
724 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
725 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
726 toolbar->addAction(m_normalEditTool);
727 m_normalEditTool->setCheckable(true);
728 m_normalEditTool->setChecked(true);
730 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
731 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
732 toolbar->addAction(m_overwriteEditTool);
733 m_overwriteEditTool->setCheckable(true);
734 m_overwriteEditTool->setChecked(false);
736 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
737 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
738 toolbar->addAction(m_insertEditTool);
739 m_insertEditTool->setCheckable(true);
740 m_insertEditTool->setChecked(false);
741 // not implemented yet
742 m_insertEditTool->setEnabled(false);
744 QActionGroup *editGroup = new QActionGroup(this);
745 editGroup->addAction(m_normalEditTool);
746 editGroup->addAction(m_overwriteEditTool);
747 editGroup->addAction(m_insertEditTool);
748 editGroup->setExclusive(true);
749 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
750 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
752 toolbar->addSeparator();
754 // create tools buttons
755 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
756 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
757 toolbar->addAction(m_buttonSelectTool);
758 m_buttonSelectTool->setCheckable(true);
759 m_buttonSelectTool->setChecked(true);
761 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
762 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
763 toolbar->addAction(m_buttonRazorTool);
764 m_buttonRazorTool->setCheckable(true);
765 m_buttonRazorTool->setChecked(false);
767 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
768 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
769 toolbar->addAction(m_buttonSpacerTool);
770 m_buttonSpacerTool->setCheckable(true);
771 m_buttonSpacerTool->setChecked(false);
773 QActionGroup *toolGroup = new QActionGroup(this);
774 toolGroup->addAction(m_buttonSelectTool);
775 toolGroup->addAction(m_buttonRazorTool);
776 toolGroup->addAction(m_buttonSpacerTool);
777 toolGroup->setExclusive(true);
778 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
780 QWidget * actionWidget;
781 int max = toolbar->iconSizeDefault() + 2;
782 actionWidget = toolbar->widgetForAction(m_normalEditTool);
783 actionWidget->setMaximumWidth(max);
784 actionWidget->setMaximumHeight(max - 4);
786 actionWidget = toolbar->widgetForAction(m_insertEditTool);
787 actionWidget->setMaximumWidth(max);
788 actionWidget->setMaximumHeight(max - 4);
790 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
791 actionWidget->setMaximumWidth(max);
792 actionWidget->setMaximumHeight(max - 4);
794 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
795 actionWidget->setMaximumWidth(max);
796 actionWidget->setMaximumHeight(max - 4);
798 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
799 actionWidget->setMaximumWidth(max);
800 actionWidget->setMaximumHeight(max - 4);
802 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
803 actionWidget->setMaximumWidth(max);
804 actionWidget->setMaximumHeight(max - 4);
806 toolbar->setStyleSheet(style1);
807 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
809 toolbar->addSeparator();
810 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
811 toolbar->addAction(m_buttonFitZoom);
812 m_buttonFitZoom->setCheckable(false);
814 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
815 toolbar->addAction(m_zoomOut);
816 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
818 m_zoomSlider = new QSlider(Qt::Horizontal, this);
819 m_zoomSlider->setMaximum(13);
820 m_zoomSlider->setPageStep(1);
821 m_zoomSlider->setInvertedAppearance(true);
823 m_zoomSlider->setMaximumWidth(150);
824 m_zoomSlider->setMinimumWidth(100);
825 toolbar->addWidget(m_zoomSlider);
827 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
828 toolbar->addAction(m_zoomIn);
829 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
831 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
832 actionWidget->setMaximumWidth(max);
833 actionWidget->setMaximumHeight(max - 4);
834 actionWidget->setStyleSheet(styleBorderless);
836 actionWidget = toolbar->widgetForAction(m_zoomIn);
837 actionWidget->setMaximumWidth(max);
838 actionWidget->setMaximumHeight(max - 4);
839 actionWidget->setStyleSheet(styleBorderless);
841 actionWidget = toolbar->widgetForAction(m_zoomOut);
842 actionWidget->setMaximumWidth(max);
843 actionWidget->setMaximumHeight(max - 4);
844 actionWidget->setStyleSheet(styleBorderless);
846 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
847 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
848 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
849 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
850 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
852 toolbar->addSeparator();
854 //create automatic audio split button
855 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
856 toolbar->addAction(m_buttonAutomaticSplitAudio);
857 m_buttonAutomaticSplitAudio->setCheckable(true);
858 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
859 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
861 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
862 toolbar->addAction(m_buttonVideoThumbs);
863 m_buttonVideoThumbs->setCheckable(true);
864 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
865 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
867 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
868 toolbar->addAction(m_buttonAudioThumbs);
869 m_buttonAudioThumbs->setCheckable(true);
870 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
871 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
873 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
874 toolbar->addAction(m_buttonShowMarkers);
875 m_buttonShowMarkers->setCheckable(true);
876 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
877 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
879 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
880 toolbar->addAction(m_buttonSnap);
881 m_buttonSnap->setCheckable(true);
882 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
883 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
885 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
886 actionWidget->setMaximumWidth(max);
887 actionWidget->setMaximumHeight(max - 4);
889 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
890 actionWidget->setMaximumWidth(max);
891 actionWidget->setMaximumHeight(max - 4);
893 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
894 actionWidget->setMaximumWidth(max);
895 actionWidget->setMaximumHeight(max - 4);
897 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
898 actionWidget->setMaximumWidth(max);
899 actionWidget->setMaximumHeight(max - 4);
901 actionWidget = toolbar->widgetForAction(m_buttonSnap);
902 actionWidget->setMaximumWidth(max);
903 actionWidget->setMaximumHeight(max - 4);
905 m_messageLabel = new StatusBarMessageLabel(this);
906 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
908 statusBar()->addWidget(m_messageLabel, 10);
909 statusBar()->addWidget(m_statusProgressBar, 0);
910 statusBar()->addPermanentWidget(toolbar);
911 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
912 statusBar()->addPermanentWidget(m_timecodeFormat);
913 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
915 collection->addAction("normal_mode", m_normalEditTool);
916 collection->addAction("overwrite_mode", m_overwriteEditTool);
917 collection->addAction("insert_mode", m_insertEditTool);
918 collection->addAction("select_tool", m_buttonSelectTool);
919 collection->addAction("razor_tool", m_buttonRazorTool);
920 collection->addAction("spacer_tool", m_buttonSpacerTool);
922 collection->addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
923 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
924 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
925 collection->addAction("show_markers", m_buttonShowMarkers);
926 collection->addAction("snap", m_buttonSnap);
927 collection->addAction("zoom_fit", m_buttonFitZoom);
928 collection->addAction("zoom_in", m_zoomIn);
929 collection->addAction("zoom_out", m_zoomOut);
931 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
932 collection->addAction("project_find", m_projectSearch);
933 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
934 m_projectSearch->setShortcut(Qt::Key_Slash);
936 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
937 collection->addAction("project_find_next", m_projectSearchNext);
938 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
939 m_projectSearchNext->setShortcut(Qt::Key_F3);
940 m_projectSearchNext->setEnabled(false);
942 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
943 collection->addAction("manage_profiles", profilesAction);
944 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
946 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
948 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
950 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
952 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
954 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
955 collection->addAction("run_wizard", wizAction);
956 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
958 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
959 collection->addAction("project_settings", projectAction);
960 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
962 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
963 collection->addAction("project_render", projectRender);
964 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
965 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
967 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
968 collection->addAction("project_clean", projectClean);
969 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
971 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
972 KShortcut playShortcut;
973 playShortcut.setPrimary(Qt::Key_Space);
974 playShortcut.setAlternate(Qt::Key_K);
975 monitorPlay->setShortcut(playShortcut);
976 collection->addAction("monitor_play", monitorPlay);
977 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
979 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
980 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
981 collection->addAction("monitor_play_zone", m_playZone);
982 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
984 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
985 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
986 collection->addAction("monitor_loop_zone", m_loopZone);
987 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
989 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
990 collection->addAction("dvd_wizard", dvdWizard);
991 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
993 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
994 collection->addAction("transcode_clip", transcodeClip);
995 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
997 KAction *markIn = collection->addAction("mark_in");
998 markIn->setText(i18n("Set Zone In"));
999 markIn->setShortcut(Qt::Key_I);
1000 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1002 KAction *markOut = collection->addAction("mark_out");
1003 markOut->setText(i18n("Set Zone Out"));
1004 markOut->setShortcut(Qt::Key_O);
1005 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1007 KAction *switchMon = collection->addAction("switch_monitor");
1008 switchMon->setText(i18n("Switch monitor"));
1009 switchMon->setShortcut(Qt::Key_T);
1010 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1012 KAction *insertTree = collection->addAction("insert_project_tree");
1013 insertTree->setText(i18n("Insert zone in project tree"));
1014 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1015 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1017 KAction *insertTimeline = collection->addAction("insert_timeline");
1018 insertTimeline->setText(i18n("Insert zone in timeline"));
1019 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1020 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1022 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1023 collection->addAction("resize_timeline_clip_start", resizeStart);
1024 resizeStart->setShortcut(Qt::Key_1);
1025 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1027 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1028 collection->addAction("resize_timeline_clip_end", resizeEnd);
1029 resizeEnd->setShortcut(Qt::Key_2);
1030 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1032 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1033 monitorSeekBackward->setShortcut(Qt::Key_J);
1034 collection->addAction("monitor_seek_backward", monitorSeekBackward);
1035 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1037 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1038 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1039 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1040 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1042 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1043 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1044 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1045 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1047 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1048 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1049 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1050 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1052 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1053 monitorSeekForward->setShortcut(Qt::Key_L);
1054 collection->addAction("monitor_seek_forward", monitorSeekForward);
1055 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1057 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1058 clipStart->setShortcut(Qt::Key_Home);
1059 collection->addAction("seek_clip_start", clipStart);
1060 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1062 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1063 clipEnd->setShortcut(Qt::Key_End);
1064 collection->addAction("seek_clip_end", clipEnd);
1065 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1067 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1068 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1069 collection->addAction("seek_zone_start", zoneStart);
1070 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1072 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1073 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1074 collection->addAction("seek_zone_end", zoneEnd);
1075 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1077 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1078 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1079 collection->addAction("seek_start", projectStart);
1080 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1082 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1083 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1084 collection->addAction("seek_end", projectEnd);
1085 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1087 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1088 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1089 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1090 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1092 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1093 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1094 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1095 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1097 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1098 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1099 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1100 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1102 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1103 deleteItem->setShortcut(Qt::Key_Delete);
1104 collection->addAction("delete_timeline_clip", deleteItem);
1105 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1107 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1108 collection->addAction("change_clip_speed", editTimelineClipSpeed);
1109 editTimelineClipSpeed->setData("change_speed");
1110 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1112 KAction *stickTransition = collection->addAction("auto_transition");
1113 stickTransition->setData(QString("auto"));
1114 stickTransition->setCheckable(true);
1115 stickTransition->setEnabled(false);
1116 stickTransition->setText(i18n("Automatic Transition"));
1117 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1119 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1120 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1121 collection->addAction("group_clip", groupClip);
1122 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1124 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1125 collection->addAction("ungroup_clip", ungroupClip);
1126 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1127 ungroupClip->setData("ungroup_clip");
1128 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1130 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1131 collection->addAction("edit_item_duration", editItemDuration);
1132 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1134 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1135 collection->addAction("clip_in_project_tree", clipInProjectTree);
1136 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1138 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1139 insertOvertwrite->setShortcut(Qt::Key_V);
1140 collection->addAction("overwrite_to_in_point", insertOvertwrite);
1141 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1143 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1144 selectTimelineClip->setShortcut(Qt::Key_Plus);
1145 collection->addAction("select_timeline_clip", selectTimelineClip);
1146 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1148 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1149 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1150 collection->addAction("deselect_timeline_clip", deselectTimelineClip);
1151 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1153 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1154 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1155 collection->addAction("select_add_timeline_clip", selectAddTimelineClip);
1156 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1158 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1159 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1160 collection->addAction("select_timeline_transition", selectTimelineTransition);
1161 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1163 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1164 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1165 collection->addAction("deselect_timeline_transition", deselectTimelineTransition);
1166 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1168 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1169 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1170 collection->addAction("select_add_timeline_transition", selectAddTimelineTransition);
1171 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1173 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1174 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1175 collection->addAction("cut_timeline_clip", cutTimelineClip);
1176 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1178 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1179 collection->addAction("add_clip_marker", addClipMarker);
1180 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1182 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1183 collection->addAction("delete_clip_marker", deleteClipMarker);
1184 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1186 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1187 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
1188 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1190 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1191 collection->addAction("edit_clip_marker", editClipMarker);
1192 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1194 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1195 collection->addAction("split_audio", splitAudio);
1196 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1198 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1199 collection->addAction("clip_audio_only", audioOnly);
1200 audioOnly->setData("clip_audio_only");
1201 audioOnly->setCheckable(true);
1203 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1204 collection->addAction("clip_video_only", videoOnly);
1205 videoOnly->setData("clip_video_only");
1206 videoOnly->setCheckable(true);
1208 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1209 collection->addAction("clip_audio_and_video", audioAndVideo);
1210 audioAndVideo->setData("clip_audio_and_video");
1211 audioAndVideo->setCheckable(true);
1213 m_clipTypeGroup = new QActionGroup(this);
1214 m_clipTypeGroup->addAction(audioOnly);
1215 m_clipTypeGroup->addAction(videoOnly);
1216 m_clipTypeGroup->addAction(audioAndVideo);
1217 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1218 m_clipTypeGroup->setEnabled(false);
1220 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1221 collection->addAction("insert_space", insertSpace);
1222 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1224 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1225 collection->addAction("delete_space", removeSpace);
1226 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1228 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1229 collection->addAction("insert_track", insertTrack);
1230 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1232 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1233 collection->addAction("delete_track", deleteTrack);
1234 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1236 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
1237 collection->addAction("config_tracks", configTracks);
1238 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1240 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1241 collection->addAction("add_guide", addGuide);
1242 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1244 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1245 collection->addAction("delete_guide", delGuide);
1246 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1248 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1249 collection->addAction("edit_guide", editGuide);
1250 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1252 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1253 collection->addAction("delete_all_guides", delAllGuides);
1254 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1256 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1257 collection->addAction("paste_effects", pasteEffects);
1258 pasteEffects->setData("paste_effects");
1259 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1261 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1262 collection->addAction("show_timeline", showTimeline);
1263 showTimeline->setCheckable(true);
1264 showTimeline->setChecked(true);
1265 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1267 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1268 collection->addAction("show_titlebars", showTitleBar);
1269 showTitleBar->setCheckable(true);
1270 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1271 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1272 slotShowTitleBars(KdenliveSettings::showtitlebars());
1274 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1275 collection->addAction("maximize_current", maxCurrent);
1276 maxCurrent->setCheckable(true);
1277 maxCurrent->setChecked(false);
1278 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1281 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1283 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1285 KStandardAction::open(this, SLOT(openFile()), collection);
1287 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1289 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1291 KStandardAction::openNew(this, SLOT(newFile()), collection);
1293 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1295 KStandardAction::configureNotifications(this , SLOT(configureNotifications()), collection);
1297 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1299 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1301 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1302 undo->setEnabled(false);
1303 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1305 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1306 redo->setEnabled(false);
1307 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1309 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1312 //TODO: Add status tooltip to actions ?
1313 connect(collection, SIGNAL(actionHovered(QAction*)),
1314 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1317 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1318 collection->addAction("add_clip", addClip);
1319 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1321 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1322 collection->addAction("add_color_clip", addColorClip);
1323 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1325 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1326 collection->addAction("add_slide_clip", addSlideClip);
1327 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1329 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1330 collection->addAction("add_text_clip", addTitleClip);
1331 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1333 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1334 collection->addAction("add_text_template_clip", addTitleTemplateClip);
1335 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1337 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1338 collection->addAction("add_folder", addFolderButton);
1339 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1341 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1342 collection->addAction("clip_properties", clipProperties);
1343 clipProperties->setData("clip_properties");
1344 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1345 clipProperties->setEnabled(false);
1347 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1348 collection->addAction("edit_clip", openClip);
1349 openClip->setData("edit_clip");
1350 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1351 openClip->setEnabled(false);
1353 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1354 collection->addAction("delete_clip", deleteClip);
1355 deleteClip->setData("delete_clip");
1356 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1357 deleteClip->setEnabled(false);
1359 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1360 collection->addAction("reload_clip", reloadClip);
1361 reloadClip->setData("reload_clip");
1362 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1363 reloadClip->setEnabled(false);
1365 QMenu *addClips = new QMenu();
1366 addClips->addAction(addClip);
1367 addClips->addAction(addColorClip);
1368 addClips->addAction(addSlideClip);
1369 addClips->addAction(addTitleClip);
1370 addClips->addAction(addTitleTemplateClip);
1371 addClips->addAction(addFolderButton);
1373 addClips->addAction(reloadClip);
1374 addClips->addAction(clipProperties);
1375 addClips->addAction(openClip);
1376 addClips->addAction(deleteClip);
1377 m_projectList->setupMenu(addClips, addClip);
1379 // Setup effects and transitions actions.
1380 m_videoEffects = new KAction*[videoEffects.count()];
1381 for (int i = 0; i < videoEffects.count(); ++i) {
1382 QStringList effectInfo = videoEffects.effectIdInfo(i);
1383 m_videoEffects[i] = new KAction(KIcon("kdenlive-show-video"), effectInfo.at(0), this);
1384 m_videoEffects[i]->setData(effectInfo);
1385 m_videoEffects[i]->setIconVisibleInMenu(false);
1386 collection->addAction("video_effect_" + effectInfo.at(0), m_videoEffects[i]);
1388 m_audioEffects = new KAction*[audioEffects.count()];
1389 for (int i = 0; i < audioEffects.count(); ++i) {
1390 QStringList effectInfo = audioEffects.effectIdInfo(i);
1391 m_audioEffects[i] = new KAction(KIcon("kdenlive-show-audio"), effectInfo.at(0), this);
1392 m_audioEffects[i]->setData(effectInfo);
1393 m_audioEffects[i]->setIconVisibleInMenu(false);
1394 collection->addAction("audio_effect_" + effectInfo.at(0), m_audioEffects[i]);
1396 m_customEffects = new KAction*[customEffects.count()];
1397 for (int i = 0; i < customEffects.count(); ++i) {
1398 QStringList effectInfo = customEffects.effectIdInfo(i);
1399 m_customEffects[i] = new KAction(KIcon("kdenlive-custom-effect"), effectInfo.at(0), this);
1400 m_customEffects[i]->setData(effectInfo);
1401 m_customEffects[i]->setIconVisibleInMenu(false);
1402 collection->addAction("custom_effect_" + effectInfo.at(0), m_customEffects[i]);
1404 m_transitions = new KAction*[transitions.count()];
1405 for (int i = 0; i < transitions.count(); i++) {
1406 QStringList effectInfo = transitions.effectIdInfo(i);
1407 m_transitions[i] = new KAction(effectInfo.at(0), this);
1408 m_transitions[i]->setData(effectInfo);
1409 m_transitions[i]->setIconVisibleInMenu(false);
1410 collection->addAction("transition_" + effectInfo.at(0), m_transitions[i]);
1413 //connect(collection, SIGNAL( clearStatusText() ),
1414 //statusBar(), SLOT( clear() ) );
1417 void MainWindow::slotDisplayActionMessage(QAction *a)
1419 statusBar()->showMessage(a->data().toString(), 3000);
1422 void MainWindow::saveOptions()
1424 KdenliveSettings::self()->writeConfig();
1425 KSharedConfigPtr config = KGlobal::config();
1426 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1427 KConfigGroup treecolumns(config, "Project Tree");
1428 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1432 void MainWindow::readOptions()
1434 KSharedConfigPtr config = KGlobal::config();
1435 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1436 KConfigGroup initialGroup(config, "version");
1437 bool upgrade = false;
1438 if (initialGroup.exists()) {
1439 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1443 if (initialGroup.readEntry("version") == "0.7") {
1444 //Add new settings from 0.7.1
1445 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1446 QString path = QDir::homePath() + "/kdenlive";
1447 if (KStandardDirs::makeDir(path) == false) {
1448 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1449 } else KdenliveSettings::setDefaultprojectfolder(path);
1455 if (!initialGroup.exists() || upgrade) {
1456 // this is our first run, show Wizard
1457 Wizard *w = new Wizard(upgrade, this);
1458 if (w->exec() == QDialog::Accepted && w->isOk()) {
1459 w->adjustSettings();
1460 initialGroup.writeEntry("version", version);
1466 KConfigGroup treecolumns(config, "Project Tree");
1467 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1468 if (!state.isEmpty())
1469 m_projectList->setHeaderInfo(state);
1472 void MainWindow::slotRunWizard()
1474 Wizard *w = new Wizard(false, this);
1475 if (w->exec() == QDialog::Accepted && w->isOk()) {
1476 w->adjustSettings();
1481 void MainWindow::newFile(bool showProjectSettings, bool force)
1483 if (!m_timelineArea->isEnabled() && !force) return;
1484 m_fileRevert->setEnabled(false);
1485 QString profileName;
1487 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1488 if (!showProjectSettings) {
1489 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1490 profileName = KdenliveSettings::default_profile();
1491 projectFolder = KdenliveSettings::defaultprojectfolder();
1493 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1494 if (w->exec() != QDialog::Accepted) return;
1495 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1496 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
1497 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
1498 profileName = w->selectedProfile();
1499 projectFolder = w->selectedFolder();
1500 projectTracks = w->tracks();
1503 m_timelineArea->setEnabled(true);
1504 m_projectList->setEnabled(true);
1505 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1506 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1508 TrackView *trackView = new TrackView(doc, &ok, this);
1509 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1512 //m_timelineArea->setEnabled(false);
1513 //m_projectList->setEnabled(false);
1517 if (m_timelineArea->count() == 1) {
1518 connectDocumentInfo(doc);
1519 connectDocument(trackView, doc);
1520 } else m_timelineArea->setTabBarHidden(false);
1521 m_monitorManager->activateMonitor("clip");
1522 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1525 void MainWindow::activateDocument()
1527 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1528 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1529 KdenliveDoc *currentDoc = currentTab->document();
1530 connectDocumentInfo(currentDoc);
1531 connectDocument(currentTab, currentDoc);
1534 void MainWindow::closeCurrentDocument(bool saveChanges)
1536 QWidget *w = m_timelineArea->currentWidget();
1538 // closing current document
1539 int ix = m_timelineArea->currentIndex() + 1;
1540 if (ix == m_timelineArea->count()) ix = 0;
1541 m_timelineArea->setCurrentIndex(ix);
1542 TrackView *tabToClose = (TrackView *) w;
1543 KdenliveDoc *docToClose = tabToClose->document();
1544 if (docToClose && docToClose->isModified() && saveChanges) {
1545 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
1546 case KMessageBox::Yes :
1547 // save document here. If saving fails, return false;
1548 if (saveFile() == false) return;
1550 case KMessageBox::Cancel :
1557 m_clipMonitor->slotSetXml(NULL);
1558 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1559 if (m_timelineArea->count() == 1) {
1560 m_timelineArea->setTabBarHidden(true);
1561 m_closeAction->setEnabled(false);
1563 if (docToClose == m_activeDocument) {
1564 delete m_activeDocument;
1565 m_activeDocument = NULL;
1566 m_effectStack->clear();
1567 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1568 } else delete docToClose;
1569 if (w == m_activeTimeline) {
1570 delete m_activeTimeline;
1571 m_activeTimeline = NULL;
1575 bool MainWindow::saveFileAs(const QString &outputFileName)
1577 QString currentSceneList;
1578 m_monitorManager->stopActiveMonitor();
1579 if (KdenliveSettings::dropbframes()) {
1580 KdenliveSettings::setDropbframes(false);
1581 m_activeDocument->clipManager()->updatePreviewSettings();
1582 currentSceneList = m_projectMonitor->sceneList();
1583 KdenliveSettings::setDropbframes(true);
1584 m_activeDocument->clipManager()->updatePreviewSettings();
1585 } else currentSceneList = m_projectMonitor->sceneList();
1587 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1590 // Save timeline thumbnails
1591 m_activeTimeline->projectView()->saveThumbnails();
1592 m_activeDocument->setUrl(KUrl(outputFileName));
1593 if (m_activeDocument->m_autosave == NULL) {
1594 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1595 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1596 setCaption(m_activeDocument->description());
1597 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1598 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1599 m_activeDocument->setModified(false);
1600 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1601 m_fileRevert->setEnabled(true);
1605 bool MainWindow::saveFileAs()
1607 QString outputFile = KFileDialog::getSaveFileName(KUrl(), getMimeType());
1608 if (outputFile.isEmpty()) return false;
1609 if (QFile::exists(outputFile)) {
1610 // Show the file dialog again if the user does not want to overwrite the file
1611 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it?")) == KMessageBox::No)
1612 return saveFileAs();
1614 return saveFileAs(outputFile);
1617 bool MainWindow::saveFile()
1619 if (!m_activeDocument) return true;
1620 if (m_activeDocument->url().isEmpty()) {
1621 return saveFileAs();
1623 bool result = saveFileAs(m_activeDocument->url().path());
1624 m_activeDocument->m_autosave->resize(0);
1629 void MainWindow::openFile()
1631 if (!m_startUrl.isEmpty()) {
1632 openFile(m_startUrl);
1633 m_startUrl = KUrl();
1636 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
1637 if (url.isEmpty()) return;
1638 m_fileOpenRecent->addUrl(url);
1642 void MainWindow::openLastFile()
1644 KSharedConfigPtr config = KGlobal::config();
1645 KUrl::List urls = m_fileOpenRecent->urls();
1646 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1647 if (urls.isEmpty()) newFile(false);
1648 else openFile(urls.last());
1651 void MainWindow::openFile(const KUrl &url)
1653 // Check if the document is already opened
1654 const int ct = m_timelineArea->count();
1655 bool isOpened = false;
1657 for (i = 0; i < ct; i++) {
1658 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1659 KdenliveDoc *doc = tab->document();
1660 if (doc->url() == url) {
1666 m_timelineArea->setCurrentIndex(i);
1670 // Check for backup file
1671 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1672 if (!staleFiles.isEmpty()) {
1673 if (KMessageBox::questionYesNo(this,
1674 i18n("Auto-saved files exist. Do you want to recover them now?"),
1675 i18n("File Recovery"),
1676 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1677 recoverFiles(staleFiles);
1680 // remove the stale files
1681 foreach(KAutoSaveFile *stale, staleFiles) {
1682 stale->open(QIODevice::ReadWrite);
1687 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1688 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
1689 m_messageLabel->repaint();
1690 doOpenFile(url, NULL);
1693 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1695 if (!m_timelineArea->isEnabled()) return;
1696 m_fileRevert->setEnabled(true);
1697 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, this);
1698 if (stale == NULL) {
1699 stale = new KAutoSaveFile(url, doc);
1700 doc->m_autosave = stale;
1702 doc->m_autosave = stale;
1703 doc->setUrl(stale->managedFile());
1704 doc->setModified(true);
1705 stale->setParent(doc);
1707 connectDocumentInfo(doc);
1709 TrackView *trackView = new TrackView(doc, &ok, this);
1710 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1712 m_timelineArea->setEnabled(false);
1713 m_projectList->setEnabled(false);
1714 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
1715 slotGotProgressInfo(QString(), -1);
1716 newFile(false, true);
1719 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1720 trackView->setDuration(trackView->duration());
1721 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1723 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1724 slotGotProgressInfo(QString(), -1);
1725 m_projectMonitor->adjustRulerSize(trackView->duration());
1726 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1727 m_clipMonitor->refreshMonitor(true);
1730 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1732 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1733 foreach(KAutoSaveFile *stale, staleFiles) {
1734 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1735 // show an error message; we could not steal the lockfile
1736 // maybe another application got to the file before us?
1740 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1741 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
1742 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1743 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1747 void MainWindow::parseProfiles(const QString &mltPath)
1749 //KdenliveSettings::setDefaulttmpfolder();
1750 if (!mltPath.isEmpty()) {
1751 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1752 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
1755 if (KdenliveSettings::mltpath().isEmpty()) {
1756 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1759 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
1760 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
1761 if (!QFile::exists(meltPath))
1762 meltPath = KStandardDirs::findExe("melt");
1763 KdenliveSettings::setRendererpath(meltPath);
1766 if (KdenliveSettings::rendererpath().isEmpty()) {
1767 // Cannot find the MLT melt renderer, ask for location
1768 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
1769 if (getUrl->exec() == QDialog::Rejected) {
1772 KUrl rendererPath = getUrl->selectedUrl();
1774 if (rendererPath.isEmpty()) ::exit(0);
1775 KdenliveSettings::setRendererpath(rendererPath.path());
1778 QStringList profilesFilter;
1779 profilesFilter << "*";
1780 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1781 if (profilesList.isEmpty()) {
1782 // Cannot find MLT path, try finding melt
1783 QString profilePath = KdenliveSettings::rendererpath();
1784 if (!profilePath.isEmpty()) {
1785 profilePath = profilePath.section('/', 0, -3);
1786 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1787 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1789 if (profilesList.isEmpty()) {
1790 // Cannot find the MLT profiles, ask for location
1791 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
1792 getUrl->fileDialog()->setMode(KFile::Directory);
1793 if (getUrl->exec() == QDialog::Rejected) {
1796 KUrl mltPath = getUrl->selectedUrl();
1798 if (mltPath.isEmpty()) ::exit(0);
1799 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
1800 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1804 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1806 // Parse again MLT profiles to build a list of available video formats
1807 if (profilesList.isEmpty()) parseProfiles();
1811 void MainWindow::slotEditProfiles()
1813 ProfilesDialog *w = new ProfilesDialog;
1814 if (w->exec() == QDialog::Accepted) {
1815 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1816 if (d) d->checkProfile();
1821 void MainWindow::slotDetectAudioDriver()
1823 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
1824 leading to no audio output, see bug #934 */
1826 //decide which audio driver is really best, in some cases SDL is wrong
1827 if (KdenliveSettings::audiodrivername().isEmpty()) {
1829 KProcess readProcess;
1830 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
1831 if (!KStandardDirs::findExe("pactl").isEmpty()) {
1832 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
1833 readProcess.setProgram("pactl", QStringList() << "stat");
1834 readProcess.execute(2000); // Kill it after 2 seconds
1836 QString result = QString(readProcess.readAllStandardOutput());
1837 kDebug() << "// / / / / / READING PACTL: ";
1839 if (!result.isEmpty()) {
1841 kDebug() << "// / / / / PULSEAUDIO DETECTED";
1845 KdenliveSettings::setAutoaudiodrivername(driver);
1849 void MainWindow::slotEditProjectSettings()
1851 QPoint p = m_activeDocument->getTracksCount();
1852 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
1854 if (w->exec() == QDialog::Accepted) {
1855 QString profile = w->selectedProfile();
1856 m_activeDocument->setProjectFolder(w->selectedFolder());
1857 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path(KUrl::AddTrailingSlash));
1858 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
1859 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
1860 if (m_activeDocument->profilePath() != profile) {
1861 // Profile was changed
1862 double dar = m_activeDocument->dar();
1864 // Deselect current effect / transition
1865 m_effectStack->slotClipItemSelected(NULL, 0);
1866 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1867 m_clipMonitor->slotSetXml(NULL);
1868 bool updateFps = m_activeDocument->setProfilePath(profile);
1869 KdenliveSettings::setCurrent_profile(profile);
1870 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1871 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1873 m_activeDocument->clipManager()->clearUnusedProducers();
1874 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1876 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
1877 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
1878 m_projectList->updateProjectFormat(m_activeDocument->timecode());
1879 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1880 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1881 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1882 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
1883 if (updateFps) m_activeTimeline->updateProjectFps();
1884 m_activeDocument->setModified(true);
1885 m_commandStack->activeStack()->clear();
1886 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
1887 slotUpdateMousePosition(0);
1888 // We need to desactivate & reactivate monitors to get a refresh
1889 //m_monitorManager->switchMonitors();
1896 void MainWindow::slotRenderProject()
1898 if (!m_renderWidget) {
1899 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
1900 m_renderWidget = new RenderWidget(projectfolder, this);
1901 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
1902 connect(m_renderWidget, SIGNAL(selectedRenderProfile(const QString &, const QString &, const QString &, const QString&)), this, SLOT(slotSetDocumentRenderProfile(const QString &, const QString &, const QString &, const QString&)));
1903 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
1904 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1905 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1906 if (m_activeDocument) {
1907 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1908 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1909 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
1910 m_renderWidget->setRenderProfile(m_activeDocument->getDocumentProperty("renderdestination"), m_activeDocument->getDocumentProperty("rendercategory"), m_activeDocument->getDocumentProperty("renderprofile"), m_activeDocument->getDocumentProperty("renderurl"));
1913 slotCheckRenderStatus();
1914 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1915 if (currentTab) m_renderWidget->setTimeline(currentTab);
1916 m_renderWidget->setDocument(m_activeDocument);*/
1917 m_renderWidget->show();
1918 m_renderWidget->showNormal();
1921 void MainWindow::slotCheckRenderStatus()
1923 // Make sure there are no missing clips
1924 if (m_renderWidget) m_renderWidget->missingClips(m_projectList->hasMissingClips());
1927 void MainWindow::setRenderingProgress(const QString &url, int progress)
1929 if (m_renderWidget) m_renderWidget->setRenderJob(url, progress);
1932 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
1934 if (m_renderWidget) m_renderWidget->setRenderStatus(url, status, error);
1937 void MainWindow::slotCleanProject()
1939 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
1940 m_projectList->cleanup();
1943 void MainWindow::slotUpdateMousePosition(int pos)
1945 if (m_activeDocument)
1946 switch (m_timecodeFormat->currentIndex()) {
1948 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1951 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1955 void MainWindow::slotUpdateDocumentState(bool modified)
1957 if (!m_activeDocument) return;
1958 setCaption(m_activeDocument->description(), modified);
1959 m_saveAction->setEnabled(modified);
1961 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1962 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1964 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1965 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1969 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
1971 if (m_activeDocument) {
1972 if (m_activeDocument == doc) return;
1973 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1975 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1978 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
1980 //m_projectMonitor->stop();
1981 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1982 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1983 if (m_activeDocument) {
1984 if (m_activeDocument == doc) return;
1985 if (m_activeTimeline) {
1986 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1987 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1988 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1989 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1990 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
1992 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1993 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1994 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1995 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1996 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1997 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1998 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1999 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2000 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2001 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2002 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2003 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2004 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2005 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2006 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2007 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2008 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2009 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2010 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2011 disconnect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
2012 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
2013 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
2014 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
2015 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2016 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2017 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2018 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2019 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2020 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2021 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2022 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2023 disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2024 disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2025 m_effectStack->clear();
2027 //m_activeDocument->setRenderer(NULL);
2028 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
2029 disconnect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2030 m_clipMonitor->stop();
2032 KdenliveSettings::setCurrent_profile(doc->profilePath());
2033 KdenliveSettings::setProject_fps(doc->fps());
2034 m_monitorManager->resetProfiles(doc->timecode());
2035 m_projectList->setDocument(doc);
2036 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2037 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2038 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint)));
2039 connect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2040 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), trackView->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2042 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2043 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2045 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
2048 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2049 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2050 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2051 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2052 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2053 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2054 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2055 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2056 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
2057 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2058 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
2060 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2061 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2062 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
2063 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2064 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2066 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
2067 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2068 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2071 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2072 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2074 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2075 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2076 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2077 m_zoomSlider->setValue(doc->zoom().x());
2078 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2079 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2080 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2081 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2083 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2084 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2087 connect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
2088 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
2089 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
2090 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
2091 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2092 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2093 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2094 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2095 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2097 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2098 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2099 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2100 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2101 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2104 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2105 m_activeTimeline = trackView;
2106 if (m_renderWidget) {
2107 slotCheckRenderStatus();
2108 m_renderWidget->setProfile(doc->mltProfile());
2109 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2110 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2111 m_renderWidget->setRenderProfile(doc->getDocumentProperty("renderdestination"), doc->getDocumentProperty("rendercategory"), doc->getDocumentProperty("renderprofile"), doc->getDocumentProperty("renderurl"));
2113 //doc->setRenderer(m_projectMonitor->render);
2114 m_commandStack->setActiveStack(doc->commandStack());
2115 KdenliveSettings::setProject_display_ratio(doc->dar());
2116 //doc->clipManager()->checkAudioThumbs();
2118 //m_overView->setScene(trackView->projectScene());
2119 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2120 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2122 setCaption(doc->description(), doc->isModified());
2123 m_saveAction->setEnabled(doc->isModified());
2124 m_normalEditTool->setChecked(true);
2125 m_activeDocument = doc;
2126 m_activeTimeline->updateProjectFps();
2127 m_activeDocument->checkProjectClips();
2128 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
2129 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2130 slotUpdateMousePosition(0);
2131 // set tool to select tool
2132 m_buttonSelectTool->setChecked(true);
2135 void MainWindow::slotZoneMoved(int start, int end)
2137 m_activeDocument->setZone(start, end);
2138 m_projectMonitor->slotZoneMoved(start, end);
2141 void MainWindow::slotGuidesUpdated()
2143 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2146 void MainWindow::slotPreferences(int page, int option)
2148 //An instance of your dialog could be already created and could be
2149 // cached, in which case you want to display the cached dialog
2150 // instead of creating another one
2151 if (KConfigDialog::showDialog("settings")) {
2152 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2153 if (page != -1) d->showPage(page, option);
2157 // KConfigDialog didn't find an instance of this dialog, so lets
2159 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
2160 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2161 //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
2162 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2163 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2165 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
2167 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2169 if (page != -1) dialog->showPage(page, option);
2172 void MainWindow::slotUpdatePreviewSettings()
2174 if (m_activeDocument) {
2175 m_clipMonitor->slotSetXml(NULL);
2176 m_activeDocument->updatePreviewSettings();
2180 void MainWindow::updateConfiguration()
2182 //TODO: we should apply settings to all projects, not only the current one
2183 if (m_activeTimeline) {
2184 m_activeTimeline->refresh();
2185 m_activeTimeline->projectView()->checkAutoScroll();
2186 m_activeTimeline->projectView()->checkTrackHeight();
2187 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
2189 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2190 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2192 // Update list of transcoding profiles
2194 #ifndef NO_JOGSHUTTLE
2195 activateShuttleDevice();
2196 #endif /* NO_JOGSHUTTLE */
2200 void MainWindow::slotSwitchSplitAudio()
2202 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2203 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2206 void MainWindow::slotSwitchVideoThumbs()
2208 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2209 if (m_activeTimeline) {
2210 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2212 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2215 void MainWindow::slotSwitchAudioThumbs()
2217 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2218 if (m_activeTimeline) {
2219 m_activeTimeline->refresh();
2220 m_activeTimeline->projectView()->checkAutoScroll();
2221 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
2223 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2226 void MainWindow::slotSwitchMarkersComments()
2228 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2229 if (m_activeTimeline) {
2230 m_activeTimeline->refresh();
2232 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2235 void MainWindow::slotSwitchSnap()
2237 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2238 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2242 void MainWindow::slotDeleteItem()
2244 if (QApplication::focusWidget()
2245 && QApplication::focusWidget()->parentWidget()
2246 && QApplication::focusWidget()->parentWidget()->parentWidget()
2247 && QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2248 m_projectList->slotRemoveClip();
2251 QWidget *widget = QApplication::focusWidget();
2253 if (widget == m_effectStackDock) {
2254 m_effectStack->slotItemDel();
2257 widget = widget->parentWidget();
2260 // effect stack has no focus
2261 if (m_activeTimeline)
2262 m_activeTimeline->projectView()->deleteSelectedClips();
2266 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2268 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2269 m_clipMonitor->updateMarkers(clip);
2272 void MainWindow::slotAddClipMarker()
2274 DocClipBase *clip = NULL;
2276 if (m_projectMonitor->isActive()) {
2277 if (m_activeTimeline) {
2278 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2280 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2281 clip = item->baseClip();
2285 clip = m_clipMonitor->activeClip();
2286 pos = m_clipMonitor->position();
2289 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2292 QString id = clip->getId();
2293 CommentedTime marker(pos, i18n("Marker"));
2294 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2295 if (d.exec() == QDialog::Accepted) {
2296 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2300 void MainWindow::slotDeleteClipMarker()
2302 DocClipBase *clip = NULL;
2304 if (m_projectMonitor->isActive()) {
2305 if (m_activeTimeline) {
2306 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2308 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2309 clip = item->baseClip();
2313 clip = m_clipMonitor->activeClip();
2314 pos = m_clipMonitor->position();
2317 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2321 QString id = clip->getId();
2322 QString comment = clip->markerComment(pos);
2323 if (comment.isEmpty()) {
2324 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2327 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2330 void MainWindow::slotDeleteAllClipMarkers()
2332 DocClipBase *clip = NULL;
2333 if (m_projectMonitor->isActive()) {
2334 if (m_activeTimeline) {
2335 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2337 clip = item->baseClip();
2341 clip = m_clipMonitor->activeClip();
2344 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2347 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2350 void MainWindow::slotEditClipMarker()
2352 DocClipBase *clip = NULL;
2354 if (m_projectMonitor->isActive()) {
2355 if (m_activeTimeline) {
2356 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2358 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2359 clip = item->baseClip();
2363 clip = m_clipMonitor->activeClip();
2364 pos = m_clipMonitor->position();
2367 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2371 QString id = clip->getId();
2372 QString oldcomment = clip->markerComment(pos);
2373 if (oldcomment.isEmpty()) {
2374 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2378 CommentedTime marker(pos, oldcomment);
2379 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2380 if (d.exec() == QDialog::Accepted) {
2381 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2382 if (d.newMarker().time() != pos) {
2383 // remove old marker
2384 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2389 void MainWindow::slotAddGuide()
2391 if (m_activeTimeline)
2392 m_activeTimeline->projectView()->slotAddGuide();
2395 void MainWindow::slotInsertSpace()
2397 if (m_activeTimeline)
2398 m_activeTimeline->projectView()->slotInsertSpace();
2401 void MainWindow::slotRemoveSpace()
2403 if (m_activeTimeline)
2404 m_activeTimeline->projectView()->slotRemoveSpace();
2407 void MainWindow::slotInsertTrack(int ix)
2409 m_projectMonitor->activateMonitor();
2410 if (m_activeTimeline)
2411 m_activeTimeline->projectView()->slotInsertTrack(ix);
2412 if (m_activeDocument)
2413 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2416 void MainWindow::slotDeleteTrack(int ix)
2418 m_projectMonitor->activateMonitor();
2419 if (m_activeTimeline)
2420 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2421 if (m_activeDocument)
2422 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2425 void MainWindow::slotConfigTrack(int ix)
2427 m_projectMonitor->activateMonitor();
2428 if (m_activeTimeline)
2429 m_activeTimeline->projectView()->slotConfigTracks(ix);
2430 if (m_activeDocument)
2431 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2434 void MainWindow::slotEditGuide()
2436 if (m_activeTimeline)
2437 m_activeTimeline->projectView()->slotEditGuide();
2440 void MainWindow::slotDeleteGuide()
2442 if (m_activeTimeline)
2443 m_activeTimeline->projectView()->slotDeleteGuide();
2446 void MainWindow::slotDeleteAllGuides()
2448 if (m_activeTimeline)
2449 m_activeTimeline->projectView()->slotDeleteAllGuides();
2452 void MainWindow::slotCutTimelineClip()
2454 if (m_activeTimeline) {
2455 m_activeTimeline->projectView()->cutSelectedClips();
2459 void MainWindow::slotInsertClipOverwrite()
2461 if (m_activeTimeline) {
2462 QStringList data = m_clipMonitor->getZoneInfo();
2463 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2467 void MainWindow::slotSelectTimelineClip()
2469 if (m_activeTimeline) {
2470 m_activeTimeline->projectView()->selectClip(true);
2474 void MainWindow::slotSelectTimelineTransition()
2476 if (m_activeTimeline) {
2477 m_activeTimeline->projectView()->selectTransition(true);
2481 void MainWindow::slotDeselectTimelineClip()
2483 if (m_activeTimeline) {
2484 m_activeTimeline->projectView()->selectClip(false, true);
2488 void MainWindow::slotDeselectTimelineTransition()
2490 if (m_activeTimeline) {
2491 m_activeTimeline->projectView()->selectTransition(false, true);
2495 void MainWindow::slotSelectAddTimelineClip()
2497 if (m_activeTimeline) {
2498 m_activeTimeline->projectView()->selectClip(true, true);
2502 void MainWindow::slotSelectAddTimelineTransition()
2504 if (m_activeTimeline) {
2505 m_activeTimeline->projectView()->selectTransition(true, true);
2509 void MainWindow::slotGroupClips()
2511 if (m_activeTimeline) {
2512 m_activeTimeline->projectView()->groupClips();
2516 void MainWindow::slotUnGroupClips()
2518 if (m_activeTimeline) {
2519 m_activeTimeline->projectView()->groupClips(false);
2523 void MainWindow::slotEditItemDuration()
2525 if (m_activeTimeline) {
2526 m_activeTimeline->projectView()->editItemDuration();
2530 void MainWindow::slotAddProjectClip(KUrl url)
2532 if (m_activeDocument)
2533 m_activeDocument->slotAddClipFile(url, QString());
2536 void MainWindow::slotAddTransition(QAction *result)
2538 if (!result) return;
2539 QStringList info = result->data().toStringList();
2540 if (info.isEmpty()) return;
2541 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2542 if (m_activeTimeline && !transition.isNull()) {
2543 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2547 void MainWindow::slotAddVideoEffect(QAction *result)
2549 if (!result) return;
2550 QStringList info = result->data().toStringList();
2551 if (info.isEmpty()) return;
2552 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2553 slotAddEffect(effect);
2556 void MainWindow::slotAddAudioEffect(QAction *result)
2558 if (!result) return;
2559 QStringList info = result->data().toStringList();
2560 if (info.isEmpty()) return;
2561 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2562 slotAddEffect(effect);
2565 void MainWindow::slotAddCustomEffect(QAction *result)
2567 if (!result) return;
2568 QStringList info = result->data().toStringList();
2569 if (info.isEmpty()) return;
2570 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2571 slotAddEffect(effect);
2574 void MainWindow::slotZoomIn()
2576 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2577 slotShowZoomSliderToolTip();
2580 void MainWindow::slotZoomOut()
2582 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2583 slotShowZoomSliderToolTip();
2586 void MainWindow::slotFitZoom()
2588 if (m_activeTimeline) {
2589 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2593 void MainWindow::slotSetZoom(int value)
2595 if (m_activeTimeline)
2596 m_activeTimeline->slotChangeZoom(value);
2598 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
2599 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
2600 slotUpdateZoomSliderToolTip(value);
2602 m_zoomSlider->blockSignals(true);
2603 m_zoomSlider->setValue(value);
2604 m_zoomSlider->blockSignals(false);
2607 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
2609 if (zoomlevel != -1)
2610 slotUpdateZoomSliderToolTip(zoomlevel);
2612 QPoint global = m_zoomSlider->rect().topLeft();
2613 global.ry() += m_zoomSlider->height() / 2;
2614 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
2615 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
2618 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
2620 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
2623 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2625 m_statusProgressBar->setValue(progress);
2626 if (progress >= 0) {
2627 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2628 m_statusProgressBar->setVisible(true);
2629 } else if (progress == -2) {
2630 if (!message.isEmpty()) m_messageLabel->setMessage(message, ErrorMessage);
2631 m_statusProgressBar->setVisible(false);
2633 m_messageLabel->setMessage(QString(), DefaultMessage);
2634 m_statusProgressBar->setVisible(false);
2638 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2640 if (clip->clipType() == TEXT) {
2641 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
2642 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
2643 // template text clip
2645 // Get the list of existing templates
2647 filter << "*.kdenlivetitle";
2648 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
2650 QDialog *dia = new QDialog(this);
2651 Ui::TemplateClip_UI dia_ui;
2652 dia_ui.setupUi(dia);
2654 const QString templatePath = clip->getProperty("resource");
2655 for (int i = 0; i < templateFiles.size(); ++i) {
2656 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
2657 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
2659 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
2660 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
2661 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
2662 //warning: setting base directory doesn't work??
2663 KUrl startDir(titlepath);
2664 dia_ui.template_list->fileDialog()->setUrl(startDir);
2665 dia_ui.description->setText(clip->getProperty("description"));
2666 if (dia->exec() == QDialog::Accepted) {
2667 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
2668 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
2670 QMap <QString, QString> newprops;
2672 if (KUrl(textTemplate).path() != templatePath) {
2673 // The template was changed
2674 newprops.insert("resource", textTemplate);
2677 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
2678 newprops.insert("description", dia_ui.description->toPlainText());
2681 QString newtemplate = newprops.value("xmltemplate");
2682 if (newtemplate.isEmpty()) newtemplate = templatePath;
2684 // template modified we need to update xmldata
2685 QString description = newprops.value("description");
2686 if (description.isEmpty()) description = clip->getProperty("description");
2687 else newprops.insert("templatetext", description);
2688 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
2689 if (!newprops.isEmpty()) {
2690 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2691 m_activeDocument->commandStack()->push(command);
2697 QString path = clip->getProperty("resource");
2698 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
2700 doc.setContent(clip->getProperty("xmldata"));
2701 dia_ui->setXml(doc);
2702 if (dia_ui->exec() == QDialog::Accepted) {
2703 QMap <QString, QString> newprops;
2704 newprops.insert("xmldata", dia_ui->xml().toString());
2705 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
2706 // duration changed, we need to update duration
2707 newprops.insert("out", QString::number(dia_ui->outPoint()));
2709 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2710 m_activeDocument->commandStack()->push(command);
2711 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
2712 m_activeDocument->setModified(true);
2716 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2719 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2720 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2721 if (dia.exec() == QDialog::Accepted) {
2722 QMap <QString, QString> newprops = dia.properties();
2723 if (newprops.isEmpty()) return;
2724 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2725 m_activeDocument->commandStack()->push(command);
2727 if (dia.needsTimelineRefresh()) {
2728 // update clip occurences in timeline
2729 m_activeTimeline->projectView()->slotUpdateClip(clip->getId(), dia.needsTimelineReload());
2735 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
2737 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
2738 if (dia.exec() == QDialog::Accepted) {
2739 QUndoCommand *command = new QUndoCommand();
2740 command->setText(i18n("Edit clips"));
2741 for (int i = 0; i < cliplist.count(); i++) {
2742 DocClipBase *clip = cliplist.at(i);
2743 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true, command);
2745 m_activeDocument->commandStack()->push(command);
2746 for (int i = 0; i < cliplist.count(); i++) {
2747 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
2752 void MainWindow::customEvent(QEvent* e)
2754 if (e->type() == QEvent::User) {
2755 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
2758 void MainWindow::slotActivateEffectStackView()
2760 m_effectStack->raiseWindow(m_effectStackDock);
2763 void MainWindow::slotActivateTransitionView(Transition *t)
2765 if (t) m_transitionConfig->raiseWindow(m_transitionConfigDock);
2768 void MainWindow::slotSnapRewind()
2770 if (m_projectMonitor->isActive()) {
2771 if (m_activeTimeline)
2772 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2773 } else m_clipMonitor->slotSeekToPreviousSnap();
2776 void MainWindow::slotSnapForward()
2778 if (m_projectMonitor->isActive()) {
2779 if (m_activeTimeline)
2780 m_activeTimeline->projectView()->slotSeekToNextSnap();
2781 } else m_clipMonitor->slotSeekToNextSnap();
2784 void MainWindow::slotClipStart()
2786 if (m_projectMonitor->isActive()) {
2787 if (m_activeTimeline)
2788 m_activeTimeline->projectView()->clipStart();
2792 void MainWindow::slotClipEnd()
2794 if (m_projectMonitor->isActive()) {
2795 if (m_activeTimeline)
2796 m_activeTimeline->projectView()->clipEnd();
2800 void MainWindow::slotZoneStart()
2802 if (m_projectMonitor->isActive()) m_projectMonitor->slotZoneStart();
2803 else m_clipMonitor->slotZoneStart();
2806 void MainWindow::slotZoneEnd()
2808 if (m_projectMonitor->isActive()) m_projectMonitor->slotZoneEnd();
2809 else m_clipMonitor->slotZoneEnd();
2812 void MainWindow::slotChangeTool(QAction * action)
2814 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
2815 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
2816 else if (action == m_buttonSpacerTool) slotSetTool(SPACERTOOL);
2819 void MainWindow::slotChangeEdit(QAction * action)
2821 if (!m_activeTimeline) return;
2822 if (action == m_overwriteEditTool) m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
2823 else if (action == m_insertEditTool) m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
2824 else m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
2827 void MainWindow::slotSetTool(PROJECTTOOL tool)
2829 if (m_activeDocument && m_activeTimeline) {
2830 //m_activeDocument->setTool(tool);
2834 message = i18n("Ctrl + click to use spacer on current track only");
2837 message = i18n("Click on a clip to cut it");
2840 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
2843 m_messageLabel->setMessage(message, InformationMessage);
2844 m_activeTimeline->projectView()->setTool(tool);
2848 void MainWindow::slotCopy()
2850 if (!m_activeDocument || !m_activeTimeline) return;
2851 m_activeTimeline->projectView()->copyClip();
2854 void MainWindow::slotPaste()
2856 if (!m_activeDocument || !m_activeTimeline) return;
2857 m_activeTimeline->projectView()->pasteClip();
2860 void MainWindow::slotPasteEffects()
2862 if (!m_activeDocument || !m_activeTimeline) return;
2863 m_activeTimeline->projectView()->pasteClipEffects();
2866 void MainWindow::slotFind()
2868 if (!m_activeDocument || !m_activeTimeline) return;
2869 m_projectSearch->setEnabled(false);
2870 m_findActivated = true;
2871 m_findString.clear();
2872 m_activeTimeline->projectView()->initSearchStrings();
2873 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2874 m_findTimer.start(5000);
2875 qApp->installEventFilter(this);
2878 void MainWindow::slotFindNext()
2880 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
2881 statusBar()->showMessage(i18n("Found: %1", m_findString));
2883 statusBar()->showMessage(i18n("Reached end of project"));
2885 m_findTimer.start(4000);
2888 void MainWindow::findAhead()
2890 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
2891 m_projectSearchNext->setEnabled(true);
2892 statusBar()->showMessage(i18n("Found: %1", m_findString));
2894 m_projectSearchNext->setEnabled(false);
2895 statusBar()->showMessage(i18n("Not found: %1", m_findString));
2899 void MainWindow::findTimeout()
2901 m_projectSearchNext->setEnabled(false);
2902 m_findActivated = false;
2903 m_findString.clear();
2904 statusBar()->showMessage(i18n("Find stopped"), 3000);
2905 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
2906 m_projectSearch->setEnabled(true);
2907 removeEventFilter(this);
2910 void MainWindow::slotClipInTimeline(const QString &clipId)
2912 if (m_activeTimeline && m_activeDocument) {
2913 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
2915 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
2916 inTimelineMenu->clear();
2918 QList <QAction *> actionList;
2920 for (int i = 0; i < matching.count(); ++i) {
2921 QString track = QString::number(matching.at(i).track);
2922 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
2924 QAction *a = new QAction(track + ": " + start, this);
2925 a->setData(QStringList() << track << start);
2926 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
2927 while (j < actionList.count()) {
2928 if (actionList.at(j)->text() > a->text()) break;
2931 actionList.insert(j, a);
2934 inTimelineMenu->addActions(actionList);
2936 if (matching.empty())
2937 inTimelineMenu->setEnabled(false);
2939 inTimelineMenu->setEnabled(true);
2943 void MainWindow::slotClipInProjectTree()
2945 if (m_activeTimeline) {
2946 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
2947 if (clipIds.isEmpty()) return;
2948 m_projectListDock->raise();
2949 for (int i = 0; i < clipIds.count(); i++) {
2950 m_projectList->selectItemById(clipIds.at(i));
2952 if (m_projectMonitor->isActive())
2953 slotSwitchMonitors();
2957 void MainWindow::slotSelectClipInTimeline()
2959 if (m_activeTimeline) {
2960 QAction *action = qobject_cast<QAction *>(sender());
2961 QStringList data = action->data().toStringList();
2962 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
2966 void MainWindow::keyPressEvent(QKeyEvent *ke)
2968 if (m_findActivated) {
2969 if (ke->key() == Qt::Key_Backspace) {
2970 m_findString = m_findString.left(m_findString.length() - 1);
2972 if (!m_findString.isEmpty()) {
2978 m_findTimer.start(4000);
2981 } else if (ke->key() == Qt::Key_Escape) {
2985 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
2986 m_findString += ke->text();
2990 m_findTimer.start(4000);
2994 } else KXmlGuiWindow::keyPressEvent(ke);
2998 /** Gets called when the window gets hidden */
2999 void MainWindow::hideEvent(QHideEvent */*event*/)
3002 if (m_monitorManager)
3003 m_monitorManager->stopActiveMonitor();
3006 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3008 if (m_findActivated) {
3009 if (event->type() == QEvent::ShortcutOverride) {
3010 QKeyEvent* ke = (QKeyEvent*) event;
3011 if (ke->text().trimmed().isEmpty()) return false;
3014 } else return false;
3016 // pass the event on to the parent class
3017 return QMainWindow::eventFilter(obj, event);
3022 void MainWindow::slotSaveZone(Render *render, QPoint zone)
3024 KDialog *dialog = new KDialog(this);
3025 dialog->setCaption("Save clip zone");
3026 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3028 QWidget *widget = new QWidget(dialog);
3029 dialog->setMainWidget(widget);
3031 QVBoxLayout *vbox = new QVBoxLayout(widget);
3032 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3033 QString path = m_activeDocument->projectFolder().path();
3035 path.append("untitled.mlt");
3036 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
3037 url->setFilter("video/mlt-playlist");
3038 QLabel *label2 = new QLabel(i18n("Description:"), this);
3039 KLineEdit *edit = new KLineEdit(this);
3040 vbox->addWidget(label1);
3041 vbox->addWidget(url);
3042 vbox->addWidget(label2);
3043 vbox->addWidget(edit);
3044 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
3048 void MainWindow::slotSetInPoint()
3050 if (m_clipMonitor->isActive()) {
3051 m_clipMonitor->slotSetZoneStart();
3052 } else m_projectMonitor->slotSetZoneStart();
3053 //else m_activeTimeline->projectView()->setInPoint();
3056 void MainWindow::slotSetOutPoint()
3058 if (m_clipMonitor->isActive()) {
3059 m_clipMonitor->slotSetZoneEnd();
3060 } else m_projectMonitor->slotSetZoneEnd();
3061 // else m_activeTimeline->projectView()->setOutPoint();
3064 void MainWindow::slotResizeItemStart()
3066 if (m_activeTimeline) m_activeTimeline->projectView()->setInPoint();
3069 void MainWindow::slotResizeItemEnd()
3071 if (m_activeTimeline) m_activeTimeline->projectView()->setOutPoint();
3074 int MainWindow::getNewStuff(const QString &configFile)
3076 KNS3::Entry::List entries;
3077 #if KDE_IS_VERSION(4,3,80)
3078 KNS3::DownloadDialog dialog(configFile);
3080 entries = dialog.changedEntries();
3081 foreach(const KNS3::Entry &entry, entries) {
3082 if (entry.status() == KNS3::Entry::Installed)
3083 kDebug() << "// Installed files: " << entry.installedFiles();
3086 KNS::Engine engine(0);
3087 if (engine.init(configFile))
3088 entries = engine.downloadDialogModal(this);
3089 foreach(KNS::Entry *entry, entries) {
3090 if (entry->status() == KNS::Entry::Installed)
3091 kDebug() << "// Installed files: " << entry->installedFiles();
3093 #endif /* KDE_IS_VERSION(4,3,80) */
3094 return entries.size();
3097 void MainWindow::slotGetNewTitleStuff()
3099 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3100 TitleWidget::refreshTitleTemplates();
3103 void MainWindow::slotGetNewLumaStuff()
3105 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3106 initEffects::refreshLumas();
3107 m_activeTimeline->projectView()->reloadTransitionLumas();
3111 void MainWindow::slotGetNewRenderStuff()
3113 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3115 m_renderWidget->reloadProfiles();
3118 void MainWindow::slotGetNewMltProfileStuff()
3120 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3121 // update the list of profiles in settings dialog
3122 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3128 void MainWindow::slotAutoTransition()
3130 if (m_activeTimeline) m_activeTimeline->projectView()->autoTransition();
3133 void MainWindow::slotSplitAudio()
3135 if (m_activeTimeline) m_activeTimeline->projectView()->splitAudio();
3138 void MainWindow::slotUpdateClipType(QAction *action)
3140 if (m_activeTimeline) {
3141 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3142 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3143 else m_activeTimeline->projectView()->setAudioAndVideo();
3147 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3149 // We must stop the monitors since we create a new on in the dvd wizard
3150 m_clipMonitor->stop();
3151 m_projectMonitor->stop();
3152 DvdWizard w(url, profile, this);
3154 m_projectMonitor->start();
3157 void MainWindow::slotShowTimeline(bool show)
3159 if (show == false) {
3160 m_timelineState = saveState();
3161 centralWidget()->setHidden(true);
3163 centralWidget()->setHidden(false);
3164 restoreState(m_timelineState);
3168 void MainWindow::slotMaximizeCurrent(bool /*show*/)
3170 //TODO: is there a way to maximize current widget?
3173 m_timelineState = saveState();
3174 QWidget *par = focusWidget()->parentWidget();
3175 while (par->parentWidget() && par->parentWidget() != this) {
3176 par = par->parentWidget();
3178 kDebug() << "CURRENT WIDGET: " << par->objectName();
3181 //centralWidget()->setHidden(false);
3182 //restoreState(m_timelineState);
3186 void MainWindow::loadTranscoders()
3188 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3191 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3192 KConfigGroup transConfig(config, "Transcoding");
3194 QMap< QString, QString > profiles = transConfig.entryMap();
3195 QMapIterator<QString, QString> i(profiles);
3196 while (i.hasNext()) {
3198 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3199 QAction *a = transMenu->addAction(i.key());
3201 if (data.count() > 1) {
3202 a->setToolTip(data.at(1));
3204 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3208 void MainWindow::slotTranscode(KUrl::List urls)
3213 if (urls.isEmpty()) {
3214 QAction *action = qobject_cast<QAction *>(sender());
3215 QStringList data = action->data().toStringList();
3216 params = data.at(0);
3217 if (data.count() > 1) desc = data.at(1);
3218 if (data.count() > 2) condition = data.at(2);
3219 urls << m_projectList->getConditionalUrls(condition);
3220 urls.removeAll(KUrl());
3222 if (urls.isEmpty()) {
3223 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3226 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3227 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3229 //QProcess::startDetached("ffmpeg", parameters);
3232 void MainWindow::slotTranscodeClip()
3234 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3235 if (urls.isEmpty()) return;
3236 slotTranscode(urls);
3239 void MainWindow::slotSetDocumentRenderProfile(const QString &dest, const QString &group, const QString &name, const QString &file)
3241 if (m_activeDocument == NULL) return;
3242 m_activeDocument->setDocumentProperty("renderdestination", dest);
3243 m_activeDocument->setDocumentProperty("rendercategory", group);
3244 m_activeDocument->setDocumentProperty("renderprofile", name);
3245 m_activeDocument->setDocumentProperty("renderurl", file);
3246 m_activeDocument->setModified(true);
3250 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3252 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3254 QString playlistPath;
3257 QString scriptsFolder = m_activeDocument->projectFolder().path() + "/scripts/";
3258 QString path = m_renderWidget->getFreeScriptName();
3259 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3260 if (!ok || scriptPath.isEmpty()) return;
3261 scriptPath.prepend(scriptsFolder);
3262 QFile f(scriptPath);
3264 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3267 playlistPath = scriptPath + ".mlt";
3268 m_projectMonitor->saveSceneList(playlistPath);
3270 KTemporaryFile temp;
3271 temp.setAutoRemove(false);
3272 temp.setSuffix(".mlt");
3274 playlistPath = temp.fileName();
3275 m_projectMonitor->saveSceneList(playlistPath);
3278 if (!chapterFile.isEmpty()) {
3281 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3283 in = m_activeTimeline->inPoint();
3284 out = m_activeTimeline->outPoint();
3287 QDomElement chapters = doc.createElement("chapters");
3288 chapters.setAttribute("fps", m_activeDocument->fps());
3289 doc.appendChild(chapters);
3291 QDomElement guidesxml = m_activeDocument->guidesXml();
3292 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3293 for (int i = 0; i < nodes.count(); i++) {
3294 QDomElement e = nodes.item(i).toElement();
3296 QString comment = e.attribute("comment");
3297 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3298 if (time >= in && time < out) {
3299 if (zoneOnly) time = time - in;
3300 QDomElement chapter = doc.createElement("chapter");
3301 chapters.appendChild(chapter);
3302 chapter.setAttribute("title", comment);
3303 chapter.setAttribute("time", time);
3307 if (chapters.childNodes().count() > 0) {
3308 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3309 // Always insert a guide in pos 0
3310 QDomElement chapter = doc.createElement("chapter");
3311 chapters.insertBefore(chapter, QDomNode());
3312 chapter.setAttribute("title", i18n("Start"));
3313 chapter.setAttribute("time", "0");
3315 // save chapters file
3316 QFile file(chapterFile);
3317 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3318 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3320 file.write(doc.toString().toUtf8());
3321 if (file.error() != QFile::NoError) {
3322 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3329 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath);
3332 void MainWindow::slotUpdateTimecodeFormat(int ix)
3334 KdenliveSettings::setFrametimecode(ix == 1);
3335 m_clipMonitor->updateTimecodeFormat();
3336 m_projectMonitor->updateTimecodeFormat();
3337 m_transitionConfig->updateTimecodeFormat();
3338 m_effectStack->updateTimecodeFormat();
3339 //m_activeTimeline->projectView()->clearSelection();
3340 m_activeTimeline->updateRuler();
3343 void MainWindow::slotRemoveFocus()
3345 statusBar()->setFocus();
3346 statusBar()->clearFocus();
3349 void MainWindow::slotRevert()
3351 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;
3352 KUrl url = m_activeDocument->url();
3353 closeCurrentDocument(false);
3354 doOpenFile(url, NULL);
3358 void MainWindow::slotShutdown()
3360 if (m_activeDocument) m_activeDocument->setModified(false);
3362 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
3363 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
3364 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
3365 smserver.call("logout", 1, 2, 2);
3366 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
3367 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
3368 smserver.call("Shutdown");
3372 void MainWindow::slotUpdateTrackInfo()
3374 if (m_activeDocument)
3375 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
3378 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
3380 // Load the theme file
3382 if (action == NULL) theme = themename;
3383 else theme = action->data().toString();
3384 KdenliveSettings::setColortheme(theme);
3385 // Make palette for all widgets.
3387 if (theme.isEmpty())
3388 plt = QApplication::desktop()->palette();
3390 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
3391 plt = KGlobalSettings::createApplicationPalette(config);
3394 kapp->setPalette(plt);
3395 const QObjectList children = statusBar()->children();
3397 foreach(QObject *child, children) {
3398 if (child->isWidgetType())
3399 ((QWidget*)child)->setPalette(plt);
3400 const QObjectList subchildren = child->children();
3401 foreach(QObject *subchild, subchildren) {
3402 if (subchild->isWidgetType())
3403 ((QWidget*)subchild)->setPalette(plt);
3409 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
3411 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
3412 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
3413 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
3414 const QSize bitsSize(24, 2);
3415 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
3416 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
3418 QPixmap pixmap(23, 16);
3419 pixmap.fill(Qt::black); // ### use some color other than black for borders?
3421 KConfigGroup group(config, "WM");
3422 QPainter p(&pixmap);
3423 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
3424 p.fillRect(1, 1, 7, 7, windowScheme.background());
3425 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
3427 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
3428 p.fillRect(8, 1, 7, 7, buttonScheme.background());
3429 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
3431 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
3432 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
3434 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
3435 p.fillRect(1, 8, 7, 7, viewScheme.background());
3436 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
3438 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
3439 p.fillRect(8, 8, 7, 7, selectionScheme.background());
3440 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
3442 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
3443 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
3449 void MainWindow::slotSwitchMonitors()
3451 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
3452 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
3453 else m_projectList->focusTree();
3456 void MainWindow::slotInsertZoneToTree()
3458 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
3459 QStringList info = m_clipMonitor->getZoneInfo();
3460 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
3463 void MainWindow::slotInsertZoneToTimeline()
3465 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
3466 QStringList info = m_clipMonitor->getZoneInfo();
3467 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
3471 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
3473 if (m_activeDocument && m_activeTimeline) {
3474 if (!ids.isEmpty()) {
3475 for (int i = 0; i < ids.size(); ++i) {
3476 m_activeTimeline->slotDeleteClip(ids.at(i));
3478 m_activeDocument->clipManager()->slotDeleteClips(ids);
3480 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
3481 m_activeDocument->setModified(true);
3485 void MainWindow::slotShowTitleBars(bool show)
3488 m_effectStackDock->setTitleBarWidget(0);
3489 m_clipMonitorDock->setTitleBarWidget(0);
3490 m_projectMonitorDock->setTitleBarWidget(0);
3492 m_recMonitorDock->setTitleBarWidget(0);
3494 m_effectListDock->setTitleBarWidget(0);
3495 m_transitionConfigDock->setTitleBarWidget(0);
3496 m_projectListDock->setTitleBarWidget(0);
3497 m_undoViewDock->setTitleBarWidget(0);
3499 if (!m_effectStackDock->isFloating()) m_effectStackDock->setTitleBarWidget(new QWidget(this));
3500 if (!m_clipMonitorDock->isFloating()) m_clipMonitorDock->setTitleBarWidget(new QWidget(this));
3501 if (!m_projectMonitorDock->isFloating()) m_projectMonitorDock->setTitleBarWidget(new QWidget(this));
3503 if (!m_recMonitorDock->isFloating()) m_recMonitorDock->setTitleBarWidget(new QWidget(this));
3505 if (!m_effectListDock->isFloating()) m_effectListDock->setTitleBarWidget(new QWidget(this));
3506 if (!m_transitionConfigDock->isFloating()) m_transitionConfigDock->setTitleBarWidget(new QWidget(this));
3507 if (!m_projectListDock->isFloating()) m_projectListDock->setTitleBarWidget(new QWidget(this));
3508 if (!m_undoViewDock->isFloating()) m_undoViewDock->setTitleBarWidget(new QWidget(this));
3510 KdenliveSettings::setShowtitlebars(show);
3513 void MainWindow::slotSwitchTitles()
3515 slotShowTitleBars(!KdenliveSettings::showtitlebars());
3518 QString MainWindow::getMimeType()
3520 QString mimetype = "application/x-kdenlive";
3521 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
3522 if (!mime) mimetype = "*.kdenlive";
3526 #include "mainwindow.moc"