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>
86 #include <QTextStream>
90 #include <QInputDialog>
94 static const char version[] = VERSION;
96 static const int ID_TIMELINE_POS = 0;
103 EffectsList MainWindow::videoEffects;
104 EffectsList MainWindow::audioEffects;
105 EffectsList MainWindow::customEffects;
106 EffectsList MainWindow::transitions;
108 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent) :
109 KXmlGuiWindow(parent),
110 m_activeDocument(NULL),
111 m_activeTimeline(NULL),
112 m_renderWidget(NULL),
113 #ifndef NO_JOGSHUTTLE
115 #endif /* NO_JOGSHUTTLE */
116 m_findActivated(false)
119 // Create DBus interface
120 new MainWindowAdaptor(this);
121 QDBusConnection dbus = QDBusConnection::sessionBus();
122 dbus.registerObject("/MainWindow", this);
124 setlocale(LC_NUMERIC, "POSIX");
125 setFont(KGlobalSettings::toolBarFont());
126 parseProfiles(MltPath);
127 m_commandStack = new QUndoGroup;
128 m_timelineArea = new KTabWidget(this);
129 m_timelineArea->setTabReorderingEnabled(true);
130 m_timelineArea->setTabBarHidden(true);
132 QToolButton *closeTabButton = new QToolButton;
133 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
134 closeTabButton->setIcon(KIcon("tab-close"));
135 closeTabButton->adjustSize();
136 closeTabButton->setToolTip(i18n("Close the current tab"));
137 m_timelineArea->setCornerWidget(closeTabButton);
138 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
140 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
141 m_findTimer.setSingleShot(true);
143 // FIXME: the next call returns a newly allocated object, which leaks
144 initEffects::parseEffectFiles();
145 //initEffects::parseCustomEffectsFile();
147 m_monitorManager = new MonitorManager();
149 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
150 m_projectListDock->setObjectName("project_tree");
151 m_projectList = new ProjectList(this);
152 m_projectListDock->setWidget(m_projectList);
153 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
155 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
156 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
158 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
159 m_effectListDock->setObjectName("effect_list");
160 m_effectList = new EffectsListView();
162 //m_effectList = new KListWidget(this);
163 m_effectListDock->setWidget(m_effectList);
164 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
166 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
167 m_effectStackDock->setObjectName("effect_stack");
168 m_effectStack = new EffectStackView(this);
169 m_effectStackDock->setWidget(m_effectStack);
170 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
172 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
173 m_transitionConfigDock->setObjectName("transition");
174 m_transitionConfig = new TransitionSettings(this);
175 m_transitionConfigDock->setWidget(m_transitionConfig);
176 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
178 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
179 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
183 //slotDetectAudioDriver();
185 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
186 m_clipMonitorDock->setObjectName("clip_monitor");
187 m_clipMonitor = new Monitor("clip", m_monitorManager, this);
188 m_clipMonitorDock->setWidget(m_clipMonitor);
189 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
190 //m_clipMonitor->stop();
192 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
193 m_projectMonitorDock->setObjectName("project_monitor");
194 m_projectMonitor = new Monitor("project", m_monitorManager, this);
195 m_projectMonitorDock->setWidget(m_projectMonitor);
196 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
199 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
200 m_recMonitorDock->setObjectName("record_monitor");
201 m_recMonitor = new RecMonitor("record", this);
202 m_recMonitorDock->setWidget(m_recMonitor);
203 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
205 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
206 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
209 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
210 m_undoViewDock->setObjectName("undo_history");
211 m_undoView = new QUndoView(this);
212 m_undoView->setCleanIcon(KIcon("edit-clear"));
213 m_undoView->setEmptyLabel(i18n("Clean"));
214 m_undoViewDock->setWidget(m_undoView);
215 m_undoView->setGroup(m_commandStack);
216 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
218 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
219 //overviewDock->setObjectName("project_overview");
220 //m_overView = new CustomTrackView(NULL, NULL, this);
221 //overviewDock->setWidget(m_overView);
222 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
225 //tabifyDockWidget(projectListDock, effectListDock);
226 tabifyDockWidget(m_projectListDock, m_effectStackDock);
227 tabifyDockWidget(m_projectListDock, m_transitionConfigDock);
228 //tabifyDockWidget(projectListDock, undoViewDock);
231 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
233 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
235 setCentralWidget(m_timelineArea);
240 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
241 guiFactory()->addClient(sp);*/
245 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
247 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone);
248 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
249 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)), static_cast<QMenu*>(factory()->container("transcoders", this)));
251 // build effects menus
253 QMenu *videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
255 QStringList effectInfo;
256 QMap<QString, QStringList> effectsList;
257 for (int ix = 0; ix < videoEffects.count(); ix++) {
258 effectInfo = videoEffects.effectIdInfo(ix);
259 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
262 foreach(const QStringList &value, effectsList) {
263 action = new QAction(value.at(0), this);
264 action->setData(value);
265 videoEffectsMenu->addAction(action);
268 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
272 for (int ix = 0; ix < audioEffects.count(); ix++) {
273 effectInfo = audioEffects.effectIdInfo(ix);
274 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
277 foreach(const QStringList &value, effectsList) {
278 action = new QAction(value.at(0), this);
279 action->setData(value);
280 audioEffectsMenu->addAction(action);
283 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
285 if (customEffects.isEmpty()) m_customEffectsMenu->setEnabled(false);
286 else m_customEffectsMenu->setEnabled(true);
289 for (int ix = 0; ix < customEffects.count(); ix++) {
290 effectInfo = customEffects.effectIdInfo(ix);
291 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
294 foreach(const QStringList &value, effectsList) {
295 action = new QAction(value.at(0), this);
296 action->setData(value);
297 m_customEffectsMenu->addAction(action);
300 QMenu *newEffect = new QMenu(this);
301 newEffect->addMenu(videoEffectsMenu);
302 newEffect->addMenu(audioEffectsMenu);
303 newEffect->addMenu(m_customEffectsMenu);
304 m_effectStack->setMenu(newEffect);
307 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
308 const QList<QAction *> viewActions = createPopupMenu()->actions();
309 viewMenu->insertActions(NULL, viewActions);
311 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
312 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
313 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
315 m_timelineContextMenu = new QMenu(this);
316 m_timelineContextClipMenu = new QMenu(this);
317 m_timelineContextTransitionMenu = new QMenu(this);
320 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
321 QStringList effects = transitions.effectNames();
324 for (int ix = 0; ix < transitions.count(); ix++) {
325 effectInfo = transitions.effectIdInfo(ix);
326 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
328 foreach(const QStringList &value, effectsList) {
329 action = new QAction(value.at(0), this);
330 action->setData(value);
331 transitionsMenu->addAction(action);
333 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
335 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
336 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
337 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
339 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
340 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
341 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
342 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
343 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
344 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
345 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
347 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
348 m_timelineContextClipMenu->addMenu(markersMenu);
349 m_timelineContextClipMenu->addMenu(transitionsMenu);
350 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
351 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
352 //TODO: re-enable custom effects menu when it is implemented
353 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
355 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
356 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
358 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
360 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
361 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
362 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
363 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
364 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
365 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
367 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
368 slotConnectMonitors();
370 // Open or create a file. Command line argument passed in Url has
371 // precedence, then "openlastproject", then just a plain empty file.
372 // If opening Url fails, openlastproject will _not_ be used.
373 if (!Url.isEmpty()) {
376 if (KdenliveSettings::openlastproject()) {
380 if (m_timelineArea->count() == 0) {
384 #ifndef NO_JOGSHUTTLE
385 activateShuttleDevice();
386 #endif /* NO_JOGSHUTTLE */
387 m_projectListDock->raise();
390 void MainWindow::queryQuit()
393 if (m_projectMonitor) m_projectMonitor->stop();
394 if (m_clipMonitor) m_clipMonitor->stop();
395 delete m_effectStack;
396 delete m_activeTimeline;
398 // This sometimes causes crash on exit on OS X for some reason.
399 delete m_projectMonitor;
400 delete m_clipMonitor;
402 delete m_activeDocument;
403 delete m_shortcutRemoveFocus;
404 Mlt::Factory::close();
410 bool MainWindow::queryClose()
412 if (m_renderWidget) {
413 int waitingJobs = m_renderWidget->waitingJobsCount();
414 if (waitingJobs > 0) {
415 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")))) {
416 case KMessageBox::Yes :
417 // create script with waiting jobs and start it
418 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
420 case KMessageBox::No :
421 // Don't do anything, jobs will be deleted
429 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
430 if (m_activeDocument && m_activeDocument->isModified()) {
431 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
432 case KMessageBox::Yes :
433 // save document here. If saving fails, return false;
435 case KMessageBox::No :
436 // User does not want to save the changes, clear recovery files
437 m_activeDocument->m_autosave->resize(0);
447 void MainWindow::loadPlugins()
449 foreach(QObject *plugin, QPluginLoader::staticInstances())
450 populateMenus(plugin);
452 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
454 filters << "libkdenlive*";
455 foreach(const QString &folder, directories) {
456 kDebug() << "// PARSING FIOLER: " << folder;
457 QDir pluginsDir(folder);
458 foreach(const QString &fileName, pluginsDir.entryList(filters, QDir::Files)) {
459 kDebug() << "// FOUND PLUGIN: " << fileName << "= " << pluginsDir.absoluteFilePath(fileName);
460 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
461 QObject *plugin = loader.instance();
463 populateMenus(plugin);
464 m_pluginFileNames += fileName;
465 } else kDebug() << "// ERROR LOADING PLUGIN: " << fileName << ", " << loader.errorString();
471 void MainWindow::populateMenus(QObject *plugin)
473 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
474 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
476 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
480 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
481 QMenu *menu, const char *member,
482 QActionGroup *actionGroup)
484 kDebug() << "// ADD to MENU" << texts;
485 foreach(const QString &text, texts) {
486 QAction *action = new QAction(text, plugin);
487 action->setData(text);
488 connect(action, SIGNAL(triggered()), this, member);
489 menu->addAction(action);
492 action->setCheckable(true);
493 actionGroup->addAction(action);
498 void MainWindow::aboutPlugins()
500 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
505 void MainWindow::generateClip()
507 QAction *action = qobject_cast<QAction *>(sender());
508 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
510 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(), QStringList(), QStringList(), 25, 720, 576);
511 if (!clipUrl.isEmpty()) {
512 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
516 void MainWindow::saveProperties(KConfigGroup &config)
518 // save properties here,used by session management
520 KMainWindow::saveProperties(config);
524 void MainWindow::readProperties(const KConfigGroup &config)
526 // read properties here,used by session management
527 KMainWindow::readProperties(config);
528 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
529 openFile(KUrl(Lastproject));
532 void MainWindow::slotReloadEffects()
534 kDebug() << "START RELOAD; COUNR: " << m_customEffectsMenu->actions().count();
535 m_customEffectsMenu->clear();
536 kDebug() << "START RELOAD; CLR: " << m_customEffectsMenu->actions().count();
537 initEffects::parseCustomEffectsFile();
538 const QStringList effects = customEffects.effectNames();
539 kDebug() << "NEW EFFS: " << effects;
541 if (effects.isEmpty()) m_customEffectsMenu->setEnabled(false);
542 else m_customEffectsMenu->setEnabled(true);
544 foreach(const QString &name, effects) {
545 action = new QAction(name, this);
546 action->setData(name);
547 m_customEffectsMenu->addAction(action);
549 m_effectList->reloadEffectList();
552 #ifndef NO_JOGSHUTTLE
553 void MainWindow::activateShuttleDevice()
557 if (KdenliveSettings::enableshuttle() == false) return;
558 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
559 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
560 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
561 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
562 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
563 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
564 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
567 void MainWindow::slotShuttleButton(int code)
571 slotShuttleAction(KdenliveSettings::shuttle1());
574 slotShuttleAction(KdenliveSettings::shuttle2());
577 slotShuttleAction(KdenliveSettings::shuttle3());
580 slotShuttleAction(KdenliveSettings::shuttle4());
583 slotShuttleAction(KdenliveSettings::shuttle5());
588 void MainWindow::slotShuttleAction(int code)
594 m_monitorManager->slotPlay();
597 m_monitorManager->slotPlay();
601 #endif /* NO_JOGSHUTTLE */
603 void MainWindow::configureNotifications()
605 KNotifyConfigWidget::configure(this);
608 void MainWindow::slotFullScreen()
610 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
613 void MainWindow::slotAddEffect(const QDomElement effect, GenTime pos, int track)
615 if (!m_activeDocument) return;
616 if (effect.isNull()) {
617 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
620 QDomElement effectToAdd = effect.cloneNode().toElement();
621 m_activeTimeline->projectView()->slotAddEffect(effectToAdd, pos, track);
624 void MainWindow::slotRaiseMonitor(bool clipMonitor)
626 if (clipMonitor) m_clipMonitorDock->raise();
627 else m_projectMonitorDock->raise();
630 void MainWindow::slotUpdateClip(const QString &id)
632 if (!m_activeDocument) return;
633 m_activeTimeline->projectView()->slotUpdateClip(id);
636 void MainWindow::slotConnectMonitors()
639 m_projectList->setRenderer(m_projectMonitor->render);
640 //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
641 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
642 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, bool)));
643 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
644 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)));
646 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
648 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
650 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
651 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
653 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
654 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
657 void MainWindow::slotAdjustClipMonitor()
659 m_clipMonitorDock->updateGeometry();
660 m_clipMonitorDock->adjustSize();
661 m_clipMonitor->resetSize();
664 void MainWindow::slotAdjustProjectMonitor()
666 m_projectMonitorDock->updateGeometry();
667 m_projectMonitorDock->adjustSize();
668 m_projectMonitor->resetSize();
671 void MainWindow::setupActions()
674 KActionCollection* collection = actionCollection();
675 m_timecodeFormat = new KComboBox(this);
676 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
677 m_timecodeFormat->addItem(i18n("Frames"));
678 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
679 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
681 m_statusProgressBar = new QProgressBar(this);
682 m_statusProgressBar->setMinimum(0);
683 m_statusProgressBar->setMaximum(100);
684 m_statusProgressBar->setMaximumWidth(150);
685 m_statusProgressBar->setVisible(false);
687 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
688 toolbar->setMovable(false);
689 m_toolGroup = new QActionGroup(this);
690 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
691 QString style1 = "QToolBar { border: 0px } QToolButton {background-color: rgba(230, 230, 230, 220); 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;}";
693 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
694 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
695 toolbar->addAction(m_buttonSelectTool);
696 m_buttonSelectTool->setCheckable(true);
697 m_buttonSelectTool->setChecked(true);
699 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
700 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
701 toolbar->addAction(m_buttonRazorTool);
702 m_buttonRazorTool->setCheckable(true);
703 m_buttonRazorTool->setChecked(false);
705 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
706 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
707 toolbar->addAction(m_buttonSpacerTool);
708 m_buttonSpacerTool->setCheckable(true);
709 m_buttonSpacerTool->setChecked(false);
711 m_toolGroup->addAction(m_buttonSelectTool);
712 m_toolGroup->addAction(m_buttonRazorTool);
713 m_toolGroup->addAction(m_buttonSpacerTool);
714 m_toolGroup->setExclusive(true);
715 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
717 QWidget * actionWidget;
718 int max = toolbar->iconSizeDefault() + 2;
719 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
720 actionWidget->setMaximumWidth(max);
721 actionWidget->setMaximumHeight(max - 4);
723 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
724 actionWidget->setMaximumWidth(max);
725 actionWidget->setMaximumHeight(max - 4);
727 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
728 actionWidget->setMaximumWidth(max);
729 actionWidget->setMaximumHeight(max - 4);
731 toolbar->setStyleSheet(style1);
732 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
734 toolbar->addSeparator();
735 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
736 toolbar->addAction(m_buttonFitZoom);
737 m_buttonFitZoom->setCheckable(false);
738 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
740 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
741 actionWidget->setMaximumWidth(max);
742 actionWidget->setMaximumHeight(max - 4);
744 m_zoomSlider = new QSlider(Qt::Horizontal, this);
745 m_zoomSlider->setMaximum(13);
746 m_zoomSlider->setPageStep(1);
748 m_zoomSlider->setMaximumWidth(150);
749 m_zoomSlider->setMinimumWidth(100);
750 toolbar->addWidget(m_zoomSlider);
752 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
753 toolbar->addAction(m_buttonVideoThumbs);
754 m_buttonVideoThumbs->setCheckable(true);
755 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
756 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
758 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
759 toolbar->addAction(m_buttonAudioThumbs);
760 m_buttonAudioThumbs->setCheckable(true);
761 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
762 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
764 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
765 toolbar->addAction(m_buttonShowMarkers);
766 m_buttonShowMarkers->setCheckable(true);
767 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
768 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
770 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
771 toolbar->addAction(m_buttonSnap);
772 m_buttonSnap->setCheckable(true);
773 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
774 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
776 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
777 actionWidget->setMaximumWidth(max);
778 actionWidget->setMaximumHeight(max - 4);
780 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
781 actionWidget->setMaximumWidth(max);
782 actionWidget->setMaximumHeight(max - 4);
784 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
785 actionWidget->setMaximumWidth(max);
786 actionWidget->setMaximumHeight(max - 4);
788 actionWidget = toolbar->widgetForAction(m_buttonSnap);
789 actionWidget->setMaximumWidth(max);
790 actionWidget->setMaximumHeight(max - 4);
792 m_messageLabel = new StatusBarMessageLabel(this);
793 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
795 statusBar()->addWidget(m_messageLabel, 10);
796 statusBar()->addWidget(m_statusProgressBar, 0);
797 statusBar()->addPermanentWidget(toolbar);
798 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
799 statusBar()->addPermanentWidget(m_timecodeFormat);
800 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
802 collection->addAction("select_tool", m_buttonSelectTool);
803 collection->addAction("razor_tool", m_buttonRazorTool);
804 collection->addAction("spacer_tool", m_buttonSpacerTool);
806 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
807 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
808 collection->addAction("show_markers", m_buttonShowMarkers);
809 collection->addAction("snap", m_buttonSnap);
810 collection->addAction("zoom_fit", m_buttonFitZoom);
812 KAction* zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
813 collection->addAction("zoom_in", zoomIn);
814 connect(zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
815 zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
817 KAction* zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
818 collection->addAction("zoom_out", zoomOut);
819 connect(zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
820 zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
822 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
823 collection->addAction("project_find", m_projectSearch);
824 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
825 m_projectSearch->setShortcut(Qt::Key_Slash);
827 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
828 collection->addAction("project_find_next", m_projectSearchNext);
829 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
830 m_projectSearchNext->setShortcut(Qt::Key_F3);
831 m_projectSearchNext->setEnabled(false);
833 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
834 collection->addAction("manage_profiles", profilesAction);
835 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
837 KNS::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
839 KNS::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
841 KNS::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
843 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
844 collection->addAction("run_wizard", wizAction);
845 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
847 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
848 collection->addAction("project_settings", projectAction);
849 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
851 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
852 collection->addAction("project_render", projectRender);
853 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
854 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
856 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
857 collection->addAction("project_clean", projectClean);
858 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
860 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
861 KShortcut playShortcut;
862 playShortcut.setPrimary(Qt::Key_Space);
863 playShortcut.setAlternate(Qt::Key_K);
864 monitorPlay->setShortcut(playShortcut);
865 collection->addAction("monitor_play", monitorPlay);
866 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
868 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
869 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
870 collection->addAction("monitor_play_zone", m_playZone);
871 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
873 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
874 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
875 collection->addAction("monitor_loop_zone", m_loopZone);
876 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
878 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
879 collection->addAction("dvd_wizard", dvdWizard);
880 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
882 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clip"), this);
883 collection->addAction("transcode_clip", transcodeClip);
884 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
886 KAction *markIn = collection->addAction("mark_in");
887 markIn->setText(i18n("Set In Point"));
888 markIn->setShortcut(Qt::Key_I);
889 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
891 KAction *markOut = collection->addAction("mark_out");
892 markOut->setText(i18n("Set Out Point"));
893 markOut->setShortcut(Qt::Key_O);
894 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
896 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
897 monitorSeekBackward->setShortcut(Qt::Key_J);
898 collection->addAction("monitor_seek_backward", monitorSeekBackward);
899 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
901 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
902 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
903 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
904 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
906 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
907 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
908 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
909 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
911 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
912 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
913 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
914 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
916 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
917 monitorSeekForward->setShortcut(Qt::Key_L);
918 collection->addAction("monitor_seek_forward", monitorSeekForward);
919 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
921 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
922 clipStart->setShortcut(Qt::Key_Home);
923 collection->addAction("seek_clip_start", clipStart);
924 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
926 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
927 clipEnd->setShortcut(Qt::Key_End);
928 collection->addAction("seek_clip_end", clipEnd);
929 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
931 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
932 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
933 collection->addAction("seek_start", projectStart);
934 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
936 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
937 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
938 collection->addAction("seek_end", projectEnd);
939 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
941 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
942 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
943 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
944 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
946 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
947 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
948 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
949 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
951 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
952 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
953 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
954 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
956 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
957 deleteTimelineClip->setShortcut(Qt::Key_Delete);
958 collection->addAction("delete_timeline_clip", deleteTimelineClip);
959 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
961 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
962 collection->addAction("change_clip_speed", editTimelineClipSpeed);
963 editTimelineClipSpeed->setData("change_speed");
964 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
966 KAction *stickTransition = collection->addAction("auto_transition");
967 stickTransition->setData(QString("auto"));
968 stickTransition->setCheckable(true);
969 stickTransition->setEnabled(false);
970 stickTransition->setText(i18n("Automatic Transition"));
971 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
973 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
974 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
975 collection->addAction("group_clip", groupClip);
976 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
978 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
979 collection->addAction("ungroup_clip", ungroupClip);
980 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
981 ungroupClip->setData("ungroup_clip");
982 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
984 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
985 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
986 collection->addAction("cut_timeline_clip", cutTimelineClip);
987 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
989 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
990 collection->addAction("add_clip_marker", addClipMarker);
991 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
993 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
994 collection->addAction("delete_clip_marker", deleteClipMarker);
995 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
997 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
998 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
999 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1001 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1002 collection->addAction("edit_clip_marker", editClipMarker);
1003 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1005 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1006 collection->addAction("split_audio", splitAudio);
1007 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1009 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1010 collection->addAction("clip_audio_only", audioOnly);
1011 audioOnly->setData("clip_audio_only");
1012 audioOnly->setCheckable(true);
1014 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1015 collection->addAction("clip_video_only", videoOnly);
1016 videoOnly->setData("clip_video_only");
1017 videoOnly->setCheckable(true);
1019 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1020 collection->addAction("clip_audio_and_video", audioAndVideo);
1021 audioAndVideo->setData("clip_audio_and_video");
1022 audioAndVideo->setCheckable(true);
1024 m_clipTypeGroup = new QActionGroup(this);
1025 m_clipTypeGroup->addAction(audioOnly);
1026 m_clipTypeGroup->addAction(videoOnly);
1027 m_clipTypeGroup->addAction(audioAndVideo);
1028 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1029 m_clipTypeGroup->setEnabled(false);
1031 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1032 collection->addAction("insert_space", insertSpace);
1033 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1035 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1036 collection->addAction("delete_space", removeSpace);
1037 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1039 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1040 collection->addAction("insert_track", insertTrack);
1041 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1043 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1044 collection->addAction("delete_track", deleteTrack);
1045 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1047 KAction *changeTrack = new KAction(KIcon(), i18n("Change Track"), this);
1048 collection->addAction("change_track", changeTrack);
1049 connect(changeTrack, SIGNAL(triggered()), this, SLOT(slotChangeTrack()));
1051 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1052 collection->addAction("add_guide", addGuide);
1053 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1055 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1056 collection->addAction("delete_guide", delGuide);
1057 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1059 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1060 collection->addAction("edit_guide", editGuide);
1061 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1063 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1064 collection->addAction("delete_all_guides", delAllGuides);
1065 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1067 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1068 collection->addAction("paste_effects", pasteEffects);
1069 pasteEffects->setData("paste_effects");
1070 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1072 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1073 collection->addAction("show_timeline", showTimeline);
1074 showTimeline->setCheckable(true);
1075 showTimeline->setChecked(true);
1076 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1078 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1079 collection->addAction("maximize_current", maxCurrent);
1080 maxCurrent->setCheckable(true);
1081 maxCurrent->setChecked(false);
1082 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1085 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1087 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1089 KStandardAction::open(this, SLOT(openFile()), collection);
1091 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1093 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1095 KStandardAction::openNew(this, SLOT(newFile()), collection);
1097 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1099 KStandardAction::configureNotifications(this , SLOT(configureNotifications()), collection);
1101 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1103 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1105 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1106 undo->setEnabled(false);
1107 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1109 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1110 redo->setEnabled(false);
1111 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1113 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1116 //TODO: Add status tooltip to actions ?
1117 connect(collection, SIGNAL(actionHovered(QAction*)),
1118 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1121 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1122 collection->addAction("add_clip", addClip);
1123 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1125 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1126 collection->addAction("add_color_clip", addColorClip);
1127 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1129 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1130 collection->addAction("add_slide_clip", addSlideClip);
1131 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1133 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1134 collection->addAction("add_text_clip", addTitleClip);
1135 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1137 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1138 collection->addAction("add_text_template_clip", addTitleTemplateClip);
1139 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1141 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1142 collection->addAction("add_folder", addFolderButton);
1143 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1145 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1146 collection->addAction("clip_properties", clipProperties);
1147 clipProperties->setData("clip_properties");
1148 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1149 clipProperties->setEnabled(false);
1151 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1152 collection->addAction("edit_clip", openClip);
1153 openClip->setData("edit_clip");
1154 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1155 openClip->setEnabled(false);
1157 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1158 collection->addAction("delete_clip", deleteClip);
1159 deleteClip->setData("delete_clip");
1160 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1161 deleteClip->setEnabled(false);
1163 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1164 collection->addAction("reload_clip", reloadClip);
1165 reloadClip->setData("reload_clip");
1166 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1167 reloadClip->setEnabled(false);
1169 QMenu *addClips = new QMenu();
1170 addClips->addAction(addClip);
1171 addClips->addAction(addColorClip);
1172 addClips->addAction(addSlideClip);
1173 addClips->addAction(addTitleClip);
1174 addClips->addAction(addTitleTemplateClip);
1175 addClips->addAction(addFolderButton);
1177 addClips->addAction(reloadClip);
1178 addClips->addAction(clipProperties);
1179 addClips->addAction(openClip);
1180 addClips->addAction(deleteClip);
1181 m_projectList->setupMenu(addClips, addClip);
1183 //connect(collection, SIGNAL( clearStatusText() ),
1184 //statusBar(), SLOT( clear() ) );
1187 void MainWindow::slotDisplayActionMessage(QAction *a)
1189 statusBar()->showMessage(a->data().toString(), 3000);
1192 void MainWindow::saveOptions()
1194 KdenliveSettings::self()->writeConfig();
1195 KSharedConfigPtr config = KGlobal::config();
1196 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1197 KConfigGroup treecolumns(config, "Project Tree");
1198 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1202 void MainWindow::readOptions()
1204 KSharedConfigPtr config = KGlobal::config();
1205 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1206 KConfigGroup initialGroup(config, "version");
1207 bool upgrade = false;
1208 if (initialGroup.exists()) {
1209 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1213 if (initialGroup.readEntry("version") == "0.7") {
1214 //Add new settings from 0.7.1
1215 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1216 QString path = QDir::homePath() + "/kdenlive";
1217 if (KStandardDirs::makeDir(path) == false) {
1218 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1219 } else KdenliveSettings::setDefaultprojectfolder(path);
1225 if (!initialGroup.exists() || upgrade) {
1226 // this is our first run, show Wizard
1227 Wizard *w = new Wizard(upgrade, this);
1228 if (w->exec() == QDialog::Accepted && w->isOk()) {
1229 w->adjustSettings();
1230 initialGroup.writeEntry("version", version);
1236 KConfigGroup treecolumns(config, "Project Tree");
1237 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1238 if (!state.isEmpty())
1239 m_projectList->setHeaderInfo(state);
1242 void MainWindow::slotRunWizard()
1244 Wizard *w = new Wizard(false, this);
1245 if (w->exec() == QDialog::Accepted && w->isOk()) {
1246 w->adjustSettings();
1251 void MainWindow::newFile(bool showProjectSettings)
1253 if (!m_timelineArea->isEnabled()) return;
1254 QString profileName;
1256 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1257 if (!showProjectSettings && m_timelineArea->count() == 0) {
1258 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1259 profileName = KdenliveSettings::default_profile();
1260 projectFolder = KdenliveSettings::defaultprojectfolder();
1262 ProjectSettings *w = new ProjectSettings(NULL, projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1263 if (w->exec() != QDialog::Accepted) return;
1264 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1265 KdenliveSettings::setVideothumbnails(w->enableVideoThumbs());
1266 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1267 KdenliveSettings::setAudiothumbnails(w->enableAudioThumbs());
1268 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1269 profileName = w->selectedProfile();
1270 projectFolder = w->selectedFolder();
1271 projectTracks = w->tracks();
1274 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1275 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1277 TrackView *trackView = new TrackView(doc, &ok, this);
1278 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1281 m_timelineArea->setEnabled(false);
1282 m_projectList->setEnabled(false);
1283 m_monitorManager->slotBlockMonitors();
1287 if (m_timelineArea->count() == 1) {
1288 connectDocumentInfo(doc);
1289 connectDocument(trackView, doc);
1290 } else m_timelineArea->setTabBarHidden(false);
1291 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1294 void MainWindow::activateDocument()
1296 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1297 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1298 KdenliveDoc *currentDoc = currentTab->document();
1299 connectDocumentInfo(currentDoc);
1300 connectDocument(currentTab, currentDoc);
1303 void MainWindow::closeCurrentDocument()
1305 QWidget *w = m_timelineArea->currentWidget();
1307 // closing current document
1308 int ix = m_timelineArea->currentIndex() + 1;
1309 if (ix == m_timelineArea->count()) ix = 0;
1310 m_timelineArea->setCurrentIndex(ix);
1311 TrackView *tabToClose = (TrackView *) w;
1312 KdenliveDoc *docToClose = tabToClose->document();
1313 if (docToClose && docToClose->isModified()) {
1314 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
1315 case KMessageBox::Yes :
1316 // save document here. If saving fails, return false;
1317 if (saveFile() == false) return;
1319 case KMessageBox::Cancel :
1326 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1327 if (m_timelineArea->count() == 1) {
1328 m_timelineArea->setTabBarHidden(true);
1329 m_closeAction->setEnabled(false);
1331 if (docToClose == m_activeDocument) {
1332 delete m_activeDocument;
1333 m_activeDocument = NULL;
1334 m_effectStack->clear();
1335 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1336 } else delete docToClose;
1337 if (w == m_activeTimeline) {
1338 delete m_activeTimeline;
1339 m_activeTimeline = NULL;
1343 bool MainWindow::saveFileAs(const QString &outputFileName)
1345 QString currentSceneList;
1346 if (KdenliveSettings::dropbframes()) {
1347 KdenliveSettings::setDropbframes(false);
1348 m_activeDocument->clipManager()->updatePreviewSettings();
1349 currentSceneList = m_projectMonitor->sceneList();
1350 KdenliveSettings::setDropbframes(true);
1351 m_activeDocument->clipManager()->updatePreviewSettings();
1352 } else currentSceneList = m_projectMonitor->sceneList();
1354 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1357 // Save timeline thumbnails
1358 m_activeTimeline->projectView()->saveThumbnails();
1359 m_activeDocument->setUrl(KUrl(outputFileName));
1360 if (m_activeDocument->m_autosave == NULL) {
1361 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1362 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1363 setCaption(m_activeDocument->description());
1364 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1365 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1366 m_activeDocument->setModified(false);
1367 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1371 bool MainWindow::saveFileAs()
1373 // Check that the Kdenlive mime type is correctly installed
1374 QString mimetype = "application/x-kdenlive";
1375 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1376 if (!mime) mimetype = "*.kdenlive";
1378 QString outputFile = KFileDialog::getSaveFileName(KUrl(), mimetype);
1379 if (outputFile.isEmpty()) return false;
1380 if (QFile::exists(outputFile)) {
1381 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it?")) == KMessageBox::No) return false;
1383 return saveFileAs(outputFile);
1386 bool MainWindow::saveFile()
1388 if (!m_activeDocument) return true;
1389 if (m_activeDocument->url().isEmpty()) {
1390 return saveFileAs();
1392 bool result = saveFileAs(m_activeDocument->url().path());
1393 m_activeDocument->m_autosave->resize(0);
1398 void MainWindow::openFile()
1400 // Check that the Kdenlive mime type is correctly installed
1401 QString mimetype = "application/x-kdenlive";
1402 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1403 if (!mime) mimetype = "*.kdenlive";
1405 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), mimetype);
1406 if (url.isEmpty()) return;
1407 m_fileOpenRecent->addUrl(url);
1411 void MainWindow::openLastFile()
1413 KSharedConfigPtr config = KGlobal::config();
1414 KUrl::List urls = m_fileOpenRecent->urls();
1415 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1416 if (urls.isEmpty()) newFile(false);
1417 else openFile(urls.last());
1420 void MainWindow::openFile(const KUrl &url)
1422 // Check if the document is already opened
1423 const int ct = m_timelineArea->count();
1424 bool isOpened = false;
1426 for (i = 0; i < ct; i++) {
1427 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1428 KdenliveDoc *doc = tab->document();
1429 if (doc->url() == url) {
1435 m_timelineArea->setCurrentIndex(i);
1439 // Check for backup file
1440 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1441 if (!staleFiles.isEmpty()) {
1442 if (KMessageBox::questionYesNo(this,
1443 i18n("Auto-saved files exist. Do you want to recover them now?"),
1444 i18n("File Recovery"),
1445 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1446 recoverFiles(staleFiles);
1449 // remove the stale files
1450 foreach(KAutoSaveFile *stale, staleFiles) {
1451 stale->open(QIODevice::ReadWrite);
1456 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1457 doOpenFile(url, NULL);
1460 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1462 if (!m_timelineArea->isEnabled()) return;
1463 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, this);
1464 if (stale == NULL) {
1465 stale = new KAutoSaveFile(url, doc);
1466 doc->m_autosave = stale;
1468 doc->m_autosave = stale;
1469 doc->setUrl(stale->managedFile());
1470 doc->setModified(true);
1471 stale->setParent(doc);
1473 connectDocumentInfo(doc);
1475 TrackView *trackView = new TrackView(doc, &ok, this);
1476 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1478 m_timelineArea->setEnabled(false);
1479 m_projectList->setEnabled(false);
1480 m_monitorManager->slotBlockMonitors();
1484 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1485 trackView->setDuration(trackView->duration());
1486 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1488 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1489 slotGotProgressInfo(QString(), -1);
1490 m_clipMonitor->refreshMonitor(true);
1491 m_projectMonitor->adjustRulerSize(trackView->duration());
1492 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1495 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1497 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1498 foreach(KAutoSaveFile *stale, staleFiles) {
1499 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1500 // show an error message; we could not steal the lockfile
1501 // maybe another application got to the file before us?
1505 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1506 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
1507 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1508 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1513 void MainWindow::parseProfiles(const QString &mltPath)
1515 // kDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
1517 //KdenliveSettings::setDefaulttmpfolder();
1518 if (!mltPath.isEmpty()) {
1519 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1520 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
1523 if (KdenliveSettings::mltpath().isEmpty()) {
1524 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1526 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
1527 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
1528 if (!QFile::exists(meltPath))
1529 meltPath = KStandardDirs::findExe("melt");
1530 KdenliveSettings::setRendererpath(meltPath);
1532 QStringList profilesFilter;
1533 profilesFilter << "*";
1534 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1536 if (profilesList.isEmpty()) {
1537 // Cannot find MLT path, try finding melt
1538 QString profilePath = KdenliveSettings::rendererpath();
1539 if (!profilePath.isEmpty()) {
1540 profilePath = profilePath.section('/', 0, -3);
1541 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1542 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1545 if (profilesList.isEmpty()) {
1546 // Cannot find the MLT profiles, ask for location
1547 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1548 getUrl->fileDialog()->setMode(KFile::Directory);
1549 if (getUrl->exec() == QDialog::Rejected) {
1552 KUrl mltPath = getUrl->selectedUrl();
1554 if (mltPath.isEmpty()) ::exit(0);
1555 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
1556 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1560 if (KdenliveSettings::rendererpath().isEmpty()) {
1561 // Cannot find the MLT melt renderer, ask for location
1562 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of Mlt)"), this);
1563 if (getUrl->exec() == QDialog::Rejected) {
1566 KUrl rendererPath = getUrl->selectedUrl();
1568 if (rendererPath.isEmpty()) ::exit(0);
1569 KdenliveSettings::setRendererpath(rendererPath.path());
1572 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1574 // Parse MLT profiles to build a list of available video formats
1575 if (profilesList.isEmpty()) parseProfiles();
1579 void MainWindow::slotEditProfiles()
1581 ProfilesDialog *w = new ProfilesDialog;
1582 if (w->exec() == QDialog::Accepted) {
1583 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1584 if (d) d->checkProfile();
1589 void MainWindow::slotDetectAudioDriver()
1591 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
1592 leading to no audio output, see bug #934 */
1594 //decide which audio driver is really best, in some cases SDL is wrong
1595 if (KdenliveSettings::audiodrivername().isEmpty()) {
1597 KProcess readProcess;
1598 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
1599 if (!KStandardDirs::findExe("pactl").isEmpty()) {
1600 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
1601 readProcess.setProgram("pactl", QStringList() << "stat");
1602 readProcess.execute(2000); // Kill it after 2 seconds
1604 QString result = QString(readProcess.readAllStandardOutput());
1605 kDebug() << "// / / / / / READING PACTL: ";
1607 if (!result.isEmpty()) {
1609 kDebug() << "// / / / / PULSEAUDIO DETECTED";
1613 KdenliveSettings::setAutoaudiodrivername(driver);
1617 void MainWindow::slotEditProjectSettings()
1619 QPoint p = m_activeDocument->getTracksCount();
1620 ProjectSettings *w = new ProjectSettings(m_activeDocument->clipManager(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
1622 if (w->exec() == QDialog::Accepted) {
1623 if (w->deleteUnused()) {
1624 // we are going to trash the unused clips
1625 m_projectList->trashUnusedClips();
1627 QString profile = w->selectedProfile();
1628 m_activeDocument->setProjectFolder(w->selectedFolder());
1629 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path(KUrl::AddTrailingSlash));
1630 if (m_activeDocument->profilePath() != profile) {
1631 // Profile was changed
1632 double dar = m_activeDocument->dar();
1634 // Deselect current effect / transition
1635 m_effectStack->slotClipItemSelected(NULL, 0);
1636 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1637 m_clipMonitor->slotSetXml(NULL, 0);
1638 bool updateFps = m_activeDocument->setProfilePath(profile);
1639 KdenliveSettings::setCurrent_profile(profile);
1640 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1641 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1643 m_activeDocument->clipManager()->clearUnusedProducers();
1644 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1646 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeTimeline->tracksNumber());
1647 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
1648 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1649 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1650 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1651 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
1652 if (updateFps) m_activeTimeline->updateProjectFps();
1653 m_activeDocument->setModified(true);
1654 m_commandStack->activeStack()->clear();
1655 // We need to desactivate & reactivate monitors to get a refresh
1656 //m_monitorManager->switchMonitors();
1663 void MainWindow::slotRenderProject()
1665 if (!m_renderWidget) {
1666 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
1667 m_renderWidget = new RenderWidget(projectfolder, this);
1668 connect(m_renderWidget, SIGNAL(selectedRenderProfile(const QString &, const QString &, const QString&)), this, SLOT(slotSetDocumentRenderProfile(const QString &, const QString &, const QString&)));
1669 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
1670 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1671 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1672 if (m_activeDocument) {
1673 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1674 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1675 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
1676 m_renderWidget->setRenderProfile(m_activeDocument->getDocumentProperty("renderdestination"), m_activeDocument->getDocumentProperty("renderprofile"), m_activeDocument->getDocumentProperty("renderurl"));
1679 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1680 if (currentTab) m_renderWidget->setTimeline(currentTab);
1681 m_renderWidget->setDocument(m_activeDocument);*/
1682 m_renderWidget->show();
1683 m_renderWidget->showNormal();
1686 void MainWindow::setRenderingProgress(const QString &url, int progress)
1688 if (m_renderWidget) m_renderWidget->setRenderJob(url, progress);
1691 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
1693 if (m_renderWidget) m_renderWidget->setRenderStatus(url, status, error);
1696 void MainWindow::slotCleanProject()
1698 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
1699 m_projectList->cleanup();
1702 void MainWindow::slotUpdateMousePosition(int pos)
1704 if (m_activeDocument)
1705 switch (m_timecodeFormat->currentIndex()) {
1707 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1710 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1714 void MainWindow::slotUpdateDocumentState(bool modified)
1716 if (!m_activeDocument) return;
1717 setCaption(m_activeDocument->description(), modified);
1718 m_saveAction->setEnabled(modified);
1720 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1721 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1723 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1724 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1728 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
1730 if (m_activeDocument) {
1731 if (m_activeDocument == doc) return;
1732 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1734 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1737 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
1739 //m_projectMonitor->stop();
1740 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1741 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1742 if (m_activeDocument) {
1743 if (m_activeDocument == doc) return;
1744 if (m_activeTimeline) {
1745 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1746 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1747 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1748 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1749 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
1751 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1752 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1753 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1754 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1755 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1756 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1757 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1758 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1759 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1760 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
1761 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1762 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1763 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1764 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1765 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1766 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1767 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1768 disconnect(m_activeTimeline, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1769 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1770 disconnect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1771 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1772 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1773 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1774 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1775 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1776 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1777 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
1778 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1779 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1780 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
1781 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1782 m_effectStack->clear();
1784 //m_activeDocument->setRenderer(NULL);
1785 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1786 disconnect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
1787 m_clipMonitor->stop();
1789 KdenliveSettings::setCurrent_profile(doc->profilePath());
1790 KdenliveSettings::setProject_fps(doc->fps());
1791 m_monitorManager->resetProfiles(doc->timecode());
1792 m_projectList->setDocument(doc);
1793 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), trackView->tracksNumber());
1794 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
1795 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1796 connect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
1797 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1798 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
1801 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1802 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1803 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1804 connect(trackView, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1805 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1806 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1807 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1808 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1809 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
1811 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1812 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1813 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1814 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1815 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1817 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1818 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1819 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1822 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1823 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1824 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
1825 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1826 m_zoomSlider->setValue(doc->zoom().x());
1827 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1828 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1829 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1830 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1832 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1835 connect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1836 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1837 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1838 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1839 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1840 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1841 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1842 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1844 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1845 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1846 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
1847 connect(m_projectList, SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1850 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup);
1851 m_activeTimeline = trackView;
1852 if (m_renderWidget) {
1853 m_renderWidget->setProfile(doc->mltProfile());
1854 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
1855 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
1856 m_renderWidget->setRenderProfile(doc->getDocumentProperty("renderdestination"), doc->getDocumentProperty("renderprofile"), doc->getDocumentProperty("renderurl"));
1858 //doc->setRenderer(m_projectMonitor->render);
1859 m_commandStack->setActiveStack(doc->commandStack());
1860 KdenliveSettings::setProject_display_ratio(doc->dar());
1861 //doc->clipManager()->checkAudioThumbs();
1863 //m_overView->setScene(trackView->projectScene());
1864 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1865 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1867 setCaption(doc->description(), doc->isModified());
1868 m_saveAction->setEnabled(doc->isModified());
1869 m_activeDocument = doc;
1870 m_activeTimeline->updateProjectFps();
1871 m_projectList->updateAllClips();
1872 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
1874 // set tool to select tool
1875 m_buttonSelectTool->setChecked(true);
1878 void MainWindow::slotZoneMoved(int start, int end)
1880 m_activeDocument->setZone(start, end);
1881 m_projectMonitor->slotZoneMoved(start, end);
1884 void MainWindow::slotGuidesUpdated()
1886 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1889 void MainWindow::slotPreferences(int page, int option)
1891 //An instance of your dialog could be already created and could be
1892 // cached, in which case you want to display the cached dialog
1893 // instead of creating another one
1894 if (KConfigDialog::showDialog("settings")) {
1895 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1896 if (page != -1) d->showPage(page, option);
1900 // KConfigDialog didn't find an instance of this dialog, so lets
1902 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1903 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1904 //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
1905 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1906 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1908 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
1910 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1912 if (page != -1) dialog->showPage(page, option);
1915 void MainWindow::slotUpdatePreviewSettings()
1917 if (m_activeDocument) {
1918 m_clipMonitor->slotSetXml(NULL, 0);
1919 m_activeDocument->updatePreviewSettings();
1923 void MainWindow::updateConfiguration()
1925 //TODO: we should apply settings to all projects, not only the current one
1926 if (m_activeTimeline) {
1927 m_activeTimeline->refresh();
1928 m_activeTimeline->projectView()->checkAutoScroll();
1929 m_activeTimeline->projectView()->checkTrackHeight();
1930 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1932 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1933 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1935 // Update list of transcoding profiles
1937 #ifndef NO_JOGSHUTTLE
1938 activateShuttleDevice();
1939 #endif /* NO_JOGSHUTTLE */
1944 void MainWindow::slotSwitchVideoThumbs()
1946 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1947 if (m_activeTimeline) {
1948 m_activeTimeline->projectView()->slotUpdateAllThumbs();
1950 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1953 void MainWindow::slotSwitchAudioThumbs()
1955 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
1956 if (m_activeTimeline) {
1957 m_activeTimeline->refresh();
1958 m_activeTimeline->projectView()->checkAutoScroll();
1959 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1961 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1964 void MainWindow::slotSwitchMarkersComments()
1966 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1967 if (m_activeTimeline) {
1968 m_activeTimeline->refresh();
1970 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1973 void MainWindow::slotSwitchSnap()
1975 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
1976 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1980 void MainWindow::slotDeleteTimelineClip()
1982 if (QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) m_projectList->slotRemoveClip();
1983 else if (m_activeTimeline) {
1984 m_activeTimeline->projectView()->deleteSelectedClips();
1988 void MainWindow::slotAddClipMarker()
1990 DocClipBase *clip = NULL;
1992 if (m_projectMonitor->isActive()) {
1993 if (m_activeTimeline) {
1994 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1996 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
1997 clip = item->baseClip();
2001 clip = m_clipMonitor->activeClip();
2002 pos = m_clipMonitor->position();
2005 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2008 QString id = clip->getId();
2009 CommentedTime marker(pos, i18n("Marker"));
2010 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2011 if (d.exec() == QDialog::Accepted) {
2012 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2013 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2014 m_clipMonitor->updateMarkers(clip);
2018 void MainWindow::slotDeleteClipMarker()
2020 DocClipBase *clip = NULL;
2022 if (m_projectMonitor->isActive()) {
2023 if (m_activeTimeline) {
2024 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2026 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2027 clip = item->baseClip();
2031 clip = m_clipMonitor->activeClip();
2032 pos = m_clipMonitor->position();
2035 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2039 QString id = clip->getId();
2040 QString comment = clip->markerComment(pos);
2041 if (comment.isEmpty()) {
2042 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2045 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2046 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2047 m_clipMonitor->updateMarkers(clip);
2051 void MainWindow::slotDeleteAllClipMarkers()
2053 DocClipBase *clip = NULL;
2054 if (m_projectMonitor->isActive()) {
2055 if (m_activeTimeline) {
2056 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2058 clip = item->baseClip();
2062 clip = m_clipMonitor->activeClip();
2065 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2068 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2069 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2070 m_clipMonitor->updateMarkers(clip);
2073 void MainWindow::slotEditClipMarker()
2075 DocClipBase *clip = NULL;
2077 if (m_projectMonitor->isActive()) {
2078 if (m_activeTimeline) {
2079 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2081 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2082 clip = item->baseClip();
2086 clip = m_clipMonitor->activeClip();
2087 pos = m_clipMonitor->position();
2090 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2094 QString id = clip->getId();
2095 QString oldcomment = clip->markerComment(pos);
2096 if (oldcomment.isEmpty()) {
2097 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2101 CommentedTime marker(pos, oldcomment);
2102 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2103 if (d.exec() == QDialog::Accepted) {
2104 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2105 if (d.newMarker().time() != pos) {
2106 // remove old marker
2107 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2108 m_clipMonitor->updateMarkers(clip);
2110 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2114 void MainWindow::slotAddGuide()
2116 if (m_activeTimeline)
2117 m_activeTimeline->projectView()->slotAddGuide();
2120 void MainWindow::slotInsertSpace()
2122 if (m_activeTimeline)
2123 m_activeTimeline->projectView()->slotInsertSpace();
2126 void MainWindow::slotRemoveSpace()
2128 if (m_activeTimeline)
2129 m_activeTimeline->projectView()->slotRemoveSpace();
2132 void MainWindow::slotInsertTrack(int ix)
2134 m_projectMonitor->activateMonitor();
2135 if (m_activeTimeline)
2136 m_activeTimeline->projectView()->slotInsertTrack(ix);
2139 void MainWindow::slotDeleteTrack(int ix)
2141 m_projectMonitor->activateMonitor();
2142 if (m_activeTimeline)
2143 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2146 void MainWindow::slotChangeTrack(int ix)
2148 m_projectMonitor->activateMonitor();
2149 if (m_activeTimeline)
2150 m_activeTimeline->projectView()->slotChangeTrack(ix);
2153 void MainWindow::slotEditGuide()
2155 if (m_activeTimeline)
2156 m_activeTimeline->projectView()->slotEditGuide();
2159 void MainWindow::slotDeleteGuide()
2161 if (m_activeTimeline)
2162 m_activeTimeline->projectView()->slotDeleteGuide();
2165 void MainWindow::slotDeleteAllGuides()
2167 if (m_activeTimeline)
2168 m_activeTimeline->projectView()->slotDeleteAllGuides();
2171 void MainWindow::slotCutTimelineClip()
2173 if (m_activeTimeline) {
2174 m_activeTimeline->projectView()->cutSelectedClips();
2178 void MainWindow::slotGroupClips()
2180 if (m_activeTimeline) {
2181 m_activeTimeline->projectView()->groupClips();
2185 void MainWindow::slotUnGroupClips()
2187 if (m_activeTimeline) {
2188 m_activeTimeline->projectView()->groupClips(false);
2192 void MainWindow::slotAddProjectClip(KUrl url)
2194 if (m_activeDocument)
2195 m_activeDocument->slotAddClipFile(url, QString());
2198 void MainWindow::slotAddTransition(QAction *result)
2200 if (!result) return;
2201 QStringList info = result->data().toStringList();
2202 if (info.isEmpty()) return;
2203 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2204 if (m_activeTimeline && !transition.isNull()) {
2205 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2209 void MainWindow::slotAddVideoEffect(QAction *result)
2211 if (!result) return;
2212 QStringList info = result->data().toStringList();
2213 if (info.isEmpty()) return;
2214 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2215 slotAddEffect(effect);
2218 void MainWindow::slotAddAudioEffect(QAction *result)
2220 if (!result) return;
2221 QStringList info = result->data().toStringList();
2222 if (info.isEmpty()) return;
2223 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2224 slotAddEffect(effect);
2227 void MainWindow::slotAddCustomEffect(QAction *result)
2229 if (!result) return;
2230 QStringList info = result->data().toStringList();
2231 if (info.isEmpty()) return;
2232 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2233 slotAddEffect(effect);
2236 void MainWindow::slotZoomIn()
2238 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2241 void MainWindow::slotZoomOut()
2243 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2246 void MainWindow::slotFitZoom()
2248 if (m_activeTimeline) {
2249 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2253 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2255 m_statusProgressBar->setValue(progress);
2256 if (progress >= 0) {
2257 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2258 m_statusProgressBar->setVisible(true);
2260 m_messageLabel->setMessage(QString(), DefaultMessage);
2261 m_statusProgressBar->setVisible(false);
2265 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2267 if (clip->clipType() == TEXT) {
2268 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
2269 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
2270 // template text clip
2272 // Get the list of existing templates
2274 filter << "*.kdenlivetitle";
2275 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
2277 QDialog *dia = new QDialog(this);
2278 Ui::TemplateClip_UI dia_ui;
2279 dia_ui.setupUi(dia);
2281 const QString templatePath = clip->getProperty("resource");
2282 for (int i = 0; i < templateFiles.size(); ++i) {
2283 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
2284 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
2286 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
2287 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
2288 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
2289 //warning: setting base directory doesn't work??
2290 KUrl startDir(titlepath);
2291 dia_ui.template_list->fileDialog()->setUrl(startDir);
2292 dia_ui.description->setText(clip->getProperty("description"));
2293 if (dia->exec() == QDialog::Accepted) {
2294 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
2295 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
2297 QMap <QString, QString> newprops;
2299 if (KUrl(textTemplate).path() != templatePath) {
2300 // The template was changed
2301 newprops.insert("resource", textTemplate);
2304 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
2305 newprops.insert("description", dia_ui.description->toPlainText());
2308 QString newtemplate = newprops.value("xmltemplate");
2309 if (newtemplate.isEmpty()) newtemplate = templatePath;
2311 // template modified we need to update xmldata
2312 QString description = newprops.value("description");
2313 if (description.isEmpty()) description = clip->getProperty("description");
2314 else newprops.insert("templatetext", description);
2315 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
2317 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2318 m_activeDocument->commandStack()->push(command);
2322 QString path = clip->getProperty("resource");
2323 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
2325 doc.setContent(clip->getProperty("xmldata"));
2326 dia_ui->setXml(doc);
2327 if (dia_ui->exec() == QDialog::Accepted) {
2328 QMap <QString, QString> newprops;
2329 newprops.insert("xmldata", dia_ui->xml().toString());
2330 newprops.insert("out", QString::number(dia_ui->duration()));
2331 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2332 m_activeDocument->commandStack()->push(command);
2333 m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
2334 m_activeDocument->setModified(true);
2338 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2341 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2342 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2343 if (dia.exec() == QDialog::Accepted) {
2344 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true);
2345 m_activeDocument->commandStack()->push(command);
2347 if (dia.needsTimelineRefresh()) {
2348 // update clip occurences in timeline
2349 m_activeTimeline->projectView()->slotUpdateClip(clip->getId(), dia.needsTimelineReload());
2354 void MainWindow::customEvent(QEvent* e)
2356 if (e->type() == QEvent::User) {
2357 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
2360 void MainWindow::slotActivateEffectStackView()
2362 m_effectStack->raiseWindow(m_effectStackDock);
2365 void MainWindow::slotActivateTransitionView(Transition *t)
2367 if (t) m_transitionConfig->raiseWindow(m_transitionConfigDock);
2370 void MainWindow::slotSnapRewind()
2372 if (m_projectMonitor->isActive()) {
2373 if (m_activeTimeline)
2374 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2375 } else m_clipMonitor->slotSeekToPreviousSnap();
2378 void MainWindow::slotSnapForward()
2380 if (m_projectMonitor->isActive()) {
2381 if (m_activeTimeline)
2382 m_activeTimeline->projectView()->slotSeekToNextSnap();
2383 } else m_clipMonitor->slotSeekToNextSnap();
2386 void MainWindow::slotClipStart()
2388 if (m_projectMonitor->isActive()) {
2389 if (m_activeTimeline)
2390 m_activeTimeline->projectView()->clipStart();
2394 void MainWindow::slotClipEnd()
2396 if (m_projectMonitor->isActive()) {
2397 if (m_activeTimeline)
2398 m_activeTimeline->projectView()->clipEnd();
2402 void MainWindow::slotChangeTool(QAction * action)
2404 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
2405 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
2406 else if (action == m_buttonSpacerTool) slotSetTool(SPACERTOOL);
2409 void MainWindow::slotSetTool(PROJECTTOOL tool)
2411 if (m_activeDocument && m_activeTimeline) {
2412 //m_activeDocument->setTool(tool);
2413 m_activeTimeline->projectView()->setTool(tool);
2417 void MainWindow::slotCopy()
2419 if (!m_activeDocument || !m_activeTimeline) return;
2420 m_activeTimeline->projectView()->copyClip();
2423 void MainWindow::slotPaste()
2425 if (!m_activeDocument || !m_activeTimeline) return;
2426 m_activeTimeline->projectView()->pasteClip();
2429 void MainWindow::slotPasteEffects()
2431 if (!m_activeDocument || !m_activeTimeline) return;
2432 m_activeTimeline->projectView()->pasteClipEffects();
2435 void MainWindow::slotFind()
2437 if (!m_activeDocument || !m_activeTimeline) return;
2438 m_projectSearch->setEnabled(false);
2439 m_findActivated = true;
2440 m_findString.clear();
2441 m_activeTimeline->projectView()->initSearchStrings();
2442 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2443 m_findTimer.start(5000);
2444 qApp->installEventFilter(this);
2447 void MainWindow::slotFindNext()
2449 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
2450 statusBar()->showMessage(i18n("Found: %1", m_findString));
2452 statusBar()->showMessage(i18n("Reached end of project"));
2454 m_findTimer.start(4000);
2457 void MainWindow::findAhead()
2459 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
2460 m_projectSearchNext->setEnabled(true);
2461 statusBar()->showMessage(i18n("Found: %1", m_findString));
2463 m_projectSearchNext->setEnabled(false);
2464 statusBar()->showMessage(i18n("Not found: %1", m_findString));
2468 void MainWindow::findTimeout()
2470 m_projectSearchNext->setEnabled(false);
2471 m_findActivated = false;
2472 m_findString.clear();
2473 statusBar()->showMessage(i18n("Find stopped"), 3000);
2474 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
2475 m_projectSearch->setEnabled(true);
2476 removeEventFilter(this);
2479 void MainWindow::keyPressEvent(QKeyEvent *ke)
2481 if (m_findActivated) {
2482 if (ke->key() == Qt::Key_Backspace) {
2483 m_findString = m_findString.left(m_findString.length() - 1);
2485 if (!m_findString.isEmpty()) {
2491 m_findTimer.start(4000);
2494 } else if (ke->key() == Qt::Key_Escape) {
2498 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
2499 m_findString += ke->text();
2503 m_findTimer.start(4000);
2507 } else KXmlGuiWindow::keyPressEvent(ke);
2511 /** Gets called when the window gets hidden */
2512 void MainWindow::hideEvent(QHideEvent */*event*/)
2514 // kDebug() << "I was hidden";
2515 // issue http://www.kdenlive.org/mantis/view.php?id=231
2516 if (isMinimized()) {
2517 // kDebug() << "I am minimized";
2518 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
2522 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
2524 if (m_findActivated) {
2525 if (event->type() == QEvent::ShortcutOverride) {
2526 QKeyEvent* ke = (QKeyEvent*) event;
2527 if (ke->text().trimmed().isEmpty()) return false;
2530 } else return false;
2532 // pass the event on to the parent class
2533 return QMainWindow::eventFilter(obj, event);
2538 void MainWindow::slotSaveZone(Render *render, QPoint zone)
2540 KDialog *dialog = new KDialog(this);
2541 dialog->setCaption("Save clip zone");
2542 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
2544 QWidget *widget = new QWidget(dialog);
2545 dialog->setMainWidget(widget);
2547 QVBoxLayout *vbox = new QVBoxLayout(widget);
2548 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
2549 QString path = m_activeDocument->projectFolder().path();
2551 path.append("untitled.mlt");
2552 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
2553 url->setFilter("video/mlt-playlist");
2554 QLabel *label2 = new QLabel(i18n("Description:"), this);
2555 KLineEdit *edit = new KLineEdit(this);
2556 vbox->addWidget(label1);
2557 vbox->addWidget(url);
2558 vbox->addWidget(label2);
2559 vbox->addWidget(edit);
2560 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
2564 void MainWindow::slotSetInPoint()
2566 if (m_clipMonitor->isActive()) {
2567 m_clipMonitor->slotSetZoneStart();
2568 } else m_activeTimeline->projectView()->setInPoint();
2571 void MainWindow::slotSetOutPoint()
2573 if (m_clipMonitor->isActive()) {
2574 m_clipMonitor->slotSetZoneEnd();
2575 } else m_activeTimeline->projectView()->setOutPoint();
2578 void MainWindow::slotGetNewLumaStuff()
2580 //KNS::Entry::List download();
2581 KNS::Entry::List entries = KNS::Engine::download();
2582 // list of changed entries
2583 kDebug() << "// PARSING KNS";
2584 foreach(KNS::Entry* entry, entries) {
2585 // care only about installed ones
2586 if (entry->status() == KNS::Entry::Installed) {
2587 foreach(const QString &file, entry->installedFiles()) {
2588 kDebug() << "// CURRENTLY INSTALLED: " << file;
2592 qDeleteAll(entries);
2593 initEffects::refreshLumas();
2594 m_activeTimeline->projectView()->reloadTransitionLumas();
2597 void MainWindow::slotGetNewRenderStuff()
2599 //KNS::Entry::List download();
2601 KNS::Engine engine(0);
2602 if (engine.init("kdenlive_render.knsrc")) {
2603 KNS::Entry::List entries = engine.downloadDialogModal(this);
2605 if (entries.size() > 0) {
2606 foreach(KNS::Entry* entry, entries) {
2607 // care only about installed ones
2608 if (entry->status() == KNS::Entry::Installed) {
2609 foreach(const QString &file, entry->installedFiles()) {
2610 kDebug() << "// CURRENTLY INSTALLED: " << file;
2615 if (m_renderWidget) m_renderWidget->reloadProfiles();
2619 void MainWindow::slotGetNewMltProfileStuff()
2621 //KNS::Entry::List download();
2623 KNS::Engine engine(0);
2624 if (engine.init("kdenlive_mltprofiles.knsrc")) {
2625 KNS::Entry::List entries = engine.downloadDialogModal(this);
2627 if (entries.size() > 0) {
2628 foreach(KNS::Entry* entry, entries) {
2629 // care only about installed ones
2630 if (entry->status() == KNS::Entry::Installed) {
2631 foreach(const QString &file, entry->installedFiles()) {
2632 kDebug() << "// CURRENTLY INSTALLED: " << file;
2637 // update the list of profiles in settings dialog
2638 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2639 if (d) d->checkProfile();
2644 void MainWindow::slotAutoTransition()
2646 if (m_activeTimeline) m_activeTimeline->projectView()->autoTransition();
2649 void MainWindow::slotSplitAudio()
2651 if (m_activeTimeline) m_activeTimeline->projectView()->splitAudio();
2654 void MainWindow::slotUpdateClipType(QAction *action)
2656 if (m_activeTimeline) {
2657 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
2658 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
2659 else m_activeTimeline->projectView()->setAudioAndVideo();
2663 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
2665 DvdWizard *w = new DvdWizard(url, profile, this);
2669 void MainWindow::slotShowTimeline(bool show)
2671 if (show == false) {
2672 m_timelineState = saveState();
2673 centralWidget()->setHidden(true);
2675 centralWidget()->setHidden(false);
2676 restoreState(m_timelineState);
2680 void MainWindow::slotMaximizeCurrent(bool /*show*/)
2682 //TODO: is there a way to maximize current widget?
2685 m_timelineState = saveState();
2686 QWidget *par = focusWidget()->parentWidget();
2687 while (par->parentWidget() && par->parentWidget() != this) {
2688 par = par->parentWidget();
2690 kDebug() << "CURRENT WIDGET: " << par->objectName();
2693 //centralWidget()->setHidden(false);
2694 //restoreState(m_timelineState);
2698 void MainWindow::loadTranscoders()
2700 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
2703 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
2704 KConfigGroup transConfig(config, "Transcoding");
2706 QMap< QString, QString > profiles = transConfig.entryMap();
2707 QMapIterator<QString, QString> i(profiles);
2708 while (i.hasNext()) {
2710 QAction *a = transMenu->addAction(i.key());
2711 a->setData(i.value());
2712 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
2716 void MainWindow::slotTranscode(KUrl::List urls)
2719 if (urls.isEmpty()) {
2720 urls.append(m_projectList->currentClipUrl());
2721 QAction *action = qobject_cast<QAction *>(sender());
2722 params = action->data().toString();
2724 if (urls.isEmpty()) return;
2725 ClipTranscode *d = new ClipTranscode(urls, params);
2726 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
2728 //QProcess::startDetached("ffmpeg", parameters);
2731 void MainWindow::slotTranscodeClip()
2733 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
2734 if (urls.isEmpty()) return;
2735 slotTranscode(urls);
2738 void MainWindow::slotSetDocumentRenderProfile(const QString &dest, const QString &name, const QString &file)
2740 if (m_activeDocument == NULL) return;
2741 m_activeDocument->setDocumentProperty("renderdestination", dest);
2742 m_activeDocument->setDocumentProperty("renderprofile", name);
2743 m_activeDocument->setDocumentProperty("renderurl", file);
2744 m_activeDocument->setModified(true);
2748 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
2750 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
2752 QString playlistPath;
2755 QString scriptsFolder = m_activeDocument->projectFolder().path() + "/scripts/";
2756 QString path = m_renderWidget->getFreeScriptName();
2757 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
2758 if (!ok || scriptPath.isEmpty()) return;
2759 scriptPath.prepend(scriptsFolder);
2760 QFile f(scriptPath);
2762 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
2765 playlistPath = scriptPath + ".mlt";
2766 m_projectMonitor->saveSceneList(playlistPath);
2768 KTemporaryFile temp;
2769 temp.setAutoRemove(false);
2770 temp.setSuffix(".mlt");
2772 playlistPath = temp.fileName();
2773 m_projectMonitor->saveSceneList(playlistPath);
2776 if (!chapterFile.isEmpty()) {
2779 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
2781 in = m_activeTimeline->inPoint();
2782 out = m_activeTimeline->outPoint();
2785 QDomElement chapters = doc.createElement("chapters");
2786 chapters.setAttribute("fps", m_activeDocument->fps());
2787 doc.appendChild(chapters);
2789 QDomElement guidesxml = m_activeDocument->guidesXml();
2790 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
2791 for (int i = 0; i < nodes.count(); i++) {
2792 QDomElement e = nodes.item(i).toElement();
2794 QString comment = e.attribute("comment");
2795 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
2796 if (time >= in && time < out) {
2797 if (zoneOnly) time = time - in;
2798 QDomElement chapter = doc.createElement("chapter");
2799 chapters.appendChild(chapter);
2800 chapter.setAttribute("title", comment);
2801 chapter.setAttribute("time", time);
2805 if (chapters.childNodes().count() > 0) {
2806 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
2807 // Always insert a guide in pos 0
2808 QDomElement chapter = doc.createElement("chapter");
2809 chapters.insertBefore(chapter, QDomNode());
2810 chapter.setAttribute("title", i18n("Start"));
2811 chapter.setAttribute("time", "0");
2813 // save chapters file
2814 QFile file(chapterFile);
2815 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
2816 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
2818 file.write(doc.toString().toUtf8());
2819 if (file.error() != QFile::NoError) {
2820 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
2827 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath);
2830 void MainWindow::slotUpdateTimecodeFormat(int ix)
2832 KdenliveSettings::setFrametimecode(ix == 1);
2833 m_clipMonitor->updateTimecodeFormat();
2834 m_projectMonitor->updateTimecodeFormat();
2837 void MainWindow::slotRemoveFocus()
2839 statusBar()->setFocus();
2840 statusBar()->clearFocus();
2846 #include "mainwindow.moc"