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("clip_to_project_tree"));
359 m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
360 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
361 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
362 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
363 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
364 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
365 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
366 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
368 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
369 m_timelineContextClipMenu->addMenu(markersMenu);
370 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
371 m_timelineContextClipMenu->addMenu(m_videoEffectsMenu);
372 m_timelineContextClipMenu->addMenu(m_audioEffectsMenu);
373 //TODO: re-enable custom effects menu when it is implemented
374 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
376 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
377 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
378 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
380 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
382 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
383 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
384 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
385 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
386 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
387 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
389 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
390 slotConnectMonitors();
392 // Disable drop B frames, see Kdenlive issue #1330, see also kdenlivesettingsdialog.cpp
393 KdenliveSettings::setDropbframes(false);
395 // Open or create a file. Command line argument passed in Url has
396 // precedence, then "openlastproject", then just a plain empty file.
397 // If opening Url fails, openlastproject will _not_ be used.
398 if (!Url.isEmpty()) {
399 // delay loading so that the window shows up
401 QTimer::singleShot(500, this, SLOT(openFile()));
402 } else if (KdenliveSettings::openlastproject()) {
403 QTimer::singleShot(500, this, SLOT(openLastFile()));
404 } else { //if (m_timelineArea->count() == 0) {
408 #ifndef NO_JOGSHUTTLE
409 activateShuttleDevice();
410 #endif /* NO_JOGSHUTTLE */
411 m_projectListDock->raise();
414 void MainWindow::queryQuit()
417 if (m_projectMonitor) m_projectMonitor->stop();
418 if (m_clipMonitor) m_clipMonitor->stop();
419 delete m_effectStack;
420 delete m_activeTimeline;
422 // This sometimes causes crash on exit on OS X for some reason.
423 delete m_projectMonitor;
424 delete m_clipMonitor;
426 delete m_activeDocument;
427 delete m_shortcutRemoveFocus;
428 Mlt::Factory::close();
434 bool MainWindow::queryClose()
436 if (m_renderWidget) {
437 int waitingJobs = m_renderWidget->waitingJobsCount();
438 if (waitingJobs > 0) {
439 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")))) {
440 case KMessageBox::Yes :
441 // create script with waiting jobs and start it
442 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
444 case KMessageBox::No :
445 // Don't do anything, jobs will be deleted
453 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
454 // warn the user to save if document is modified and we have clips in our project list
455 if (m_activeDocument && m_activeDocument->isModified()
456 && ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty())
457 || !m_projectList->documentClipList().isEmpty())) {
458 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
459 case KMessageBox::Yes :
460 // save document here. If saving fails, return false;
462 case KMessageBox::No :
463 // User does not want to save the changes, clear recovery files
464 m_activeDocument->m_autosave->resize(0);
474 void MainWindow::loadPlugins()
476 foreach(QObject *plugin, QPluginLoader::staticInstances())
477 populateMenus(plugin);
479 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
481 filters << "libkdenlive*";
482 foreach(const QString &folder, directories) {
483 kDebug() << "// PARSING FIOLER: " << folder;
484 QDir pluginsDir(folder);
485 foreach(const QString &fileName, pluginsDir.entryList(filters, QDir::Files)) {
486 kDebug() << "// FOUND PLUGIN: " << fileName << "= " << pluginsDir.absoluteFilePath(fileName);
487 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
488 QObject *plugin = loader.instance();
490 populateMenus(plugin);
491 m_pluginFileNames += fileName;
492 } else kDebug() << "// ERROR LOADING PLUGIN: " << fileName << ", " << loader.errorString();
498 void MainWindow::populateMenus(QObject *plugin)
500 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
501 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
503 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
507 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
508 QMenu *menu, const char *member,
509 QActionGroup *actionGroup)
511 kDebug() << "// ADD to MENU" << texts;
512 foreach(const QString &text, texts) {
513 QAction *action = new QAction(text, plugin);
514 action->setData(text);
515 connect(action, SIGNAL(triggered()), this, member);
516 menu->addAction(action);
519 action->setCheckable(true);
520 actionGroup->addAction(action);
525 void MainWindow::aboutPlugins()
527 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
532 void MainWindow::generateClip()
534 QAction *action = qobject_cast<QAction *>(sender());
535 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
537 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
538 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
539 if (!clipUrl.isEmpty()) {
540 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
544 void MainWindow::saveProperties(KConfigGroup &config)
546 // save properties here,used by session management
548 KMainWindow::saveProperties(config);
552 void MainWindow::readProperties(const KConfigGroup &config)
554 // read properties here,used by session management
555 KMainWindow::readProperties(config);
556 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
557 openFile(KUrl(Lastproject));
560 void MainWindow::slotReloadEffects()
562 m_customEffectsMenu->clear();
563 initEffects::parseCustomEffectsFile();
565 QStringList effectInfo;
566 QMap<QString, QStringList> effectsList;
568 for (int ix = 0; ix < customEffects.count(); ix++) {
569 effectInfo = customEffects.effectIdInfo(ix);
570 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
572 if (effectsList.isEmpty()) {
573 m_customEffectsMenu->setEnabled(false);
575 } else m_customEffectsMenu->setEnabled(true);
577 foreach(const QStringList &value, effectsList) {
578 action = new QAction(value.at(0), this);
579 action->setData(value);
580 m_customEffectsMenu->addAction(action);
582 m_effectList->reloadEffectList();
585 #ifndef NO_JOGSHUTTLE
586 void MainWindow::activateShuttleDevice()
590 if (KdenliveSettings::enableshuttle() == false) return;
591 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
592 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
593 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
594 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
595 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
596 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
597 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
600 void MainWindow::slotShuttleButton(int code)
604 slotShuttleAction(KdenliveSettings::shuttle1());
607 slotShuttleAction(KdenliveSettings::shuttle2());
610 slotShuttleAction(KdenliveSettings::shuttle3());
613 slotShuttleAction(KdenliveSettings::shuttle4());
616 slotShuttleAction(KdenliveSettings::shuttle5());
621 void MainWindow::slotShuttleAction(int code)
627 m_monitorManager->slotPlay();
630 m_monitorManager->slotPlay();
634 #endif /* NO_JOGSHUTTLE */
636 void MainWindow::configureNotifications()
638 KNotifyConfigWidget::configure(this);
641 void MainWindow::slotFullScreen()
643 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
646 void MainWindow::slotAddEffect(const QDomElement effect, GenTime pos, int track)
648 if (!m_activeDocument) return;
649 if (effect.isNull()) {
650 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
653 QDomElement effectToAdd = effect.cloneNode().toElement();
654 m_activeTimeline->projectView()->slotAddEffect(effectToAdd, pos, track);
657 void MainWindow::slotRaiseMonitor(bool clipMonitor)
659 if (clipMonitor) m_clipMonitorDock->raise();
660 else m_projectMonitorDock->raise();
663 void MainWindow::slotUpdateClip(const QString &id)
665 if (!m_activeDocument) return;
666 m_activeTimeline->projectView()->slotUpdateClip(id);
669 void MainWindow::slotConnectMonitors()
671 m_projectList->setRenderer(m_projectMonitor->render);
672 //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
673 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
674 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
675 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
676 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, int, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, int, bool)));
677 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
678 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)));
680 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
682 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
684 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
685 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
687 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
688 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
691 void MainWindow::slotAdjustClipMonitor()
693 m_clipMonitorDock->updateGeometry();
694 m_clipMonitorDock->adjustSize();
695 m_clipMonitor->resetSize();
698 void MainWindow::slotAdjustProjectMonitor()
700 m_projectMonitorDock->updateGeometry();
701 m_projectMonitorDock->adjustSize();
702 m_projectMonitor->resetSize();
705 void MainWindow::setupActions()
708 KActionCollection* collection = actionCollection();
709 m_timecodeFormat = new KComboBox(this);
710 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
711 m_timecodeFormat->addItem(i18n("Frames"));
712 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
713 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
715 m_statusProgressBar = new QProgressBar(this);
716 m_statusProgressBar->setMinimum(0);
717 m_statusProgressBar->setMaximum(100);
718 m_statusProgressBar->setMaximumWidth(150);
719 m_statusProgressBar->setVisible(false);
721 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
722 toolbar->setMovable(false);
723 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
724 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;}";
725 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
727 //create edit mode buttons
728 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
729 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
730 toolbar->addAction(m_normalEditTool);
731 m_normalEditTool->setCheckable(true);
732 m_normalEditTool->setChecked(true);
734 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
735 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
736 toolbar->addAction(m_overwriteEditTool);
737 m_overwriteEditTool->setCheckable(true);
738 m_overwriteEditTool->setChecked(false);
740 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
741 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
742 toolbar->addAction(m_insertEditTool);
743 m_insertEditTool->setCheckable(true);
744 m_insertEditTool->setChecked(false);
745 // not implemented yet
746 m_insertEditTool->setEnabled(false);
748 QActionGroup *editGroup = new QActionGroup(this);
749 editGroup->addAction(m_normalEditTool);
750 editGroup->addAction(m_overwriteEditTool);
751 editGroup->addAction(m_insertEditTool);
752 editGroup->setExclusive(true);
753 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
754 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
756 toolbar->addSeparator();
758 // create tools buttons
759 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
760 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
761 toolbar->addAction(m_buttonSelectTool);
762 m_buttonSelectTool->setCheckable(true);
763 m_buttonSelectTool->setChecked(true);
765 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
766 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
767 toolbar->addAction(m_buttonRazorTool);
768 m_buttonRazorTool->setCheckable(true);
769 m_buttonRazorTool->setChecked(false);
771 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
772 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
773 toolbar->addAction(m_buttonSpacerTool);
774 m_buttonSpacerTool->setCheckable(true);
775 m_buttonSpacerTool->setChecked(false);
777 QActionGroup *toolGroup = new QActionGroup(this);
778 toolGroup->addAction(m_buttonSelectTool);
779 toolGroup->addAction(m_buttonRazorTool);
780 toolGroup->addAction(m_buttonSpacerTool);
781 toolGroup->setExclusive(true);
782 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
784 QWidget * actionWidget;
785 int max = toolbar->iconSizeDefault() + 2;
786 actionWidget = toolbar->widgetForAction(m_normalEditTool);
787 actionWidget->setMaximumWidth(max);
788 actionWidget->setMaximumHeight(max - 4);
790 actionWidget = toolbar->widgetForAction(m_insertEditTool);
791 actionWidget->setMaximumWidth(max);
792 actionWidget->setMaximumHeight(max - 4);
794 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
795 actionWidget->setMaximumWidth(max);
796 actionWidget->setMaximumHeight(max - 4);
798 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
799 actionWidget->setMaximumWidth(max);
800 actionWidget->setMaximumHeight(max - 4);
802 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
803 actionWidget->setMaximumWidth(max);
804 actionWidget->setMaximumHeight(max - 4);
806 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
807 actionWidget->setMaximumWidth(max);
808 actionWidget->setMaximumHeight(max - 4);
810 toolbar->setStyleSheet(style1);
811 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
813 toolbar->addSeparator();
814 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
815 toolbar->addAction(m_buttonFitZoom);
816 m_buttonFitZoom->setCheckable(false);
818 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
819 toolbar->addAction(m_zoomOut);
820 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
822 m_zoomSlider = new QSlider(Qt::Horizontal, this);
823 m_zoomSlider->setMaximum(13);
824 m_zoomSlider->setPageStep(1);
825 m_zoomSlider->setInvertedAppearance(true);
827 m_zoomSlider->setMaximumWidth(150);
828 m_zoomSlider->setMinimumWidth(100);
829 toolbar->addWidget(m_zoomSlider);
831 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
832 toolbar->addAction(m_zoomIn);
833 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
835 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
836 actionWidget->setMaximumWidth(max);
837 actionWidget->setMaximumHeight(max - 4);
838 actionWidget->setStyleSheet(styleBorderless);
840 actionWidget = toolbar->widgetForAction(m_zoomIn);
841 actionWidget->setMaximumWidth(max);
842 actionWidget->setMaximumHeight(max - 4);
843 actionWidget->setStyleSheet(styleBorderless);
845 actionWidget = toolbar->widgetForAction(m_zoomOut);
846 actionWidget->setMaximumWidth(max);
847 actionWidget->setMaximumHeight(max - 4);
848 actionWidget->setStyleSheet(styleBorderless);
850 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
851 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
852 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
853 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
854 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
856 toolbar->addSeparator();
858 //create automatic audio split button
859 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
860 toolbar->addAction(m_buttonAutomaticSplitAudio);
861 m_buttonAutomaticSplitAudio->setCheckable(true);
862 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
863 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
865 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
866 toolbar->addAction(m_buttonVideoThumbs);
867 m_buttonVideoThumbs->setCheckable(true);
868 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
869 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
871 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
872 toolbar->addAction(m_buttonAudioThumbs);
873 m_buttonAudioThumbs->setCheckable(true);
874 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
875 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
877 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
878 toolbar->addAction(m_buttonShowMarkers);
879 m_buttonShowMarkers->setCheckable(true);
880 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
881 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
883 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
884 toolbar->addAction(m_buttonSnap);
885 m_buttonSnap->setCheckable(true);
886 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
887 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
889 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
890 actionWidget->setMaximumWidth(max);
891 actionWidget->setMaximumHeight(max - 4);
893 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
894 actionWidget->setMaximumWidth(max);
895 actionWidget->setMaximumHeight(max - 4);
897 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
898 actionWidget->setMaximumWidth(max);
899 actionWidget->setMaximumHeight(max - 4);
901 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
902 actionWidget->setMaximumWidth(max);
903 actionWidget->setMaximumHeight(max - 4);
905 actionWidget = toolbar->widgetForAction(m_buttonSnap);
906 actionWidget->setMaximumWidth(max);
907 actionWidget->setMaximumHeight(max - 4);
909 m_messageLabel = new StatusBarMessageLabel(this);
910 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
912 statusBar()->addWidget(m_messageLabel, 10);
913 statusBar()->addWidget(m_statusProgressBar, 0);
914 statusBar()->addPermanentWidget(toolbar);
915 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
916 statusBar()->addPermanentWidget(m_timecodeFormat);
917 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
919 collection->addAction("normal_mode", m_normalEditTool);
920 collection->addAction("overwrite_mode", m_overwriteEditTool);
921 collection->addAction("insert_mode", m_insertEditTool);
922 collection->addAction("select_tool", m_buttonSelectTool);
923 collection->addAction("razor_tool", m_buttonRazorTool);
924 collection->addAction("spacer_tool", m_buttonSpacerTool);
926 collection->addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
927 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
928 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
929 collection->addAction("show_markers", m_buttonShowMarkers);
930 collection->addAction("snap", m_buttonSnap);
931 collection->addAction("zoom_fit", m_buttonFitZoom);
932 collection->addAction("zoom_in", m_zoomIn);
933 collection->addAction("zoom_out", m_zoomOut);
935 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
936 collection->addAction("project_find", m_projectSearch);
937 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
938 m_projectSearch->setShortcut(Qt::Key_Slash);
940 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
941 collection->addAction("project_find_next", m_projectSearchNext);
942 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
943 m_projectSearchNext->setShortcut(Qt::Key_F3);
944 m_projectSearchNext->setEnabled(false);
946 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
947 collection->addAction("manage_profiles", profilesAction);
948 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
950 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
952 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
954 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
956 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
958 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
959 collection->addAction("run_wizard", wizAction);
960 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
962 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
963 collection->addAction("project_settings", projectAction);
964 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
966 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
967 collection->addAction("project_render", projectRender);
968 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
969 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
971 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
972 collection->addAction("project_clean", projectClean);
973 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
975 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
976 KShortcut playShortcut;
977 playShortcut.setPrimary(Qt::Key_Space);
978 playShortcut.setAlternate(Qt::Key_K);
979 monitorPlay->setShortcut(playShortcut);
980 collection->addAction("monitor_play", monitorPlay);
981 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
983 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
984 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
985 collection->addAction("monitor_play_zone", m_playZone);
986 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
988 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
989 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
990 collection->addAction("monitor_loop_zone", m_loopZone);
991 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
993 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
994 collection->addAction("dvd_wizard", dvdWizard);
995 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
997 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
998 collection->addAction("transcode_clip", transcodeClip);
999 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1001 KAction *markIn = collection->addAction("mark_in");
1002 markIn->setText(i18n("Set Zone In"));
1003 markIn->setShortcut(Qt::Key_I);
1004 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1006 KAction *markOut = collection->addAction("mark_out");
1007 markOut->setText(i18n("Set Zone Out"));
1008 markOut->setShortcut(Qt::Key_O);
1009 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1011 KAction *switchMon = collection->addAction("switch_monitor");
1012 switchMon->setText(i18n("Switch monitor"));
1013 switchMon->setShortcut(Qt::Key_T);
1014 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1016 KAction *insertTree = collection->addAction("insert_project_tree");
1017 insertTree->setText(i18n("Insert zone in project tree"));
1018 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1019 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1021 KAction *insertTimeline = collection->addAction("insert_timeline");
1022 insertTimeline->setText(i18n("Insert zone in timeline"));
1023 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1024 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1026 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1027 collection->addAction("resize_timeline_clip_start", resizeStart);
1028 resizeStart->setShortcut(Qt::Key_1);
1029 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1031 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1032 collection->addAction("resize_timeline_clip_end", resizeEnd);
1033 resizeEnd->setShortcut(Qt::Key_2);
1034 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1036 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1037 monitorSeekBackward->setShortcut(Qt::Key_J);
1038 collection->addAction("monitor_seek_backward", monitorSeekBackward);
1039 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1041 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1042 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1043 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1044 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1046 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1047 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1048 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1049 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1051 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1052 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1053 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1054 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1056 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1057 monitorSeekForward->setShortcut(Qt::Key_L);
1058 collection->addAction("monitor_seek_forward", monitorSeekForward);
1059 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1061 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1062 clipStart->setShortcut(Qt::Key_Home);
1063 collection->addAction("seek_clip_start", clipStart);
1064 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1066 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1067 clipEnd->setShortcut(Qt::Key_End);
1068 collection->addAction("seek_clip_end", clipEnd);
1069 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1071 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1072 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1073 collection->addAction("seek_zone_start", zoneStart);
1074 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1076 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1077 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1078 collection->addAction("seek_zone_end", zoneEnd);
1079 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1081 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1082 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1083 collection->addAction("seek_start", projectStart);
1084 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1086 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1087 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1088 collection->addAction("seek_end", projectEnd);
1089 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1091 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1092 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1093 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1094 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1096 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1097 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1098 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1099 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1101 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1102 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1103 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1104 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1106 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1107 deleteItem->setShortcut(Qt::Key_Delete);
1108 collection->addAction("delete_timeline_clip", deleteItem);
1109 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1111 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1112 collection->addAction("change_clip_speed", editTimelineClipSpeed);
1113 editTimelineClipSpeed->setData("change_speed");
1114 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1116 KAction *stickTransition = collection->addAction("auto_transition");
1117 stickTransition->setData(QString("auto"));
1118 stickTransition->setCheckable(true);
1119 stickTransition->setEnabled(false);
1120 stickTransition->setText(i18n("Automatic Transition"));
1121 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1123 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1124 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1125 collection->addAction("group_clip", groupClip);
1126 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1128 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1129 collection->addAction("ungroup_clip", ungroupClip);
1130 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1131 ungroupClip->setData("ungroup_clip");
1132 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1134 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1135 collection->addAction("edit_item_duration", editItemDuration);
1136 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1138 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1139 collection->addAction("clip_in_project_tree", clipInProjectTree);
1140 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1142 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1143 collection->addAction("clip_to_project_tree", clipToProjectTree);
1144 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1146 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1147 insertOvertwrite->setShortcut(Qt::Key_V);
1148 collection->addAction("overwrite_to_in_point", insertOvertwrite);
1149 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1151 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1152 selectTimelineClip->setShortcut(Qt::Key_Plus);
1153 collection->addAction("select_timeline_clip", selectTimelineClip);
1154 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1156 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1157 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1158 collection->addAction("deselect_timeline_clip", deselectTimelineClip);
1159 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1161 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1162 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1163 collection->addAction("select_add_timeline_clip", selectAddTimelineClip);
1164 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1166 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1167 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1168 collection->addAction("select_timeline_transition", selectTimelineTransition);
1169 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1171 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1172 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1173 collection->addAction("deselect_timeline_transition", deselectTimelineTransition);
1174 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1176 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1177 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1178 collection->addAction("select_add_timeline_transition", selectAddTimelineTransition);
1179 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1181 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1182 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1183 collection->addAction("cut_timeline_clip", cutTimelineClip);
1184 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1186 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1187 collection->addAction("add_clip_marker", addClipMarker);
1188 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1190 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1191 collection->addAction("delete_clip_marker", deleteClipMarker);
1192 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1194 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1195 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
1196 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1198 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1199 collection->addAction("edit_clip_marker", editClipMarker);
1200 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1202 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1203 collection->addAction("split_audio", splitAudio);
1204 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1206 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1207 collection->addAction("clip_audio_only", audioOnly);
1208 audioOnly->setData("clip_audio_only");
1209 audioOnly->setCheckable(true);
1211 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1212 collection->addAction("clip_video_only", videoOnly);
1213 videoOnly->setData("clip_video_only");
1214 videoOnly->setCheckable(true);
1216 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1217 collection->addAction("clip_audio_and_video", audioAndVideo);
1218 audioAndVideo->setData("clip_audio_and_video");
1219 audioAndVideo->setCheckable(true);
1221 m_clipTypeGroup = new QActionGroup(this);
1222 m_clipTypeGroup->addAction(audioOnly);
1223 m_clipTypeGroup->addAction(videoOnly);
1224 m_clipTypeGroup->addAction(audioAndVideo);
1225 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1226 m_clipTypeGroup->setEnabled(false);
1228 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1229 collection->addAction("insert_space", insertSpace);
1230 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1232 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1233 collection->addAction("delete_space", removeSpace);
1234 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1236 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1237 collection->addAction("insert_track", insertTrack);
1238 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1240 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1241 collection->addAction("delete_track", deleteTrack);
1242 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1244 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
1245 collection->addAction("config_tracks", configTracks);
1246 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1248 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1249 collection->addAction("add_guide", addGuide);
1250 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1252 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1253 collection->addAction("delete_guide", delGuide);
1254 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1256 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1257 collection->addAction("edit_guide", editGuide);
1258 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1260 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1261 collection->addAction("delete_all_guides", delAllGuides);
1262 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1264 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1265 collection->addAction("paste_effects", pasteEffects);
1266 pasteEffects->setData("paste_effects");
1267 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1269 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1270 collection->addAction("show_timeline", showTimeline);
1271 showTimeline->setCheckable(true);
1272 showTimeline->setChecked(true);
1273 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1275 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1276 collection->addAction("show_titlebars", showTitleBar);
1277 showTitleBar->setCheckable(true);
1278 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1279 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1280 slotShowTitleBars(KdenliveSettings::showtitlebars());
1282 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1283 collection->addAction("maximize_current", maxCurrent);
1284 maxCurrent->setCheckable(true);
1285 maxCurrent->setChecked(false);
1286 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1289 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1291 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1293 KStandardAction::open(this, SLOT(openFile()), collection);
1295 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1297 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1299 KStandardAction::openNew(this, SLOT(newFile()), collection);
1301 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1303 KStandardAction::configureNotifications(this , SLOT(configureNotifications()), collection);
1305 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1307 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1309 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1310 undo->setEnabled(false);
1311 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1313 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1314 redo->setEnabled(false);
1315 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1317 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1320 //TODO: Add status tooltip to actions ?
1321 connect(collection, SIGNAL(actionHovered(QAction*)),
1322 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1325 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1326 collection->addAction("add_clip", addClip);
1327 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1329 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1330 collection->addAction("add_color_clip", addColorClip);
1331 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1333 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1334 collection->addAction("add_slide_clip", addSlideClip);
1335 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1337 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1338 collection->addAction("add_text_clip", addTitleClip);
1339 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1341 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1342 collection->addAction("add_text_template_clip", addTitleTemplateClip);
1343 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1345 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1346 collection->addAction("add_folder", addFolderButton);
1347 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1349 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1350 collection->addAction("clip_properties", clipProperties);
1351 clipProperties->setData("clip_properties");
1352 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1353 clipProperties->setEnabled(false);
1355 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1356 collection->addAction("edit_clip", openClip);
1357 openClip->setData("edit_clip");
1358 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1359 openClip->setEnabled(false);
1361 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1362 collection->addAction("delete_clip", deleteClip);
1363 deleteClip->setData("delete_clip");
1364 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1365 deleteClip->setEnabled(false);
1367 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1368 collection->addAction("reload_clip", reloadClip);
1369 reloadClip->setData("reload_clip");
1370 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1371 reloadClip->setEnabled(false);
1373 QMenu *addClips = new QMenu();
1374 addClips->addAction(addClip);
1375 addClips->addAction(addColorClip);
1376 addClips->addAction(addSlideClip);
1377 addClips->addAction(addTitleClip);
1378 addClips->addAction(addTitleTemplateClip);
1379 addClips->addAction(addFolderButton);
1381 addClips->addAction(reloadClip);
1382 addClips->addAction(clipProperties);
1383 addClips->addAction(openClip);
1384 addClips->addAction(deleteClip);
1385 m_projectList->setupMenu(addClips, addClip);
1387 // Setup effects and transitions actions.
1388 m_videoEffects = new KAction*[videoEffects.count()];
1389 for (int i = 0; i < videoEffects.count(); ++i) {
1390 QStringList effectInfo = videoEffects.effectIdInfo(i);
1391 m_videoEffects[i] = new KAction(KIcon("kdenlive-show-video"), effectInfo.at(0), this);
1392 m_videoEffects[i]->setData(effectInfo);
1393 m_videoEffects[i]->setIconVisibleInMenu(false);
1394 collection->addAction("video_effect_" + effectInfo.at(0), m_videoEffects[i]);
1396 m_audioEffects = new KAction*[audioEffects.count()];
1397 for (int i = 0; i < audioEffects.count(); ++i) {
1398 QStringList effectInfo = audioEffects.effectIdInfo(i);
1399 m_audioEffects[i] = new KAction(KIcon("kdenlive-show-audio"), effectInfo.at(0), this);
1400 m_audioEffects[i]->setData(effectInfo);
1401 m_audioEffects[i]->setIconVisibleInMenu(false);
1402 collection->addAction("audio_effect_" + effectInfo.at(0), m_audioEffects[i]);
1404 m_customEffects = new KAction*[customEffects.count()];
1405 for (int i = 0; i < customEffects.count(); ++i) {
1406 QStringList effectInfo = customEffects.effectIdInfo(i);
1407 m_customEffects[i] = new KAction(KIcon("kdenlive-custom-effect"), effectInfo.at(0), this);
1408 m_customEffects[i]->setData(effectInfo);
1409 m_customEffects[i]->setIconVisibleInMenu(false);
1410 collection->addAction("custom_effect_" + effectInfo.at(0), m_customEffects[i]);
1412 m_transitions = new KAction*[transitions.count()];
1413 for (int i = 0; i < transitions.count(); i++) {
1414 QStringList effectInfo = transitions.effectIdInfo(i);
1415 m_transitions[i] = new KAction(effectInfo.at(0), this);
1416 m_transitions[i]->setData(effectInfo);
1417 m_transitions[i]->setIconVisibleInMenu(false);
1418 collection->addAction("transition_" + effectInfo.at(0), m_transitions[i]);
1421 //connect(collection, SIGNAL( clearStatusText() ),
1422 //statusBar(), SLOT( clear() ) );
1425 void MainWindow::slotDisplayActionMessage(QAction *a)
1427 statusBar()->showMessage(a->data().toString(), 3000);
1430 void MainWindow::saveOptions()
1432 KdenliveSettings::self()->writeConfig();
1433 KSharedConfigPtr config = KGlobal::config();
1434 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1435 KConfigGroup treecolumns(config, "Project Tree");
1436 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1440 void MainWindow::readOptions()
1442 KSharedConfigPtr config = KGlobal::config();
1443 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1444 KConfigGroup initialGroup(config, "version");
1445 bool upgrade = false;
1446 if (initialGroup.exists()) {
1447 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1451 if (initialGroup.readEntry("version") == "0.7") {
1452 //Add new settings from 0.7.1
1453 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1454 QString path = QDir::homePath() + "/kdenlive";
1455 if (KStandardDirs::makeDir(path) == false) {
1456 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1457 } else KdenliveSettings::setDefaultprojectfolder(path);
1463 if (!initialGroup.exists() || upgrade) {
1464 // this is our first run, show Wizard
1465 Wizard *w = new Wizard(upgrade, this);
1466 if (w->exec() == QDialog::Accepted && w->isOk()) {
1467 w->adjustSettings();
1468 initialGroup.writeEntry("version", version);
1474 KConfigGroup treecolumns(config, "Project Tree");
1475 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1476 if (!state.isEmpty())
1477 m_projectList->setHeaderInfo(state);
1480 void MainWindow::slotRunWizard()
1482 Wizard *w = new Wizard(false, this);
1483 if (w->exec() == QDialog::Accepted && w->isOk()) {
1484 w->adjustSettings();
1489 void MainWindow::newFile(bool showProjectSettings, bool force)
1491 if (!m_timelineArea->isEnabled() && !force) return;
1492 m_fileRevert->setEnabled(false);
1493 QString profileName;
1495 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1496 if (!showProjectSettings) {
1497 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1498 profileName = KdenliveSettings::default_profile();
1499 projectFolder = KdenliveSettings::defaultprojectfolder();
1501 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1502 if (w->exec() != QDialog::Accepted) return;
1503 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1504 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
1505 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
1506 profileName = w->selectedProfile();
1507 projectFolder = w->selectedFolder();
1508 projectTracks = w->tracks();
1511 m_timelineArea->setEnabled(true);
1512 m_projectList->setEnabled(true);
1513 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1514 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1516 TrackView *trackView = new TrackView(doc, &ok, this);
1517 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1520 //m_timelineArea->setEnabled(false);
1521 //m_projectList->setEnabled(false);
1525 if (m_timelineArea->count() == 1) {
1526 connectDocumentInfo(doc);
1527 connectDocument(trackView, doc);
1528 } else m_timelineArea->setTabBarHidden(false);
1529 m_monitorManager->activateMonitor("clip");
1530 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1533 void MainWindow::activateDocument()
1535 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1536 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1537 KdenliveDoc *currentDoc = currentTab->document();
1538 connectDocumentInfo(currentDoc);
1539 connectDocument(currentTab, currentDoc);
1542 void MainWindow::closeCurrentDocument(bool saveChanges)
1544 QWidget *w = m_timelineArea->currentWidget();
1546 // closing current document
1547 int ix = m_timelineArea->currentIndex() + 1;
1548 if (ix == m_timelineArea->count()) ix = 0;
1549 m_timelineArea->setCurrentIndex(ix);
1550 TrackView *tabToClose = (TrackView *) w;
1551 KdenliveDoc *docToClose = tabToClose->document();
1552 if (docToClose && docToClose->isModified() && saveChanges) {
1553 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
1554 case KMessageBox::Yes :
1555 // save document here. If saving fails, return false;
1556 if (saveFile() == false) return;
1558 case KMessageBox::Cancel :
1565 m_clipMonitor->slotSetXml(NULL);
1566 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1567 if (m_timelineArea->count() == 1) {
1568 m_timelineArea->setTabBarHidden(true);
1569 m_closeAction->setEnabled(false);
1571 if (docToClose == m_activeDocument) {
1572 delete m_activeDocument;
1573 m_activeDocument = NULL;
1574 m_effectStack->clear();
1575 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1576 } else delete docToClose;
1577 if (w == m_activeTimeline) {
1578 delete m_activeTimeline;
1579 m_activeTimeline = NULL;
1583 bool MainWindow::saveFileAs(const QString &outputFileName)
1585 QString currentSceneList;
1586 m_monitorManager->stopActiveMonitor();
1587 if (KdenliveSettings::dropbframes()) {
1588 KdenliveSettings::setDropbframes(false);
1589 m_activeDocument->clipManager()->updatePreviewSettings();
1590 currentSceneList = m_projectMonitor->sceneList();
1591 KdenliveSettings::setDropbframes(true);
1592 m_activeDocument->clipManager()->updatePreviewSettings();
1593 } else currentSceneList = m_projectMonitor->sceneList();
1595 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1598 // Save timeline thumbnails
1599 m_activeTimeline->projectView()->saveThumbnails();
1600 m_activeDocument->setUrl(KUrl(outputFileName));
1601 if (m_activeDocument->m_autosave == NULL) {
1602 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1603 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1604 setCaption(m_activeDocument->description());
1605 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1606 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1607 m_activeDocument->setModified(false);
1608 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1609 m_fileRevert->setEnabled(true);
1613 bool MainWindow::saveFileAs()
1615 QString outputFile = KFileDialog::getSaveFileName(KUrl(), getMimeType());
1616 if (outputFile.isEmpty()) return false;
1617 if (QFile::exists(outputFile)) {
1618 // Show the file dialog again if the user does not want to overwrite the file
1619 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it?")) == KMessageBox::No)
1620 return saveFileAs();
1622 return saveFileAs(outputFile);
1625 bool MainWindow::saveFile()
1627 if (!m_activeDocument) return true;
1628 if (m_activeDocument->url().isEmpty()) {
1629 return saveFileAs();
1631 bool result = saveFileAs(m_activeDocument->url().path());
1632 m_activeDocument->m_autosave->resize(0);
1637 void MainWindow::openFile()
1639 if (!m_startUrl.isEmpty()) {
1640 openFile(m_startUrl);
1641 m_startUrl = KUrl();
1644 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
1645 if (url.isEmpty()) return;
1646 m_fileOpenRecent->addUrl(url);
1650 void MainWindow::openLastFile()
1652 KSharedConfigPtr config = KGlobal::config();
1653 KUrl::List urls = m_fileOpenRecent->urls();
1654 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1655 if (urls.isEmpty()) newFile(false);
1656 else openFile(urls.last());
1659 void MainWindow::openFile(const KUrl &url)
1661 // Check if the document is already opened
1662 const int ct = m_timelineArea->count();
1663 bool isOpened = false;
1665 for (i = 0; i < ct; i++) {
1666 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1667 KdenliveDoc *doc = tab->document();
1668 if (doc->url() == url) {
1674 m_timelineArea->setCurrentIndex(i);
1678 // Check for backup file
1679 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1680 if (!staleFiles.isEmpty()) {
1681 if (KMessageBox::questionYesNo(this,
1682 i18n("Auto-saved files exist. Do you want to recover them now?"),
1683 i18n("File Recovery"),
1684 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1685 recoverFiles(staleFiles);
1688 // remove the stale files
1689 foreach(KAutoSaveFile *stale, staleFiles) {
1690 stale->open(QIODevice::ReadWrite);
1695 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1696 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
1697 m_messageLabel->repaint();
1698 doOpenFile(url, NULL);
1701 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1703 if (!m_timelineArea->isEnabled()) return;
1704 m_fileRevert->setEnabled(true);
1705 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, this);
1706 if (stale == NULL) {
1707 stale = new KAutoSaveFile(url, doc);
1708 doc->m_autosave = stale;
1710 doc->m_autosave = stale;
1711 doc->setUrl(stale->managedFile());
1712 doc->setModified(true);
1713 stale->setParent(doc);
1715 connectDocumentInfo(doc);
1717 TrackView *trackView = new TrackView(doc, &ok, this);
1718 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1720 m_timelineArea->setEnabled(false);
1721 m_projectList->setEnabled(false);
1722 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
1723 slotGotProgressInfo(QString(), -1);
1724 newFile(false, true);
1727 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1728 trackView->setDuration(trackView->duration());
1729 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1731 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1732 slotGotProgressInfo(QString(), -1);
1733 m_projectMonitor->adjustRulerSize(trackView->duration());
1734 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1735 m_clipMonitor->refreshMonitor(true);
1738 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1740 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1741 foreach(KAutoSaveFile *stale, staleFiles) {
1742 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1743 // show an error message; we could not steal the lockfile
1744 // maybe another application got to the file before us?
1748 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1749 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
1750 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1751 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1755 void MainWindow::parseProfiles(const QString &mltPath)
1757 //KdenliveSettings::setDefaulttmpfolder();
1758 if (!mltPath.isEmpty()) {
1759 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1760 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
1763 if (KdenliveSettings::mltpath().isEmpty()) {
1764 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1767 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
1768 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
1769 if (!QFile::exists(meltPath))
1770 meltPath = KStandardDirs::findExe("melt");
1771 KdenliveSettings::setRendererpath(meltPath);
1774 if (KdenliveSettings::rendererpath().isEmpty()) {
1775 // Cannot find the MLT melt renderer, ask for location
1776 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
1777 if (getUrl->exec() == QDialog::Rejected) {
1780 KUrl rendererPath = getUrl->selectedUrl();
1782 if (rendererPath.isEmpty()) ::exit(0);
1783 KdenliveSettings::setRendererpath(rendererPath.path());
1786 QStringList profilesFilter;
1787 profilesFilter << "*";
1788 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1789 if (profilesList.isEmpty()) {
1790 // Cannot find MLT path, try finding melt
1791 QString profilePath = KdenliveSettings::rendererpath();
1792 if (!profilePath.isEmpty()) {
1793 profilePath = profilePath.section('/', 0, -3);
1794 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1795 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1797 if (profilesList.isEmpty()) {
1798 // Cannot find the MLT profiles, ask for location
1799 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
1800 getUrl->fileDialog()->setMode(KFile::Directory);
1801 if (getUrl->exec() == QDialog::Rejected) {
1804 KUrl mltPath = getUrl->selectedUrl();
1806 if (mltPath.isEmpty()) ::exit(0);
1807 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
1808 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1812 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1814 // Parse again MLT profiles to build a list of available video formats
1815 if (profilesList.isEmpty()) parseProfiles();
1819 void MainWindow::slotEditProfiles()
1821 ProfilesDialog *w = new ProfilesDialog;
1822 if (w->exec() == QDialog::Accepted) {
1823 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1824 if (d) d->checkProfile();
1829 void MainWindow::slotDetectAudioDriver()
1831 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
1832 leading to no audio output, see bug #934 */
1834 //decide which audio driver is really best, in some cases SDL is wrong
1835 if (KdenliveSettings::audiodrivername().isEmpty()) {
1837 KProcess readProcess;
1838 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
1839 if (!KStandardDirs::findExe("pactl").isEmpty()) {
1840 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
1841 readProcess.setProgram("pactl", QStringList() << "stat");
1842 readProcess.execute(2000); // Kill it after 2 seconds
1844 QString result = QString(readProcess.readAllStandardOutput());
1845 kDebug() << "// / / / / / READING PACTL: ";
1847 if (!result.isEmpty()) {
1849 kDebug() << "// / / / / PULSEAUDIO DETECTED";
1853 KdenliveSettings::setAutoaudiodrivername(driver);
1857 void MainWindow::slotEditProjectSettings()
1859 QPoint p = m_activeDocument->getTracksCount();
1860 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
1862 if (w->exec() == QDialog::Accepted) {
1863 QString profile = w->selectedProfile();
1864 m_activeDocument->setProjectFolder(w->selectedFolder());
1865 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path(KUrl::AddTrailingSlash));
1866 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
1867 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
1868 if (m_activeDocument->profilePath() != profile) {
1869 // Profile was changed
1870 double dar = m_activeDocument->dar();
1872 // Deselect current effect / transition
1873 m_effectStack->slotClipItemSelected(NULL, 0);
1874 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1875 m_clipMonitor->slotSetXml(NULL);
1876 bool updateFps = m_activeDocument->setProfilePath(profile);
1877 KdenliveSettings::setCurrent_profile(profile);
1878 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1879 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1881 m_activeDocument->clipManager()->clearUnusedProducers();
1882 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1884 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
1885 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
1886 m_projectList->updateProjectFormat(m_activeDocument->timecode());
1887 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1888 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1889 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1890 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
1891 if (updateFps) m_activeTimeline->updateProjectFps();
1892 m_activeDocument->setModified(true);
1893 m_commandStack->activeStack()->clear();
1894 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
1895 slotUpdateMousePosition(0);
1896 // We need to desactivate & reactivate monitors to get a refresh
1897 //m_monitorManager->switchMonitors();
1904 void MainWindow::slotRenderProject()
1906 if (!m_renderWidget) {
1907 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
1908 m_renderWidget = new RenderWidget(projectfolder, this);
1909 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
1910 connect(m_renderWidget, SIGNAL(selectedRenderProfile(const QString &, const QString &, const QString &, const QString&)), this, SLOT(slotSetDocumentRenderProfile(const QString &, const QString &, const QString &, const QString&)));
1911 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
1912 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1913 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1914 if (m_activeDocument) {
1915 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1916 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1917 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
1918 m_renderWidget->setRenderProfile(m_activeDocument->getDocumentProperty("renderdestination"), m_activeDocument->getDocumentProperty("rendercategory"), m_activeDocument->getDocumentProperty("renderprofile"), m_activeDocument->getDocumentProperty("renderurl"));
1921 slotCheckRenderStatus();
1922 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1923 if (currentTab) m_renderWidget->setTimeline(currentTab);
1924 m_renderWidget->setDocument(m_activeDocument);*/
1925 m_renderWidget->show();
1926 m_renderWidget->showNormal();
1929 void MainWindow::slotCheckRenderStatus()
1931 // Make sure there are no missing clips
1932 if (m_renderWidget) m_renderWidget->missingClips(m_projectList->hasMissingClips());
1935 void MainWindow::setRenderingProgress(const QString &url, int progress)
1937 if (m_renderWidget) m_renderWidget->setRenderJob(url, progress);
1940 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
1942 if (m_renderWidget) m_renderWidget->setRenderStatus(url, status, error);
1945 void MainWindow::slotCleanProject()
1947 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
1948 m_projectList->cleanup();
1951 void MainWindow::slotUpdateMousePosition(int pos)
1953 if (m_activeDocument)
1954 switch (m_timecodeFormat->currentIndex()) {
1956 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1959 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1963 void MainWindow::slotUpdateDocumentState(bool modified)
1965 if (!m_activeDocument) return;
1966 setCaption(m_activeDocument->description(), modified);
1967 m_saveAction->setEnabled(modified);
1969 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1970 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1972 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1973 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1977 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
1979 if (m_activeDocument) {
1980 if (m_activeDocument == doc) return;
1981 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1983 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1986 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
1988 //m_projectMonitor->stop();
1989 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1990 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1991 if (m_activeDocument) {
1992 if (m_activeDocument == doc) return;
1993 if (m_activeTimeline) {
1994 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1995 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1996 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1997 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1998 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
2000 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2001 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2002 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2003 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
2004 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2005 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2006 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
2007 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2008 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2009 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2010 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2011 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2012 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2013 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2014 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2015 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2016 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2017 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2018 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2019 disconnect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
2020 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
2021 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
2022 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
2023 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2024 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2025 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2026 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2027 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2028 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2029 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2030 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2031 disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2032 disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2033 m_effectStack->clear();
2035 //m_activeDocument->setRenderer(NULL);
2036 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
2037 disconnect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2038 m_clipMonitor->stop();
2040 KdenliveSettings::setCurrent_profile(doc->profilePath());
2041 KdenliveSettings::setProject_fps(doc->fps());
2042 m_monitorManager->resetProfiles(doc->timecode());
2043 m_projectList->setDocument(doc);
2044 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2045 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2046 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint)));
2047 connect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2048 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), trackView->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2050 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2051 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2053 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
2056 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2057 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2058 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2059 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2060 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2061 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2062 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2063 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2064 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
2065 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2066 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
2068 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2069 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2070 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
2071 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2072 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2074 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
2075 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2076 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2079 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2080 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2082 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2083 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2084 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2085 m_zoomSlider->setValue(doc->zoom().x());
2086 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2087 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2088 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2089 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2091 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2092 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2095 connect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
2096 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
2097 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
2098 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
2099 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2100 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2101 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2102 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2103 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2105 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2106 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2107 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2108 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2109 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2112 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2113 m_activeTimeline = trackView;
2114 if (m_renderWidget) {
2115 slotCheckRenderStatus();
2116 m_renderWidget->setProfile(doc->mltProfile());
2117 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2118 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2119 m_renderWidget->setRenderProfile(doc->getDocumentProperty("renderdestination"), doc->getDocumentProperty("rendercategory"), doc->getDocumentProperty("renderprofile"), doc->getDocumentProperty("renderurl"));
2121 //doc->setRenderer(m_projectMonitor->render);
2122 m_commandStack->setActiveStack(doc->commandStack());
2123 KdenliveSettings::setProject_display_ratio(doc->dar());
2124 //doc->clipManager()->checkAudioThumbs();
2126 //m_overView->setScene(trackView->projectScene());
2127 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2128 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2130 setCaption(doc->description(), doc->isModified());
2131 m_saveAction->setEnabled(doc->isModified());
2132 m_normalEditTool->setChecked(true);
2133 m_activeDocument = doc;
2134 m_activeTimeline->updateProjectFps();
2135 m_activeDocument->checkProjectClips();
2136 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
2137 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2138 slotUpdateMousePosition(0);
2139 // set tool to select tool
2140 m_buttonSelectTool->setChecked(true);
2143 void MainWindow::slotZoneMoved(int start, int end)
2145 m_activeDocument->setZone(start, end);
2146 m_projectMonitor->slotZoneMoved(start, end);
2149 void MainWindow::slotGuidesUpdated()
2151 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2154 void MainWindow::slotPreferences(int page, int option)
2156 //An instance of your dialog could be already created and could be
2157 // cached, in which case you want to display the cached dialog
2158 // instead of creating another one
2159 if (KConfigDialog::showDialog("settings")) {
2160 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2161 if (page != -1) d->showPage(page, option);
2165 // KConfigDialog didn't find an instance of this dialog, so lets
2167 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
2168 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2169 //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
2170 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2171 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2173 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
2175 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2177 if (page != -1) dialog->showPage(page, option);
2180 void MainWindow::slotUpdatePreviewSettings()
2182 if (m_activeDocument) {
2183 m_clipMonitor->slotSetXml(NULL);
2184 m_activeDocument->updatePreviewSettings();
2188 void MainWindow::updateConfiguration()
2190 //TODO: we should apply settings to all projects, not only the current one
2191 if (m_activeTimeline) {
2192 m_activeTimeline->refresh();
2193 m_activeTimeline->projectView()->checkAutoScroll();
2194 m_activeTimeline->projectView()->checkTrackHeight();
2195 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
2197 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2198 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2199 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2201 // Update list of transcoding profiles
2203 #ifndef NO_JOGSHUTTLE
2204 activateShuttleDevice();
2205 #endif /* NO_JOGSHUTTLE */
2209 void MainWindow::slotSwitchSplitAudio()
2211 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2212 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2215 void MainWindow::slotSwitchVideoThumbs()
2217 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2218 if (m_activeTimeline) {
2219 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2221 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2224 void MainWindow::slotSwitchAudioThumbs()
2226 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2227 if (m_activeTimeline) {
2228 m_activeTimeline->refresh();
2229 m_activeTimeline->projectView()->checkAutoScroll();
2230 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
2232 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2235 void MainWindow::slotSwitchMarkersComments()
2237 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2238 if (m_activeTimeline) {
2239 m_activeTimeline->refresh();
2241 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2244 void MainWindow::slotSwitchSnap()
2246 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2247 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2251 void MainWindow::slotDeleteItem()
2253 if (QApplication::focusWidget()
2254 && QApplication::focusWidget()->parentWidget()
2255 && QApplication::focusWidget()->parentWidget()->parentWidget()
2256 && QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2257 m_projectList->slotRemoveClip();
2260 QWidget *widget = QApplication::focusWidget();
2262 if (widget == m_effectStackDock) {
2263 m_effectStack->slotItemDel();
2266 widget = widget->parentWidget();
2269 // effect stack has no focus
2270 if (m_activeTimeline)
2271 m_activeTimeline->projectView()->deleteSelectedClips();
2275 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2277 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2278 m_clipMonitor->updateMarkers(clip);
2281 void MainWindow::slotAddClipMarker()
2283 DocClipBase *clip = NULL;
2285 if (m_projectMonitor->isActive()) {
2286 if (m_activeTimeline) {
2287 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2289 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2290 clip = item->baseClip();
2294 clip = m_clipMonitor->activeClip();
2295 pos = m_clipMonitor->position();
2298 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2301 QString id = clip->getId();
2302 CommentedTime marker(pos, i18n("Marker"));
2303 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2304 if (d.exec() == QDialog::Accepted) {
2305 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2309 void MainWindow::slotDeleteClipMarker()
2311 DocClipBase *clip = NULL;
2313 if (m_projectMonitor->isActive()) {
2314 if (m_activeTimeline) {
2315 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2317 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2318 clip = item->baseClip();
2322 clip = m_clipMonitor->activeClip();
2323 pos = m_clipMonitor->position();
2326 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2330 QString id = clip->getId();
2331 QString comment = clip->markerComment(pos);
2332 if (comment.isEmpty()) {
2333 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2336 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2339 void MainWindow::slotDeleteAllClipMarkers()
2341 DocClipBase *clip = NULL;
2342 if (m_projectMonitor->isActive()) {
2343 if (m_activeTimeline) {
2344 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2346 clip = item->baseClip();
2350 clip = m_clipMonitor->activeClip();
2353 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2356 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2359 void MainWindow::slotEditClipMarker()
2361 DocClipBase *clip = NULL;
2363 if (m_projectMonitor->isActive()) {
2364 if (m_activeTimeline) {
2365 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2367 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2368 clip = item->baseClip();
2372 clip = m_clipMonitor->activeClip();
2373 pos = m_clipMonitor->position();
2376 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2380 QString id = clip->getId();
2381 QString oldcomment = clip->markerComment(pos);
2382 if (oldcomment.isEmpty()) {
2383 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2387 CommentedTime marker(pos, oldcomment);
2388 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2389 if (d.exec() == QDialog::Accepted) {
2390 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2391 if (d.newMarker().time() != pos) {
2392 // remove old marker
2393 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2398 void MainWindow::slotAddGuide()
2400 if (m_activeTimeline)
2401 m_activeTimeline->projectView()->slotAddGuide();
2404 void MainWindow::slotInsertSpace()
2406 if (m_activeTimeline)
2407 m_activeTimeline->projectView()->slotInsertSpace();
2410 void MainWindow::slotRemoveSpace()
2412 if (m_activeTimeline)
2413 m_activeTimeline->projectView()->slotRemoveSpace();
2416 void MainWindow::slotInsertTrack(int ix)
2418 m_projectMonitor->activateMonitor();
2419 if (m_activeTimeline)
2420 m_activeTimeline->projectView()->slotInsertTrack(ix);
2421 if (m_activeDocument)
2422 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2425 void MainWindow::slotDeleteTrack(int ix)
2427 m_projectMonitor->activateMonitor();
2428 if (m_activeTimeline)
2429 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2430 if (m_activeDocument)
2431 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2434 void MainWindow::slotConfigTrack(int ix)
2436 m_projectMonitor->activateMonitor();
2437 if (m_activeTimeline)
2438 m_activeTimeline->projectView()->slotConfigTracks(ix);
2439 if (m_activeDocument)
2440 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2443 void MainWindow::slotEditGuide()
2445 if (m_activeTimeline)
2446 m_activeTimeline->projectView()->slotEditGuide();
2449 void MainWindow::slotDeleteGuide()
2451 if (m_activeTimeline)
2452 m_activeTimeline->projectView()->slotDeleteGuide();
2455 void MainWindow::slotDeleteAllGuides()
2457 if (m_activeTimeline)
2458 m_activeTimeline->projectView()->slotDeleteAllGuides();
2461 void MainWindow::slotCutTimelineClip()
2463 if (m_activeTimeline) {
2464 m_activeTimeline->projectView()->cutSelectedClips();
2468 void MainWindow::slotInsertClipOverwrite()
2470 if (m_activeTimeline) {
2471 QStringList data = m_clipMonitor->getZoneInfo();
2472 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2476 void MainWindow::slotSelectTimelineClip()
2478 if (m_activeTimeline) {
2479 m_activeTimeline->projectView()->selectClip(true);
2483 void MainWindow::slotSelectTimelineTransition()
2485 if (m_activeTimeline) {
2486 m_activeTimeline->projectView()->selectTransition(true);
2490 void MainWindow::slotDeselectTimelineClip()
2492 if (m_activeTimeline) {
2493 m_activeTimeline->projectView()->selectClip(false, true);
2497 void MainWindow::slotDeselectTimelineTransition()
2499 if (m_activeTimeline) {
2500 m_activeTimeline->projectView()->selectTransition(false, true);
2504 void MainWindow::slotSelectAddTimelineClip()
2506 if (m_activeTimeline) {
2507 m_activeTimeline->projectView()->selectClip(true, true);
2511 void MainWindow::slotSelectAddTimelineTransition()
2513 if (m_activeTimeline) {
2514 m_activeTimeline->projectView()->selectTransition(true, true);
2518 void MainWindow::slotGroupClips()
2520 if (m_activeTimeline) {
2521 m_activeTimeline->projectView()->groupClips();
2525 void MainWindow::slotUnGroupClips()
2527 if (m_activeTimeline) {
2528 m_activeTimeline->projectView()->groupClips(false);
2532 void MainWindow::slotEditItemDuration()
2534 if (m_activeTimeline) {
2535 m_activeTimeline->projectView()->editItemDuration();
2539 void MainWindow::slotAddProjectClip(KUrl url)
2541 if (m_activeDocument)
2542 m_activeDocument->slotAddClipFile(url, QString());
2545 void MainWindow::slotAddTransition(QAction *result)
2547 if (!result) return;
2548 QStringList info = result->data().toStringList();
2549 if (info.isEmpty()) return;
2550 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2551 if (m_activeTimeline && !transition.isNull()) {
2552 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2556 void MainWindow::slotAddVideoEffect(QAction *result)
2558 if (!result) return;
2559 QStringList info = result->data().toStringList();
2560 if (info.isEmpty()) return;
2561 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2562 slotAddEffect(effect);
2565 void MainWindow::slotAddAudioEffect(QAction *result)
2567 if (!result) return;
2568 QStringList info = result->data().toStringList();
2569 if (info.isEmpty()) return;
2570 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2571 slotAddEffect(effect);
2574 void MainWindow::slotAddCustomEffect(QAction *result)
2576 if (!result) return;
2577 QStringList info = result->data().toStringList();
2578 if (info.isEmpty()) return;
2579 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2580 slotAddEffect(effect);
2583 void MainWindow::slotZoomIn()
2585 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2586 slotShowZoomSliderToolTip();
2589 void MainWindow::slotZoomOut()
2591 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2592 slotShowZoomSliderToolTip();
2595 void MainWindow::slotFitZoom()
2597 if (m_activeTimeline) {
2598 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2602 void MainWindow::slotSetZoom(int value)
2604 if (m_activeTimeline)
2605 m_activeTimeline->slotChangeZoom(value);
2607 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
2608 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
2609 slotUpdateZoomSliderToolTip(value);
2611 m_zoomSlider->blockSignals(true);
2612 m_zoomSlider->setValue(value);
2613 m_zoomSlider->blockSignals(false);
2616 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
2618 if (zoomlevel != -1)
2619 slotUpdateZoomSliderToolTip(zoomlevel);
2621 QPoint global = m_zoomSlider->rect().topLeft();
2622 global.ry() += m_zoomSlider->height() / 2;
2623 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
2624 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
2627 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
2629 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
2632 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2634 m_statusProgressBar->setValue(progress);
2635 if (progress >= 0) {
2636 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2637 m_statusProgressBar->setVisible(true);
2638 } else if (progress == -2) {
2639 if (!message.isEmpty()) m_messageLabel->setMessage(message, ErrorMessage);
2640 m_statusProgressBar->setVisible(false);
2642 m_messageLabel->setMessage(QString(), DefaultMessage);
2643 m_statusProgressBar->setVisible(false);
2647 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2649 if (clip->clipType() == TEXT) {
2650 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
2651 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
2652 // template text clip
2654 // Get the list of existing templates
2656 filter << "*.kdenlivetitle";
2657 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
2659 QDialog *dia = new QDialog(this);
2660 Ui::TemplateClip_UI dia_ui;
2661 dia_ui.setupUi(dia);
2663 const QString templatePath = clip->getProperty("resource");
2664 for (int i = 0; i < templateFiles.size(); ++i) {
2665 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
2666 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
2668 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
2669 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
2670 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
2671 //warning: setting base directory doesn't work??
2672 KUrl startDir(titlepath);
2673 dia_ui.template_list->fileDialog()->setUrl(startDir);
2674 dia_ui.description->setText(clip->getProperty("description"));
2675 if (dia->exec() == QDialog::Accepted) {
2676 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
2677 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
2679 QMap <QString, QString> newprops;
2681 if (KUrl(textTemplate).path() != templatePath) {
2682 // The template was changed
2683 newprops.insert("resource", textTemplate);
2686 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
2687 newprops.insert("description", dia_ui.description->toPlainText());
2690 QString newtemplate = newprops.value("xmltemplate");
2691 if (newtemplate.isEmpty()) newtemplate = templatePath;
2693 // template modified we need to update xmldata
2694 QString description = newprops.value("description");
2695 if (description.isEmpty()) description = clip->getProperty("description");
2696 else newprops.insert("templatetext", description);
2697 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
2698 if (!newprops.isEmpty()) {
2699 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2700 m_activeDocument->commandStack()->push(command);
2706 QString path = clip->getProperty("resource");
2707 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
2709 doc.setContent(clip->getProperty("xmldata"));
2710 dia_ui->setXml(doc);
2711 if (dia_ui->exec() == QDialog::Accepted) {
2712 QMap <QString, QString> newprops;
2713 newprops.insert("xmldata", dia_ui->xml().toString());
2714 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
2715 // duration changed, we need to update duration
2716 newprops.insert("out", QString::number(dia_ui->outPoint()));
2718 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2719 m_activeDocument->commandStack()->push(command);
2720 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
2721 m_activeDocument->setModified(true);
2725 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2728 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2729 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2730 if (dia.exec() == QDialog::Accepted) {
2731 QMap <QString, QString> newprops = dia.properties();
2732 if (newprops.isEmpty()) return;
2733 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2734 m_activeDocument->commandStack()->push(command);
2736 if (dia.needsTimelineRefresh()) {
2737 // update clip occurences in timeline
2738 m_activeTimeline->projectView()->slotUpdateClip(clip->getId(), dia.needsTimelineReload());
2744 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
2746 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
2747 if (dia.exec() == QDialog::Accepted) {
2748 QUndoCommand *command = new QUndoCommand();
2749 command->setText(i18n("Edit clips"));
2750 for (int i = 0; i < cliplist.count(); i++) {
2751 DocClipBase *clip = cliplist.at(i);
2752 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true, command);
2754 m_activeDocument->commandStack()->push(command);
2755 for (int i = 0; i < cliplist.count(); i++) {
2756 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
2761 void MainWindow::customEvent(QEvent* e)
2763 if (e->type() == QEvent::User) {
2764 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
2767 void MainWindow::slotActivateEffectStackView()
2769 m_effectStack->raiseWindow(m_effectStackDock);
2772 void MainWindow::slotActivateTransitionView(Transition *t)
2774 if (t) m_transitionConfig->raiseWindow(m_transitionConfigDock);
2777 void MainWindow::slotSnapRewind()
2779 if (m_projectMonitor->isActive()) {
2780 if (m_activeTimeline)
2781 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2782 } else m_clipMonitor->slotSeekToPreviousSnap();
2785 void MainWindow::slotSnapForward()
2787 if (m_projectMonitor->isActive()) {
2788 if (m_activeTimeline)
2789 m_activeTimeline->projectView()->slotSeekToNextSnap();
2790 } else m_clipMonitor->slotSeekToNextSnap();
2793 void MainWindow::slotClipStart()
2795 if (m_projectMonitor->isActive()) {
2796 if (m_activeTimeline)
2797 m_activeTimeline->projectView()->clipStart();
2801 void MainWindow::slotClipEnd()
2803 if (m_projectMonitor->isActive()) {
2804 if (m_activeTimeline)
2805 m_activeTimeline->projectView()->clipEnd();
2809 void MainWindow::slotZoneStart()
2811 if (m_projectMonitor->isActive()) m_projectMonitor->slotZoneStart();
2812 else m_clipMonitor->slotZoneStart();
2815 void MainWindow::slotZoneEnd()
2817 if (m_projectMonitor->isActive()) m_projectMonitor->slotZoneEnd();
2818 else m_clipMonitor->slotZoneEnd();
2821 void MainWindow::slotChangeTool(QAction * action)
2823 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
2824 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
2825 else if (action == m_buttonSpacerTool) slotSetTool(SPACERTOOL);
2828 void MainWindow::slotChangeEdit(QAction * action)
2830 if (!m_activeTimeline) return;
2831 if (action == m_overwriteEditTool) m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
2832 else if (action == m_insertEditTool) m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
2833 else m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
2836 void MainWindow::slotSetTool(PROJECTTOOL tool)
2838 if (m_activeDocument && m_activeTimeline) {
2839 //m_activeDocument->setTool(tool);
2843 message = i18n("Ctrl + click to use spacer on current track only");
2846 message = i18n("Click on a clip to cut it");
2849 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
2852 m_messageLabel->setMessage(message, InformationMessage);
2853 m_activeTimeline->projectView()->setTool(tool);
2857 void MainWindow::slotCopy()
2859 if (!m_activeDocument || !m_activeTimeline) return;
2860 m_activeTimeline->projectView()->copyClip();
2863 void MainWindow::slotPaste()
2865 if (!m_activeDocument || !m_activeTimeline) return;
2866 m_activeTimeline->projectView()->pasteClip();
2869 void MainWindow::slotPasteEffects()
2871 if (!m_activeDocument || !m_activeTimeline) return;
2872 m_activeTimeline->projectView()->pasteClipEffects();
2875 void MainWindow::slotFind()
2877 if (!m_activeDocument || !m_activeTimeline) return;
2878 m_projectSearch->setEnabled(false);
2879 m_findActivated = true;
2880 m_findString.clear();
2881 m_activeTimeline->projectView()->initSearchStrings();
2882 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2883 m_findTimer.start(5000);
2884 qApp->installEventFilter(this);
2887 void MainWindow::slotFindNext()
2889 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
2890 statusBar()->showMessage(i18n("Found: %1", m_findString));
2892 statusBar()->showMessage(i18n("Reached end of project"));
2894 m_findTimer.start(4000);
2897 void MainWindow::findAhead()
2899 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
2900 m_projectSearchNext->setEnabled(true);
2901 statusBar()->showMessage(i18n("Found: %1", m_findString));
2903 m_projectSearchNext->setEnabled(false);
2904 statusBar()->showMessage(i18n("Not found: %1", m_findString));
2908 void MainWindow::findTimeout()
2910 m_projectSearchNext->setEnabled(false);
2911 m_findActivated = false;
2912 m_findString.clear();
2913 statusBar()->showMessage(i18n("Find stopped"), 3000);
2914 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
2915 m_projectSearch->setEnabled(true);
2916 removeEventFilter(this);
2919 void MainWindow::slotClipInTimeline(const QString &clipId)
2921 if (m_activeTimeline && m_activeDocument) {
2922 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
2924 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
2925 inTimelineMenu->clear();
2927 QList <QAction *> actionList;
2929 for (int i = 0; i < matching.count(); ++i) {
2930 QString track = QString::number(matching.at(i).track);
2931 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
2933 QAction *a = new QAction(track + ": " + start, this);
2934 a->setData(QStringList() << track << start);
2935 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
2936 while (j < actionList.count()) {
2937 if (actionList.at(j)->text() > a->text()) break;
2940 actionList.insert(j, a);
2943 inTimelineMenu->addActions(actionList);
2945 if (matching.empty())
2946 inTimelineMenu->setEnabled(false);
2948 inTimelineMenu->setEnabled(true);
2952 void MainWindow::slotClipInProjectTree()
2954 if (m_activeTimeline) {
2955 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
2956 if (clipIds.isEmpty()) return;
2957 m_projectListDock->raise();
2958 for (int i = 0; i < clipIds.count(); i++) {
2959 m_projectList->selectItemById(clipIds.at(i));
2961 if (m_projectMonitor->isActive())
2962 slotSwitchMonitors();
2966 /*void MainWindow::slotClipToProjectTree()
2968 if (m_activeTimeline) {
2969 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
2970 if (clips.isEmpty()) return;
2971 for (int i = 0; i < clips.count(); i++) {
2972 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
2974 //m_projectList->selectItemById(clipIds.at(i));
2978 void MainWindow::slotSelectClipInTimeline()
2980 if (m_activeTimeline) {
2981 QAction *action = qobject_cast<QAction *>(sender());
2982 QStringList data = action->data().toStringList();
2983 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
2987 void MainWindow::keyPressEvent(QKeyEvent *ke)
2989 if (m_findActivated) {
2990 if (ke->key() == Qt::Key_Backspace) {
2991 m_findString = m_findString.left(m_findString.length() - 1);
2993 if (!m_findString.isEmpty()) {
2999 m_findTimer.start(4000);
3002 } else if (ke->key() == Qt::Key_Escape) {
3006 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3007 m_findString += ke->text();
3011 m_findTimer.start(4000);
3015 } else KXmlGuiWindow::keyPressEvent(ke);
3019 /** Gets called when the window gets hidden */
3020 void MainWindow::hideEvent(QHideEvent */*event*/)
3023 if (m_monitorManager)
3024 m_monitorManager->stopActiveMonitor();
3027 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3029 if (m_findActivated) {
3030 if (event->type() == QEvent::ShortcutOverride) {
3031 QKeyEvent* ke = (QKeyEvent*) event;
3032 if (ke->text().trimmed().isEmpty()) return false;
3035 } else return false;
3037 // pass the event on to the parent class
3038 return QMainWindow::eventFilter(obj, event);
3043 void MainWindow::slotSaveZone(Render *render, QPoint zone)
3045 KDialog *dialog = new KDialog(this);
3046 dialog->setCaption("Save clip zone");
3047 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3049 QWidget *widget = new QWidget(dialog);
3050 dialog->setMainWidget(widget);
3052 QVBoxLayout *vbox = new QVBoxLayout(widget);
3053 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3054 QString path = m_activeDocument->projectFolder().path();
3056 path.append("untitled.mlt");
3057 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
3058 url->setFilter("video/mlt-playlist");
3059 QLabel *label2 = new QLabel(i18n("Description:"), this);
3060 KLineEdit *edit = new KLineEdit(this);
3061 vbox->addWidget(label1);
3062 vbox->addWidget(url);
3063 vbox->addWidget(label2);
3064 vbox->addWidget(edit);
3065 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
3069 void MainWindow::slotSetInPoint()
3071 if (m_clipMonitor->isActive()) {
3072 m_clipMonitor->slotSetZoneStart();
3073 } else m_projectMonitor->slotSetZoneStart();
3074 //else m_activeTimeline->projectView()->setInPoint();
3077 void MainWindow::slotSetOutPoint()
3079 if (m_clipMonitor->isActive()) {
3080 m_clipMonitor->slotSetZoneEnd();
3081 } else m_projectMonitor->slotSetZoneEnd();
3082 // else m_activeTimeline->projectView()->setOutPoint();
3085 void MainWindow::slotResizeItemStart()
3087 if (m_activeTimeline) m_activeTimeline->projectView()->setInPoint();
3090 void MainWindow::slotResizeItemEnd()
3092 if (m_activeTimeline) m_activeTimeline->projectView()->setOutPoint();
3095 int MainWindow::getNewStuff(const QString &configFile)
3097 KNS3::Entry::List entries;
3098 #if KDE_IS_VERSION(4,3,80)
3099 KNS3::DownloadDialog dialog(configFile);
3101 entries = dialog.changedEntries();
3102 foreach(const KNS3::Entry &entry, entries) {
3103 if (entry.status() == KNS3::Entry::Installed)
3104 kDebug() << "// Installed files: " << entry.installedFiles();
3107 KNS::Engine engine(0);
3108 if (engine.init(configFile))
3109 entries = engine.downloadDialogModal(this);
3110 foreach(KNS::Entry *entry, entries) {
3111 if (entry->status() == KNS::Entry::Installed)
3112 kDebug() << "// Installed files: " << entry->installedFiles();
3114 #endif /* KDE_IS_VERSION(4,3,80) */
3115 return entries.size();
3118 void MainWindow::slotGetNewTitleStuff()
3120 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3121 TitleWidget::refreshTitleTemplates();
3124 void MainWindow::slotGetNewLumaStuff()
3126 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3127 initEffects::refreshLumas();
3128 m_activeTimeline->projectView()->reloadTransitionLumas();
3132 void MainWindow::slotGetNewRenderStuff()
3134 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3136 m_renderWidget->reloadProfiles();
3139 void MainWindow::slotGetNewMltProfileStuff()
3141 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3142 // update the list of profiles in settings dialog
3143 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3149 void MainWindow::slotAutoTransition()
3151 if (m_activeTimeline) m_activeTimeline->projectView()->autoTransition();
3154 void MainWindow::slotSplitAudio()
3156 if (m_activeTimeline) m_activeTimeline->projectView()->splitAudio();
3159 void MainWindow::slotUpdateClipType(QAction *action)
3161 if (m_activeTimeline) {
3162 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3163 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3164 else m_activeTimeline->projectView()->setAudioAndVideo();
3168 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3170 // We must stop the monitors since we create a new on in the dvd wizard
3171 m_clipMonitor->stop();
3172 m_projectMonitor->stop();
3173 DvdWizard w(url, profile, this);
3175 m_projectMonitor->start();
3178 void MainWindow::slotShowTimeline(bool show)
3180 if (show == false) {
3181 m_timelineState = saveState();
3182 centralWidget()->setHidden(true);
3184 centralWidget()->setHidden(false);
3185 restoreState(m_timelineState);
3189 void MainWindow::slotMaximizeCurrent(bool /*show*/)
3191 //TODO: is there a way to maximize current widget?
3194 m_timelineState = saveState();
3195 QWidget *par = focusWidget()->parentWidget();
3196 while (par->parentWidget() && par->parentWidget() != this) {
3197 par = par->parentWidget();
3199 kDebug() << "CURRENT WIDGET: " << par->objectName();
3202 //centralWidget()->setHidden(false);
3203 //restoreState(m_timelineState);
3207 void MainWindow::loadTranscoders()
3209 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3212 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3213 KConfigGroup transConfig(config, "Transcoding");
3215 QMap< QString, QString > profiles = transConfig.entryMap();
3216 QMapIterator<QString, QString> i(profiles);
3217 while (i.hasNext()) {
3219 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3220 QAction *a = transMenu->addAction(i.key());
3222 if (data.count() > 1) {
3223 a->setToolTip(data.at(1));
3225 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3229 void MainWindow::slotTranscode(KUrl::List urls)
3234 if (urls.isEmpty()) {
3235 QAction *action = qobject_cast<QAction *>(sender());
3236 QStringList data = action->data().toStringList();
3237 params = data.at(0);
3238 if (data.count() > 1) desc = data.at(1);
3239 if (data.count() > 2) condition = data.at(2);
3240 urls << m_projectList->getConditionalUrls(condition);
3241 urls.removeAll(KUrl());
3243 if (urls.isEmpty()) {
3244 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3247 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3248 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3250 //QProcess::startDetached("ffmpeg", parameters);
3253 void MainWindow::slotTranscodeClip()
3255 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3256 if (urls.isEmpty()) return;
3257 slotTranscode(urls);
3260 void MainWindow::slotSetDocumentRenderProfile(const QString &dest, const QString &group, const QString &name, const QString &file)
3262 if (m_activeDocument == NULL) return;
3263 m_activeDocument->setDocumentProperty("renderdestination", dest);
3264 m_activeDocument->setDocumentProperty("rendercategory", group);
3265 m_activeDocument->setDocumentProperty("renderprofile", name);
3266 m_activeDocument->setDocumentProperty("renderurl", file);
3267 m_activeDocument->setModified(true);
3271 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3273 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3275 QString playlistPath;
3278 QString scriptsFolder = m_activeDocument->projectFolder().path() + "/scripts/";
3279 QString path = m_renderWidget->getFreeScriptName();
3280 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3281 if (!ok || scriptPath.isEmpty()) return;
3282 scriptPath.prepend(scriptsFolder);
3283 QFile f(scriptPath);
3285 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3288 playlistPath = scriptPath + ".mlt";
3289 m_projectMonitor->saveSceneList(playlistPath);
3291 KTemporaryFile temp;
3292 temp.setAutoRemove(false);
3293 temp.setSuffix(".mlt");
3295 playlistPath = temp.fileName();
3296 m_projectMonitor->saveSceneList(playlistPath);
3299 if (!chapterFile.isEmpty()) {
3302 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3304 in = m_activeTimeline->inPoint();
3305 out = m_activeTimeline->outPoint();
3308 QDomElement chapters = doc.createElement("chapters");
3309 chapters.setAttribute("fps", m_activeDocument->fps());
3310 doc.appendChild(chapters);
3312 QDomElement guidesxml = m_activeDocument->guidesXml();
3313 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3314 for (int i = 0; i < nodes.count(); i++) {
3315 QDomElement e = nodes.item(i).toElement();
3317 QString comment = e.attribute("comment");
3318 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3319 if (time >= in && time < out) {
3320 if (zoneOnly) time = time - in;
3321 QDomElement chapter = doc.createElement("chapter");
3322 chapters.appendChild(chapter);
3323 chapter.setAttribute("title", comment);
3324 chapter.setAttribute("time", time);
3328 if (chapters.childNodes().count() > 0) {
3329 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3330 // Always insert a guide in pos 0
3331 QDomElement chapter = doc.createElement("chapter");
3332 chapters.insertBefore(chapter, QDomNode());
3333 chapter.setAttribute("title", i18n("Start"));
3334 chapter.setAttribute("time", "0");
3336 // save chapters file
3337 QFile file(chapterFile);
3338 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3339 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3341 file.write(doc.toString().toUtf8());
3342 if (file.error() != QFile::NoError) {
3343 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3350 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath);
3353 void MainWindow::slotUpdateTimecodeFormat(int ix)
3355 KdenliveSettings::setFrametimecode(ix == 1);
3356 m_clipMonitor->updateTimecodeFormat();
3357 m_projectMonitor->updateTimecodeFormat();
3358 m_transitionConfig->updateTimecodeFormat();
3359 m_effectStack->updateTimecodeFormat();
3360 //m_activeTimeline->projectView()->clearSelection();
3361 m_activeTimeline->updateRuler();
3364 void MainWindow::slotRemoveFocus()
3366 statusBar()->setFocus();
3367 statusBar()->clearFocus();
3370 void MainWindow::slotRevert()
3372 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;
3373 KUrl url = m_activeDocument->url();
3374 closeCurrentDocument(false);
3375 doOpenFile(url, NULL);
3379 void MainWindow::slotShutdown()
3381 if (m_activeDocument) m_activeDocument->setModified(false);
3383 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
3384 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
3385 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
3386 smserver.call("logout", 1, 2, 2);
3387 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
3388 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
3389 smserver.call("Shutdown");
3393 void MainWindow::slotUpdateTrackInfo()
3395 if (m_activeDocument)
3396 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
3399 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
3401 // Load the theme file
3403 if (action == NULL) theme = themename;
3404 else theme = action->data().toString();
3405 KdenliveSettings::setColortheme(theme);
3406 // Make palette for all widgets.
3408 if (theme.isEmpty())
3409 plt = QApplication::desktop()->palette();
3411 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
3412 plt = KGlobalSettings::createApplicationPalette(config);
3415 kapp->setPalette(plt);
3416 const QObjectList children = statusBar()->children();
3418 foreach(QObject *child, children) {
3419 if (child->isWidgetType())
3420 ((QWidget*)child)->setPalette(plt);
3421 const QObjectList subchildren = child->children();
3422 foreach(QObject *subchild, subchildren) {
3423 if (subchild->isWidgetType())
3424 ((QWidget*)subchild)->setPalette(plt);
3427 m_activeTimeline->projectView()->updatePalette();
3431 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
3433 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
3434 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
3435 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
3436 const QSize bitsSize(24, 2);
3437 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
3438 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
3440 QPixmap pixmap(23, 16);
3441 pixmap.fill(Qt::black); // ### use some color other than black for borders?
3443 KConfigGroup group(config, "WM");
3444 QPainter p(&pixmap);
3445 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
3446 p.fillRect(1, 1, 7, 7, windowScheme.background());
3447 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
3449 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
3450 p.fillRect(8, 1, 7, 7, buttonScheme.background());
3451 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
3453 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
3454 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
3456 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
3457 p.fillRect(1, 8, 7, 7, viewScheme.background());
3458 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
3460 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
3461 p.fillRect(8, 8, 7, 7, selectionScheme.background());
3462 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
3464 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
3465 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
3471 void MainWindow::slotSwitchMonitors()
3473 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
3474 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
3475 else m_projectList->focusTree();
3478 void MainWindow::slotInsertZoneToTree()
3480 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
3481 QStringList info = m_clipMonitor->getZoneInfo();
3482 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
3485 void MainWindow::slotInsertZoneToTimeline()
3487 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
3488 QStringList info = m_clipMonitor->getZoneInfo();
3489 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
3493 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
3495 if (m_activeDocument && m_activeTimeline) {
3496 if (!ids.isEmpty()) {
3497 for (int i = 0; i < ids.size(); ++i) {
3498 m_activeTimeline->slotDeleteClip(ids.at(i));
3500 m_activeDocument->clipManager()->slotDeleteClips(ids);
3502 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
3503 m_activeDocument->setModified(true);
3507 void MainWindow::slotShowTitleBars(bool show)
3510 m_effectStackDock->setTitleBarWidget(0);
3511 m_clipMonitorDock->setTitleBarWidget(0);
3512 m_projectMonitorDock->setTitleBarWidget(0);
3514 m_recMonitorDock->setTitleBarWidget(0);
3516 m_effectListDock->setTitleBarWidget(0);
3517 m_transitionConfigDock->setTitleBarWidget(0);
3518 m_projectListDock->setTitleBarWidget(0);
3519 m_undoViewDock->setTitleBarWidget(0);
3521 if (!m_effectStackDock->isFloating()) m_effectStackDock->setTitleBarWidget(new QWidget(this));
3522 if (!m_clipMonitorDock->isFloating()) m_clipMonitorDock->setTitleBarWidget(new QWidget(this));
3523 if (!m_projectMonitorDock->isFloating()) m_projectMonitorDock->setTitleBarWidget(new QWidget(this));
3525 if (!m_recMonitorDock->isFloating()) m_recMonitorDock->setTitleBarWidget(new QWidget(this));
3527 if (!m_effectListDock->isFloating()) m_effectListDock->setTitleBarWidget(new QWidget(this));
3528 if (!m_transitionConfigDock->isFloating()) m_transitionConfigDock->setTitleBarWidget(new QWidget(this));
3529 if (!m_projectListDock->isFloating()) m_projectListDock->setTitleBarWidget(new QWidget(this));
3530 if (!m_undoViewDock->isFloating()) m_undoViewDock->setTitleBarWidget(new QWidget(this));
3532 KdenliveSettings::setShowtitlebars(show);
3535 void MainWindow::slotSwitchTitles()
3537 slotShowTitleBars(!KdenliveSettings::showtitlebars());
3540 QString MainWindow::getMimeType()
3542 QString mimetype = "application/x-kdenlive";
3543 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
3544 if (!mime) mimetype = "*.kdenlive";
3548 #include "mainwindow.moc"