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 #include <knewstuff2/engine.h>
83 #include <knewstuff2/ui/knewstuffaction.h>
85 #include <KColorScheme>
87 #include <QTextStream>
91 #include <QInputDialog>
92 #include <QDesktopWidget>
97 static const char version[] = VERSION;
99 static const int ID_TIMELINE_POS = 0;
106 EffectsList MainWindow::videoEffects;
107 EffectsList MainWindow::audioEffects;
108 EffectsList MainWindow::customEffects;
109 EffectsList MainWindow::transitions;
111 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent) :
112 KXmlGuiWindow(parent),
113 m_activeDocument(NULL),
114 m_activeTimeline(NULL),
115 m_timecodeFormat(NULL),
116 m_renderWidget(NULL),
117 #ifndef NO_JOGSHUTTLE
119 #endif /* NO_JOGSHUTTLE */
121 m_findActivated(false)
124 // Create DBus interface
125 new MainWindowAdaptor(this);
126 QDBusConnection dbus = QDBusConnection::sessionBus();
127 dbus.registerObject("/MainWindow", this);
129 setlocale(LC_NUMERIC, "POSIX");
130 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
131 setFont(KGlobalSettings::toolBarFont());
132 parseProfiles(MltPath);
133 m_commandStack = new QUndoGroup;
134 m_timelineArea = new KTabWidget(this);
135 m_timelineArea->setTabReorderingEnabled(true);
136 m_timelineArea->setTabBarHidden(true);
138 QToolButton *closeTabButton = new QToolButton;
139 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
140 closeTabButton->setIcon(KIcon("tab-close"));
141 closeTabButton->adjustSize();
142 closeTabButton->setToolTip(i18n("Close the current tab"));
143 m_timelineArea->setCornerWidget(closeTabButton);
144 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
146 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
147 m_findTimer.setSingleShot(true);
149 // FIXME: the next call returns a newly allocated object, which leaks
150 initEffects::parseEffectFiles();
151 //initEffects::parseCustomEffectsFile();
153 m_monitorManager = new MonitorManager();
155 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
156 m_projectListDock->setObjectName("project_tree");
157 m_projectList = new ProjectList(this);
158 m_projectListDock->setWidget(m_projectList);
159 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
161 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
162 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
164 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
165 m_effectListDock->setObjectName("effect_list");
166 m_effectList = new EffectsListView();
168 //m_effectList = new KListWidget(this);
169 m_effectListDock->setWidget(m_effectList);
170 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
172 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
173 m_effectStackDock->setObjectName("effect_stack");
174 m_effectStack = new EffectStackView(this);
175 m_effectStackDock->setWidget(m_effectStack);
176 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
178 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
179 m_transitionConfigDock->setObjectName("transition");
180 m_transitionConfig = new TransitionSettings(this);
181 m_transitionConfigDock->setWidget(m_transitionConfig);
182 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
184 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
185 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
187 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
188 m_fileRevert->setEnabled(false);
190 //slotDetectAudioDriver();
192 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
193 m_clipMonitorDock->setObjectName("clip_monitor");
194 m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), this);
195 m_clipMonitorDock->setWidget(m_clipMonitor);
196 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
197 //m_clipMonitor->stop();
199 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
200 m_projectMonitorDock->setObjectName("project_monitor");
201 m_projectMonitor = new Monitor("project", m_monitorManager, QString(), this);
202 m_projectMonitorDock->setWidget(m_projectMonitor);
203 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
206 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
207 m_recMonitorDock->setObjectName("record_monitor");
208 m_recMonitor = new RecMonitor("record", this);
209 m_recMonitorDock->setWidget(m_recMonitor);
210 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
212 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
213 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
216 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
217 m_undoViewDock->setObjectName("undo_history");
218 m_undoView = new QUndoView(this);
219 m_undoView->setCleanIcon(KIcon("edit-clear"));
220 m_undoView->setEmptyLabel(i18n("Clean"));
221 m_undoViewDock->setWidget(m_undoView);
222 m_undoView->setGroup(m_commandStack);
223 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
225 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
226 //overviewDock->setObjectName("project_overview");
227 //m_overView = new CustomTrackView(NULL, NULL, this);
228 //overviewDock->setWidget(m_overView);
229 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
232 //tabifyDockWidget(projectListDock, effectListDock);
233 tabifyDockWidget(m_projectListDock, m_effectStackDock);
234 tabifyDockWidget(m_projectListDock, m_transitionConfigDock);
235 //tabifyDockWidget(projectListDock, undoViewDock);
238 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
240 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
242 setCentralWidget(m_timelineArea);
247 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
248 guiFactory()->addClient(sp);*/
252 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
254 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone);
255 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
256 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)), static_cast<QMenu*>(factory()->container("transcoders", this)));
259 // build themes menus
260 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
261 QActionGroup *themegroup = new QActionGroup(this);
262 themegroup->setExclusive(true);
263 action = new QAction(i18n("Default"), this);
264 action->setCheckable(true);
265 themegroup->addAction(action);
266 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
269 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
271 for (int i = 0; i < schemeFiles.size(); ++i) {
273 const QString filename = schemeFiles.at(i);
274 const QFileInfo info(filename);
277 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
278 QIcon icon = createSchemePreviewIcon(config);
279 KConfigGroup group(config, "General");
280 const QString name = group.readEntry("Name", info.baseName());
281 action = new QAction(name, this);
282 action->setData(filename);
283 action->setIcon(icon);
284 action->setCheckable(true);
285 themegroup->addAction(action);
286 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
294 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
295 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
296 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
299 action = new QAction(fi.fileName(), this);
300 action->setData(*it);
301 action->setCheckable(true);
302 themegroup->addAction(action);
303 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
305 themesMenu->addActions(themegroup->actions());
306 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
308 // build effects menus
309 QMenu *videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
311 QStringList effectInfo;
312 QMap<QString, QStringList> effectsList;
313 for (int ix = 0; ix < videoEffects.count(); ix++) {
314 effectInfo = videoEffects.effectIdInfo(ix);
315 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
318 foreach(const QStringList &value, effectsList) {
319 action = new QAction(value.at(0), this);
320 action->setData(value);
321 videoEffectsMenu->addAction(action);
324 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
328 for (int ix = 0; ix < audioEffects.count(); ix++) {
329 effectInfo = audioEffects.effectIdInfo(ix);
330 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
333 foreach(const QStringList &value, effectsList) {
334 action = new QAction(value.at(0), this);
335 action->setData(value);
336 audioEffectsMenu->addAction(action);
339 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
341 if (customEffects.isEmpty()) m_customEffectsMenu->setEnabled(false);
342 else m_customEffectsMenu->setEnabled(true);
345 for (int ix = 0; ix < customEffects.count(); ix++) {
346 effectInfo = customEffects.effectIdInfo(ix);
347 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
350 foreach(const QStringList &value, effectsList) {
351 action = new QAction(value.at(0), this);
352 action->setData(value);
353 m_customEffectsMenu->addAction(action);
356 QMenu *newEffect = new QMenu(this);
357 newEffect->addMenu(videoEffectsMenu);
358 newEffect->addMenu(audioEffectsMenu);
359 newEffect->addMenu(m_customEffectsMenu);
360 m_effectStack->setMenu(newEffect);
363 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
364 const QList<QAction *> viewActions = createPopupMenu()->actions();
365 viewMenu->insertActions(NULL, viewActions);
367 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
368 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
369 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
371 m_timelineContextMenu = new QMenu(this);
372 m_timelineContextClipMenu = new QMenu(this);
373 m_timelineContextTransitionMenu = new QMenu(this);
376 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
377 QStringList effects = transitions.effectNames();
380 for (int ix = 0; ix < transitions.count(); ix++) {
381 effectInfo = transitions.effectIdInfo(ix);
382 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
384 foreach(const QStringList &value, effectsList) {
385 action = new QAction(value.at(0), this);
386 action->setData(value);
387 transitionsMenu->addAction(action);
389 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
391 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
392 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
393 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
395 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
396 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
397 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
398 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
399 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
400 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
401 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
403 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
404 m_timelineContextClipMenu->addMenu(markersMenu);
405 m_timelineContextClipMenu->addMenu(transitionsMenu);
406 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
407 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
408 //TODO: re-enable custom effects menu when it is implemented
409 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
411 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
412 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
414 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
416 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
417 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
418 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
419 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
420 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
421 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
423 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
424 slotConnectMonitors();
426 // Open or create a file. Command line argument passed in Url has
427 // precedence, then "openlastproject", then just a plain empty file.
428 // If opening Url fails, openlastproject will _not_ be used.
429 if (!Url.isEmpty()) {
430 // delay loading so that the window shows up
432 QTimer::singleShot(500, this, SLOT(openFile()));
433 } else if (KdenliveSettings::openlastproject()) {
434 QTimer::singleShot(500, this, SLOT(openLastFile()));
435 } else { //if (m_timelineArea->count() == 0) {
439 #ifndef NO_JOGSHUTTLE
440 activateShuttleDevice();
441 #endif /* NO_JOGSHUTTLE */
442 m_projectListDock->raise();
445 void MainWindow::queryQuit()
448 if (m_projectMonitor) m_projectMonitor->stop();
449 if (m_clipMonitor) m_clipMonitor->stop();
450 delete m_effectStack;
451 delete m_activeTimeline;
453 // This sometimes causes crash on exit on OS X for some reason.
454 delete m_projectMonitor;
455 delete m_clipMonitor;
457 delete m_activeDocument;
458 delete m_shortcutRemoveFocus;
459 Mlt::Factory::close();
465 bool MainWindow::queryClose()
467 if (m_renderWidget) {
468 int waitingJobs = m_renderWidget->waitingJobsCount();
469 if (waitingJobs > 0) {
470 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")))) {
471 case KMessageBox::Yes :
472 // create script with waiting jobs and start it
473 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
475 case KMessageBox::No :
476 // Don't do anything, jobs will be deleted
484 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
485 if (m_activeDocument && m_activeDocument->isModified()) {
486 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
487 case KMessageBox::Yes :
488 // save document here. If saving fails, return false;
490 case KMessageBox::No :
491 // User does not want to save the changes, clear recovery files
492 m_activeDocument->m_autosave->resize(0);
502 void MainWindow::loadPlugins()
504 foreach(QObject *plugin, QPluginLoader::staticInstances())
505 populateMenus(plugin);
507 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
509 filters << "libkdenlive*";
510 foreach(const QString &folder, directories) {
511 kDebug() << "// PARSING FIOLER: " << folder;
512 QDir pluginsDir(folder);
513 foreach(const QString &fileName, pluginsDir.entryList(filters, QDir::Files)) {
514 kDebug() << "// FOUND PLUGIN: " << fileName << "= " << pluginsDir.absoluteFilePath(fileName);
515 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
516 QObject *plugin = loader.instance();
518 populateMenus(plugin);
519 m_pluginFileNames += fileName;
520 } else kDebug() << "// ERROR LOADING PLUGIN: " << fileName << ", " << loader.errorString();
526 void MainWindow::populateMenus(QObject *plugin)
528 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
529 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
531 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
535 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
536 QMenu *menu, const char *member,
537 QActionGroup *actionGroup)
539 kDebug() << "// ADD to MENU" << texts;
540 foreach(const QString &text, texts) {
541 QAction *action = new QAction(text, plugin);
542 action->setData(text);
543 connect(action, SIGNAL(triggered()), this, member);
544 menu->addAction(action);
547 action->setCheckable(true);
548 actionGroup->addAction(action);
553 void MainWindow::aboutPlugins()
555 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
560 void MainWindow::generateClip()
562 QAction *action = qobject_cast<QAction *>(sender());
563 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
565 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(), QStringList(), QStringList(), 25, 720, 576);
566 if (!clipUrl.isEmpty()) {
567 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
571 void MainWindow::saveProperties(KConfigGroup &config)
573 // save properties here,used by session management
575 KMainWindow::saveProperties(config);
579 void MainWindow::readProperties(const KConfigGroup &config)
581 // read properties here,used by session management
582 KMainWindow::readProperties(config);
583 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
584 openFile(KUrl(Lastproject));
587 void MainWindow::slotReloadEffects()
589 kDebug() << "START RELOAD; COUNR: " << m_customEffectsMenu->actions().count();
590 m_customEffectsMenu->clear();
591 kDebug() << "START RELOAD; CLR: " << m_customEffectsMenu->actions().count();
592 initEffects::parseCustomEffectsFile();
593 const QStringList effects = customEffects.effectNames();
594 kDebug() << "NEW EFFS: " << effects;
596 if (effects.isEmpty()) m_customEffectsMenu->setEnabled(false);
597 else m_customEffectsMenu->setEnabled(true);
599 foreach(const QString &name, effects) {
600 action = new QAction(name, this);
601 action->setData(name);
602 m_customEffectsMenu->addAction(action);
604 m_effectList->reloadEffectList();
607 #ifndef NO_JOGSHUTTLE
608 void MainWindow::activateShuttleDevice()
612 if (KdenliveSettings::enableshuttle() == false) return;
613 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
614 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
615 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
616 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
617 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
618 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
619 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
622 void MainWindow::slotShuttleButton(int code)
626 slotShuttleAction(KdenliveSettings::shuttle1());
629 slotShuttleAction(KdenliveSettings::shuttle2());
632 slotShuttleAction(KdenliveSettings::shuttle3());
635 slotShuttleAction(KdenliveSettings::shuttle4());
638 slotShuttleAction(KdenliveSettings::shuttle5());
643 void MainWindow::slotShuttleAction(int code)
649 m_monitorManager->slotPlay();
652 m_monitorManager->slotPlay();
656 #endif /* NO_JOGSHUTTLE */
658 void MainWindow::configureNotifications()
660 KNotifyConfigWidget::configure(this);
663 void MainWindow::slotFullScreen()
665 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
668 void MainWindow::slotAddEffect(const QDomElement effect, GenTime pos, int track)
670 if (!m_activeDocument) return;
671 if (effect.isNull()) {
672 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
675 QDomElement effectToAdd = effect.cloneNode().toElement();
676 m_activeTimeline->projectView()->slotAddEffect(effectToAdd, pos, track);
679 void MainWindow::slotRaiseMonitor(bool clipMonitor)
681 if (clipMonitor) m_clipMonitorDock->raise();
682 else m_projectMonitorDock->raise();
685 void MainWindow::slotUpdateClip(const QString &id)
687 if (!m_activeDocument) return;
688 m_activeTimeline->projectView()->slotUpdateClip(id);
691 void MainWindow::slotConnectMonitors()
694 m_projectList->setRenderer(m_projectMonitor->render);
695 //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
696 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
697 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, bool)));
698 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
699 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)));
701 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
703 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
705 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
706 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
708 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
709 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
712 void MainWindow::slotAdjustClipMonitor()
714 m_clipMonitorDock->updateGeometry();
715 m_clipMonitorDock->adjustSize();
716 m_clipMonitor->resetSize();
719 void MainWindow::slotAdjustProjectMonitor()
721 m_projectMonitorDock->updateGeometry();
722 m_projectMonitorDock->adjustSize();
723 m_projectMonitor->resetSize();
726 void MainWindow::setupActions()
729 KActionCollection* collection = actionCollection();
730 m_timecodeFormat = new KComboBox(this);
731 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
732 m_timecodeFormat->addItem(i18n("Frames"));
733 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
734 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
736 m_statusProgressBar = new QProgressBar(this);
737 m_statusProgressBar->setMinimum(0);
738 m_statusProgressBar->setMaximum(100);
739 m_statusProgressBar->setMaximumWidth(150);
740 m_statusProgressBar->setVisible(false);
742 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
743 toolbar->setMovable(false);
744 m_toolGroup = new QActionGroup(this);
745 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
746 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;}";
748 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
749 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
750 toolbar->addAction(m_buttonSelectTool);
751 m_buttonSelectTool->setCheckable(true);
752 m_buttonSelectTool->setChecked(true);
754 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
755 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
756 toolbar->addAction(m_buttonRazorTool);
757 m_buttonRazorTool->setCheckable(true);
758 m_buttonRazorTool->setChecked(false);
760 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
761 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
762 toolbar->addAction(m_buttonSpacerTool);
763 m_buttonSpacerTool->setCheckable(true);
764 m_buttonSpacerTool->setChecked(false);
766 m_toolGroup->addAction(m_buttonSelectTool);
767 m_toolGroup->addAction(m_buttonRazorTool);
768 m_toolGroup->addAction(m_buttonSpacerTool);
769 m_toolGroup->setExclusive(true);
770 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
772 QWidget * actionWidget;
773 int max = toolbar->iconSizeDefault() + 2;
774 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
775 actionWidget->setMaximumWidth(max);
776 actionWidget->setMaximumHeight(max - 4);
778 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
779 actionWidget->setMaximumWidth(max);
780 actionWidget->setMaximumHeight(max - 4);
782 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
783 actionWidget->setMaximumWidth(max);
784 actionWidget->setMaximumHeight(max - 4);
786 toolbar->setStyleSheet(style1);
787 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
789 toolbar->addSeparator();
790 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
791 toolbar->addAction(m_buttonFitZoom);
792 m_buttonFitZoom->setCheckable(false);
793 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
795 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
796 actionWidget->setMaximumWidth(max);
797 actionWidget->setMaximumHeight(max - 4);
799 m_zoomSlider = new QSlider(Qt::Horizontal, this);
800 m_zoomSlider->setMaximum(13);
801 m_zoomSlider->setPageStep(1);
803 m_zoomSlider->setMaximumWidth(150);
804 m_zoomSlider->setMinimumWidth(100);
805 toolbar->addWidget(m_zoomSlider);
807 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
808 toolbar->addAction(m_buttonVideoThumbs);
809 m_buttonVideoThumbs->setCheckable(true);
810 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
811 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
813 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
814 toolbar->addAction(m_buttonAudioThumbs);
815 m_buttonAudioThumbs->setCheckable(true);
816 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
817 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
819 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
820 toolbar->addAction(m_buttonShowMarkers);
821 m_buttonShowMarkers->setCheckable(true);
822 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
823 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
825 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
826 toolbar->addAction(m_buttonSnap);
827 m_buttonSnap->setCheckable(true);
828 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
829 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
831 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
832 actionWidget->setMaximumWidth(max);
833 actionWidget->setMaximumHeight(max - 4);
835 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
836 actionWidget->setMaximumWidth(max);
837 actionWidget->setMaximumHeight(max - 4);
839 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
840 actionWidget->setMaximumWidth(max);
841 actionWidget->setMaximumHeight(max - 4);
843 actionWidget = toolbar->widgetForAction(m_buttonSnap);
844 actionWidget->setMaximumWidth(max);
845 actionWidget->setMaximumHeight(max - 4);
847 m_messageLabel = new StatusBarMessageLabel(this);
848 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
850 statusBar()->addWidget(m_messageLabel, 10);
851 statusBar()->addWidget(m_statusProgressBar, 0);
852 statusBar()->addPermanentWidget(toolbar);
853 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
854 statusBar()->addPermanentWidget(m_timecodeFormat);
855 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
857 collection->addAction("select_tool", m_buttonSelectTool);
858 collection->addAction("razor_tool", m_buttonRazorTool);
859 collection->addAction("spacer_tool", m_buttonSpacerTool);
861 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
862 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
863 collection->addAction("show_markers", m_buttonShowMarkers);
864 collection->addAction("snap", m_buttonSnap);
865 collection->addAction("zoom_fit", m_buttonFitZoom);
867 KAction* zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
868 collection->addAction("zoom_in", zoomIn);
869 connect(zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
870 zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
872 KAction* zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
873 collection->addAction("zoom_out", zoomOut);
874 connect(zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
875 zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
877 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
878 collection->addAction("project_find", m_projectSearch);
879 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
880 m_projectSearch->setShortcut(Qt::Key_Slash);
882 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
883 collection->addAction("project_find_next", m_projectSearchNext);
884 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
885 m_projectSearchNext->setShortcut(Qt::Key_F3);
886 m_projectSearchNext->setEnabled(false);
888 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
889 collection->addAction("manage_profiles", profilesAction);
890 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
892 KNS::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
894 KNS::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
896 KNS::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
898 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
899 collection->addAction("run_wizard", wizAction);
900 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
902 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
903 collection->addAction("project_settings", projectAction);
904 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
906 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
907 collection->addAction("project_render", projectRender);
908 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
909 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
911 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
912 collection->addAction("project_clean", projectClean);
913 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
915 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
916 KShortcut playShortcut;
917 playShortcut.setPrimary(Qt::Key_Space);
918 playShortcut.setAlternate(Qt::Key_K);
919 monitorPlay->setShortcut(playShortcut);
920 collection->addAction("monitor_play", monitorPlay);
921 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
923 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
924 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
925 collection->addAction("monitor_play_zone", m_playZone);
926 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
928 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
929 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
930 collection->addAction("monitor_loop_zone", m_loopZone);
931 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
933 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
934 collection->addAction("dvd_wizard", dvdWizard);
935 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
937 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
938 collection->addAction("transcode_clip", transcodeClip);
939 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
941 KAction *markIn = collection->addAction("mark_in");
942 markIn->setText(i18n("Set In Point"));
943 markIn->setShortcut(Qt::Key_I);
944 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
946 KAction *markOut = collection->addAction("mark_out");
947 markOut->setText(i18n("Set Out Point"));
948 markOut->setShortcut(Qt::Key_O);
949 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
951 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
952 monitorSeekBackward->setShortcut(Qt::Key_J);
953 collection->addAction("monitor_seek_backward", monitorSeekBackward);
954 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
956 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
957 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
958 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
959 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
961 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
962 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
963 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
964 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
966 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
967 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
968 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
969 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
971 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
972 monitorSeekForward->setShortcut(Qt::Key_L);
973 collection->addAction("monitor_seek_forward", monitorSeekForward);
974 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
976 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
977 clipStart->setShortcut(Qt::Key_Home);
978 collection->addAction("seek_clip_start", clipStart);
979 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
981 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
982 clipEnd->setShortcut(Qt::Key_End);
983 collection->addAction("seek_clip_end", clipEnd);
984 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
986 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
987 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
988 collection->addAction("seek_start", projectStart);
989 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
991 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
992 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
993 collection->addAction("seek_end", projectEnd);
994 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
996 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
997 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
998 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
999 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1001 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1002 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1003 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1004 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1006 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1007 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1008 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1009 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1011 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1012 deleteTimelineClip->setShortcut(Qt::Key_Delete);
1013 collection->addAction("delete_timeline_clip", deleteTimelineClip);
1014 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
1016 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1017 collection->addAction("change_clip_speed", editTimelineClipSpeed);
1018 editTimelineClipSpeed->setData("change_speed");
1019 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1021 KAction *stickTransition = collection->addAction("auto_transition");
1022 stickTransition->setData(QString("auto"));
1023 stickTransition->setCheckable(true);
1024 stickTransition->setEnabled(false);
1025 stickTransition->setText(i18n("Automatic Transition"));
1026 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1028 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1029 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1030 collection->addAction("group_clip", groupClip);
1031 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1033 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1034 collection->addAction("ungroup_clip", ungroupClip);
1035 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1036 ungroupClip->setData("ungroup_clip");
1037 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1039 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1040 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1041 collection->addAction("cut_timeline_clip", cutTimelineClip);
1042 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1044 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1045 collection->addAction("add_clip_marker", addClipMarker);
1046 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1048 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1049 collection->addAction("delete_clip_marker", deleteClipMarker);
1050 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1052 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1053 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
1054 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1056 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1057 collection->addAction("edit_clip_marker", editClipMarker);
1058 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1060 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1061 collection->addAction("split_audio", splitAudio);
1062 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1064 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1065 collection->addAction("clip_audio_only", audioOnly);
1066 audioOnly->setData("clip_audio_only");
1067 audioOnly->setCheckable(true);
1069 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1070 collection->addAction("clip_video_only", videoOnly);
1071 videoOnly->setData("clip_video_only");
1072 videoOnly->setCheckable(true);
1074 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1075 collection->addAction("clip_audio_and_video", audioAndVideo);
1076 audioAndVideo->setData("clip_audio_and_video");
1077 audioAndVideo->setCheckable(true);
1079 m_clipTypeGroup = new QActionGroup(this);
1080 m_clipTypeGroup->addAction(audioOnly);
1081 m_clipTypeGroup->addAction(videoOnly);
1082 m_clipTypeGroup->addAction(audioAndVideo);
1083 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1084 m_clipTypeGroup->setEnabled(false);
1086 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1087 collection->addAction("insert_space", insertSpace);
1088 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1090 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1091 collection->addAction("delete_space", removeSpace);
1092 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1094 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1095 collection->addAction("insert_track", insertTrack);
1096 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1098 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1099 collection->addAction("delete_track", deleteTrack);
1100 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1102 KAction *changeTrack = new KAction(KIcon(), i18n("Change Track"), this);
1103 collection->addAction("change_track", changeTrack);
1104 connect(changeTrack, SIGNAL(triggered()), this, SLOT(slotChangeTrack()));
1106 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1107 collection->addAction("add_guide", addGuide);
1108 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1110 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1111 collection->addAction("delete_guide", delGuide);
1112 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1114 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1115 collection->addAction("edit_guide", editGuide);
1116 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1118 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1119 collection->addAction("delete_all_guides", delAllGuides);
1120 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1122 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1123 collection->addAction("paste_effects", pasteEffects);
1124 pasteEffects->setData("paste_effects");
1125 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1127 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1128 collection->addAction("show_timeline", showTimeline);
1129 showTimeline->setCheckable(true);
1130 showTimeline->setChecked(true);
1131 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1133 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1134 collection->addAction("maximize_current", maxCurrent);
1135 maxCurrent->setCheckable(true);
1136 maxCurrent->setChecked(false);
1137 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1140 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1142 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1144 KStandardAction::open(this, SLOT(openFile()), collection);
1146 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1148 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1150 KStandardAction::openNew(this, SLOT(newFile()), collection);
1152 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1154 KStandardAction::configureNotifications(this , SLOT(configureNotifications()), collection);
1156 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1158 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1160 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1161 undo->setEnabled(false);
1162 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1164 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1165 redo->setEnabled(false);
1166 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1168 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1171 //TODO: Add status tooltip to actions ?
1172 connect(collection, SIGNAL(actionHovered(QAction*)),
1173 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1176 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1177 collection->addAction("add_clip", addClip);
1178 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1180 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1181 collection->addAction("add_color_clip", addColorClip);
1182 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1184 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1185 collection->addAction("add_slide_clip", addSlideClip);
1186 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1188 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1189 collection->addAction("add_text_clip", addTitleClip);
1190 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1192 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1193 collection->addAction("add_text_template_clip", addTitleTemplateClip);
1194 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1196 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1197 collection->addAction("add_folder", addFolderButton);
1198 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1200 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1201 collection->addAction("clip_properties", clipProperties);
1202 clipProperties->setData("clip_properties");
1203 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1204 clipProperties->setEnabled(false);
1206 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1207 collection->addAction("edit_clip", openClip);
1208 openClip->setData("edit_clip");
1209 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1210 openClip->setEnabled(false);
1212 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1213 collection->addAction("delete_clip", deleteClip);
1214 deleteClip->setData("delete_clip");
1215 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1216 deleteClip->setEnabled(false);
1218 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1219 collection->addAction("reload_clip", reloadClip);
1220 reloadClip->setData("reload_clip");
1221 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1222 reloadClip->setEnabled(false);
1224 QMenu *addClips = new QMenu();
1225 addClips->addAction(addClip);
1226 addClips->addAction(addColorClip);
1227 addClips->addAction(addSlideClip);
1228 addClips->addAction(addTitleClip);
1229 addClips->addAction(addTitleTemplateClip);
1230 addClips->addAction(addFolderButton);
1232 addClips->addAction(reloadClip);
1233 addClips->addAction(clipProperties);
1234 addClips->addAction(openClip);
1235 addClips->addAction(deleteClip);
1236 m_projectList->setupMenu(addClips, addClip);
1238 //connect(collection, SIGNAL( clearStatusText() ),
1239 //statusBar(), SLOT( clear() ) );
1242 void MainWindow::slotDisplayActionMessage(QAction *a)
1244 statusBar()->showMessage(a->data().toString(), 3000);
1247 void MainWindow::saveOptions()
1249 KdenliveSettings::self()->writeConfig();
1250 KSharedConfigPtr config = KGlobal::config();
1251 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1252 KConfigGroup treecolumns(config, "Project Tree");
1253 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1257 void MainWindow::readOptions()
1259 KSharedConfigPtr config = KGlobal::config();
1260 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1261 KConfigGroup initialGroup(config, "version");
1262 bool upgrade = false;
1263 if (initialGroup.exists()) {
1264 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1268 if (initialGroup.readEntry("version") == "0.7") {
1269 //Add new settings from 0.7.1
1270 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1271 QString path = QDir::homePath() + "/kdenlive";
1272 if (KStandardDirs::makeDir(path) == false) {
1273 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1274 } else KdenliveSettings::setDefaultprojectfolder(path);
1280 if (!initialGroup.exists() || upgrade) {
1281 // this is our first run, show Wizard
1282 Wizard *w = new Wizard(upgrade, this);
1283 if (w->exec() == QDialog::Accepted && w->isOk()) {
1284 w->adjustSettings();
1285 initialGroup.writeEntry("version", version);
1291 KConfigGroup treecolumns(config, "Project Tree");
1292 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1293 if (!state.isEmpty())
1294 m_projectList->setHeaderInfo(state);
1297 void MainWindow::slotRunWizard()
1299 Wizard *w = new Wizard(false, this);
1300 if (w->exec() == QDialog::Accepted && w->isOk()) {
1301 w->adjustSettings();
1306 void MainWindow::newFile(bool showProjectSettings)
1308 if (!m_timelineArea->isEnabled()) return;
1309 m_fileRevert->setEnabled(false);
1310 QString profileName;
1312 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1313 if (!showProjectSettings && m_timelineArea->count() == 0) {
1314 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1315 profileName = KdenliveSettings::default_profile();
1316 projectFolder = KdenliveSettings::defaultprojectfolder();
1318 ProjectSettings *w = new ProjectSettings(NULL, projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1319 if (w->exec() != QDialog::Accepted) return;
1320 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1321 KdenliveSettings::setVideothumbnails(w->enableVideoThumbs());
1322 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1323 KdenliveSettings::setAudiothumbnails(w->enableAudioThumbs());
1324 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1325 profileName = w->selectedProfile();
1326 projectFolder = w->selectedFolder();
1327 projectTracks = w->tracks();
1330 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1331 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1333 TrackView *trackView = new TrackView(doc, &ok, this);
1334 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1337 m_timelineArea->setEnabled(false);
1338 m_projectList->setEnabled(false);
1339 m_monitorManager->slotBlockMonitors();
1343 if (m_timelineArea->count() == 1) {
1344 connectDocumentInfo(doc);
1345 connectDocument(trackView, doc);
1346 } else m_timelineArea->setTabBarHidden(false);
1347 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1350 void MainWindow::activateDocument()
1352 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1353 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1354 KdenliveDoc *currentDoc = currentTab->document();
1355 connectDocumentInfo(currentDoc);
1356 connectDocument(currentTab, currentDoc);
1359 void MainWindow::closeCurrentDocument(bool saveChanges)
1361 QWidget *w = m_timelineArea->currentWidget();
1363 // closing current document
1364 int ix = m_timelineArea->currentIndex() + 1;
1365 if (ix == m_timelineArea->count()) ix = 0;
1366 m_timelineArea->setCurrentIndex(ix);
1367 TrackView *tabToClose = (TrackView *) w;
1368 KdenliveDoc *docToClose = tabToClose->document();
1369 if (docToClose && docToClose->isModified() && saveChanges) {
1370 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
1371 case KMessageBox::Yes :
1372 // save document here. If saving fails, return false;
1373 if (saveFile() == false) return;
1375 case KMessageBox::Cancel :
1382 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1383 if (m_timelineArea->count() == 1) {
1384 m_timelineArea->setTabBarHidden(true);
1385 m_closeAction->setEnabled(false);
1387 if (docToClose == m_activeDocument) {
1388 delete m_activeDocument;
1389 m_activeDocument = NULL;
1390 m_effectStack->clear();
1391 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1392 } else delete docToClose;
1393 if (w == m_activeTimeline) {
1394 delete m_activeTimeline;
1395 m_activeTimeline = NULL;
1399 bool MainWindow::saveFileAs(const QString &outputFileName)
1401 QString currentSceneList;
1402 if (KdenliveSettings::dropbframes()) {
1403 KdenliveSettings::setDropbframes(false);
1404 m_activeDocument->clipManager()->updatePreviewSettings();
1405 currentSceneList = m_projectMonitor->sceneList();
1406 KdenliveSettings::setDropbframes(true);
1407 m_activeDocument->clipManager()->updatePreviewSettings();
1408 } else currentSceneList = m_projectMonitor->sceneList();
1410 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1413 // Save timeline thumbnails
1414 m_activeTimeline->projectView()->saveThumbnails();
1415 m_activeDocument->setUrl(KUrl(outputFileName));
1416 if (m_activeDocument->m_autosave == NULL) {
1417 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1418 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1419 setCaption(m_activeDocument->description());
1420 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1421 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1422 m_activeDocument->setModified(false);
1423 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1424 m_fileRevert->setEnabled(true);
1428 bool MainWindow::saveFileAs()
1430 // Check that the Kdenlive mime type is correctly installed
1431 QString mimetype = "application/x-kdenlive";
1432 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1433 if (!mime) mimetype = "*.kdenlive";
1435 QString outputFile = KFileDialog::getSaveFileName(KUrl(), mimetype);
1436 if (outputFile.isEmpty()) return false;
1437 if (QFile::exists(outputFile)) {
1438 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it?")) == KMessageBox::No) return false;
1440 return saveFileAs(outputFile);
1443 bool MainWindow::saveFile()
1445 if (!m_activeDocument) return true;
1446 if (m_activeDocument->url().isEmpty()) {
1447 return saveFileAs();
1449 bool result = saveFileAs(m_activeDocument->url().path());
1450 m_activeDocument->m_autosave->resize(0);
1455 void MainWindow::openFile()
1457 if (!m_startUrl.isEmpty()) {
1458 openFile(m_startUrl);
1459 m_startUrl = KUrl();
1462 // Check that the Kdenlive mime type is correctly installed
1463 QString mimetype = "application/x-kdenlive";
1464 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1465 if (!mime) mimetype = "*.kdenlive";
1467 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), mimetype);
1468 if (url.isEmpty()) return;
1469 m_fileOpenRecent->addUrl(url);
1473 void MainWindow::openLastFile()
1475 KSharedConfigPtr config = KGlobal::config();
1476 KUrl::List urls = m_fileOpenRecent->urls();
1477 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1478 if (urls.isEmpty()) newFile(false);
1479 else openFile(urls.last());
1482 void MainWindow::openFile(const KUrl &url)
1484 // Check if the document is already opened
1485 const int ct = m_timelineArea->count();
1486 bool isOpened = false;
1488 for (i = 0; i < ct; i++) {
1489 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1490 KdenliveDoc *doc = tab->document();
1491 if (doc->url() == url) {
1497 m_timelineArea->setCurrentIndex(i);
1501 // Check for backup file
1502 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1503 if (!staleFiles.isEmpty()) {
1504 if (KMessageBox::questionYesNo(this,
1505 i18n("Auto-saved files exist. Do you want to recover them now?"),
1506 i18n("File Recovery"),
1507 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1508 recoverFiles(staleFiles);
1511 // remove the stale files
1512 foreach(KAutoSaveFile *stale, staleFiles) {
1513 stale->open(QIODevice::ReadWrite);
1518 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1519 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
1520 qApp->processEvents();
1521 doOpenFile(url, NULL);
1524 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1526 if (!m_timelineArea->isEnabled()) return;
1527 m_fileRevert->setEnabled(true);
1528 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, this);
1529 if (stale == NULL) {
1530 stale = new KAutoSaveFile(url, doc);
1531 doc->m_autosave = stale;
1533 doc->m_autosave = stale;
1534 doc->setUrl(stale->managedFile());
1535 doc->setModified(true);
1536 stale->setParent(doc);
1538 connectDocumentInfo(doc);
1540 TrackView *trackView = new TrackView(doc, &ok, this);
1541 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1543 m_timelineArea->setEnabled(false);
1544 m_projectList->setEnabled(false);
1545 m_monitorManager->slotBlockMonitors();
1549 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1550 trackView->setDuration(trackView->duration());
1551 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1553 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1554 slotGotProgressInfo(QString(), -1);
1555 m_clipMonitor->refreshMonitor(true);
1556 m_projectMonitor->adjustRulerSize(trackView->duration());
1557 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1560 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1562 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1563 foreach(KAutoSaveFile *stale, staleFiles) {
1564 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1565 // show an error message; we could not steal the lockfile
1566 // maybe another application got to the file before us?
1570 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1571 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
1572 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1573 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1578 void MainWindow::parseProfiles(const QString &mltPath)
1580 // kDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
1582 //KdenliveSettings::setDefaulttmpfolder();
1583 if (!mltPath.isEmpty()) {
1584 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1585 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
1588 if (KdenliveSettings::mltpath().isEmpty()) {
1589 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1591 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
1592 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
1593 if (!QFile::exists(meltPath))
1594 meltPath = KStandardDirs::findExe("melt");
1595 KdenliveSettings::setRendererpath(meltPath);
1597 QStringList profilesFilter;
1598 profilesFilter << "*";
1599 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1601 if (profilesList.isEmpty()) {
1602 // Cannot find MLT path, try finding melt
1603 QString profilePath = KdenliveSettings::rendererpath();
1604 if (!profilePath.isEmpty()) {
1605 profilePath = profilePath.section('/', 0, -3);
1606 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1607 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1610 if (profilesList.isEmpty()) {
1611 // Cannot find the MLT profiles, ask for location
1612 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1613 getUrl->fileDialog()->setMode(KFile::Directory);
1614 if (getUrl->exec() == QDialog::Rejected) {
1617 KUrl mltPath = getUrl->selectedUrl();
1619 if (mltPath.isEmpty()) ::exit(0);
1620 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
1621 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1625 if (KdenliveSettings::rendererpath().isEmpty()) {
1626 // Cannot find the MLT melt renderer, ask for location
1627 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of Mlt)"), this);
1628 if (getUrl->exec() == QDialog::Rejected) {
1631 KUrl rendererPath = getUrl->selectedUrl();
1633 if (rendererPath.isEmpty()) ::exit(0);
1634 KdenliveSettings::setRendererpath(rendererPath.path());
1637 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1639 // Parse MLT profiles to build a list of available video formats
1640 if (profilesList.isEmpty()) parseProfiles();
1644 void MainWindow::slotEditProfiles()
1646 ProfilesDialog *w = new ProfilesDialog;
1647 if (w->exec() == QDialog::Accepted) {
1648 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1649 if (d) d->checkProfile();
1654 void MainWindow::slotDetectAudioDriver()
1656 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
1657 leading to no audio output, see bug #934 */
1659 //decide which audio driver is really best, in some cases SDL is wrong
1660 if (KdenliveSettings::audiodrivername().isEmpty()) {
1662 KProcess readProcess;
1663 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
1664 if (!KStandardDirs::findExe("pactl").isEmpty()) {
1665 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
1666 readProcess.setProgram("pactl", QStringList() << "stat");
1667 readProcess.execute(2000); // Kill it after 2 seconds
1669 QString result = QString(readProcess.readAllStandardOutput());
1670 kDebug() << "// / / / / / READING PACTL: ";
1672 if (!result.isEmpty()) {
1674 kDebug() << "// / / / / PULSEAUDIO DETECTED";
1678 KdenliveSettings::setAutoaudiodrivername(driver);
1682 void MainWindow::slotEditProjectSettings()
1684 QPoint p = m_activeDocument->getTracksCount();
1685 ProjectSettings *w = new ProjectSettings(m_activeDocument->clipManager(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
1687 if (w->exec() == QDialog::Accepted) {
1688 if (w->deleteUnused()) {
1689 // we are going to trash the unused clips
1690 m_projectList->trashUnusedClips();
1692 QString profile = w->selectedProfile();
1693 m_activeDocument->setProjectFolder(w->selectedFolder());
1694 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path(KUrl::AddTrailingSlash));
1695 if (m_activeDocument->profilePath() != profile) {
1696 // Profile was changed
1697 double dar = m_activeDocument->dar();
1699 // Deselect current effect / transition
1700 m_effectStack->slotClipItemSelected(NULL, 0);
1701 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1702 m_clipMonitor->slotSetXml(NULL, 0);
1703 bool updateFps = m_activeDocument->setProfilePath(profile);
1704 KdenliveSettings::setCurrent_profile(profile);
1705 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1706 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1708 m_activeDocument->clipManager()->clearUnusedProducers();
1709 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1711 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
1712 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
1713 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1714 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1715 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1716 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
1717 if (updateFps) m_activeTimeline->updateProjectFps();
1718 m_activeDocument->setModified(true);
1719 m_commandStack->activeStack()->clear();
1720 // We need to desactivate & reactivate monitors to get a refresh
1721 //m_monitorManager->switchMonitors();
1728 void MainWindow::slotRenderProject()
1730 if (!m_renderWidget) {
1731 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
1732 m_renderWidget = new RenderWidget(projectfolder, this);
1733 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
1734 connect(m_renderWidget, SIGNAL(selectedRenderProfile(const QString &, const QString &, const QString&)), this, SLOT(slotSetDocumentRenderProfile(const QString &, const QString &, const QString&)));
1735 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
1736 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1737 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1738 if (m_activeDocument) {
1739 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1740 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1741 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
1742 m_renderWidget->setRenderProfile(m_activeDocument->getDocumentProperty("renderdestination"), m_activeDocument->getDocumentProperty("renderprofile"), m_activeDocument->getDocumentProperty("renderurl"));
1745 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1746 if (currentTab) m_renderWidget->setTimeline(currentTab);
1747 m_renderWidget->setDocument(m_activeDocument);*/
1748 m_renderWidget->show();
1749 m_renderWidget->showNormal();
1752 void MainWindow::setRenderingProgress(const QString &url, int progress)
1754 if (m_renderWidget) m_renderWidget->setRenderJob(url, progress);
1757 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
1759 if (m_renderWidget) m_renderWidget->setRenderStatus(url, status, error);
1762 void MainWindow::slotCleanProject()
1764 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
1765 m_projectList->cleanup();
1768 void MainWindow::slotUpdateMousePosition(int pos)
1770 if (m_activeDocument)
1771 switch (m_timecodeFormat->currentIndex()) {
1773 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1776 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1780 void MainWindow::slotUpdateDocumentState(bool modified)
1782 if (!m_activeDocument) return;
1783 setCaption(m_activeDocument->description(), modified);
1784 m_saveAction->setEnabled(modified);
1786 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1787 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1789 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1790 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1794 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
1796 if (m_activeDocument) {
1797 if (m_activeDocument == doc) return;
1798 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1800 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1803 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
1805 //m_projectMonitor->stop();
1806 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1807 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1808 if (m_activeDocument) {
1809 if (m_activeDocument == doc) return;
1810 if (m_activeTimeline) {
1811 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1812 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1813 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1814 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1815 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
1817 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1818 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1819 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1820 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1821 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1822 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1823 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1824 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1825 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1826 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
1827 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1828 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1829 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1830 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1831 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1832 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1833 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1834 disconnect(m_activeTimeline, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1835 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1836 disconnect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1837 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1838 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1839 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1840 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1841 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1842 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1843 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
1844 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1845 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1846 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
1847 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
1848 m_effectStack->clear();
1850 //m_activeDocument->setRenderer(NULL);
1851 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1852 disconnect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
1853 m_clipMonitor->stop();
1855 KdenliveSettings::setCurrent_profile(doc->profilePath());
1856 KdenliveSettings::setProject_fps(doc->fps());
1857 m_monitorManager->resetProfiles(doc->timecode());
1858 m_projectList->setDocument(doc);
1859 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
1860 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
1861 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1862 connect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
1863 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1864 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
1867 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1868 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1869 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1870 connect(trackView, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1871 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
1872 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1873 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1874 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1875 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1876 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
1878 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1879 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1880 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1881 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1882 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1884 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1885 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1886 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1889 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1890 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
1892 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1893 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
1894 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1895 m_zoomSlider->setValue(doc->zoom().x());
1896 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1897 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1898 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1899 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
1900 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1902 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1905 connect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1906 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1907 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1908 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1909 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1910 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1911 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1912 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1914 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1915 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1916 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
1917 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
1920 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup);
1921 m_activeTimeline = trackView;
1922 if (m_renderWidget) {
1923 m_renderWidget->setProfile(doc->mltProfile());
1924 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
1925 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
1926 m_renderWidget->setRenderProfile(doc->getDocumentProperty("renderdestination"), doc->getDocumentProperty("renderprofile"), doc->getDocumentProperty("renderurl"));
1928 //doc->setRenderer(m_projectMonitor->render);
1929 m_commandStack->setActiveStack(doc->commandStack());
1930 KdenliveSettings::setProject_display_ratio(doc->dar());
1931 //doc->clipManager()->checkAudioThumbs();
1933 //m_overView->setScene(trackView->projectScene());
1934 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1935 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1937 setCaption(doc->description(), doc->isModified());
1938 m_saveAction->setEnabled(doc->isModified());
1939 m_activeDocument = doc;
1940 m_activeTimeline->updateProjectFps();
1941 m_activeDocument->checkProjectClips();
1942 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
1944 // set tool to select tool
1945 m_buttonSelectTool->setChecked(true);
1948 void MainWindow::slotZoneMoved(int start, int end)
1950 m_activeDocument->setZone(start, end);
1951 m_projectMonitor->slotZoneMoved(start, end);
1954 void MainWindow::slotGuidesUpdated()
1956 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1959 void MainWindow::slotPreferences(int page, int option)
1961 //An instance of your dialog could be already created and could be
1962 // cached, in which case you want to display the cached dialog
1963 // instead of creating another one
1964 if (KConfigDialog::showDialog("settings")) {
1965 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1966 if (page != -1) d->showPage(page, option);
1970 // KConfigDialog didn't find an instance of this dialog, so lets
1972 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1973 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1974 //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
1975 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1976 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1978 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
1980 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1982 if (page != -1) dialog->showPage(page, option);
1985 void MainWindow::slotUpdatePreviewSettings()
1987 if (m_activeDocument) {
1988 m_clipMonitor->slotSetXml(NULL, 0);
1989 m_activeDocument->updatePreviewSettings();
1993 void MainWindow::updateConfiguration()
1995 //TODO: we should apply settings to all projects, not only the current one
1996 if (m_activeTimeline) {
1997 m_activeTimeline->refresh();
1998 m_activeTimeline->projectView()->checkAutoScroll();
1999 m_activeTimeline->projectView()->checkTrackHeight();
2000 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
2002 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2003 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2005 // Update list of transcoding profiles
2007 #ifndef NO_JOGSHUTTLE
2008 activateShuttleDevice();
2009 #endif /* NO_JOGSHUTTLE */
2014 void MainWindow::slotSwitchVideoThumbs()
2016 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2017 if (m_activeTimeline) {
2018 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2020 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2023 void MainWindow::slotSwitchAudioThumbs()
2025 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2026 if (m_activeTimeline) {
2027 m_activeTimeline->refresh();
2028 m_activeTimeline->projectView()->checkAutoScroll();
2029 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
2031 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2034 void MainWindow::slotSwitchMarkersComments()
2036 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2037 if (m_activeTimeline) {
2038 m_activeTimeline->refresh();
2040 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2043 void MainWindow::slotSwitchSnap()
2045 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2046 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2050 void MainWindow::slotDeleteTimelineClip()
2052 if (QApplication::focusWidget() && QApplication::focusWidget()->parentWidget() && QApplication::focusWidget()->parentWidget()->parentWidget() && QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) m_projectList->slotRemoveClip();
2053 else if (m_activeTimeline) {
2054 m_activeTimeline->projectView()->deleteSelectedClips();
2058 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2060 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2061 m_clipMonitor->updateMarkers(clip);
2064 void MainWindow::slotAddClipMarker()
2066 DocClipBase *clip = NULL;
2068 if (m_projectMonitor->isActive()) {
2069 if (m_activeTimeline) {
2070 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2072 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2073 clip = item->baseClip();
2077 clip = m_clipMonitor->activeClip();
2078 pos = m_clipMonitor->position();
2081 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2084 QString id = clip->getId();
2085 CommentedTime marker(pos, i18n("Marker"));
2086 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2087 if (d.exec() == QDialog::Accepted) {
2088 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2092 void MainWindow::slotDeleteClipMarker()
2094 DocClipBase *clip = NULL;
2096 if (m_projectMonitor->isActive()) {
2097 if (m_activeTimeline) {
2098 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2100 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2101 clip = item->baseClip();
2105 clip = m_clipMonitor->activeClip();
2106 pos = m_clipMonitor->position();
2109 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2113 QString id = clip->getId();
2114 QString comment = clip->markerComment(pos);
2115 if (comment.isEmpty()) {
2116 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2119 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2122 void MainWindow::slotDeleteAllClipMarkers()
2124 DocClipBase *clip = NULL;
2125 if (m_projectMonitor->isActive()) {
2126 if (m_activeTimeline) {
2127 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2129 clip = item->baseClip();
2133 clip = m_clipMonitor->activeClip();
2136 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2139 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2142 void MainWindow::slotEditClipMarker()
2144 DocClipBase *clip = NULL;
2146 if (m_projectMonitor->isActive()) {
2147 if (m_activeTimeline) {
2148 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2150 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2151 clip = item->baseClip();
2155 clip = m_clipMonitor->activeClip();
2156 pos = m_clipMonitor->position();
2159 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2163 QString id = clip->getId();
2164 QString oldcomment = clip->markerComment(pos);
2165 if (oldcomment.isEmpty()) {
2166 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2170 CommentedTime marker(pos, oldcomment);
2171 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2172 if (d.exec() == QDialog::Accepted) {
2173 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2174 if (d.newMarker().time() != pos) {
2175 // remove old marker
2176 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2181 void MainWindow::slotAddGuide()
2183 if (m_activeTimeline)
2184 m_activeTimeline->projectView()->slotAddGuide();
2187 void MainWindow::slotInsertSpace()
2189 if (m_activeTimeline)
2190 m_activeTimeline->projectView()->slotInsertSpace();
2193 void MainWindow::slotRemoveSpace()
2195 if (m_activeTimeline)
2196 m_activeTimeline->projectView()->slotRemoveSpace();
2199 void MainWindow::slotInsertTrack(int ix)
2201 m_projectMonitor->activateMonitor();
2202 if (m_activeTimeline)
2203 m_activeTimeline->projectView()->slotInsertTrack(ix);
2206 void MainWindow::slotDeleteTrack(int ix)
2208 m_projectMonitor->activateMonitor();
2209 if (m_activeTimeline)
2210 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2213 void MainWindow::slotChangeTrack(int ix)
2215 m_projectMonitor->activateMonitor();
2216 if (m_activeTimeline)
2217 m_activeTimeline->projectView()->slotChangeTrack(ix);
2220 void MainWindow::slotEditGuide()
2222 if (m_activeTimeline)
2223 m_activeTimeline->projectView()->slotEditGuide();
2226 void MainWindow::slotDeleteGuide()
2228 if (m_activeTimeline)
2229 m_activeTimeline->projectView()->slotDeleteGuide();
2232 void MainWindow::slotDeleteAllGuides()
2234 if (m_activeTimeline)
2235 m_activeTimeline->projectView()->slotDeleteAllGuides();
2238 void MainWindow::slotCutTimelineClip()
2240 if (m_activeTimeline) {
2241 m_activeTimeline->projectView()->cutSelectedClips();
2245 void MainWindow::slotGroupClips()
2247 if (m_activeTimeline) {
2248 m_activeTimeline->projectView()->groupClips();
2252 void MainWindow::slotUnGroupClips()
2254 if (m_activeTimeline) {
2255 m_activeTimeline->projectView()->groupClips(false);
2259 void MainWindow::slotAddProjectClip(KUrl url)
2261 if (m_activeDocument)
2262 m_activeDocument->slotAddClipFile(url, QString());
2265 void MainWindow::slotAddTransition(QAction *result)
2267 if (!result) return;
2268 QStringList info = result->data().toStringList();
2269 if (info.isEmpty()) return;
2270 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2271 if (m_activeTimeline && !transition.isNull()) {
2272 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2276 void MainWindow::slotAddVideoEffect(QAction *result)
2278 if (!result) return;
2279 QStringList info = result->data().toStringList();
2280 if (info.isEmpty()) return;
2281 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2282 slotAddEffect(effect);
2285 void MainWindow::slotAddAudioEffect(QAction *result)
2287 if (!result) return;
2288 QStringList info = result->data().toStringList();
2289 if (info.isEmpty()) return;
2290 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2291 slotAddEffect(effect);
2294 void MainWindow::slotAddCustomEffect(QAction *result)
2296 if (!result) return;
2297 QStringList info = result->data().toStringList();
2298 if (info.isEmpty()) return;
2299 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2300 slotAddEffect(effect);
2303 void MainWindow::slotZoomIn()
2305 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2308 void MainWindow::slotZoomOut()
2310 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2313 void MainWindow::slotFitZoom()
2315 if (m_activeTimeline) {
2316 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2320 void MainWindow::slotSetZoom(int value)
2322 m_zoomSlider->setValue(value);
2325 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2327 m_statusProgressBar->setValue(progress);
2328 if (progress >= 0) {
2329 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2330 m_statusProgressBar->setVisible(true);
2332 m_messageLabel->setMessage(QString(), DefaultMessage);
2333 m_statusProgressBar->setVisible(false);
2337 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2339 if (clip->clipType() == TEXT) {
2340 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
2341 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
2342 // template text clip
2344 // Get the list of existing templates
2346 filter << "*.kdenlivetitle";
2347 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
2349 QDialog *dia = new QDialog(this);
2350 Ui::TemplateClip_UI dia_ui;
2351 dia_ui.setupUi(dia);
2353 const QString templatePath = clip->getProperty("resource");
2354 for (int i = 0; i < templateFiles.size(); ++i) {
2355 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
2356 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
2358 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
2359 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
2360 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
2361 //warning: setting base directory doesn't work??
2362 KUrl startDir(titlepath);
2363 dia_ui.template_list->fileDialog()->setUrl(startDir);
2364 dia_ui.description->setText(clip->getProperty("description"));
2365 if (dia->exec() == QDialog::Accepted) {
2366 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
2367 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
2369 QMap <QString, QString> newprops;
2371 if (KUrl(textTemplate).path() != templatePath) {
2372 // The template was changed
2373 newprops.insert("resource", textTemplate);
2376 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
2377 newprops.insert("description", dia_ui.description->toPlainText());
2380 QString newtemplate = newprops.value("xmltemplate");
2381 if (newtemplate.isEmpty()) newtemplate = templatePath;
2383 // template modified we need to update xmldata
2384 QString description = newprops.value("description");
2385 if (description.isEmpty()) description = clip->getProperty("description");
2386 else newprops.insert("templatetext", description);
2387 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
2389 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2390 m_activeDocument->commandStack()->push(command);
2394 QString path = clip->getProperty("resource");
2395 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
2397 doc.setContent(clip->getProperty("xmldata"));
2398 dia_ui->setXml(doc);
2399 if (dia_ui->exec() == QDialog::Accepted) {
2400 QMap <QString, QString> newprops;
2401 newprops.insert("xmldata", dia_ui->xml().toString());
2402 if (dia_ui->duration() != clip->duration().frames(m_activeDocument->fps()) - 1) {
2403 // duration changed, we need to update duration
2404 newprops.insert("out", QString::number(dia_ui->duration()));
2406 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2407 m_activeDocument->commandStack()->push(command);
2408 m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
2409 m_activeDocument->setModified(true);
2413 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2416 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2417 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2418 if (dia.exec() == QDialog::Accepted) {
2419 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true);
2420 m_activeDocument->commandStack()->push(command);
2422 if (dia.needsTimelineRefresh()) {
2423 // update clip occurences in timeline
2424 m_activeTimeline->projectView()->slotUpdateClip(clip->getId(), dia.needsTimelineReload());
2429 void MainWindow::customEvent(QEvent* e)
2431 if (e->type() == QEvent::User) {
2432 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
2435 void MainWindow::slotActivateEffectStackView()
2437 m_effectStack->raiseWindow(m_effectStackDock);
2440 void MainWindow::slotActivateTransitionView(Transition *t)
2442 if (t) m_transitionConfig->raiseWindow(m_transitionConfigDock);
2445 void MainWindow::slotSnapRewind()
2447 if (m_projectMonitor->isActive()) {
2448 if (m_activeTimeline)
2449 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2450 } else m_clipMonitor->slotSeekToPreviousSnap();
2453 void MainWindow::slotSnapForward()
2455 if (m_projectMonitor->isActive()) {
2456 if (m_activeTimeline)
2457 m_activeTimeline->projectView()->slotSeekToNextSnap();
2458 } else m_clipMonitor->slotSeekToNextSnap();
2461 void MainWindow::slotClipStart()
2463 if (m_projectMonitor->isActive()) {
2464 if (m_activeTimeline)
2465 m_activeTimeline->projectView()->clipStart();
2469 void MainWindow::slotClipEnd()
2471 if (m_projectMonitor->isActive()) {
2472 if (m_activeTimeline)
2473 m_activeTimeline->projectView()->clipEnd();
2477 void MainWindow::slotChangeTool(QAction * action)
2479 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
2480 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
2481 else if (action == m_buttonSpacerTool) slotSetTool(SPACERTOOL);
2484 void MainWindow::slotSetTool(PROJECTTOOL tool)
2486 if (m_activeDocument && m_activeTimeline) {
2487 //m_activeDocument->setTool(tool);
2491 message = i18n("Ctrl + click to use spacer on current track only");
2494 message = i18n("Click on a clip to cut it");
2497 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
2500 m_messageLabel->setMessage(message, InformationMessage);
2501 m_activeTimeline->projectView()->setTool(tool);
2505 void MainWindow::slotCopy()
2507 if (!m_activeDocument || !m_activeTimeline) return;
2508 m_activeTimeline->projectView()->copyClip();
2511 void MainWindow::slotPaste()
2513 if (!m_activeDocument || !m_activeTimeline) return;
2514 m_activeTimeline->projectView()->pasteClip();
2517 void MainWindow::slotPasteEffects()
2519 if (!m_activeDocument || !m_activeTimeline) return;
2520 m_activeTimeline->projectView()->pasteClipEffects();
2523 void MainWindow::slotFind()
2525 if (!m_activeDocument || !m_activeTimeline) return;
2526 m_projectSearch->setEnabled(false);
2527 m_findActivated = true;
2528 m_findString.clear();
2529 m_activeTimeline->projectView()->initSearchStrings();
2530 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2531 m_findTimer.start(5000);
2532 qApp->installEventFilter(this);
2535 void MainWindow::slotFindNext()
2537 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
2538 statusBar()->showMessage(i18n("Found: %1", m_findString));
2540 statusBar()->showMessage(i18n("Reached end of project"));
2542 m_findTimer.start(4000);
2545 void MainWindow::findAhead()
2547 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
2548 m_projectSearchNext->setEnabled(true);
2549 statusBar()->showMessage(i18n("Found: %1", m_findString));
2551 m_projectSearchNext->setEnabled(false);
2552 statusBar()->showMessage(i18n("Not found: %1", m_findString));
2556 void MainWindow::findTimeout()
2558 m_projectSearchNext->setEnabled(false);
2559 m_findActivated = false;
2560 m_findString.clear();
2561 statusBar()->showMessage(i18n("Find stopped"), 3000);
2562 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
2563 m_projectSearch->setEnabled(true);
2564 removeEventFilter(this);
2567 void MainWindow::keyPressEvent(QKeyEvent *ke)
2569 if (m_findActivated) {
2570 if (ke->key() == Qt::Key_Backspace) {
2571 m_findString = m_findString.left(m_findString.length() - 1);
2573 if (!m_findString.isEmpty()) {
2579 m_findTimer.start(4000);
2582 } else if (ke->key() == Qt::Key_Escape) {
2586 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
2587 m_findString += ke->text();
2591 m_findTimer.start(4000);
2595 } else KXmlGuiWindow::keyPressEvent(ke);
2599 /** Gets called when the window gets hidden */
2600 void MainWindow::hideEvent(QHideEvent */*event*/)
2602 // kDebug() << "I was hidden";
2603 // issue http://www.kdenlive.org/mantis/view.php?id=231
2604 if (isMinimized()) {
2605 // kDebug() << "I am minimized";
2606 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
2610 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
2612 if (m_findActivated) {
2613 if (event->type() == QEvent::ShortcutOverride) {
2614 QKeyEvent* ke = (QKeyEvent*) event;
2615 if (ke->text().trimmed().isEmpty()) return false;
2618 } else return false;
2620 // pass the event on to the parent class
2621 return QMainWindow::eventFilter(obj, event);
2626 void MainWindow::slotSaveZone(Render *render, QPoint zone)
2628 KDialog *dialog = new KDialog(this);
2629 dialog->setCaption("Save clip zone");
2630 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
2632 QWidget *widget = new QWidget(dialog);
2633 dialog->setMainWidget(widget);
2635 QVBoxLayout *vbox = new QVBoxLayout(widget);
2636 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
2637 QString path = m_activeDocument->projectFolder().path();
2639 path.append("untitled.mlt");
2640 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
2641 url->setFilter("video/mlt-playlist");
2642 QLabel *label2 = new QLabel(i18n("Description:"), this);
2643 KLineEdit *edit = new KLineEdit(this);
2644 vbox->addWidget(label1);
2645 vbox->addWidget(url);
2646 vbox->addWidget(label2);
2647 vbox->addWidget(edit);
2648 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
2652 void MainWindow::slotSetInPoint()
2654 if (m_clipMonitor->isActive()) {
2655 m_clipMonitor->slotSetZoneStart();
2656 } else m_activeTimeline->projectView()->setInPoint();
2659 void MainWindow::slotSetOutPoint()
2661 if (m_clipMonitor->isActive()) {
2662 m_clipMonitor->slotSetZoneEnd();
2663 } else m_activeTimeline->projectView()->setOutPoint();
2666 void MainWindow::slotGetNewLumaStuff()
2668 //KNS::Entry::List download();
2669 KNS::Entry::List entries = KNS::Engine::download();
2670 // list of changed entries
2671 kDebug() << "// PARSING KNS";
2672 foreach(KNS::Entry* entry, entries) {
2673 // care only about installed ones
2674 if (entry->status() == KNS::Entry::Installed) {
2675 foreach(const QString &file, entry->installedFiles()) {
2676 kDebug() << "// CURRENTLY INSTALLED: " << file;
2680 qDeleteAll(entries);
2681 initEffects::refreshLumas();
2682 m_activeTimeline->projectView()->reloadTransitionLumas();
2685 void MainWindow::slotGetNewRenderStuff()
2687 //KNS::Entry::List download();
2689 KNS::Engine engine(0);
2690 if (engine.init("kdenlive_render.knsrc")) {
2691 KNS::Entry::List entries = engine.downloadDialogModal(this);
2693 if (entries.size() > 0) {
2694 foreach(KNS::Entry* entry, entries) {
2695 // care only about installed ones
2696 if (entry->status() == KNS::Entry::Installed) {
2697 foreach(const QString &file, entry->installedFiles()) {
2698 kDebug() << "// CURRENTLY INSTALLED: " << file;
2703 if (m_renderWidget) m_renderWidget->reloadProfiles();
2707 void MainWindow::slotGetNewMltProfileStuff()
2709 //KNS::Entry::List download();
2711 KNS::Engine engine(0);
2712 if (engine.init("kdenlive_mltprofiles.knsrc")) {
2713 KNS::Entry::List entries = engine.downloadDialogModal(this);
2715 if (entries.size() > 0) {
2716 foreach(KNS::Entry* entry, entries) {
2717 // care only about installed ones
2718 if (entry->status() == KNS::Entry::Installed) {
2719 foreach(const QString &file, entry->installedFiles()) {
2720 kDebug() << "// CURRENTLY INSTALLED: " << file;
2725 // update the list of profiles in settings dialog
2726 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2727 if (d) d->checkProfile();
2732 void MainWindow::slotAutoTransition()
2734 if (m_activeTimeline) m_activeTimeline->projectView()->autoTransition();
2737 void MainWindow::slotSplitAudio()
2739 if (m_activeTimeline) m_activeTimeline->projectView()->splitAudio();
2742 void MainWindow::slotUpdateClipType(QAction *action)
2744 if (m_activeTimeline) {
2745 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
2746 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
2747 else m_activeTimeline->projectView()->setAudioAndVideo();
2751 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
2753 // We must stop the monitors since we create a new on in the dvd wizard
2754 m_clipMonitor->stop();
2755 m_projectMonitor->stop();
2756 DvdWizard w(url, profile, this);
2758 m_projectMonitor->start();
2761 void MainWindow::slotShowTimeline(bool show)
2763 if (show == false) {
2764 m_timelineState = saveState();
2765 centralWidget()->setHidden(true);
2767 centralWidget()->setHidden(false);
2768 restoreState(m_timelineState);
2772 void MainWindow::slotMaximizeCurrent(bool /*show*/)
2774 //TODO: is there a way to maximize current widget?
2777 m_timelineState = saveState();
2778 QWidget *par = focusWidget()->parentWidget();
2779 while (par->parentWidget() && par->parentWidget() != this) {
2780 par = par->parentWidget();
2782 kDebug() << "CURRENT WIDGET: " << par->objectName();
2785 //centralWidget()->setHidden(false);
2786 //restoreState(m_timelineState);
2790 void MainWindow::loadTranscoders()
2792 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
2795 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
2796 KConfigGroup transConfig(config, "Transcoding");
2798 QMap< QString, QString > profiles = transConfig.entryMap();
2799 QMapIterator<QString, QString> i(profiles);
2800 while (i.hasNext()) {
2802 QAction *a = transMenu->addAction(i.key());
2803 a->setData(i.value());
2804 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
2808 void MainWindow::slotTranscode(KUrl::List urls)
2811 if (urls.isEmpty()) {
2812 urls.append(m_projectList->currentClipUrl());
2813 QAction *action = qobject_cast<QAction *>(sender());
2814 params = action->data().toString();
2816 if (urls.isEmpty()) return;
2817 ClipTranscode *d = new ClipTranscode(urls, params);
2818 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
2820 //QProcess::startDetached("ffmpeg", parameters);
2823 void MainWindow::slotTranscodeClip()
2825 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
2826 if (urls.isEmpty()) return;
2827 slotTranscode(urls);
2830 void MainWindow::slotSetDocumentRenderProfile(const QString &dest, const QString &name, const QString &file)
2832 if (m_activeDocument == NULL) return;
2833 m_activeDocument->setDocumentProperty("renderdestination", dest);
2834 m_activeDocument->setDocumentProperty("renderprofile", name);
2835 m_activeDocument->setDocumentProperty("renderurl", file);
2836 m_activeDocument->setModified(true);
2840 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
2842 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
2844 QString playlistPath;
2847 QString scriptsFolder = m_activeDocument->projectFolder().path() + "/scripts/";
2848 QString path = m_renderWidget->getFreeScriptName();
2849 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
2850 if (!ok || scriptPath.isEmpty()) return;
2851 scriptPath.prepend(scriptsFolder);
2852 QFile f(scriptPath);
2854 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
2857 playlistPath = scriptPath + ".mlt";
2858 m_projectMonitor->saveSceneList(playlistPath);
2860 KTemporaryFile temp;
2861 temp.setAutoRemove(false);
2862 temp.setSuffix(".mlt");
2864 playlistPath = temp.fileName();
2865 m_projectMonitor->saveSceneList(playlistPath);
2868 if (!chapterFile.isEmpty()) {
2871 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
2873 in = m_activeTimeline->inPoint();
2874 out = m_activeTimeline->outPoint();
2877 QDomElement chapters = doc.createElement("chapters");
2878 chapters.setAttribute("fps", m_activeDocument->fps());
2879 doc.appendChild(chapters);
2881 QDomElement guidesxml = m_activeDocument->guidesXml();
2882 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
2883 for (int i = 0; i < nodes.count(); i++) {
2884 QDomElement e = nodes.item(i).toElement();
2886 QString comment = e.attribute("comment");
2887 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
2888 if (time >= in && time < out) {
2889 if (zoneOnly) time = time - in;
2890 QDomElement chapter = doc.createElement("chapter");
2891 chapters.appendChild(chapter);
2892 chapter.setAttribute("title", comment);
2893 chapter.setAttribute("time", time);
2897 if (chapters.childNodes().count() > 0) {
2898 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
2899 // Always insert a guide in pos 0
2900 QDomElement chapter = doc.createElement("chapter");
2901 chapters.insertBefore(chapter, QDomNode());
2902 chapter.setAttribute("title", i18n("Start"));
2903 chapter.setAttribute("time", "0");
2905 // save chapters file
2906 QFile file(chapterFile);
2907 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
2908 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
2910 file.write(doc.toString().toUtf8());
2911 if (file.error() != QFile::NoError) {
2912 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
2919 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath);
2922 void MainWindow::slotUpdateTimecodeFormat(int ix)
2924 KdenliveSettings::setFrametimecode(ix == 1);
2925 m_clipMonitor->updateTimecodeFormat();
2926 m_projectMonitor->updateTimecodeFormat();
2929 void MainWindow::slotRemoveFocus()
2931 statusBar()->setFocus();
2932 statusBar()->clearFocus();
2935 void MainWindow::slotRevert()
2937 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;
2938 KUrl url = m_activeDocument->url();
2939 closeCurrentDocument(false);
2940 doOpenFile(url, NULL);
2944 void MainWindow::slotShutdown()
2946 if (m_activeDocument) m_activeDocument->setModified(false);
2948 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
2949 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
2950 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
2951 smserver.call("logout", 1, 2, 2);
2955 void MainWindow::slotUpdateTrackInfo()
2957 if (m_activeDocument)
2958 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2961 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
2963 // Load the theme file
2965 if (action == NULL) theme = themename;
2966 else theme = action->data().toString();
2967 KdenliveSettings::setColortheme(theme);
2968 // Make palette for all widgets.
2970 if (theme.isEmpty())
2971 plt = QApplication::desktop()->palette();
2973 fprintf(stderr, "CReate pal %s\n", theme.toUtf8().data());
2974 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
2975 plt = KGlobalSettings::createApplicationPalette(config);
2978 kapp->setPalette(plt);
2979 if (m_zoomSlider) m_zoomSlider->setPalette(plt);
2980 if (m_timecodeFormat) m_timecodeFormat->setPalette(plt);
2984 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
2986 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
2987 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
2988 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
2989 const QSize bitsSize(24, 2);
2990 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
2991 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
2993 QPixmap pixmap(23, 16);
2994 pixmap.fill(Qt::black); // ### use some color other than black for borders?
2996 KConfigGroup group(config, "WM");
2997 QPainter p(&pixmap);
2998 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
2999 p.fillRect(1, 1, 7, 7, windowScheme.background());
3000 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
3002 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
3003 p.fillRect(8, 1, 7, 7, buttonScheme.background());
3004 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
3006 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
3007 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
3009 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
3010 p.fillRect(1, 8, 7, 7, viewScheme.background());
3011 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
3013 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
3014 p.fillRect(8, 8, 7, 7, selectionScheme.background());
3015 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
3017 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
3018 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
3024 #include "mainwindow.moc"