1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
21 #include "mainwindow.h"
22 #include "mainwindowadaptor.h"
23 #include "kdenlivesettings.h"
24 #include "kdenlivesettingsdialog.h"
25 #include "initeffects.h"
26 #include "profilesdialog.h"
27 #include "projectsettings.h"
29 #include "clipmanager.h"
30 #include "projectlist.h"
32 #include "recmonitor.h"
33 #include "monitormanager.h"
34 #include "kdenlivedoc.h"
35 #include "trackview.h"
36 #include "customtrackview.h"
37 #include "effectslistview.h"
38 #include "effectstackview.h"
39 #include "transitionsettings.h"
40 #include "renderwidget.h"
43 #include "jogshuttle.h"
44 #endif /* NO_JOGSHUTTLE */
45 #include "clipproperties.h"
47 #include "editclipcommand.h"
48 #include "titlewidget.h"
49 #include "markerdialog.h"
51 #include "interfaces.h"
52 #include "kdenlive-config.h"
53 #include "cliptranscode.h"
54 #include "ui_templateclip_ui.h"
56 #include <KApplication>
60 #include <KActionCollection>
61 #include <KStandardAction>
62 #include <KFileDialog>
63 #include <KMessageBox>
65 #include <KIO/NetAccess>
68 #include <KConfigDialog>
69 #include <KXMLGUIFactory>
71 #include <kstandarddirs.h>
72 #include <KUrlRequesterDialog>
73 #include <KTemporaryFile>
75 #include <KActionMenu>
78 #include <ktogglefullscreenaction.h>
80 #include <KNotification>
81 #include <KNotifyConfigWidget>
82 #include <knewstuff2/engine.h>
83 #include <knewstuff2/ui/knewstuffaction.h>
85 #include <QTextStream>
89 #include <QInputDialog>
93 static const char version[] = VERSION;
95 static const int ID_TIMELINE_POS = 0;
102 EffectsList MainWindow::videoEffects;
103 EffectsList MainWindow::audioEffects;
104 EffectsList MainWindow::customEffects;
105 EffectsList MainWindow::transitions;
107 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent) :
108 KXmlGuiWindow(parent),
109 m_activeDocument(NULL),
110 m_activeTimeline(NULL),
111 m_renderWidget(NULL),
112 #ifndef NO_JOGSHUTTLE
114 #endif /* NO_JOGSHUTTLE */
115 m_findActivated(false)
118 // Create DBus interface
119 new MainWindowAdaptor(this);
120 QDBusConnection dbus = QDBusConnection::sessionBus();
121 dbus.registerObject("/MainWindow", this);
123 setlocale(LC_NUMERIC, "POSIX");
124 setFont(KGlobalSettings::toolBarFont());
125 parseProfiles(MltPath);
126 m_commandStack = new QUndoGroup;
127 m_timelineArea = new KTabWidget(this);
128 m_timelineArea->setTabReorderingEnabled(true);
129 m_timelineArea->setTabBarHidden(true);
131 QToolButton *closeTabButton = new QToolButton;
132 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
133 closeTabButton->setIcon(KIcon("tab-close"));
134 closeTabButton->adjustSize();
135 closeTabButton->setToolTip(i18n("Close the current tab"));
136 m_timelineArea->setCornerWidget(closeTabButton);
137 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
139 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
140 m_findTimer.setSingleShot(true);
142 // FIXME: the next call returns a newly allocated object, which leaks
143 initEffects::parseEffectFiles();
144 //initEffects::parseCustomEffectsFile();
146 m_monitorManager = new MonitorManager();
148 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
149 m_projectListDock->setObjectName("project_tree");
150 m_projectList = new ProjectList(this);
151 m_projectListDock->setWidget(m_projectList);
152 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
154 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
155 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
157 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
158 m_effectListDock->setObjectName("effect_list");
159 m_effectList = new EffectsListView();
161 //m_effectList = new KListWidget(this);
162 m_effectListDock->setWidget(m_effectList);
163 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
165 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
166 m_effectStackDock->setObjectName("effect_stack");
167 m_effectStack = new EffectStackView(this);
168 m_effectStackDock->setWidget(m_effectStack);
169 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
171 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
172 m_transitionConfigDock->setObjectName("transition");
173 m_transitionConfig = new TransitionSettings(this);
174 m_transitionConfigDock->setWidget(m_transitionConfig);
175 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
177 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
178 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
182 //slotDetectAudioDriver();
184 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
185 m_clipMonitorDock->setObjectName("clip_monitor");
186 m_clipMonitor = new Monitor("clip", m_monitorManager, this);
187 m_clipMonitorDock->setWidget(m_clipMonitor);
188 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
189 //m_clipMonitor->stop();
191 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
192 m_projectMonitorDock->setObjectName("project_monitor");
193 m_projectMonitor = new Monitor("project", m_monitorManager, this);
194 m_projectMonitorDock->setWidget(m_projectMonitor);
195 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
197 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
198 m_recMonitorDock->setObjectName("record_monitor");
199 m_recMonitor = new RecMonitor("record", this);
200 m_recMonitorDock->setWidget(m_recMonitor);
201 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
203 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
204 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
206 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
207 m_undoViewDock->setObjectName("undo_history");
208 m_undoView = new QUndoView(this);
209 m_undoView->setCleanIcon(KIcon("edit-clear"));
210 m_undoView->setEmptyLabel(i18n("Clean"));
211 m_undoViewDock->setWidget(m_undoView);
212 m_undoView->setGroup(m_commandStack);
213 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
215 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
216 //overviewDock->setObjectName("project_overview");
217 //m_overView = new CustomTrackView(NULL, NULL, this);
218 //overviewDock->setWidget(m_overView);
219 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
222 //tabifyDockWidget(projectListDock, effectListDock);
223 tabifyDockWidget(m_projectListDock, m_effectStackDock);
224 tabifyDockWidget(m_projectListDock, m_transitionConfigDock);
225 //tabifyDockWidget(projectListDock, undoViewDock);
228 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
229 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
230 setCentralWidget(m_timelineArea);
234 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
235 guiFactory()->addClient(sp);*/
239 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
241 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone);
242 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
243 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)), static_cast<QMenu*>(factory()->container("transcoders", this)));
245 // build effects menus
247 QMenu *videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
249 QStringList effectInfo;
250 QMap<QString, QStringList> effectsList;
251 for (int ix = 0; ix < videoEffects.count(); ix++) {
252 effectInfo = videoEffects.effectIdInfo(ix);
253 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
256 foreach(const QStringList &value, effectsList) {
257 action = new QAction(value.at(0), this);
258 action->setData(value);
259 videoEffectsMenu->addAction(action);
262 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
266 for (int ix = 0; ix < audioEffects.count(); ix++) {
267 effectInfo = audioEffects.effectIdInfo(ix);
268 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
271 foreach(const QStringList &value, effectsList) {
272 action = new QAction(value.at(0), this);
273 action->setData(value);
274 audioEffectsMenu->addAction(action);
277 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
279 if (customEffects.isEmpty()) m_customEffectsMenu->setEnabled(false);
280 else m_customEffectsMenu->setEnabled(true);
283 for (int ix = 0; ix < customEffects.count(); ix++) {
284 effectInfo = customEffects.effectIdInfo(ix);
285 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
288 foreach(const QStringList &value, effectsList) {
289 action = new QAction(value.at(0), this);
290 action->setData(value);
291 m_customEffectsMenu->addAction(action);
294 QMenu *newEffect = new QMenu(this);
295 newEffect->addMenu(videoEffectsMenu);
296 newEffect->addMenu(audioEffectsMenu);
297 newEffect->addMenu(m_customEffectsMenu);
298 m_effectStack->setMenu(newEffect);
301 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
302 const QList<QAction *> viewActions = createPopupMenu()->actions();
303 viewMenu->insertActions(NULL, viewActions);
305 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
306 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
307 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
309 m_timelineContextMenu = new QMenu(this);
310 m_timelineContextClipMenu = new QMenu(this);
311 m_timelineContextTransitionMenu = new QMenu(this);
314 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
315 QStringList effects = transitions.effectNames();
318 for (int ix = 0; ix < transitions.count(); ix++) {
319 effectInfo = transitions.effectIdInfo(ix);
320 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
322 foreach(const QStringList &value, effectsList) {
323 action = new QAction(value.at(0), this);
324 action->setData(value);
325 transitionsMenu->addAction(action);
327 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
329 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
330 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
331 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
333 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
334 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
335 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
336 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
337 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
338 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
339 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
341 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
342 m_timelineContextClipMenu->addMenu(markersMenu);
343 m_timelineContextClipMenu->addMenu(transitionsMenu);
344 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
345 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
346 //TODO: re-enable custom effects menu when it is implemented
347 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
349 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
350 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
352 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
354 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
355 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
356 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
357 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
358 connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
359 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
361 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
362 slotConnectMonitors();
364 // Open or create a file. Command line argument passed in Url has
365 // precedence, then "openlastproject", then just a plain empty file.
366 // If opening Url fails, openlastproject will _not_ be used.
367 if (!Url.isEmpty()) {
370 if (KdenliveSettings::openlastproject()) {
374 if (m_timelineArea->count() == 0) {
378 #ifndef NO_JOGSHUTTLE
379 activateShuttleDevice();
380 #endif /* NO_JOGSHUTTLE */
381 m_projectListDock->raise();
384 void MainWindow::queryQuit()
387 delete m_effectStack;
388 delete m_activeTimeline;
389 delete m_projectMonitor;
390 delete m_clipMonitor;
391 delete m_activeDocument;
392 delete m_shortcutRemoveFocus;
393 Mlt::Factory::close();
399 bool MainWindow::queryClose()
401 if (m_renderWidget) {
402 int waitingJobs = m_renderWidget->waitingJobsCount();
403 if (waitingJobs > 0) {
404 switch (KMessageBox::warningYesNoCancel(this, i18n("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")))) {
405 case KMessageBox::Yes :
406 // create script with waiting jobs and start it
407 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
409 case KMessageBox::No :
410 // Don't do anything, jobs will be deleted
418 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
419 if (m_activeDocument && m_activeDocument->isModified()) {
420 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
421 case KMessageBox::Yes :
422 // save document here. If saving fails, return false;
424 case KMessageBox::No :
425 // User does not want to save the changes, clear recovery files
426 m_activeDocument->m_autosave->resize(0);
436 void MainWindow::loadPlugins()
438 foreach(QObject *plugin, QPluginLoader::staticInstances())
439 populateMenus(plugin);
441 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
443 filters << "libkdenlive*";
444 foreach(const QString &folder, directories) {
445 kDebug() << "// PARSING FIOLER: " << folder;
446 QDir pluginsDir(folder);
447 foreach(const QString &fileName, pluginsDir.entryList(filters, QDir::Files)) {
448 kDebug() << "// FOUND PLUGIN: " << fileName << "= " << pluginsDir.absoluteFilePath(fileName);
449 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
450 QObject *plugin = loader.instance();
452 populateMenus(plugin);
453 m_pluginFileNames += fileName;
454 } else kDebug() << "// ERROR LOADING PLUGIN: " << fileName << ", " << loader.errorString();
460 void MainWindow::populateMenus(QObject *plugin)
462 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
463 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
465 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
469 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
470 QMenu *menu, const char *member,
471 QActionGroup *actionGroup)
473 kDebug() << "// ADD to MENU" << texts;
474 foreach(const QString &text, texts) {
475 QAction *action = new QAction(text, plugin);
476 action->setData(text);
477 connect(action, SIGNAL(triggered()), this, member);
478 menu->addAction(action);
481 action->setCheckable(true);
482 actionGroup->addAction(action);
487 void MainWindow::aboutPlugins()
489 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
494 void MainWindow::generateClip()
496 QAction *action = qobject_cast<QAction *>(sender());
497 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
499 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(), QStringList(), QStringList(), 25, 720, 576);
500 if (!clipUrl.isEmpty()) {
501 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
505 void MainWindow::saveProperties(KConfigGroup &config)
507 // save properties here,used by session management
509 KMainWindow::saveProperties(config);
513 void MainWindow::readProperties(const KConfigGroup &config)
515 // read properties here,used by session management
516 KMainWindow::readProperties(config);
517 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
518 openFile(KUrl(Lastproject));
521 void MainWindow::slotReloadEffects()
523 initEffects::parseCustomEffectsFile();
524 m_customEffectsMenu->clear();
525 const QStringList effects = customEffects.effectNames();
527 if (effects.isEmpty()) m_customEffectsMenu->setEnabled(false);
528 else m_customEffectsMenu->setEnabled(true);
530 foreach(const QString &name, effects) {
531 action = new QAction(name, this);
532 action->setData(name);
533 m_customEffectsMenu->addAction(action);
535 m_effectList->reloadEffectList();
538 #ifndef NO_JOGSHUTTLE
539 void MainWindow::activateShuttleDevice()
543 if (KdenliveSettings::enableshuttle() == false) return;
544 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
545 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
546 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
547 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
548 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
549 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
550 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
553 void MainWindow::slotShuttleButton(int code)
557 slotShuttleAction(KdenliveSettings::shuttle1());
560 slotShuttleAction(KdenliveSettings::shuttle2());
563 slotShuttleAction(KdenliveSettings::shuttle3());
566 slotShuttleAction(KdenliveSettings::shuttle4());
569 slotShuttleAction(KdenliveSettings::shuttle5());
574 void MainWindow::slotShuttleAction(int code)
580 m_monitorManager->slotPlay();
583 m_monitorManager->slotPlay();
587 #endif /* NO_JOGSHUTTLE */
589 void MainWindow::configureNotifications()
591 KNotifyConfigWidget::configure(this);
594 void MainWindow::slotFullScreen()
596 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
599 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track)
601 if (!m_activeDocument) return;
602 if (effect.isNull()) {
603 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
606 m_activeTimeline->projectView()->slotAddEffect(effect.cloneNode().toElement(), pos, track);
609 void MainWindow::slotRaiseMonitor(bool clipMonitor)
611 if (clipMonitor) m_clipMonitorDock->raise();
612 else m_projectMonitorDock->raise();
615 void MainWindow::slotUpdateClip(const QString &id)
617 if (!m_activeDocument) return;
618 m_activeTimeline->projectView()->slotUpdateClip(id);
621 void MainWindow::slotConnectMonitors()
624 m_projectList->setRenderer(m_projectMonitor->render);
625 connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
626 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
627 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, bool)));
628 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
629 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)));
631 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
633 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
635 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
636 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
638 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
639 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
642 void MainWindow::slotAdjustClipMonitor()
644 m_clipMonitorDock->updateGeometry();
645 m_clipMonitorDock->adjustSize();
646 m_clipMonitor->resetSize();
649 void MainWindow::slotAdjustProjectMonitor()
651 m_projectMonitorDock->updateGeometry();
652 m_projectMonitorDock->adjustSize();
653 m_projectMonitor->resetSize();
656 void MainWindow::setupActions()
659 KActionCollection* collection = actionCollection();
660 m_timecodeFormat = new KComboBox(this);
661 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
662 m_timecodeFormat->addItem(i18n("Frames"));
663 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
664 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
666 m_statusProgressBar = new QProgressBar(this);
667 m_statusProgressBar->setMinimum(0);
668 m_statusProgressBar->setMaximum(100);
669 m_statusProgressBar->setMaximumWidth(150);
670 m_statusProgressBar->setVisible(false);
672 QWidget *w = new QWidget;
674 QHBoxLayout *layout = new QHBoxLayout;
675 w->setLayout(layout);
676 layout->setContentsMargins(5, 0, 5, 0);
677 QToolBar *toolbar = new QToolBar("statusToolBar", this);
680 m_toolGroup = new QActionGroup(this);
682 QString style1 = "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;}";
684 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
685 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
686 toolbar->addAction(m_buttonSelectTool);
687 m_buttonSelectTool->setCheckable(true);
688 m_buttonSelectTool->setChecked(true);
690 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
691 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
692 toolbar->addAction(m_buttonRazorTool);
693 m_buttonRazorTool->setCheckable(true);
694 m_buttonRazorTool->setChecked(false);
696 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
697 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
698 toolbar->addAction(m_buttonSpacerTool);
699 m_buttonSpacerTool->setCheckable(true);
700 m_buttonSpacerTool->setChecked(false);
702 m_toolGroup->addAction(m_buttonSelectTool);
703 m_toolGroup->addAction(m_buttonRazorTool);
704 m_toolGroup->addAction(m_buttonSpacerTool);
705 m_toolGroup->setExclusive(true);
706 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
708 QWidget * actionWidget;
709 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
710 actionWidget->setMaximumWidth(24);
711 actionWidget->setMinimumHeight(18);
713 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
714 actionWidget->setMaximumWidth(24);
715 actionWidget->setMinimumHeight(18);
717 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
718 actionWidget->setMaximumWidth(24);
719 actionWidget->setMinimumHeight(18);
721 toolbar->setStyleSheet(style1);
722 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
724 toolbar->addSeparator();
725 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
726 toolbar->addAction(m_buttonFitZoom);
727 m_buttonFitZoom->setCheckable(false);
728 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
730 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
731 actionWidget->setMaximumWidth(24);
732 actionWidget->setMinimumHeight(18);
734 m_zoomSlider = new QSlider(Qt::Horizontal, this);
735 m_zoomSlider->setMaximum(13);
736 m_zoomSlider->setPageStep(1);
738 m_zoomSlider->setMaximumWidth(150);
739 m_zoomSlider->setMinimumWidth(100);
741 const int contentHeight = QFontMetrics(w->font()).height() + 8;
743 QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
744 style.append("QSlider::handle:horizontal { background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
746 m_zoomSlider->setStyleSheet(style);
748 //m_zoomSlider->height() + 5;
749 statusBar()->setMinimumHeight(contentHeight);
752 toolbar->addWidget(m_zoomSlider);
754 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
755 toolbar->addAction(m_buttonVideoThumbs);
756 m_buttonVideoThumbs->setCheckable(true);
757 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
758 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
760 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
761 toolbar->addAction(m_buttonAudioThumbs);
762 m_buttonAudioThumbs->setCheckable(true);
763 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
764 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
766 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
767 toolbar->addAction(m_buttonShowMarkers);
768 m_buttonShowMarkers->setCheckable(true);
769 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
770 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
772 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
773 toolbar->addAction(m_buttonSnap);
774 m_buttonSnap->setCheckable(true);
775 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
776 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
777 layout->addWidget(toolbar);
780 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
781 actionWidget->setMaximumWidth(24);
782 actionWidget->setMinimumHeight(18);
784 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
785 actionWidget->setMaximumWidth(24);
786 actionWidget->setMinimumHeight(18);
788 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
789 actionWidget->setMaximumWidth(24);
790 actionWidget->setMinimumHeight(18);
792 actionWidget = toolbar->widgetForAction(m_buttonSnap);
793 actionWidget->setMaximumWidth(24);
794 actionWidget->setMinimumHeight(18);
796 m_messageLabel = new StatusBarMessageLabel(this);
797 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
799 statusBar()->addWidget(m_messageLabel, 10);
800 statusBar()->addWidget(m_statusProgressBar, 0);
801 statusBar()->addPermanentWidget(w);
802 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
803 statusBar()->addPermanentWidget(m_timecodeFormat);
804 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
806 collection->addAction("select_tool", m_buttonSelectTool);
807 collection->addAction("razor_tool", m_buttonRazorTool);
808 collection->addAction("spacer_tool", m_buttonSpacerTool);
810 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
811 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
812 collection->addAction("show_markers", m_buttonShowMarkers);
813 collection->addAction("snap", m_buttonSnap);
814 collection->addAction("zoom_fit", m_buttonFitZoom);
816 KAction* zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
817 collection->addAction("zoom_in", zoomIn);
818 connect(zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
819 zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
821 KAction* zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
822 collection->addAction("zoom_out", zoomOut);
823 connect(zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
824 zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
826 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
827 collection->addAction("project_find", m_projectSearch);
828 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
829 m_projectSearch->setShortcut(Qt::Key_Slash);
831 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
832 collection->addAction("project_find_next", m_projectSearchNext);
833 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
834 m_projectSearchNext->setShortcut(Qt::Key_F3);
835 m_projectSearchNext->setEnabled(false);
837 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
838 collection->addAction("manage_profiles", profilesAction);
839 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
841 #if KDE_IS_VERSION(4,3,63)
842 KNS::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), QString("get_new_lumas"));
844 KNS::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), QString("get_new_profiles"));
846 KNS::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), QString("get_new_mlt_profiles"));
848 KNS::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
850 KNS::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
852 KNS::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
855 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
856 collection->addAction("run_wizard", wizAction);
857 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
859 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
860 collection->addAction("project_settings", projectAction);
861 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
863 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
864 collection->addAction("project_render", projectRender);
865 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
866 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
868 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
869 KShortcut playShortcut;
870 playShortcut.setPrimary(Qt::Key_Space);
871 playShortcut.setAlternate(Qt::Key_K);
872 monitorPlay->setShortcut(playShortcut);
873 collection->addAction("monitor_play", monitorPlay);
874 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
876 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
877 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
878 collection->addAction("monitor_play_zone", m_playZone);
879 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
881 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
882 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
883 collection->addAction("monitor_loop_zone", m_loopZone);
884 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
886 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
887 collection->addAction("dvd_wizard", dvdWizard);
888 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
890 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clip"), this);
891 collection->addAction("transcode_clip", transcodeClip);
892 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
894 KAction *markIn = collection->addAction("mark_in");
895 markIn->setText(i18n("Set In Point"));
896 markIn->setShortcut(Qt::Key_I);
897 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
899 KAction *markOut = collection->addAction("mark_out");
900 markOut->setText(i18n("Set Out Point"));
901 markOut->setShortcut(Qt::Key_O);
902 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
904 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
905 monitorSeekBackward->setShortcut(Qt::Key_J);
906 collection->addAction("monitor_seek_backward", monitorSeekBackward);
907 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
909 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
910 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
911 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
912 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
914 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
915 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
916 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
917 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
919 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
920 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
921 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
922 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
924 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
925 monitorSeekForward->setShortcut(Qt::Key_L);
926 collection->addAction("monitor_seek_forward", monitorSeekForward);
927 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
929 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
930 clipStart->setShortcut(Qt::Key_Home);
931 collection->addAction("seek_clip_start", clipStart);
932 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
934 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
935 clipEnd->setShortcut(Qt::Key_End);
936 collection->addAction("seek_clip_end", clipEnd);
937 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
939 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
940 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
941 collection->addAction("seek_start", projectStart);
942 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
944 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
945 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
946 collection->addAction("seek_end", projectEnd);
947 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
949 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
950 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
951 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
952 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
954 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
955 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
956 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
957 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
959 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
960 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
961 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
962 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
964 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
965 deleteTimelineClip->setShortcut(Qt::Key_Delete);
966 collection->addAction("delete_timeline_clip", deleteTimelineClip);
967 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
969 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
970 collection->addAction("change_clip_speed", editTimelineClipSpeed);
971 editTimelineClipSpeed->setData("change_speed");
972 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
974 KAction *stickTransition = collection->addAction("auto_transition");
975 stickTransition->setData(QString("auto"));
976 stickTransition->setCheckable(true);
977 stickTransition->setEnabled(false);
978 stickTransition->setText(i18n("Automatic Transition"));
979 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
981 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
982 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
983 collection->addAction("group_clip", groupClip);
984 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
986 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
987 collection->addAction("ungroup_clip", ungroupClip);
988 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
989 ungroupClip->setData("ungroup_clip");
990 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
992 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
993 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
994 collection->addAction("cut_timeline_clip", cutTimelineClip);
995 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
997 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
998 collection->addAction("add_clip_marker", addClipMarker);
999 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1001 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1002 collection->addAction("delete_clip_marker", deleteClipMarker);
1003 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1005 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1006 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
1007 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1009 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1010 collection->addAction("edit_clip_marker", editClipMarker);
1011 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1013 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1014 collection->addAction("split_audio", splitAudio);
1015 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1017 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1018 collection->addAction("clip_audio_only", audioOnly);
1019 audioOnly->setData("clip_audio_only");
1020 audioOnly->setCheckable(true);
1022 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1023 collection->addAction("clip_video_only", videoOnly);
1024 videoOnly->setData("clip_video_only");
1025 videoOnly->setCheckable(true);
1027 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1028 collection->addAction("clip_audio_and_video", audioAndVideo);
1029 audioAndVideo->setData("clip_audio_and_video");
1030 audioAndVideo->setCheckable(true);
1032 m_clipTypeGroup = new QActionGroup(this);
1033 m_clipTypeGroup->addAction(audioOnly);
1034 m_clipTypeGroup->addAction(videoOnly);
1035 m_clipTypeGroup->addAction(audioAndVideo);
1036 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1037 m_clipTypeGroup->setEnabled(false);
1039 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1040 collection->addAction("insert_space", insertSpace);
1041 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1043 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1044 collection->addAction("delete_space", removeSpace);
1045 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1047 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1048 collection->addAction("insert_track", insertTrack);
1049 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1051 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1052 collection->addAction("delete_track", deleteTrack);
1053 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1055 KAction *changeTrack = new KAction(KIcon(), i18n("Change Track"), this);
1056 collection->addAction("change_track", changeTrack);
1057 connect(changeTrack, SIGNAL(triggered()), this, SLOT(slotChangeTrack()));
1059 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1060 collection->addAction("add_guide", addGuide);
1061 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1063 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1064 collection->addAction("delete_guide", delGuide);
1065 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1067 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1068 collection->addAction("edit_guide", editGuide);
1069 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1071 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1072 collection->addAction("delete_all_guides", delAllGuides);
1073 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1075 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1076 collection->addAction("paste_effects", pasteEffects);
1077 pasteEffects->setData("paste_effects");
1078 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1080 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1081 collection->addAction("show_timeline", showTimeline);
1082 showTimeline->setCheckable(true);
1083 showTimeline->setChecked(true);
1084 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1086 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1087 collection->addAction("maximize_current", maxCurrent);
1088 maxCurrent->setCheckable(true);
1089 maxCurrent->setChecked(false);
1090 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1093 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1095 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1097 KStandardAction::open(this, SLOT(openFile()), collection);
1099 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1101 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1103 KStandardAction::openNew(this, SLOT(newFile()), collection);
1105 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1107 KStandardAction::configureNotifications(this , SLOT(configureNotifications()), collection);
1109 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1111 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1113 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1114 undo->setEnabled(false);
1115 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1117 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1118 redo->setEnabled(false);
1119 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1121 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1124 //TODO: Add status tooltip to actions ?
1125 connect(collection, SIGNAL(actionHovered(QAction*)),
1126 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1129 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1130 collection->addAction("add_clip", addClip);
1131 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1133 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1134 collection->addAction("add_color_clip", addColorClip);
1135 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1137 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1138 collection->addAction("add_slide_clip", addSlideClip);
1139 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1141 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1142 collection->addAction("add_text_clip", addTitleClip);
1143 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1145 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1146 collection->addAction("add_text_template_clip", addTitleTemplateClip);
1147 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1149 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1150 collection->addAction("add_folder", addFolderButton);
1151 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1153 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1154 collection->addAction("clip_properties", clipProperties);
1155 clipProperties->setData("clip_properties");
1156 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1157 clipProperties->setEnabled(false);
1159 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1160 collection->addAction("edit_clip", openClip);
1161 openClip->setData("edit_clip");
1162 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1163 openClip->setEnabled(false);
1165 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1166 collection->addAction("delete_clip", deleteClip);
1167 deleteClip->setData("delete_clip");
1168 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1169 deleteClip->setEnabled(false);
1171 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1172 collection->addAction("reload_clip", reloadClip);
1173 reloadClip->setData("reload_clip");
1174 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1175 reloadClip->setEnabled(false);
1177 QMenu *addClips = new QMenu();
1178 addClips->addAction(addClip);
1179 addClips->addAction(addColorClip);
1180 addClips->addAction(addSlideClip);
1181 addClips->addAction(addTitleClip);
1182 addClips->addAction(addTitleTemplateClip);
1183 addClips->addAction(addFolderButton);
1185 addClips->addAction(reloadClip);
1186 addClips->addAction(clipProperties);
1187 addClips->addAction(openClip);
1188 addClips->addAction(deleteClip);
1189 m_projectList->setupMenu(addClips, addClip);
1191 //connect(collection, SIGNAL( clearStatusText() ),
1192 //statusBar(), SLOT( clear() ) );
1195 void MainWindow::slotDisplayActionMessage(QAction *a)
1197 statusBar()->showMessage(a->data().toString(), 3000);
1200 void MainWindow::saveOptions()
1202 KdenliveSettings::self()->writeConfig();
1203 KSharedConfigPtr config = KGlobal::config();
1204 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1205 KConfigGroup treecolumns(config, "Project Tree");
1206 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1210 void MainWindow::readOptions()
1212 KSharedConfigPtr config = KGlobal::config();
1213 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1214 KConfigGroup initialGroup(config, "version");
1215 bool upgrade = false;
1216 if (initialGroup.exists()) {
1217 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1221 if (initialGroup.readEntry("version") == "0.7") {
1222 //Add new settings from 0.7.1
1223 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1224 QString path = QDir::homePath() + "/kdenlive";
1225 if (KStandardDirs::makeDir(path) == false) {
1226 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1227 } else KdenliveSettings::setDefaultprojectfolder(path);
1233 if (!initialGroup.exists() || upgrade) {
1234 // this is our first run, show Wizard
1235 Wizard *w = new Wizard(upgrade, this);
1236 if (w->exec() == QDialog::Accepted && w->isOk()) {
1237 w->adjustSettings();
1238 initialGroup.writeEntry("version", version);
1244 KConfigGroup treecolumns(config, "Project Tree");
1245 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1246 if (!state.isEmpty())
1247 m_projectList->setHeaderInfo(state);
1250 void MainWindow::slotRunWizard()
1252 Wizard *w = new Wizard(false, this);
1253 if (w->exec() == QDialog::Accepted && w->isOk()) {
1254 w->adjustSettings();
1259 void MainWindow::newFile(bool showProjectSettings)
1261 if (!m_timelineArea->isEnabled()) return;
1262 QString profileName;
1264 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1265 if (!showProjectSettings && m_timelineArea->count() == 0) {
1266 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1267 profileName = KdenliveSettings::default_profile();
1268 projectFolder = KdenliveSettings::defaultprojectfolder();
1270 ProjectSettings *w = new ProjectSettings(projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, this);
1271 if (w->exec() != QDialog::Accepted) return;
1272 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1273 KdenliveSettings::setVideothumbnails(w->enableVideoThumbs());
1274 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1275 KdenliveSettings::setAudiothumbnails(w->enableAudioThumbs());
1276 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1277 profileName = w->selectedProfile();
1278 projectFolder = w->selectedFolder();
1279 projectTracks = w->tracks();
1282 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1283 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1285 TrackView *trackView = new TrackView(doc, &ok, this);
1286 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1289 m_timelineArea->setEnabled(false);
1290 m_projectList->setEnabled(false);
1291 m_monitorManager->slotBlockMonitors();
1295 if (m_timelineArea->count() == 1) {
1296 connectDocumentInfo(doc);
1297 connectDocument(trackView, doc);
1298 } else m_timelineArea->setTabBarHidden(false);
1299 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1302 void MainWindow::activateDocument()
1304 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1305 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1306 KdenliveDoc *currentDoc = currentTab->document();
1307 connectDocumentInfo(currentDoc);
1308 connectDocument(currentTab, currentDoc);
1311 void MainWindow::closeCurrentDocument()
1313 QWidget *w = m_timelineArea->currentWidget();
1315 // closing current document
1316 int ix = m_timelineArea->currentIndex() + 1;
1317 if (ix == m_timelineArea->count()) ix = 0;
1318 m_timelineArea->setCurrentIndex(ix);
1319 TrackView *tabToClose = (TrackView *) w;
1320 KdenliveDoc *docToClose = tabToClose->document();
1321 if (docToClose && docToClose->isModified()) {
1322 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
1323 case KMessageBox::Yes :
1324 // save document here. If saving fails, return false;
1325 if (saveFile() == false) return;
1327 case KMessageBox::Cancel :
1334 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1335 if (m_timelineArea->count() == 1) {
1336 m_timelineArea->setTabBarHidden(true);
1337 m_closeAction->setEnabled(false);
1339 if (docToClose == m_activeDocument) {
1340 delete m_activeDocument;
1341 m_activeDocument = NULL;
1342 m_effectStack->clear();
1343 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1344 } else delete docToClose;
1345 if (w == m_activeTimeline) {
1346 delete m_activeTimeline;
1347 m_activeTimeline = NULL;
1351 bool MainWindow::saveFileAs(const QString &outputFileName)
1353 QString currentSceneList;
1354 if (KdenliveSettings::dropbframes()) {
1355 KdenliveSettings::setDropbframes(false);
1356 m_activeDocument->clipManager()->updatePreviewSettings();
1357 currentSceneList = m_projectMonitor->sceneList();
1358 KdenliveSettings::setDropbframes(true);
1359 m_activeDocument->clipManager()->updatePreviewSettings();
1360 } else currentSceneList = m_projectMonitor->sceneList();
1362 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1365 // Save timeline thumbnails
1366 m_activeTimeline->projectView()->saveThumbnails();
1367 m_activeDocument->setUrl(KUrl(outputFileName));
1368 if (m_activeDocument->m_autosave == NULL) {
1369 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1370 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1371 setCaption(m_activeDocument->description());
1372 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1373 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1374 m_activeDocument->setModified(false);
1375 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1379 bool MainWindow::saveFileAs()
1381 // Check that the Kdenlive mime type is correctly installed
1382 QString mimetype = "application/x-kdenlive";
1383 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1384 if (!mime) mimetype = "*.kdenlive";
1386 QString outputFile = KFileDialog::getSaveFileName(KUrl(), mimetype);
1387 if (outputFile.isEmpty()) return false;
1388 if (QFile::exists(outputFile)) {
1389 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it?")) == KMessageBox::No) return false;
1391 return saveFileAs(outputFile);
1394 bool MainWindow::saveFile()
1396 if (!m_activeDocument) return true;
1397 if (m_activeDocument->url().isEmpty()) {
1398 return saveFileAs();
1400 bool result = saveFileAs(m_activeDocument->url().path());
1401 m_activeDocument->m_autosave->resize(0);
1406 void MainWindow::openFile()
1408 // Check that the Kdenlive mime type is correctly installed
1409 QString mimetype = "application/x-kdenlive";
1410 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1411 if (!mime) mimetype = "*.kdenlive";
1413 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), mimetype);
1414 if (url.isEmpty()) return;
1415 m_fileOpenRecent->addUrl(url);
1419 void MainWindow::openLastFile()
1421 KSharedConfigPtr config = KGlobal::config();
1422 KUrl::List urls = m_fileOpenRecent->urls();
1423 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1424 if (urls.isEmpty()) newFile(false);
1425 else openFile(urls.last());
1428 void MainWindow::openFile(const KUrl &url)
1430 // Check if the document is already opened
1431 const int ct = m_timelineArea->count();
1432 bool isOpened = false;
1434 for (i = 0; i < ct; i++) {
1435 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1436 KdenliveDoc *doc = tab->document();
1437 if (doc->url() == url) {
1443 m_timelineArea->setCurrentIndex(i);
1447 // Check for backup file
1448 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1449 if (!staleFiles.isEmpty()) {
1450 if (KMessageBox::questionYesNo(this,
1451 i18n("Auto-saved files exist. Do you want to recover them now?"),
1452 i18n("File Recovery"),
1453 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1454 recoverFiles(staleFiles);
1457 // remove the stale files
1458 foreach(KAutoSaveFile *stale, staleFiles) {
1459 stale->open(QIODevice::ReadWrite);
1464 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1465 doOpenFile(url, NULL);
1468 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1470 if (!m_timelineArea->isEnabled()) return;
1471 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, this);
1472 if (stale == NULL) {
1473 stale = new KAutoSaveFile(url, doc);
1474 doc->m_autosave = stale;
1476 doc->m_autosave = stale;
1477 doc->setUrl(stale->managedFile());
1478 doc->setModified(true);
1479 stale->setParent(doc);
1481 connectDocumentInfo(doc);
1483 TrackView *trackView = new TrackView(doc, &ok, this);
1484 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1486 m_timelineArea->setEnabled(false);
1487 m_projectList->setEnabled(false);
1488 m_monitorManager->slotBlockMonitors();
1492 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1493 trackView->setDuration(trackView->duration());
1494 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1496 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1497 slotGotProgressInfo(QString(), -1);
1498 m_clipMonitor->refreshMonitor(true);
1499 m_projectMonitor->adjustRulerSize(trackView->duration());
1500 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1503 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1505 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1506 foreach(KAutoSaveFile *stale, staleFiles) {
1507 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1508 // show an error message; we could not steal the lockfile
1509 // maybe another application got to the file before us?
1513 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1514 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
1515 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1516 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1521 void MainWindow::parseProfiles(const QString &mltPath)
1523 // kDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
1525 //KdenliveSettings::setDefaulttmpfolder();
1526 if (!mltPath.isEmpty()) {
1527 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1528 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
1531 if (KdenliveSettings::mltpath().isEmpty()) {
1532 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1534 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
1535 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
1536 if (!QFile::exists(meltPath))
1537 meltPath = KStandardDirs::findExe("melt");
1538 KdenliveSettings::setRendererpath(meltPath);
1540 QStringList profilesFilter;
1541 profilesFilter << "*";
1542 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1544 if (profilesList.isEmpty()) {
1545 // Cannot find MLT path, try finding melt
1546 QString profilePath = KdenliveSettings::rendererpath();
1547 if (!profilePath.isEmpty()) {
1548 profilePath = profilePath.section('/', 0, -3);
1549 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1550 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1553 if (profilesList.isEmpty()) {
1554 // Cannot find the MLT profiles, ask for location
1555 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1556 getUrl->fileDialog()->setMode(KFile::Directory);
1557 if (getUrl->exec() == QDialog::Rejected) {
1560 KUrl mltPath = getUrl->selectedUrl();
1562 if (mltPath.isEmpty()) ::exit(0);
1563 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
1564 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1568 if (KdenliveSettings::rendererpath().isEmpty()) {
1569 // Cannot find the MLT melt renderer, ask for location
1570 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of Mlt)"), this);
1571 if (getUrl->exec() == QDialog::Rejected) {
1574 KUrl rendererPath = getUrl->selectedUrl();
1576 if (rendererPath.isEmpty()) ::exit(0);
1577 KdenliveSettings::setRendererpath(rendererPath.path());
1580 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1582 // Parse MLT profiles to build a list of available video formats
1583 if (profilesList.isEmpty()) parseProfiles();
1587 void MainWindow::slotEditProfiles()
1589 ProfilesDialog *w = new ProfilesDialog;
1590 if (w->exec() == QDialog::Accepted) {
1591 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1592 if (d) d->checkProfile();
1597 void MainWindow::slotDetectAudioDriver()
1599 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
1600 leading to no audio output, see bug #934 */
1602 //decide which audio driver is really best, in some cases SDL is wrong
1603 if (KdenliveSettings::audiodrivername().isEmpty()) {
1605 KProcess readProcess;
1606 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
1607 if (!KStandardDirs::findExe("pactl").isEmpty()) {
1608 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
1609 readProcess.setProgram("pactl", QStringList() << "stat");
1610 readProcess.execute(2000); // Kill it after 2 seconds
1612 QString result = QString(readProcess.readAllStandardOutput());
1613 kDebug() << "// / / / / / READING PACTL: ";
1615 if (!result.isEmpty()) {
1617 kDebug() << "// / / / / PULSEAUDIO DETECTED";
1621 KdenliveSettings::setAutoaudiodrivername(driver);
1625 void MainWindow::slotEditProjectSettings()
1627 QPoint p = m_activeDocument->getTracksCount();
1628 ProjectSettings *w = new ProjectSettings(p.x(), p.y(), m_activeDocument->projectFolder().path(), true, this);
1630 if (w->exec() == QDialog::Accepted) {
1631 QString profile = w->selectedProfile();
1632 m_activeDocument->setProjectFolder(w->selectedFolder());
1633 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path(KUrl::AddTrailingSlash));
1634 if (m_activeDocument->profilePath() != profile) {
1635 // Profile was changed
1636 double dar = m_activeDocument->dar();
1638 // Deselect current effect / transition
1639 m_effectStack->slotClipItemSelected(NULL, 0);
1640 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1641 m_clipMonitor->slotSetXml(NULL, 0);
1642 m_activeDocument->setProfilePath(profile);
1643 KdenliveSettings::setCurrent_profile(profile);
1644 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1645 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1647 m_activeDocument->clipManager()->clearUnusedProducers();
1648 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1650 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeTimeline->tracksNumber());
1651 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
1652 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1653 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1654 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1655 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
1656 m_activeTimeline->updateProjectFps();
1658 // We need to desactivate & reactivate monitors to get a refresh
1659 //m_monitorManager->switchMonitors();
1665 void MainWindow::slotRenderProject()
1667 if (!m_renderWidget) {
1668 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
1669 m_renderWidget = new RenderWidget(projectfolder, this);
1670 connect(m_renderWidget, SIGNAL(selectedRenderProfile(const QString &, const QString &, const QString&)), this, SLOT(slotSetDocumentRenderProfile(const QString &, const QString &, const QString&)));
1671 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
1672 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1673 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1674 if (m_activeDocument) {
1675 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1676 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1677 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
1678 m_renderWidget->setRenderProfile(m_activeDocument->getDocumentProperty("renderdestination"), m_activeDocument->getDocumentProperty("renderprofile"), m_activeDocument->getDocumentProperty("renderurl"));
1681 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1682 if (currentTab) m_renderWidget->setTimeline(currentTab);
1683 m_renderWidget->setDocument(m_activeDocument);*/
1684 m_renderWidget->show();
1685 m_renderWidget->showNormal();
1688 void MainWindow::setRenderingProgress(const QString &url, int progress)
1690 if (m_renderWidget) m_renderWidget->setRenderJob(url, progress);
1693 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
1695 if (m_renderWidget) m_renderWidget->setRenderStatus(url, status, error);
1698 void MainWindow::slotUpdateMousePosition(int pos)
1700 if (m_activeDocument)
1701 switch (m_timecodeFormat->currentIndex()) {
1703 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1706 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1710 void MainWindow::slotUpdateDocumentState(bool modified)
1712 if (!m_activeDocument) return;
1713 setCaption(m_activeDocument->description(), modified);
1714 m_saveAction->setEnabled(modified);
1716 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1717 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1719 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1720 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1724 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
1726 if (m_activeDocument) {
1727 if (m_activeDocument == doc) return;
1728 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1730 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1733 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
1735 //m_projectMonitor->stop();
1736 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1737 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1738 if (m_activeDocument) {
1739 if (m_activeDocument == doc) return;
1740 if (m_activeTimeline) {
1741 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1742 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1743 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1744 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1745 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
1747 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1748 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1749 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1750 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1751 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1752 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1753 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1754 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1755 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1756 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
1757 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1758 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1759 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1760 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1761 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1762 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1763 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1764 disconnect(m_activeTimeline, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1765 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1766 disconnect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1767 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1768 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1769 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1770 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1771 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1772 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1773 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
1774 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1775 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1776 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
1777 m_effectStack->clear();
1779 //m_activeDocument->setRenderer(NULL);
1780 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1781 disconnect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
1782 m_clipMonitor->stop();
1784 KdenliveSettings::setCurrent_profile(doc->profilePath());
1785 KdenliveSettings::setProject_fps(doc->fps());
1786 m_monitorManager->resetProfiles(doc->timecode());
1787 m_projectList->setDocument(doc);
1788 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), trackView->tracksNumber());
1789 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
1790 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1791 connect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
1792 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1793 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
1796 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1797 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1798 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1799 connect(trackView, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1800 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1801 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1802 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1803 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1804 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
1806 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1807 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1808 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1809 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1810 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1812 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1813 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1814 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1817 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1818 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1819 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
1820 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1821 m_zoomSlider->setValue(doc->zoom().x());
1822 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1823 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1824 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1825 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1827 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1830 connect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1831 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1832 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1833 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1834 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1835 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1836 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1837 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1839 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1840 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1841 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
1843 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup);
1844 m_activeTimeline = trackView;
1845 if (m_renderWidget) {
1846 m_renderWidget->setProfile(doc->mltProfile());
1847 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
1848 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
1849 m_renderWidget->setRenderProfile(doc->getDocumentProperty("renderdestination"), doc->getDocumentProperty("renderprofile"), doc->getDocumentProperty("renderurl"));
1851 //doc->setRenderer(m_projectMonitor->render);
1852 m_commandStack->setActiveStack(doc->commandStack());
1853 KdenliveSettings::setProject_display_ratio(doc->dar());
1854 //doc->clipManager()->checkAudioThumbs();
1856 //m_overView->setScene(trackView->projectScene());
1857 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1858 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1860 setCaption(doc->description(), doc->isModified());
1861 m_saveAction->setEnabled(doc->isModified());
1862 m_activeDocument = doc;
1863 m_activeTimeline->updateProjectFps();
1864 m_projectList->updateAllClips();
1865 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
1867 // set tool to select tool
1868 m_buttonSelectTool->setChecked(true);
1871 void MainWindow::slotZoneMoved(int start, int end)
1873 m_activeDocument->setZone(start, end);
1874 m_projectMonitor->slotZoneMoved(start, end);
1877 void MainWindow::slotGuidesUpdated()
1879 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1882 void MainWindow::slotPreferences(int page, int option)
1884 //An instance of your dialog could be already created and could be
1885 // cached, in which case you want to display the cached dialog
1886 // instead of creating another one
1887 if (KConfigDialog::showDialog("settings")) {
1888 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1889 if (page != -1) d->showPage(page, option);
1893 // KConfigDialog didn't find an instance of this dialog, so lets
1895 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1896 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1897 //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
1898 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1899 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1900 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
1901 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1903 if (page != -1) dialog->showPage(page, option);
1906 void MainWindow::slotUpdatePreviewSettings()
1908 if (m_activeDocument) {
1909 m_clipMonitor->slotSetXml(NULL, 0);
1910 m_activeDocument->updatePreviewSettings();
1914 void MainWindow::updateConfiguration()
1916 //TODO: we should apply settings to all projects, not only the current one
1917 if (m_activeTimeline) {
1918 m_activeTimeline->refresh();
1919 m_activeTimeline->projectView()->checkAutoScroll();
1920 m_activeTimeline->projectView()->checkTrackHeight();
1921 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1923 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1924 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1926 // Update list of transcoding profiles
1928 #ifndef NO_JOGSHUTTLE
1929 activateShuttleDevice();
1930 #endif /* NO_JOGSHUTTLE */
1935 void MainWindow::slotSwitchVideoThumbs()
1937 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1938 if (m_activeTimeline) {
1939 m_activeTimeline->projectView()->slotUpdateAllThumbs();
1941 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1944 void MainWindow::slotSwitchAudioThumbs()
1946 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
1947 if (m_activeTimeline) {
1948 m_activeTimeline->refresh();
1949 m_activeTimeline->projectView()->checkAutoScroll();
1950 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1952 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1955 void MainWindow::slotSwitchMarkersComments()
1957 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1958 if (m_activeTimeline) {
1959 m_activeTimeline->refresh();
1961 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1964 void MainWindow::slotSwitchSnap()
1966 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
1967 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1971 void MainWindow::slotDeleteTimelineClip()
1973 if (QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) m_projectList->slotRemoveClip();
1974 else if (m_activeTimeline) {
1975 m_activeTimeline->projectView()->deleteSelectedClips();
1979 void MainWindow::slotAddClipMarker()
1981 DocClipBase *clip = NULL;
1983 if (m_projectMonitor->isActive()) {
1984 if (m_activeTimeline) {
1985 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1987 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
1988 clip = item->baseClip();
1992 clip = m_clipMonitor->activeClip();
1993 pos = m_clipMonitor->position();
1996 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
1999 QString id = clip->getId();
2000 CommentedTime marker(pos, i18n("Marker"));
2001 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2002 if (d.exec() == QDialog::Accepted) {
2003 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2005 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2008 void MainWindow::slotDeleteClipMarker()
2010 DocClipBase *clip = NULL;
2012 if (m_projectMonitor->isActive()) {
2013 if (m_activeTimeline) {
2014 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2016 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2017 clip = item->baseClip();
2021 clip = m_clipMonitor->activeClip();
2022 pos = m_clipMonitor->position();
2025 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2029 QString id = clip->getId();
2030 QString comment = clip->markerComment(pos);
2031 if (comment.isEmpty()) {
2032 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2035 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2036 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2040 void MainWindow::slotDeleteAllClipMarkers()
2042 DocClipBase *clip = NULL;
2043 if (m_projectMonitor->isActive()) {
2044 if (m_activeTimeline) {
2045 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2047 clip = item->baseClip();
2051 clip = m_clipMonitor->activeClip();
2054 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2057 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2058 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2061 void MainWindow::slotEditClipMarker()
2063 DocClipBase *clip = NULL;
2065 if (m_projectMonitor->isActive()) {
2066 if (m_activeTimeline) {
2067 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2069 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2070 clip = item->baseClip();
2074 clip = m_clipMonitor->activeClip();
2075 pos = m_clipMonitor->position();
2078 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2082 QString id = clip->getId();
2083 QString oldcomment = clip->markerComment(pos);
2084 if (oldcomment.isEmpty()) {
2085 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2089 CommentedTime marker(pos, oldcomment);
2090 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2091 if (d.exec() == QDialog::Accepted) {
2092 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2093 if (d.newMarker().time() != pos) {
2094 // remove old marker
2095 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2097 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2101 void MainWindow::slotAddGuide()
2103 if (m_activeTimeline)
2104 m_activeTimeline->projectView()->slotAddGuide();
2107 void MainWindow::slotInsertSpace()
2109 if (m_activeTimeline)
2110 m_activeTimeline->projectView()->slotInsertSpace();
2113 void MainWindow::slotRemoveSpace()
2115 if (m_activeTimeline)
2116 m_activeTimeline->projectView()->slotRemoveSpace();
2119 void MainWindow::slotInsertTrack(int ix)
2121 m_projectMonitor->activateMonitor();
2122 if (m_activeTimeline)
2123 m_activeTimeline->projectView()->slotInsertTrack(ix);
2126 void MainWindow::slotDeleteTrack(int ix)
2128 m_projectMonitor->activateMonitor();
2129 if (m_activeTimeline)
2130 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2133 void MainWindow::slotChangeTrack(int ix)
2135 m_projectMonitor->activateMonitor();
2136 if (m_activeTimeline)
2137 m_activeTimeline->projectView()->slotChangeTrack(ix);
2140 void MainWindow::slotEditGuide()
2142 if (m_activeTimeline)
2143 m_activeTimeline->projectView()->slotEditGuide();
2146 void MainWindow::slotDeleteGuide()
2148 if (m_activeTimeline)
2149 m_activeTimeline->projectView()->slotDeleteGuide();
2152 void MainWindow::slotDeleteAllGuides()
2154 if (m_activeTimeline)
2155 m_activeTimeline->projectView()->slotDeleteAllGuides();
2158 void MainWindow::slotCutTimelineClip()
2160 if (m_activeTimeline) {
2161 m_activeTimeline->projectView()->cutSelectedClips();
2165 void MainWindow::slotGroupClips()
2167 if (m_activeTimeline) {
2168 m_activeTimeline->projectView()->groupClips();
2172 void MainWindow::slotUnGroupClips()
2174 if (m_activeTimeline) {
2175 m_activeTimeline->projectView()->groupClips(false);
2179 void MainWindow::slotAddProjectClip(KUrl url)
2181 if (m_activeDocument)
2182 m_activeDocument->slotAddClipFile(url, QString());
2185 void MainWindow::slotAddTransition(QAction *result)
2187 if (!result) return;
2188 QStringList info = result->data().toStringList();
2189 if (info.isEmpty()) return;
2190 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2191 if (m_activeTimeline && !transition.isNull()) {
2192 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2196 void MainWindow::slotAddVideoEffect(QAction *result)
2198 if (!result) return;
2199 QStringList info = result->data().toStringList();
2200 if (info.isEmpty()) return;
2201 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2202 slotAddEffect(effect);
2205 void MainWindow::slotAddAudioEffect(QAction *result)
2207 if (!result) return;
2208 QStringList info = result->data().toStringList();
2209 if (info.isEmpty()) return;
2210 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2211 slotAddEffect(effect);
2214 void MainWindow::slotAddCustomEffect(QAction *result)
2216 if (!result) return;
2217 QStringList info = result->data().toStringList();
2218 if (info.isEmpty()) return;
2219 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2220 slotAddEffect(effect);
2223 void MainWindow::slotZoomIn()
2225 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2228 void MainWindow::slotZoomOut()
2230 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2233 void MainWindow::slotFitZoom()
2235 if (m_activeTimeline) {
2236 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2240 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2242 m_statusProgressBar->setValue(progress);
2243 if (progress >= 0) {
2244 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2245 m_statusProgressBar->setVisible(true);
2247 m_messageLabel->setMessage(QString(), DefaultMessage);
2248 m_statusProgressBar->setVisible(false);
2252 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2254 if (clip->clipType() == TEXT) {
2255 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
2256 if (!clip->getProperty("xmltemplate").isEmpty()) {
2257 // template text clip
2259 // Get the list of existing templates
2261 filter << "*.kdenlivetitle";
2262 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
2264 QDialog *dia = new QDialog(this);
2265 Ui::TemplateClip_UI dia_ui;
2266 dia_ui.setupUi(dia);
2268 const QString templatePath = clip->getProperty("xmltemplate");
2269 for (int i = 0; i < templateFiles.size(); ++i) {
2270 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
2271 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
2273 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
2274 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
2275 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
2276 //warning: setting base directory doesn't work??
2277 KUrl startDir(titlepath);
2278 dia_ui.template_list->fileDialog()->setUrl(startDir);
2279 dia_ui.description->setText(clip->getProperty("description"));
2280 dia_ui.clone_clip->setChecked(true);
2281 if (dia->exec() == QDialog::Accepted) {
2282 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
2283 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
2285 QMap <QString, QString> newprops;
2287 if (KUrl(textTemplate).path() != templatePath) {
2288 // The template was changed
2289 newprops.insert("xmltemplate", textTemplate);
2292 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
2293 newprops.insert("description", dia_ui.description->toPlainText());
2296 QString newtemplate = newprops.value("xmltemplate");
2297 if (newtemplate.isEmpty()) newtemplate = templatePath;
2299 // template modified we need to update xmldata
2300 QString description = newprops.value("description");
2301 if (description.isEmpty()) description = clip->getProperty("description");
2302 newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
2303 if (dia_ui.normal_clip->isChecked()) {
2304 // Switch clip to normal clip
2305 newprops.insert("xmltemplate", QString());
2307 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2308 m_activeDocument->commandStack()->push(command);
2312 QString path = clip->getProperty("resource");
2313 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
2315 doc.setContent(clip->getProperty("xmldata"));
2316 dia_ui->setXml(doc);
2317 if (dia_ui->exec() == QDialog::Accepted) {
2318 QRect rect = dia_ui->renderedRect();
2319 QMap <QString, QString> newprops;
2320 newprops.insert("xmldata", dia_ui->xml().toString());
2321 newprops.insert("out", QString::number(dia_ui->duration()));
2322 newprops.insert("frame_size", QString::number(rect.width()) + 'x' + QString::number(rect.height()));
2323 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2324 m_activeDocument->commandStack()->push(command);
2325 m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
2326 m_activeDocument->setModified(true);
2330 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2333 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2334 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2335 if (dia.exec() == QDialog::Accepted) {
2336 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true);
2337 m_activeDocument->commandStack()->push(command);
2339 //m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
2340 if (dia.needsTimelineRefresh()) {
2341 // update clip occurences in timeline
2342 m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
2347 void MainWindow::customEvent(QEvent* e)
2349 if (e->type() == QEvent::User) {
2350 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
2353 void MainWindow::slotActivateEffectStackView()
2355 m_effectStack->raiseWindow(m_effectStackDock);
2358 void MainWindow::slotActivateTransitionView(Transition *t)
2360 if (t) m_transitionConfig->raiseWindow(m_transitionConfigDock);
2363 void MainWindow::slotSnapRewind()
2365 if (m_projectMonitor->isActive()) {
2366 if (m_activeTimeline)
2367 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2368 } else m_clipMonitor->slotSeekToPreviousSnap();
2371 void MainWindow::slotSnapForward()
2373 if (m_projectMonitor->isActive()) {
2374 if (m_activeTimeline)
2375 m_activeTimeline->projectView()->slotSeekToNextSnap();
2376 } else m_clipMonitor->slotSeekToNextSnap();
2379 void MainWindow::slotClipStart()
2381 if (m_projectMonitor->isActive()) {
2382 if (m_activeTimeline)
2383 m_activeTimeline->projectView()->clipStart();
2387 void MainWindow::slotClipEnd()
2389 if (m_projectMonitor->isActive()) {
2390 if (m_activeTimeline)
2391 m_activeTimeline->projectView()->clipEnd();
2395 void MainWindow::slotChangeTool(QAction * action)
2397 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
2398 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
2399 else if (action == m_buttonSpacerTool) slotSetTool(SPACERTOOL);
2402 void MainWindow::slotSetTool(PROJECTTOOL tool)
2404 if (m_activeDocument && m_activeTimeline) {
2405 //m_activeDocument->setTool(tool);
2406 m_activeTimeline->projectView()->setTool(tool);
2410 void MainWindow::slotCopy()
2412 if (!m_activeDocument || !m_activeTimeline) return;
2413 m_activeTimeline->projectView()->copyClip();
2416 void MainWindow::slotPaste()
2418 if (!m_activeDocument || !m_activeTimeline) return;
2419 m_activeTimeline->projectView()->pasteClip();
2422 void MainWindow::slotPasteEffects()
2424 if (!m_activeDocument || !m_activeTimeline) return;
2425 m_activeTimeline->projectView()->pasteClipEffects();
2428 void MainWindow::slotFind()
2430 if (!m_activeDocument || !m_activeTimeline) return;
2431 m_projectSearch->setEnabled(false);
2432 m_findActivated = true;
2433 m_findString.clear();
2434 m_activeTimeline->projectView()->initSearchStrings();
2435 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2436 m_findTimer.start(5000);
2437 qApp->installEventFilter(this);
2440 void MainWindow::slotFindNext()
2442 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
2443 statusBar()->showMessage(i18n("Found: %1", m_findString));
2445 statusBar()->showMessage(i18n("Reached end of project"));
2447 m_findTimer.start(4000);
2450 void MainWindow::findAhead()
2452 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
2453 m_projectSearchNext->setEnabled(true);
2454 statusBar()->showMessage(i18n("Found: %1", m_findString));
2456 m_projectSearchNext->setEnabled(false);
2457 statusBar()->showMessage(i18n("Not found: %1", m_findString));
2461 void MainWindow::findTimeout()
2463 m_projectSearchNext->setEnabled(false);
2464 m_findActivated = false;
2465 m_findString.clear();
2466 statusBar()->showMessage(i18n("Find stopped"), 3000);
2467 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
2468 m_projectSearch->setEnabled(true);
2469 removeEventFilter(this);
2472 void MainWindow::keyPressEvent(QKeyEvent *ke)
2474 if (m_findActivated) {
2475 if (ke->key() == Qt::Key_Backspace) {
2476 m_findString = m_findString.left(m_findString.length() - 1);
2478 if (!m_findString.isEmpty()) {
2484 m_findTimer.start(4000);
2487 } else if (ke->key() == Qt::Key_Escape) {
2491 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
2492 m_findString += ke->text();
2496 m_findTimer.start(4000);
2500 } else KXmlGuiWindow::keyPressEvent(ke);
2504 /** Gets called when the window gets hidden */
2505 void MainWindow::hideEvent(QHideEvent */*event*/)
2507 // kDebug() << "I was hidden";
2508 // issue http://www.kdenlive.org/mantis/view.php?id=231
2509 if (isMinimized()) {
2510 // kDebug() << "I am minimized";
2511 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
2515 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
2517 if (m_findActivated) {
2518 if (event->type() == QEvent::ShortcutOverride) {
2519 QKeyEvent* ke = (QKeyEvent*) event;
2520 if (ke->text().trimmed().isEmpty()) return false;
2523 } else return false;
2525 // pass the event on to the parent class
2526 return QMainWindow::eventFilter(obj, event);
2531 void MainWindow::slotSaveZone(Render *render, QPoint zone)
2533 KDialog *dialog = new KDialog(this);
2534 dialog->setCaption("Save clip zone");
2535 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
2537 QWidget *widget = new QWidget(dialog);
2538 dialog->setMainWidget(widget);
2540 QVBoxLayout *vbox = new QVBoxLayout(widget);
2541 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
2542 QString path = m_activeDocument->projectFolder().path();
2544 path.append("untitled.mlt");
2545 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
2546 url->setFilter("video/mlt-playlist");
2547 QLabel *label2 = new QLabel(i18n("Description:"), this);
2548 KLineEdit *edit = new KLineEdit(this);
2549 vbox->addWidget(label1);
2550 vbox->addWidget(url);
2551 vbox->addWidget(label2);
2552 vbox->addWidget(edit);
2553 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
2557 void MainWindow::slotSetInPoint()
2559 if (m_clipMonitor->isActive()) {
2560 m_clipMonitor->slotSetZoneStart();
2561 } else m_activeTimeline->projectView()->setInPoint();
2564 void MainWindow::slotSetOutPoint()
2566 if (m_clipMonitor->isActive()) {
2567 m_clipMonitor->slotSetZoneEnd();
2568 } else m_activeTimeline->projectView()->setOutPoint();
2571 void MainWindow::slotGetNewLumaStuff()
2573 //KNS::Entry::List download();
2574 KNS::Entry::List entries = KNS::Engine::download();
2575 // list of changed entries
2576 kDebug() << "// PARSING KNS";
2577 foreach(KNS::Entry* entry, entries) {
2578 // care only about installed ones
2579 if (entry->status() == KNS::Entry::Installed) {
2580 foreach(const QString &file, entry->installedFiles()) {
2581 kDebug() << "// CURRENTLY INSTALLED: " << file;
2585 qDeleteAll(entries);
2586 initEffects::refreshLumas();
2587 m_activeTimeline->projectView()->reloadTransitionLumas();
2590 void MainWindow::slotGetNewRenderStuff()
2592 //KNS::Entry::List download();
2594 KNS::Engine engine(0);
2595 if (engine.init("kdenlive_render.knsrc")) {
2596 KNS::Entry::List entries = engine.downloadDialogModal(this);
2598 if (entries.size() > 0) {
2599 foreach(KNS::Entry* entry, entries) {
2600 // care only about installed ones
2601 if (entry->status() == KNS::Entry::Installed) {
2602 foreach(const QString &file, entry->installedFiles()) {
2603 kDebug() << "// CURRENTLY INSTALLED: " << file;
2608 if (m_renderWidget) m_renderWidget->reloadProfiles();
2612 void MainWindow::slotGetNewMltProfileStuff()
2614 //KNS::Entry::List download();
2616 KNS::Engine engine(0);
2617 if (engine.init("kdenlive_mltprofiles.knsrc")) {
2618 KNS::Entry::List entries = engine.downloadDialogModal(this);
2620 if (entries.size() > 0) {
2621 foreach(KNS::Entry* entry, entries) {
2622 // care only about installed ones
2623 if (entry->status() == KNS::Entry::Installed) {
2624 foreach(const QString &file, entry->installedFiles()) {
2625 kDebug() << "// CURRENTLY INSTALLED: " << file;
2630 // update the list of profiles in settings dialog
2631 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2632 if (d) d->checkProfile();
2637 void MainWindow::slotAutoTransition()
2639 if (m_activeTimeline) m_activeTimeline->projectView()->autoTransition();
2642 void MainWindow::slotSplitAudio()
2644 if (m_activeTimeline) m_activeTimeline->projectView()->splitAudio();
2647 void MainWindow::slotUpdateClipType(QAction *action)
2649 if (m_activeTimeline) {
2650 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
2651 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
2652 else m_activeTimeline->projectView()->setAudioAndVideo();
2656 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
2658 DvdWizard *w = new DvdWizard(url, profile, this);
2662 void MainWindow::slotShowTimeline(bool show)
2664 if (show == false) {
2665 m_timelineState = saveState();
2666 centralWidget()->setHidden(true);
2668 centralWidget()->setHidden(false);
2669 restoreState(m_timelineState);
2673 void MainWindow::slotMaximizeCurrent(bool /*show*/)
2675 //TODO: is there a way to maximize current widget?
2678 m_timelineState = saveState();
2679 QWidget *par = focusWidget()->parentWidget();
2680 while (par->parentWidget() && par->parentWidget() != this) {
2681 par = par->parentWidget();
2683 kDebug() << "CURRENT WIDGET: " << par->objectName();
2686 //centralWidget()->setHidden(false);
2687 //restoreState(m_timelineState);
2691 void MainWindow::loadTranscoders()
2693 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
2696 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
2697 KConfigGroup transConfig(config, "Transcoding");
2699 QMap< QString, QString > profiles = transConfig.entryMap();
2700 QMapIterator<QString, QString> i(profiles);
2701 while (i.hasNext()) {
2703 QAction *a = transMenu->addAction(i.key());
2704 a->setData(i.value());
2705 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
2709 void MainWindow::slotTranscode(KUrl::List urls)
2712 if (urls.isEmpty()) {
2713 urls.append(m_projectList->currentClipUrl());
2714 QAction *action = qobject_cast<QAction *>(sender());
2715 params = action->data().toString();
2717 if (urls.isEmpty()) return;
2718 ClipTranscode *d = new ClipTranscode(urls, params);
2719 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
2721 //QProcess::startDetached("ffmpeg", parameters);
2724 void MainWindow::slotTranscodeClip()
2726 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
2727 if (urls.isEmpty()) return;
2728 slotTranscode(urls);
2731 void MainWindow::slotSetDocumentRenderProfile(const QString &dest, const QString &name, const QString &file)
2733 if (m_activeDocument == NULL) return;
2734 m_activeDocument->setDocumentProperty("renderdestination", dest);
2735 m_activeDocument->setDocumentProperty("renderprofile", name);
2736 m_activeDocument->setDocumentProperty("renderurl", file);
2737 m_activeDocument->setModified(true);
2741 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
2743 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
2745 QString playlistPath;
2748 QString scriptsFolder = m_activeDocument->projectFolder().path() + "/scripts/";
2749 QString path = m_renderWidget->getFreeScriptName();
2750 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
2751 if (!ok || scriptPath.isEmpty()) return;
2752 scriptPath.prepend(scriptsFolder);
2753 QFile f(scriptPath);
2755 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
2758 playlistPath = scriptPath + ".mlt";
2759 m_projectMonitor->saveSceneList(playlistPath);
2761 KTemporaryFile temp;
2762 temp.setAutoRemove(false);
2763 temp.setSuffix(".mlt");
2765 playlistPath = temp.fileName();
2766 m_projectMonitor->saveSceneList(playlistPath);
2769 if (!chapterFile.isEmpty()) {
2772 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
2774 in = m_activeTimeline->inPoint();
2775 out = m_activeTimeline->outPoint();
2778 QDomElement chapters = doc.createElement("chapters");
2779 chapters.setAttribute("fps", m_activeDocument->fps());
2780 doc.appendChild(chapters);
2782 QDomElement guidesxml = m_activeDocument->guidesXml();
2783 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
2784 for (int i = 0; i < nodes.count(); i++) {
2785 QDomElement e = nodes.item(i).toElement();
2787 QString comment = e.attribute("comment");
2788 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
2789 if (time >= in && time < out) {
2790 if (zoneOnly) time = time - in;
2791 QDomElement chapter = doc.createElement("chapter");
2792 chapters.appendChild(chapter);
2793 chapter.setAttribute("title", comment);
2794 chapter.setAttribute("time", time);
2798 if (chapters.childNodes().count() > 0) {
2799 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
2800 // Always insert a guide in pos 0
2801 QDomElement chapter = doc.createElement("chapter");
2802 chapters.insertBefore(chapter, QDomNode());
2803 chapter.setAttribute("title", i18n("Start"));
2804 chapter.setAttribute("time", "0");
2806 // save chapters file
2807 QFile file(chapterFile);
2808 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
2809 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
2811 file.write(doc.toString().toUtf8());
2812 if (file.error() != QFile::NoError) {
2813 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
2820 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath);
2823 void MainWindow::slotUpdateTimecodeFormat(int ix)
2825 KdenliveSettings::setFrametimecode(ix == 1);
2826 m_clipMonitor->updateTimecodeFormat();
2827 m_projectMonitor->updateTimecodeFormat();
2830 void MainWindow::slotRemoveFocus()
2832 statusBar()->setFocus();
2833 statusBar()->clearFocus();
2839 #include "mainwindow.moc"